I'm running my ActivityInstrumentationTestCase. it runs in the
emulator. I can watch the Intents triggering Activities in 'adb
logcat". I see in the logcat output that the Activity was displayed:
I/ActivityManager( 50): Displayed activity my.manifest.packate/
my.package.CountingActivity: 556 ms
so I believe I've sent the keys to press the button that fire the
startActivity. What I'm not seeing is the monitor that I've added
through the test. My waitForMonitorWithTimeout always times out.
Here is the part of the unit test that sets up the monitor, triggers
it, then waits:
ActivityResult result = new ActivityResult(1, null);
String activityClassName = "my.manifest.packate/
my.package.CountingActivity";
ActivityMonitor monitor = getInstrumentation().addMonitor
(activityClassName, result, true);
sendKeys(KeyEvent.KEYCODE_ENTER);
System.out.println("wait for timeout");
Activity actualActivity = getInstrumentation
().waitForMonitorWithTimeout(monitor, 20000);
System.out.println("after timeout");
assertNotNull("non null activity means the monitor was invoked",
actualActivity);
The activity implementation "CountingActivity" has a sysout, it always
prints in logcat after "wait for timeout" and before "after timeout",
but the actualActivity is always null. I show here using the full
<package>/<full-class-name> for the activityClassName. I began with
out the "<package>/" and used just the classname, but that had the
same effect -- never triggering the monitor. Further evidence that
I'm not registering the monitor correctly is that that addMonitor call
with true at the end should skip the actual Activity and return my
canned result.
Has anyone successfully tested with this process?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" 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-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---