Cannot enter Unicode characters in Espresso - unicode

Here's a simple command to match a text field and type in a variable name.
private final String name = "foo";
onView(withId(R.id.editTextName)).perform(typeText(name));
It works fine in my application with "foo". However:
private final String name = "á";
private final String name = "\u00E1";
In both of these cases, the onView line fails, blaming inability to find a view within the previous activity's view:
android.support.test.espresso.NoMatchingViewException: No views in hierarchy found matching: with id: <myappid>:id/listViewAccounts
It seems that Espresso cannot handle Unicode characters and will fail if asked to enter them. This is running on an AVD with either the "English (US) Android Keyboard (AOSP)" or the "English (United States) Sample Soft Keyboard". The latter also flattens double letters, which is probably a separate problem with how fast Espresso enters them.
Has anyone run into this before? Is it Espresso, or the keyboard used, or something else?
I've changed the Android soft keyboard to the US International one which can long-press a to get á, but Espresso fails identically.
Update:
Using á does leave this in the stack trace (but \u00E1 doesn't):
java.lang.RuntimeException: Failed to get key events for string á (i.e. current IME does not understand how to translate the string into key events). As a workaround, you can use replaceText action to set the text directly in the EditText field.
Might be worth just doing that, although it's slightly decoupled from how the real user interaction would go.

onView(withId(R.id.editTextName)).perform(replaceText(name));
Switching out typeText() for replaceText() allows other characters to be entered. I'm not sure this is an ideal solution, as there may be events on keypress which are not triggered, but if you just want to test how these strings are handled internally then it's probably fine.
Espresso does explicitly advise the workaround.

Related

Error handling in Sublime Text Plugin API

I'm creating my first sublime plugin to be used internally and was wondering if there's a way to stop the plugin from executing and display an error message on screen like an alert?
I took a look at view#show_popup() but this didn't render for me. Below is how I attempted to show it:
if "WebContent" in subdirectories:
directory = ROOT_DIR + "/WebContent"
elif "Content" in subdirectories:
directory = ROOT_DIR + "/Content"
else:
self.view.show_popup('Directory not found', location=-1)
Working Principle:
The plugin takes some data from one view and then pastes them in another view. The plugin has two TextCommands. One command takes the data from the first view, opens a new view and then executes the 2nd command on the new view. The above snippet is in the 2nd command.
I was unable to find any resources to help with show_popup() or any other error handling.
Does any one have possible ideas?
view.show_popup() is for showing things like hover popups next to the cursor; it's used for things like the built in functionality for going to references/definitions for functions:
While you could in theory use this for error messages, it may not be the sort of user experience that anyone would expect.
Your code above is technically valid, but since the content is expected to be minihtml it may be hard to see because as just a single string all you're going to see is just the text (i.e. you have no font style, padding, etc):
Perhaps more importantly, when location is -1, the popup appears at the point in the buffer closest to the first cursor position, so depending on your circumstance it may be appearing in a place you don't expect, and then vanishing away before you can scroll to see it, etc.
What you want here is sublime.error_message(); given a string, it will display that string in a dialog for the user to interact with, and it also logs the error into the Sublime console as well so that there's an additional trace.

Flutter Bluetooth printing to Zebra

I need to add printing functionality on a zebra zq520 bluetooth thermal printer.
I manage to do so using the flutter_blue plugin but I am not happy with the implementation.
I hate to break the string to smaller chunks in order to pass through bluetooth (and wait!!!!!).
I was wondering if there is a better approach, like the one we used in the (good?) old days of java for android using the android.bluetooth.BluetoothAdapter class
Thanks.
I ended up creating my own plugin.
source code
EDIT: 2021/11/29 integrate some comments from comments section
This code is not limited to zpl. In theory it can support every printer language that sends clear text to bluetooth serial
It is only for Android
For this source code to works as is:
You have to pair a bluetooth printer with name that starts with "zebra"
You have to send the zpl commands as string.
The easiest way to check that your zpl command is valid, is by using the ultra useful labelary viewer. The easiest way to test a label layout (font size, images, barcodes etc) is by using the above free service. in fact all you have to do, is to create the layout you need in labelary and the just copy the entire string from first ^XA to last ^XZ to FlutterCblue.printToBT. For example if you send this
printToBT("^XA
^FX Top section with logo, name and address.
^CF0,60
^FO50,50^GB100,100,100^FS
^FO75,75^FR^GB100,100,100^FS
^FO93,93^GB40,40,40^FS
^FO220,50^FDIntershipping, Inc.^FS
^CF0,30
^FO220,115^FD1000 Shipping Lane^FS
^FO220,155^FDShelbyville TN 38102^FS
^FO220,195^FDUnited States (USA)^FS
^FO50,250^GB700,3,3^FS
^FX Second section with recipient address and permit information.
^CFA,30
^FO50,300^FDJohn Doe^FS
^FO50,340^FD100 Main Street^FS
^FO50,380^FDSpringfield TN 39021^FS
^FO50,420^FDUnited States (USA)^FS
^CFA,15
^FO600,300^GB150,150,3^FS
^FO638,340^FDPermit^FS
^FO638,390^FD123456^FS
^FO50,500^GB700,3,3^FS
^FX Third section with bar code.
^BY5,2,270
^FO100,550^BC^FD12345678^FS
^FX Fourth section (the two boxes on the bottom).
^FO50,900^GB700,250,3^FS
^FO400,900^GB3,250,3^FS
^CF0,40
^FO100,960^FDCtr. X34B-1^FS
^FO100,1010^FDREF1 F00B47^FS
^FO100,1060^FDREF2 BL4H8^FS
^CF0,190
^FO470,955^FDCA^FS
^XZ")
You will get this:
One more thing: keep in mind that if you want to print special language characters (I need to print Greek) you have to find the correct font that is installed in your printer. For example: In order to print Greek characters I have to integrate this
^CWN,E:TT0003M_.FNT
just after the first ^XA. Then I use the N font in order to print Greek. It is very flexible if you understand the basics
Hope it helps

AutoHotKey ControlGet

I have a script that is throwing and error when I issue a ControlGet.
OtPtVar := AfxWnd422
strMPP := Material Planning Profile
ControlFocus,%OtPtVar%,,%strMPP%
Control,Show,,%OtPtVar%,,%strMPP%
These all work but when it gets to the next line it throws an error:
ControlGet,sysList,List,,%OtptVar%,,%strMPP%
The control is a grid with five fields row number,Part,Description,Time,Lateness.
`ControlFocus,%OtPtVar%,,%strMPP%`
`Control,Show,,%OtPtVar%,,%strMPP%`
`ControlGet,sysList,List,,%OtPtVar%,,%strMPP%`
The error occurs on the last line.
Thank you.
After searching the AutoHotKey site I found to the following:
Those Afx window classes were custom classes distributed with early versions of MFC, before the "Common Controls" concept was introduced.
Many people have tried to "read" text from them but you CAN'T, not with messages anyway!
They're almost certainly owner-drawn - the text is not delivered by messages, it's "hand-drawn" into the window's DC
...
Messages are a dead-end I think - those who have pursued this problem must have already clocked up several hundreds of hours of monitoring message traffic between them!
So its not possible to get a hold of the control.
ControlGet's List subcommand can only handle standard listview controls, which usually have the class 'SysListView32'.
Did you try AccViewer just in case.
This link mentions textcapturex by Deskperience Software in case that helps.
"AfxWnd42s" Please Help - AutoIt General Help and Support - AutoIt Forums
https://www.autoitscript.com/forum/topic/49057-afxwnd42s-please-help/
There are theoretically process hacker methods,
but I'm not an expert on those, and wouldn't recommend such methods.
And yes, unfortunately when I really needed to, I used OCR once.
Potentially you can do OCR, recreate the text in the same font,
and check for an exact image match as a double-check.
Also, if possible, set the font to one where characters such as capital i and small L are unambiguous.

LMS cmi.suspend_data not stored

I would like to store data in our ILIAS LMS with cmi.suspend_data, but the string e.g. "L_0_0_0_0_0_0_0" is not stored at all.
The commit I have done.
Tips -
Check what mode you are in cmi.mode. If you are in browse or review modes you will not be able to set any data.
Check error codes. This may give you some tip as to either the above, or other issues reported. That string is not over 64,000 characters and appears legal, so var ec = lms.GetLastError(); will get you a string code, and use that to get the message var msg = lms.GetErrorString(ec);
Keep in mind my 'lms' API example is the resolved connection to the API_1484_11 and not an actual 'thing'. So replace that with your local var.
I have a bookmarklet here https://www.cybercussion.com/bookmarklets/SCORM/ which may allow you some transparency finding out what mode you are in when viewing the content.
Good luck

Good Code Practice - Why does eClipse force us to use "only lower-case letters, numbers and !" for Token name?

Ok, I am using GWTP on eclipse. When creating a Presenter using eclipse & when I enter a token name say "!manageOrder" then eclipse show an error that "Token name must contain only lower-case letters, numbers and !". See the following picture.
However, in the NameTokens class, there is a line:
public static final String manageorder = "!mnageorder";
We can change to lowercase or upper the system is still ok.
So why does eClipse force us to use "only lower-case letters, numbers and !" for Token name?
if i use "!manageOrder" then it must easier for customer to figure out the what the page is right?
I believe this is just best practice being enforced by the version of the GWTP plugin you are using. It looks like you are using the old version of the plugin (for before GWTP 1.0)...
The new plugin allows capitals in the names:
Anyhow I would say use capitals if you want to, as long as it works.
More importantly, get using the current versions of GWTP and the associated plugin: https://github.com/ArcBees/gwtp-eclipse-plugin