Hi Dianne,
The following code can work well in my computer:
@UiThreadTest
public void testBikeButton(){
//click the bike button
bike_btn.performClick();
..
//I delete the following code, then it works
//getInstrumentation().waitForIdleSync();
..
Annotations have nothing to do with this, waitForIdleSync() has nothing to
do with this, it's just a basic aspect of Android that you can only call on
to UI objects from the thread running the UI. Use this:
http://developer.android.com/reference/android/app/Instrumentation.html#runOnMainSync%28ja
I have found the root cause of this problem.
That's because of getInstrumentation().waitForIdleSync()
I have seen someone else use waitForIdleSync() after UI action, I want
to know if it is necessary, and in which case we need to call this
method?
If we want to call it, how do we call it correctly
Hi Dianne,
I have tried to annotate the test method with UiThreadTest, but still
it doesn't work, the trace log is:
java.lang.RuntimeException: This method can not be called from the
main application thread
at android.app.Instrumentation.validateNotAppThread
(Instrumentation.java:1500)
at android.
As the error says, you are calling peformClick() for a different thread than
the UI thread (here the instrumentation thread). You can use the
Instrumentation API to perform a call on the UI thread.
On Mon, Aug 24, 2009 at 6:08 PM, android.bu...@gmail.com <
android.bu...@gmail.com> wrote:
>
> no
no one know it?
On Aug 24, 11:01 am, "android.bu...@gmail.com"
wrote:
> I am using ActivityInstrumentationTestCase2 to do some test for an
> activity.
> I get a button in the setUp() method like this:
> protected void setUp() throws Exception {
> super.setUp();
> act = getActivit
6 matches
Mail list logo