Robolectric does not start activity in the correct orientation

I am trying to have a unit test that checks to see if the activity was started in the correct orientation.
So, in my AndroidManifest.xml file, I have the orientation given as:

 <activity
            android:name="com.xxx.MyActivity"
            android:screenOrientation="portrait"
            android:theme="@style/MyTheme" >
            <meta-data
                android:name="target_device"
                android:value="phone" />
  </activity>

The tests and the test code are in the same project, so I believe Robolectric has no problem finding a manifest.
In addition, all tests are excellent, except for this.

And here is my unit test:

ActivityController<MyActivity> activityController = Robolectric
                .buildActivity(MyActivity.class)
                .create()
                .start()
                .postCreate(null)       
                .resume()
                .visible();
        MyActivity mActivity = activityController.get();
assertEquals(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT, mActivity.getResources().getConfiguration().orientation);

mActivity.getResources().getConfiguration().orientation always 0, and portrait - 1.

Any idea why? (using Robolectric 2.4)

+4
source share

No one has answered this question yet.

See related questions:

1492
Java ?
1338
Java ?
1249
Java ?
1042
,

All Articles