Issue with Test class SingleLaunchActivityTestCase

by cg-dev » Fri, 04 Mar 2011 18:41:48 GMT


Sponsored Links
 Hi,

We're developping a test activity using SingleLaunchActivityTestCase<>
and JUnit on Android 2.3.3

We face the following issue :

In JUnit view in eclipse we have the following function call order :

testActivityTestCaseSetUpProperly() <- this one is built in android.
testA()
testB()
testC()

Each test use sendKeys() or TouchUtils.clickView().

On testC() sometimes we get this error :
W/InputDispatcher(  112): Permission denied: injecting event from pid
3753 uid 10001 to window with input channel 406a0b70
com.android.launcher/com.android.launcher2.Launcher (server) owned by
uid 10022

??? Launcher (desktop) get Events ??? We do nothing for that


So I put a Thread.sleep(5000) in testC() at the beginning.

I launch the test again :

testActivityTestCaseSetUpProperly() : Ok
testA() : Ok
testB() : Ok
Here application is put in background (for no reason we do not call
activity.finish() and co.)
testC() is launched but desktop is display. The test failed as we
cannot inject events to desktop.

The workaround for this is to create a dummy testZZZZ() function in
that way, testC() is executed before activity get closed.

testActivityTestCaseSetUpProperly() : Ok
testA() : Ok
testB() : Ok
testC() : Ok
testZZZZ() : don't care of result.

NOTE : sometimes the function order change :

testA()
testB()
testC()
testActivityTestCaseSetUpProperly()

In that way, the issue is not visible.


Hope it helps.





-- 



Re: Issue with Test class SingleLaunchActivityTestCase

by cg-dev » Fri, 04 Mar 2011 18:46:07 GMT


 I notice this in SingleLaunchActivityTestCase.java:

@Override
    protected void tearDown() throws Exception {
        // If it is the last test case, call finish on the activity.
        sTestCaseCounter --;
        if (sTestCaseCounter == 1) {
            sActivity.finish();
        }
        super.tearDown();
    }
This : "if (sTestCaseCounter == 1)" should be replaced by "if
(sTestCaseCounter == 0)" ?

Regards.




-- 


Sponsored Links


Other Threads

1. obtain recently used app list programatically?

As a user, whenever I long-press home key, I get this 'recently used
apps' list. As a developer, how do I fetch the same list
programatically?

PS I am mainly a forum guy and this is the first time i'm using a
mailing list, so very sorry if I dont post this in a proper way...

-- 

2. EndLess ListView

I want to display a list view with end less scrolling.

the list items are geeting WebService response. I am using CWAC-
EndLessAdapter and got it.

But the list items are one or two as from the webservice response the
web service calls upto filling the screen visible size.

how to solve this problem.




-- 

3. To apply a background to a Button

4. access html files in sdcard using commands or any...

5. Application don't want to close

6. Cant get helloWorld Loaded on AVD

7. Replacing native calendar