On Wed, Feb 4, 2009 at 6:43 PM, Andrew Stadler <[email protected]> wrote:
>
> Meryl-
>
> It's hard to say with only a partial snippet, but I'm guessing that
> you're using an InstrumentationTestCase or possibly an
> ActivityUnitTestCase. You'll be better served here using an
> ActivityInstrumentationTestCase, which will start your activity for
> you, and then you should be able to call into it normally.
>
Andy,
Thank you. Can you please tell me where I can find example of
ActivityInstrumentationTestCase?
The only thing I found is. And I am not sure why it does not have any
'assert' for unit testing...
Thank you for any more pointers.
/**
* Make sure that the main launcher activity opens up properly, which will be
* verified by {...@link
ActivityInstrumentationTestCase#testActivityTestCaseSetUpProperly}.
*/
public class ApiDemosTest extends ActivityInstrumentationTestCase<ApiDemos> {
public ApiDemosTest() {
super("com.example.android.apis", ApiDemos.class);
}
}
> In either case, a clue that something is wrong is that you're calling
> both startActivity() *and* callActivityOnStart(), which cannot be
> right.
>
> --Andy
>
>
> On Wed, Feb 4, 2009 at 4:50 PM, Meryl Silverburgh
> <[email protected]> wrote:
>>
>> Hi,
>>
>> I have the following test code which calls
>> callActivityOnRestoreInstanceState of Instrumentation class.
>> mStartIntent = new Intent(Intent.ACTION_MAIN);
>> Bundle bundle = new Bundle();
>> bundle.putBoolean("testProperty", false);
>>
>> MyActivity myActivity = startActivity(mStartIntent, null,
>> null);
>>
>> getInstrumentation().callActivityOnStart(myActivity);
>>
>>
>> getInstrumentation().callActivityOnRestoreInstanceState(myActivity, bundle);
>>
>> But when I run the unit test with instrumentation, i get this error:
>> ndroid.util.AndroidRuntimeException: Acquiring SearchManager objects
>> only valid in Activity Contexts.
>> at
>> android.app.ApplicationContext.getSearchManager(ApplicationContext.java:976)
>> at
>> android.app.ApplicationContext.getSystemService(ApplicationContext.java:861)
>> at
>> android.view.ContextThemeWrapper.getSystemService(ContextThemeWrapper.java:73)
>> at android.app.Activity.getSystemService(Activity.java:3091)
>> at android.app.Activity.performRestoreInstanceState(Activity.java:797)
>> at
>> android.app.Instrumentation.callActivityOnRestoreInstanceState(Instrumentation.java:1171)
>> at
>> com.mycompany.TestMyActivity.testSaveRestoreInstanceState(TestMyActivity.java:79)
>>
>> Can you please tell me what am I missing in setting up my instrumentation?
>>
>> Thank you.
>>
>> >
>>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---