Closed GoogleCodeExporter closed 9 years ago
The problem with adding and using a option like this is that
getCurrentActivity() and all the methods that are using the activitymonitor
would stop to function. Would it work for you that we add a method that returns
the ActivityMonitor used in Robotium? In that case you could do a
inst.removeMonitor(activityMonitor); in your test case and add a new
ActivityMonitor that better suits your needs?
Original comment by renasr...@gmail.com
on 18 Apr 2011 at 12:22
Yes, that sounds like an easier solution to implement, and lets you be more
precise about when to disable/replace the ActivityMonitor.
Good idea :)
Original comment by chris@orr.me.uk
on 18 Apr 2011 at 12:53
Great. That will be included into the next release :)
Original comment by renasr...@gmail.com
on 18 Apr 2011 at 1:00
Original comment by renasr...@gmail.com
on 18 Apr 2011 at 6:20
This has been included into Robotium 2.3
Original comment by renasr...@gmail.com
on 21 Apr 2011 at 5:46
Thanks for doing this change. I added something this like in my base TestCase,
in case it's useful to anyone else:
/**
* Runs the given action, monitors activity starts for the given FQCN
* (e.g. {@code MyActivity.class.getName()}. Returns the monitor hit
* count, typically 1 on success.
*
* @param solo The instance of Solo
* @param activityFQCN The activity FQCN that should be started.
* @param action The action that should start the activity.
* @return The hit count of the activity monitor.
*/
int monitorActivityStart(Solo solo, String activityFQCN, Runnable action) {
// Solo has its own catch-all monitor which we must remove and replace
// by ours temporarily, then restore it back.
ActivityMonitor soloMonitor = solo.getActivityMonitor();
ActivityMonitor myMonitor = new ActivityMonitor(
PrefsTabUI.class.getName(),
null, // result
true); // block
try {
getInstrumentation().removeMonitor(soloMonitor);
getInstrumentation().addMonitor(myMonitor);
assertEquals(0, myMonitor.getHits());
action.run();
getInstrumentation().waitForIdleSync();
getInstrumentation().waitForMonitorWithTimeout(myMonitor, 1000);
return myMonitor.getHits();
} finally {
getInstrumentation().removeMonitor(myMonitor);
getInstrumentation().addMonitor(soloMonitor);
}
}
Original comment by r...@android.com
on 21 Nov 2011 at 5:20
Original issue reported on code.google.com by
chris@orr.me.uk
on 18 Apr 2011 at 11:24