sangmingming / robotium

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

waitforactivity() returns 'false' even when we have actvity on screen #255

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.Create 3 or more test cases in a package for an app with many activity screen
2.Each test case should include call solo.waitforactivity("testAvtivity", 60000)
3.Now batch run all the test cases in a package
4.First test case executes as expected but from second test case, where ever we 
have the function call it waits for all the 60sec and returns false as if it 
has not found the activity even when it is visible on screen. Test was executed 
from eclipse. 

What is the expected output? What do you see instead?
Expect the function to wait only till the activity is loaded

What version of the product are you using? On what operating system?
OS: 2.3.3 with robotium 3.2.1

Please provide any additional information below.

Original issue reported on code.google.com by santus...@gmail.com on 27 Apr 2012 at 7:15

GoogleCodeExporter commented 9 years ago
Thanks for reporting this. Can you provide me with a sample project that 
exhibits this problem?

Original comment by renasr...@gmail.com on 27 Apr 2012 at 7:57

GoogleCodeExporter commented 9 years ago
Will open up when more information is given.

Original comment by renasr...@gmail.com on 4 May 2012 at 5:30

GoogleCodeExporter commented 9 years ago
Hi,
I am also facing the same problem with Solo.waitforactivity.
With android 2.2 it works fine and with Android 3.2 it does not work.

Thanks in advance,
Vaibhav

Original comment by vaibha...@gmail.com on 4 May 2012 at 7:11

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Hi, I am facing the same problem. I am using android 2.3.3 on emulator. The 
problem is that when the 'assertTrue("Some error message", 
solo.waitForActivity("Name of activity"))' is used, it always fails, even if 
the activity was started. When just 'solo.waitForActivity("Name of activity")' 
is used, it always passes even if the activity never existed.

Original comment by fawa...@gmail.com on 31 Jul 2012 at 5:39

GoogleCodeExporter commented 9 years ago
Same problem here. Seems as if the ActivityMonitor doesn't record any more hits 
(at least when I peek the instance, mHits is 0).

Original comment by m...@thomaskeller.biz on 9 Nov 2012 at 12:40

GoogleCodeExporter commented 9 years ago
@thomaskeller, would it be possible for you to send me a sample app that 
exhibits this issue?

Original comment by renasr...@gmail.com on 12 Nov 2012 at 1:23

GoogleCodeExporter commented 9 years ago
@Renas: Unfortunately not, the app is closed source and we're really tight on 
schedule. I guess this issue is highly interconnected with issue 348. So far I 
read a lot of Robotiums source code and found that I could "fix" some of the 
issues by ensuring that my tests do not run too fast (e.g. I return data mocks 
with a delay), since the ActivityMonitor that is used by the ActivityUtils only 
checks every 50ms if the topmost activity has changed.

Now my tests run a bit more stable, but I still have problems when I try to 
read out TextViews: Instead of getting the dynamic value that I set in 
onCreate() I just get the original value that has been configured in the layout 
xml. Of course this particular problem only pops up sometimes and also only 
when the code is executed very slowly on arm-based emulators...

Original comment by m...@thomaskeller.biz on 13 Nov 2012 at 8:12

GoogleCodeExporter commented 9 years ago
Thanks for the feedback. I will decrease the delay. Please let me know if you 
find more things that results in non-stable test cases. 

Original comment by renasr...@gmail.com on 13 Nov 2012 at 8:19

GoogleCodeExporter commented 9 years ago
Happens on 4.3.1.
Rarely reproducible. Usually able to catch in on emulator running in headless 
more. Taking screenshot right after waitForActivity returned with false shows 
that activity is actually there.

Original comment by Paul.Tur...@gmail.com on 31 Aug 2014 at 7:14

GoogleCodeExporter commented 9 years ago
Please use 5.2.1.
Den 31 aug 2014 09:14 skrev <robotium@googlecode.com>:

Original comment by renasr...@gmail.com on 31 Aug 2014 at 7:22

GoogleCodeExporter commented 9 years ago
Just to add to my comment above: I'm unable to test this on 5.x verision of 
robolectric because it crashes with OOM. See defect 627 for details.

Original comment by Paul.Tur...@gmail.com on 31 Aug 2014 at 7:24

GoogleCodeExporter commented 9 years ago
robotiume 5.2.1 also can reproduce this error.
I wrote test case as this:
protected void setUp() throws Exception {
        super.setUp();
        Intent i = new Intent();
        i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        setActivityIntent(i);
        solo = new Solo(getInstrumentation());
        getActivity();
    }

public void testCapture() {
            //solo.assertCurrentActivity("current activity is not CameraActivity", CameraActivity.class);

            Activity act=solo.getCurrentActivity();
            assertTrue(act.getClass().getName().equals("com.android.camera.CameraActivity")); 

            int id=act.getResources().getIdentifier("shutter_button", "id", act.getPackageName());//通过String的id获取int的id
            ImageView shutterButton=(ImageView)act.findViewById(id);//获取View
            solo.sleep(1000);   
            solo.clickOnView(shutterButton);
            solo.sleep(1000);
            //assertTrue(PhotoEditor.class.getName().equals("com.android.s3dgallery3d.photoeditor.PhotoEditor")); 
            //ActivityMonitor imageActivityMonitor = this.getInstrumentation().addMonitor(PhotoEditor.class.getName(), null, false);
            solo.clickOnView(shutterButton);
            solo.sleep(1000);

            solo.waitForActivity(PhotoEditor.class.getName(),3000);
            solo.assertCurrentActivity("Failure to start PhotoEditorActivity", PhotoEditor.class);
}

surely,cameraActivity and PhotoEditor in the same process.
but solo.assertCurrentActivity("Failure to start PhotoEditorActivity", 
PhotoEditor.class) failed.

Original comment by lina_b...@163.com on 4 Jan 2015 at 10:21