How do you force an orientation change in an Android Instrumentation test?

You do not actually have to use Robotium for this at all. In fact, if you view the source of Robotium all it is doing when you call.

You do not actually have to use Robotium for this at all. In fact, if you view the source of Robotium all it is doing when you call solo. SetActivityOrientation(Solo.

LANDSCAPE); is myActivity = this.getActivity(); // In your setUp method() ... myActivity. SetRequestedOrientation(ActivityInfo. SCREEN_ORIENTATION_LANDSCAPE).

Awesome, switched the accepted answer to yours. Kudo's for the detective work go to you sir. – Jimbo Aug 25 at 3:20.

Use Robotium for it. There is a class called Solo, using which you can change orientation by just calling a method: solo. SetActivityOrientation(Solo.

LANDSCAPE); That's it! Your orientation would get changed. You can google Robotium and obtain its jar and add it to your Test project.

The Robotium site also gives an example Test project on Android's Notepad App (which is available as a sample project with Android SDK) which shows how powerful it is and how easily it could be used.

Wow, thank you! It's been a while since I asked the question and its seen a lot of views. This definitely solves the problem I had.

Robotium looks like a great testing library. – Jimbo Jan 19 at 22:03 Yes James, It sure is! :) – Kiran Parmar Jan 20 at 11:13.

As AndrewKS wrote you can use getActivity(). SetRequestedOrientation(ActivityInfo. SCREEN_ORIENTATION_LANDSCAPE); assertTrue(...); to request an orientation change.

But the rotation itself is executed asynchronous. To really test the state after the orientation change you need to wait a short time after the request: getActivity(). SetRequestedOrientation(ActivityInfo.

SCREEN_ORIENTATION_LANDSCAPE); Thread. Sleep(50); // depends on performance of the testing device/emulator assertTrue(...).

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions