asifurrouf / android-test-kit

Automatically exported from code.google.com/p/android-test-kit
0 stars 0 forks source link

startActivities does not work in tests #97

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. start some activity
2. call from this activity something like:
   TaskStackBuilder.create(mContext)
                .addNextIntent(MainActivity.newIntent(mContext))
                .addNextIntent(SettingsActivity.newIntent(mContext))
                .startActivities();

What is the expected output? What do you see instead?
Expected to get:
started SettingsActivity, than after Espresso.pressBack(); we should get 
MainActivity.
We get:
only MainActivity, after Espresso.pressBack(); app deos close
Further more same code works in application when we run code outside tests.

What version of the product are you using? On what operating system?
Android emulator KitKat
I'm using Jake Wharton build 'com.jakewharton.espresso:espresso:1.1-r3', but I 
believe this is a master branch issue.

Please provide any additional information below.
I Think I found a bug in method:

"public void execStartActivities(Context who, IBinder contextThread, IBinder 
token, Activity target, Intent[] intents, Bundle options)"
In GoogleInstrumentation class
https://code.google.com/p/android-test-kit/source/browse/testrunner/src/main/jav
a/com/google/android/apps/common/testing/testrunner/GoogleInstrumentation.java?r
=ae3e6031add94e17e6a655bc0ec4768e57ebada0

There is a backward iteration and I think it should be a forward.
after changing:
"for (int idx = intentList.size() - 1; idx >= 0; idx--)" to "for (Intent 
anIntentList : intentList)" everything started working in my test case.

Original issue reported on code.google.com by jacek.ma...@gmail.com on 9 Sep 2014 at 2:04

GoogleCodeExporter commented 9 years ago
That's a bug. Working on a fix for the coming release.

Original comment by vale...@google.com on 19 Nov 2014 at 10:44

GoogleCodeExporter commented 9 years ago
Fixed in Espresso 2.0

Original comment by vale...@google.com on 20 Dec 2014 at 4:33