pekechis
pekechis

Reputation: 388

android automate testing orientation change

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

Upvotes: 2

Views: 2618

Answers (3)

TBieniek
TBieniek

Reputation: 4937

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.

Upvotes: 1

ol_v_er
ol_v_er

Reputation: 27284

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:

jenkins matrix

It will be painfull to set up but the benefits are really great!

Upvotes: 0

HexAndBugs
HexAndBugs

Reputation: 5789

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.

Upvotes: 7

Related Questions