xiaofans / robotium

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

APK test stuck after app is automatically opened #404

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Install any re-signed APK
2.  protected void setUp() throws Exception {
        solo = new Solo(getInstrumentation(), getActivity());
    }
3. Create a simple test, such as:
    public void testLogin() {
        solo.clickOnButton("Log in");
                //any other operations
    }

What is the expected output? What do you see instead?
Expecting app to launch and button to be clicked.
Instead app is launched but nothing happens regardless of the contents of 
testLogin. 
The workaround is to press the Back button, then tap the app on the home screen 
to open it again. Once this happens, the test progresses and finishes 
successfully.

What version of the product are you using? On what operating system?
Robotium 4.0, Android 2.3.4 (API 10), OS X Mountain Lion 10.8.2 

Please provide any additional information below.
Attempting to recreate the exact Intent flags as a manual homescreen launch 
does not fix Robotium in recognizing the app on first launch.

   protected void setUp()
            throws Exception {
       Intent i = new Intent();
        i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        i.addFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
        i.addCategory(Intent.CATEGORY_LAUNCHER);
        i.addCategory(Intent.CATEGORY_HOME);
        i.setAction(Intent.ACTION_MAIN);
        setActivityIntent(i);
        solo = new Solo(getInstrumentation(), getActivity());
   }

Original issue reported on code.google.com by valentin...@gmail.com on 6 Mar 2013 at 5:29

GoogleCodeExporter commented 9 years ago
Thanks for reporting this. Will get back to you if I have any questions. 

Original comment by renasr...@gmail.com on 6 Mar 2013 at 5:32

GoogleCodeExporter commented 9 years ago
I am not able to reproduce this issue. Would it be possible for you to send me 
an apk that behaves this way?

Original comment by renasr...@gmail.com on 3 Apr 2013 at 5:15

GoogleCodeExporter commented 9 years ago
I emailed you an apk to try (resigned twitter), although this issue is the same 
for all apks I tried so far.

Basically once the robotium test is built and deployed (I use mvn clean package 
android:deploy):
adb install com.twitter.android.apk
adb shell am instrument -w 
com.robotium.tests.twitter/android.test.InstrumentationTestRunner
This opens the app and it just stays so forever, doesn't ever click a button.
The prompt shows only:
com.robotium.tests.twitter.RobotTwitter:

My current workaround is to:
1) disable auto open: solo = new Solo(getInstrumentation()) instead of solo = 
new Solo(getInstrumentation(), getActivity()).
2) start the test (which now waits for app activity to open)
3) manually launch the app activity: adb shell am start -W -n 
com.twitter.android/.StartActivity

Hope this helps.
Please let me know if you need need any details.

Original comment by valentin...@gmail.com on 3 Apr 2013 at 4:27

Attachments:

GoogleCodeExporter commented 9 years ago
Thank you for the apk. I have tried through Eclipse and everything works well 
(tried with auto open as well). I think you are experiencing a maven 
configuration issue or such. Are you using the maven-android-plugin? Maybe they 
know what the problem might be. 

Original comment by renasr...@gmail.com on 4 Apr 2013 at 5:25

GoogleCodeExporter commented 9 years ago
Sorry, I should have mentioned this earlier, but I initially started and tested 
with Eclipse and I get the same behavior. So I think we can rule out 
maven-android-plugin.

I'm using stock/unmodified Android 2.3.4 on a Nexus S. Maybe you're using a 
newer Android version where this issue is not present?

Original comment by valentin...@gmail.com on 4 Apr 2013 at 5:46

GoogleCodeExporter commented 9 years ago
I am able to reproduce it on the 2.3.3 emulator. I can see that it is 
getActivity() that belongs to ActivityInstrumentationTestCase2 that is hanging. 
The issue is not within Robotium.  

Original comment by renasr...@gmail.com on 4 Apr 2013 at 6:01

GoogleCodeExporter commented 9 years ago
Thanks a lot for confirming this as a Android 2.3.3 issue and not a Robotium 
one.

Original comment by valentin...@gmail.com on 4 Apr 2013 at 4:57