rahul7386 / robotium

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

clickOnActionBarHomeButton() throws IllegalStateException #619

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Running Robotium 5.2.1.

Android 4.3 on a Galaxy s3

from our manifest
  android:minSdkVersion="10"
  android:targetSdkVersion="19"

I observe that solo.clickOnActionBarHomeButton() does nothing. Running manually 
it does work.

When I put a break point in our application in the onOptionsItemSelected method 
and run via Robotium

                   try {
                        manager.popBackStackImmediate(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
                    }
                    catch (Exception e) {
                        Log.d("robotiumError", e.toString(), e);  //breakpoint put here
                    }

An exception is thrown. The walkback stack at the breakpoint location

<11> Instr: android.test.InstrumentationTestRunner@830043907832, prio=5, in 
group 'main', status: 'RUNNING'
      at com.yahoo.mobile.client.android.XXX.ui.MainActivity.onOptionsItemSelected(MainActivity.java:704)
      at android.support.v4.app.Watson.onMenuItemSelected(Watson.java:119)
      at com.actionbarsherlock.ActionBarSherlock.callbackOptionsItemSelected(ActionBarSherlock.java:603)
      at com.actionbarsherlock.internal.ActionBarSherlockNative.dispatchOptionsItemSelected(ActionBarSherlockNative.java:78)
      at com.actionbarsherlock.app.SherlockFragmentActivity.onMenuItemSelected(SherlockFragmentActivity.java:205)
      at com.robotium.solo.Clicker.clickOnActionBarHomeButton(Clicker.java:375)
      at com.robotium.solo.Solo.clickOnActionBarHomeButton(Solo.java:1301)
      at test.appview.AbstractXXXView.goUp(AbstractXXXView.java:27)
      at test.SmokeTest.testUpButton(SmokeTest.java:70)
      at java.lang.reflect.Method.invokeNative(Method.java:-1)
      at java.lang.reflect.Method.invoke(Method.java:525)
      at android.test.InstrumentationTestCase.runMethod(InstrumentationTestCase.java:214)
      at android.test.InstrumentationTestCase.runTest(InstrumentationTestCase.java:199)
      at android.test.ActivityInstrumentationTestCase2.runTest(ActivityInstrumentationTestCase2.java:192)
      at test.AbstractActivityTest.runTest(AbstractActivityTest.java:23)
      at junit.framework.TestCase.runBare(TestCase.java:134)
      at junit.framework.TestResult$1.protect(TestResult.java:115)
      at junit.framework.TestResult.runProtected(TestResult.java:133)
      at junit.framework.TestResult.run(TestResult.java:118)
      at junit.framework.TestCase.run(TestCase.java:124)
      at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:191)
      at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:176)
      at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:554)
      at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1738)

This code is invoked  via com.robotium.solo.Clicker (375) 
clickOnActionBarHomeButton

The exception e is a java.lang.IllegalStateException "Must be called from main 
thread of process"

The Robotium code on Clicker (375) ignores the exception.

I reran without the debugger to see if I was observing some debugging artifact, 

06-30 14:39:26.715: D/robotiumError(18296): java.lang.IllegalStateException: 
Must be called from main thread of process
06-30 14:39:26.715: D/robotiumError(18296): java.lang.IllegalStateException: 
Must be called from main thread of process
06-30 14:39:26.715: D/robotiumError(18296):     at 
android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.ja
va:1454)
06-30 14:39:26.715: D/robotiumError(18296):     at 
android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentMa
nager.java:478)
06-30 14:39:26.715: D/robotiumError(18296):     at 
android.support.v4.app.FragmentManagerImpl.popBackStackImmediate(FragmentManager
.java:509)
06-30 14:39:26.715: D/robotiumError(18296):     at 
com.yahoo.mobile.client.android.xxx.ui.MainActivity.onOptionsItemSelected(MainAc
tivity.java:701)
06-30 14:39:26.715: D/robotiumError(18296):     at 
android.support.v4.app.Watson.onMenuItemSelected(Watson.java:119)
06-30 14:39:26.715: D/robotiumError(18296):     at 
com.actionbarsherlock.ActionBarSherlock.callbackOptionsItemSelected(ActionBarShe
rlock.java:603)
06-30 14:39:26.715: D/robotiumError(18296):     at 
com.actionbarsherlock.internal.ActionBarSherlockNative.dispatchOptionsItemSelect
ed(ActionBarSherlockNative.java:78)
06-30 14:39:26.715: D/robotiumError(18296):     at 
com.actionbarsherlock.app.SherlockFragmentActivity.onMenuItemSelected(SherlockFr
agmentActivity.java:205)
06-30 14:39:26.715: D/robotiumError(18296):     at 
com.robotium.solo.Clicker.clickOnActionBarHomeButton(Clicker.java:375)
06-30 14:39:26.715: D/robotiumError(18296):     at 
com.robotium.solo.Solo.clickOnActionBarHomeButton(Solo.java:1301)
06-30 14:39:26.715: D/robotiumError(18296):     at 
test.appview.AbstractXXXView.goUp(AbstractXXXView.java:27)
06-30 14:39:26.715: D/robotiumError(18296):     at 
test.SmokeTest.testUpButton(SmokeTest.java:70)
06-30 14:39:26.715: D/robotiumError(18296):     at 
java.lang.reflect.Method.invokeNative(Native Method)
06-30 14:39:26.715: D/robotiumError(18296):     at 
java.lang.reflect.Method.invoke(Method.java:525)
06-30 14:39:26.715: D/robotiumError(18296):     at 
android.test.InstrumentationTestCase.runMethod(InstrumentationTestCase.java:214)
06-30 14:39:26.715: D/robotiumError(18296):     at 
android.test.InstrumentationTestCase.runTest(InstrumentationTestCase.java:199)
06-30 14:39:26.715: D/robotiumError(18296):     at 
android.test.ActivityInstrumentationTestCase2.runTest(ActivityInstrumentationTes
tCase2.java:192)
06-30 14:39:26.715: D/robotiumError(18296):     at 
test.AbstractActivityTest.runTest(AbstractActivityTest.java:23)
06-30 14:39:26.715: D/robotiumError(18296):     at 
junit.framework.TestCase.runBare(TestCase.java:134)
06-30 14:39:26.715: D/robotiumError(18296):     at 
junit.framework.TestResult$1.protect(TestResult.java:115)
06-30 14:39:26.715: D/robotiumError(18296):     at 
junit.framework.TestResult.runProtected(TestResult.java:133)
06-30 14:39:26.715: D/robotiumError(18296):     at 
junit.framework.TestResult.run(TestResult.java:118)
06-30 14:39:26.715: D/robotiumError(18296):     at 
junit.framework.TestCase.run(TestCase.java:124)
06-30 14:39:26.715: D/robotiumError(18296):     at 
android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:191)
06-30 14:39:26.715: D/robotiumError(18296):     at 
android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:176)
06-30 14:39:26.715: D/robotiumError(18296):     at 
android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:55
4)
06-30 14:39:26.715: D/robotiumError(18296):     at 
android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1738)

Original issue reported on code.google.com by bru...@yahoo-inc.com on 1 Jul 2014 at 1:52

GoogleCodeExporter commented 9 years ago
Thanks for reporting this. Currently Robotium does not support 
ActionBarSherlock and that is why you are getting this exception. Maybe this 
extension can help: https://github.com/atermenji/robotium-actionbarsherlock

Original comment by renasr...@gmail.com on 2 Jul 2014 at 9:32