android automate testing orientation change - android

I spend many time testing orientation changes, going back, changing again etc etc..checking if fragment are loaded correctly..
has anyone think about a process to test that issues or use a tool for that?
thanks

Using Robotium, you can change the orientation by simply calling:
solo.setActivityOrientation(Solo.LANDSCAPE);
or in JUnit:
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
I'm not really aware of an existing method of automatically testing with several screen sizes, but it would be easy enough to manually run the test using a different AVD if you configure AVDs for each screen resolution you want to test with. You could probably start various emulators and run the tests all from the command line on each emulator using something like the following (if you're using a Unix like operating system or Cygwin):
for i in avd_1 avd_2 avd_3
do
emulator -avd $i &
PID=$!
adb wait-for-device
adb -e install path/to/your/app.apk
kill $PID
done
where avd_1, avd_2, etc. are replaced by your android virtual device names for the devices with the different screen resolutions.

You might want to have a look at the Spoon test runner. It will run your instrumentation tests on all connected devices and can also make screenshots during the test to help you see the results visually.

If you want to run your unit & HMI tests on multiples emulators with different Screen size and resolution, the best thing to do is to setup a Jenkins with the android emulator plugin.
It allows you to define matrix jobs and check if your tests are ok on several platforms:
It will be painfull to set up but the benefits are really great!

Related

Change screen size of Genymotion programatically

There's a chance to change the screen size and density of an already created genymotion machine by going to the machine on the genymotion launcher-> configure-> Screen size - Density.
I'd like to do this through a shell command, does this command exist? How can it be called if so?
For now it is not possible.
But we will soon release features related to continuous integration and automation. A command line tool will be included on these features. It allows you to do all what you can do with your mouse, but through the command line. And it will be available to paid licenses.
Editing the screen size and resolution is part of it.
Here is a demo we gave at Droidcon Paris

Automation Blackbox testing render scripts

I need to find a solution to test some render scripts. Basically are some applications that display some animations on the screen. If the animation is displayed the test passes if not it fails.
I don't have the sources for the apk.
Until now using monkeyrunner i used to take 2 screenshots and compare them. If the two pictures where different the tests pass. Now because of a bug in android emulator i cannot take screenshot anymore.
If you can't take screenshots using MonkeyRunner, I'd suggest trying to take a screenshot on the device using a shell command, pulling the resulting image to the host computer and reading the image to a MonkeyImage.
First, get the device to take a screenshot on it's own:
monkeyDevice.shell("screencap -p /sdcard/screen.png")
Second, pull the screenshot from the device:
from subprocess import call
call(["adb", "pull", "/sdcard/screen.png"])
Third, load the screenshot as a MonkeyImage
image = MonkeyRunner.loadImageFromFile('screen.png')
Now you can compare the images using image.sameAs like normal.
Note that MonkeyRunner.loadImageFromFile was added in SDK version 13.

Do I have to run emulator or the editor is enough

I would like to test my android on difference screen sizes. I use eclipse, Should I run it on the emulator (AVD) with different screens/densities? Or would I be ok just using the editor and changing the skin to match what I want? I just want to see how my buttons/images look like.
Thank you
If you're making an app for tablet and phone then you really should consider running it at least on an emulator. I personally prefer using actual devices. Tablets, phones, etc. If that's not an option then yea, I'd make a couple AVDs and test it out. It's better safe than sorry. You can go into Window --> Android Virtual Device Manager ---> Device Definitions and there is a bunch of pre-made AVDs for actual devices. Just click the clone button and then set them up. Easiest way.
Just changing the screen sizes in the editor should be enough for getting a sense of where things are. Remember to always test your application periodically on the emulator and (preferably) on actual devices after the introduction of every new feature.

Changing screen resolution on android devices without re booting

I tried changing the screen resolution in build.prop file in system, but it requires re booting.
I need a solution for changing screen resolution on android devices without re booting.
Thanks,
Krishna
Unfortunately that is not possible. Everytime when Android boots, it will read the build.prop file and set parameters pointed by it accordingly. After it has booted, it will not access that file dynamically to change parameters. So for any change to take effect, a reboot is compulsary, you cannot escape it.
Set resolution (e.g. 1024x768):
$ am display-size 1024x768
Reset:
$ am display-size reset
Doesn't require a reboot. This works with Android 4.2. Solution for 4.3 is mentioned by LiTTle
There is also an App for that called NOMone Resolution Changer.
Android can change the screen resolution.
I think that you need Android 4.0 and above version.
Only things you need is terminal emulator and root access.
Reproduce the following steps:
1. Open the terminal emulator app.
2. Type su.
3. Type wm.
Read the help message appeared and you will understand...
In case you want an App take a look at this on Play Store or the source from Github.

How to test android application for different screen sized?

I have finished my application, but I have only 1 real device, and I need to test my application for different screen sizes. So, please, tell me, which emulator configurations should I use for diffrent screen sizes in order to I will be sure that my application will work on each configuration? Thank you.
there are more than 20 target devices are available in android developer website.
you can download few of them and load those devices in your emulator...
there is option in eclipse to select your target device before running your application...
Even by using the ADT plugin, in the layout editor, we can select the desired type of the phone, resolution, orientation and can check immediately with different types of resolutions..

Categories

Resources