Keyboard shortcut for Run As -> Android JUnit Test in Eclipse - android

Anybody figured out the keyboard equivalent of this menu?
I have been using this menu on test cases infused with Robotium with class signatures like:
public class AccountTest extends ActivityInstrumentationTestCase2<MainActivity> { ... }
Somehow, Alt-Shift-X, T just doesn't quite do the same thing even if you select the Android JUnit Runner in the dialog that pops up...
The similar Run As -> Android Application has a tricky shortcut of Alt-Shift-A, R when launching every other conceivable type of runnable begins with Alt-Shift-X, so there is hope.

Window -> Preferences -> Run/Debug -> Launching -> Always launch the previously launched application.
Run the test case, either the whole thing, or a particular test method, once. It then becomes available to run again in the history. Press the Run or Debug button's drop down menu. Select the configuration you want to run.
From then on, F11 or Ctrl+F11 (debug or run) rinses and repeats the exact same thing again.
type type type, F11, observe results, type type type. No mouse. Very productive.

On my macbook I'm using Shift-Command-Fn-F11.

I am using a similar shortcut but for TestNG, in my case, the shortcut is SHIFT + ALT + X, G
So when I press SHIFT + ALT + X, I get a small window at bottom right side as:
Once I see this window on the bottom right, as I hit the key G, it launches TestNG Suite as expected.

Related

Set no-touch option to Chrome OS emulator

Good morning. I need to test my application in Chrome OS, but without the "touch screen"
I used this guide to run a emulation of Chrome OS:
https://www.groovypost.com/howto/chrome-os-android-studio/
Ok, I succeeded to run it, I activated the debugging mode and I activated the adb debugging....finally everything is working and I can run my application on it.
The problem is, I want to test it without touchscreen.
I found the hw.screen property inside
~/.android/avd/<machine-name>.avd/hardware-qemu.ini
that was set to hw.screen = multi-touch.
WOW, exactly what I want, let's change it to no-touch.
Inside ~/Android/Sdk/emulator/lib/hardware-properties.ini you can see
# Touch screen type
name = hw.screen
type = string
enum = touch, multi-touch, no-touch
default = multi-touch
abstract = Touch screen type
description = Defines type of the screen.
so, no-touch is a valid option.
The problem is, even if I change it, every time I restart the emulator, it is set back to multi-touch.
I also tried to change the option directly in ~/Android/Sdk/emulator/lib/hardware-properties.ini, that should contain the default option, but no luck...
Someone can tell me who is overwriting this property each time I start the emulation?
How can I remove the touch screen in the emulation?
Launch the emulator from the command line and use the flag -screen no-touch. This is because the emulator overrides the config in the .ini file. That gives no touch screen but the mouse wasn't usable, at least on Windows.
See the docs for more details

Recent Apps on UiAutomator

I am now working with Android UiAutomator on for UI Test on my Android app. My app has a function that requires the user to verify the email to continue, so I try to do it like this: after reach to that function -> getUiDevice.pressHome -> Browser -> try to log in email -> PressHome again -> Press RecentApps then I stuck here, I cannot press on my Apps to return to it again. I try another way by clicking on my App icon but it starts my app again, not at the state before. Can anyone suggest me a solution for this? Any help is appreciate.
Thanks in advance.
Try this :
UiObject appBackground = new UiObject(new UiSelector().description("ABC"));
appBackground.click();
It did not show any description through 'uiautomatorviewer' command but this worked for me.
I could manage to create this behavior with:
fun backgroundAndForeground() {
val device = UiDevice.getInstance(getInstrumentation())
device.pressHome()
// Pressing app switch two times makes the last app put on background come to foreground.
device.pressKeyCode(KeyEvent.KEYCODE_APP_SWITCH)
device.pressKeyCode(KeyEvent.KEYCODE_APP_SWITCH)
}
In this case, I think that android only resume app when clicking the recent app image. It does not work on clicking display text or app icon. So, we need to click image of your app in recent app list. At that time you need to write as below. I always do that for similar case.
// Take all image view by class type and click by instance no.
new UiObject(new UiSelector().className("android.widget.ImageView").instance(3)).click();
You need to count instance no of your recent app image view. Not app icon image in recent app scroll view. Please try this. Thanks.
I've spent half a day on this and concluded I needed to issue a device.click(). Since my use-case is that my app was the last one running (not switching to the browser like you), I can safely click the middle of the screen and it'll always work.
If you're the 2nd to last running app, you can probably do x: 0 and y: device.displayHeight/2.
I've not tested this on many operating systems, only 9.

