Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Ok, I think I finally managed to solve it - with <a href="http://robotium.org">robotium</a> framework. I'm attaching the solution in case someone had the same problem.<br></p> <p>Test:</p> <pre><code>public class MyActivityTest extends ActivityInstrumentationTestCase2&lt;MyActivity&gt;{ private static final String TAG = "RAMPS"; private MyActivity mActivity; private Solo mSolo; public MyActivityTest() { super("com.ramps", MyActivity.class); } @Override protected void setUp() throws Exception { super.setUp(); mActivity = getActivity(); mSolo = new Solo(getInstrumentation(), getActivity()); Log.v(TAG, "setUp; activity=" + mActivity); } public void testOrienationChange(){ mSolo.setActivityOrientation(Solo.LANDSCAPE); getInstrumentation().waitForIdleSync(); MyActivity newActivity = getActivity(); //should be new, but it's not Activity newActivity2 = mSolo.getCurrentActivity(); //this will return new activity Log.v(TAG, "testOrienationChange; activity=" + newActivity); Log.v(TAG, "testOrienationChange; activity2=" + newActivity2); } </code></pre> <p>}</p> <p>And log messages - for confirmation:</p> <pre><code>06-11 18:47:02.631: V/RAMPS(716): onCreate; activity=MyActivity@44c326a8 06-11 18:47:03.061: V/RAMPS(716): setUp; activity=MyActivity@44c326a8 06-11 18:47:03.781: V/RAMPS(716): onCreate; activity=MyActivity@44c481e0 06-11 18:47:04.482: V/RAMPS(716): testOrienationChange; activity=MyActivity@44c326a8 06-11 18:47:04.482: V/RAMPS(716): testOrienationChange; activity2=MyActivity@44c481e0 </code></pre> <p>As you can see, activity returned from mSolo.getCurrentActivity() is the same that was created after orientation change. I really recommend Robotium - another great piece of code from Jayway!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload