Issue with Test class SingleLaunchActivityTestCase

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

Sponsored Links

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.

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 (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 :


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

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



Sponsored Links

Other Threads

1. gallery issues

Whoever answers these questions first gets a free gPhone* courtesy of

1) My gallery is an element in a list view right now... but once I
scroll down to select the gallery in the list, I can't scroll up and
down the list anymore (the gallery hijacks the "up" and "down" keys).

2) When I implement the gallery's onItemSelected listener, the gallery
stops doing its default animation when switching between images.  How
do I get the animation back?

3) I want to override my keys such that the "left" and "right"
softkeys switch the selected images in the gallery, even while the
gallery is not the selected view in the list.


*Offer valid until Google actually decides to release a real gPhone.

2. Title bar color and style


I have an issue with the definition of a style for my app.

I'd like to change the background color of the titles bar. I found
that the only way to do is to use styles and it's fine but ... I can't
succed in defining my styles.xml file from the documentation.

I read the doc on classes R.attr and R.styles and I did the following
styles.xml file (values are for test !) :

<?xml version="1.0" encoding="utf-8"?>

   <style name="TitleStyle">
        <item name="android:background">#008</item>
        <item name="android:textColor">#008</item>

    <style name="MyTheme">
       <item name="android:windowTitleBackgroundStyle">@styles/

But the line in MyTheme reject an error from the compiler : No
resource found that match the given name (<blabla name and values ...

Does anyone have an idea on the way of doing ? or anymore
documentation on "style" definition ?

Thanks a lot !

3. relative layout is not working at all?

4. How to control the image size in a ListView?

5. Database with Andriod

6. HTTPS GET/POST Methods don't work with HttpClient(4) - Bug or my fault?

7. How to create directories on sdcard?