Keyboard shortcurts for Android Emulator?

I just do this in android emulator for copying and pasting the data in edittext.
Ctrl + C = Copy
Ctrl + V = Paste
But it didn't works. So, i need to know if these shortcuts are working or not in emulator. Or, any other special shortcuts available for android emulator. Anyone knows this means, help me to find out the problem? Hope this will very useful for me. I'm working on Windows 7 Professional OS.
You can see the shortcuts by clicking on the "more" button:
And going to the "Help" tab:
For more information: Android Emulator.
You can check current config from console
emulator -help-keys
When running the emulator, use the following keypresses:
Ctrl-H Home button
Ctrl-M Menu (Soft-Left) button
Ctrl-Backspace Back button
Ctrl-Escape Power button
Ctrl-Equal Volume up button
Ctrl-Minus Volume down button
note that NumLock must be deactivated for keypad keys to work
Copy the text you want:
Ctrl + C = Copy
Then when the emulator is in focus, paste using:
Ctrl + V = Paste
Then in the edit text that you want, long click on the field until you see the emulator paste button pop up above your cursor. Click that and it should work.
In the Android Studio Emulator the ctrl+v doensn't works, just hold the left mouse button for a second and paste menu will appear (in textbox etc.).
For Mac OS, the most important shortcuts are:
Cmd + Backspace: Back button
Cmd + O: Overview (The square button)
Cmd + Shift + H: Home (The center button)
You can see the rest from the Triple Dot menu, go to Help section.

How to prevent some of the unittest files from running

I have few unit tests setup using juit in unittest1.java unittest2.java unittest3.java in android.
I want unittest1 and unittest2 not run when I am writing unittest3.java. Is there a way to do that. Googgling did not yield much.
Thanks.
Just go inside your unittest3.java and click Ctrl+F11 for Run or F11 for Debug. This will run only tests inside current class.
Also, you can setup Run/Debug configurations manually. Assuming I have MacTest.java file with MacTest class inside:

Detecting alt keypresses in Android app

I want to create keyboard shortcuts in my Android app such that, say, alt-t runs a certain command. I can't seem to figure out how to detect the presence of the alt modifier in the emulator, though.
I've overridden onKeyDown() in my app to look like the following (Scala):
override def onKeyDown(keycode:Int, event:KeyEvent) = keycode match {
case KeyEvent.KEYCODE_B =>
StatisticsService.map(_.sayBatteryLevel())
true
case KeyEvent.KEYCODE_D =>
StatisticsService.map(_.sayDate())
true
case KeyEvent.KEYCODE_S =>
StatisticsService.map(_.saySignalStrengths())
true
case KeyEvent.KEYCODE_T =>
StatisticsService.map(_.sayTime())
true
case _ => super.onKeyDown(keycode, event)
}
That of course matches the plain keys just fine, but not alt-b, alt-t, etc. How can I change the above to match the given alt-modified bindings?
I've searched Google and have tried using event.isAltPressed, but this doesn't work. I've also logged the results of the keypresses, and have noticed that the alt key isn't at all picked up. That is, simply pressing alt does nothing, and pressing alt-t produces identical logs to just t.
This is being tested in the emulator if that makes a difference.
Edit: Not sure how to respond to comments left on my question, but I'm aware that not all devices have alt keys, but that's not an issue here because I'm coding for a custom device that does. The question isn't "what's the most generic way to do this," but "how do I match alt keybindings when the documented methods don't work and no explanation seems to be given in Google's own docs?"
Thanks.

Categories

Resources