stephenwang1011 / robotium

Automatically exported from code.google.com/p/robotium
0 stars 0 forks source link

finishOpenedActivities does not quit the activities? #196

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Launch Activity (test starts)
2. Click Button
3. Wait for new Activity
5. Done (Should quit Activity)

What is the expected output? What do you see instead?
This should quit the activities so that my next tests can run from scratch. But 
it seems like the activity hangs in emulator (Also tried on a device)

What version of the product are you using? On what operating system?
3.0

Please provide any additional information below.
This only happens when I navigate between multiple activities.
It seems to be random, sometimes it quits the activity correctly, some other 
times it hangs on emulator so all other tests fail.

Here is my tearDown:

@Override
protected void tearDown() throws Exception {
     solo.finishOpenedActivities();
     getActivity().finish();
     super.tearDown();
}

Original issue reported on code.google.com by ary...@gmail.com on 14 Dec 2011 at 6:22

GoogleCodeExporter commented 9 years ago
More specific Bug reproduction steps:

1. Launch first Activity (Activity1)
2. Click Button, and launch second Activity (Activity2)
3. Click SignOut (Causes the app to open another Activity1)
4. Test done

Is it possible that since my last Activity class is the same as the first one, 
it's not trying to quit it. Although the activity classes are the same, they 
are different instances of this class.

Original comment by ary...@gmail.com on 14 Dec 2011 at 7:32

GoogleCodeExporter commented 9 years ago
How often does this happen?Is it always the same activity that is not finished? 
Would it be possible for you to send me your application?

Original comment by renasr...@gmail.com on 15 Dec 2011 at 8:06

GoogleCodeExporter commented 9 years ago
It happens probably 95% of the times. and yes, it's always the same activity, 
because all my tests start with a sign in and end with a sign out. 
Unfortunately, I can't share the application. I downloaded the source code for 
Robotium and I'm trying to troubleshoot this problem. I'll keep you updated 
with more information.

Original comment by ary...@gmail.com on 15 Dec 2011 at 2:54

GoogleCodeExporter commented 9 years ago
I created a sample project that demonstrates this bug.

Is it possible that the logic below is causing the problem (getCurrentActivity 
method under ActivityUtils.Java)
I think this logic does not allow multiple Activities with the same class to be 
added to activityList array, and therefore finish doesn't get called on all 
live activities.

for(int i = 0; i < activityList.size(); i++){
storedActivity = activityList.get(i);
if (storedActivity.getClass().getName().equals(
activity.getClass().getName()))
found = true;
}
if (found)
return activity;
else {
activityList.add(activity);
return activity;
}

Original comment by ary...@gmail.com on 16 Dec 2011 at 5:31

Attachments:

GoogleCodeExporter commented 9 years ago
Thanks for reporting this. The issue will be fixed in the next release.

Original comment by renasr...@gmail.com on 16 Dec 2011 at 6:47

GoogleCodeExporter commented 9 years ago
This has been fixed in Robotium 3.1.

Original comment by renasr...@gmail.com on 9 Jan 2012 at 11:59

GoogleCodeExporter commented 9 years ago
Thanks for the fix, this fixed the problem In the sample project; however, my 
actual project still does not work properly. I am still investigating this, 
I'll report a new bug when I can verify that this problem is not specific to my 
application.

Thanks again

Original comment by ary...@gmail.com on 9 Jan 2012 at 5:06

GoogleCodeExporter commented 9 years ago
You could try to use the second solo constructor Robotium(Instrumentation 
instrumentation) and then call getActivity() after the solo object is created. 

Original comment by renasr...@gmail.com on 9 Jan 2012 at 5:32

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Sorry for the delay, I haven't been working on automation for a while.
You said call getActivity(), but solo doesn't have a method called 
getActivity(), did you mean getCurrentActivity().

I tried the following and this change completely prevents solo from interacting 
with my application.
solo = new Solo(getInstrumentation());
solo.getCurrentActivity();

Original comment by ary...@gmail.com on 23 Jan 2012 at 11:13

GoogleCodeExporter commented 9 years ago
Please try the following:

solo = new Solo(getInstrumentation());
getActivity(); //included in ActivityInstrumentationTestCase2

Original comment by renasr...@gmail.com on 24 Jan 2012 at 4:17

GoogleCodeExporter commented 9 years ago
With very customized back stack and the last activity has "press Back Twice to 
exit", Robotium has difficulty handling the tearDown(). This issue may be the 
cause of Issue 172

Original comment by airg.aut...@gmail.com on 28 Jan 2012 at 2:01

GoogleCodeExporter commented 9 years ago
I tried the code you suggested, but that doesn't work.
while using this code, solo can't interact with the application at all.
I'll try "pressing back twice" and I'll post the result.

Original comment by ary...@gmail.com on 28 Jan 2012 at 2:05