1

I'm writing test case for my android application. One of my activity has landscape and portrait xml files in respective folders. I have TextView only in landscape xml file. How to run my test case by forcing the activity in landscape orientation.

I used the below code in my test case, emulator gets opened in landscape orientation and immediately returning back to portrait mode.

Instrumentation.ActivityMonitor monitor =
            new Instrumentation.ActivityMonitor(MYActivity.class.getName(), null, false);
    getInstrumentation().addMonitor(monitor);
    // Rotate the screen
    mActivity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    getInstrumentation().waitForIdleSync();
    // Updates current activity
    mActivity = getInstrumentation().waitForMonitor(monitor);

Please help me how to keep in landscape till executing my testcase.

Vignesh
  • 2,295
  • 7
  • 33
  • 41

0 Answers0