views:

58

answers:

1

I just got started with Robotium and tried a first very simple test, but experience some problem which I can't explain / doesn't seem logic to me.

I have a TabHost with an ActivityGroup and a toggle button on each activity that's displayed in the tabhost content section. When I press the toggle button, the tab content area changes to another activity (mTabHost.setCurrentTab(Intent intent);). Every activity holds such a toggle button, always with a label "Toggle". When I click the toggle button on the seconds activity, it will switch back to the first (all inside the tab content area).

|-----------------|
| TabHost |       | 
|-----------------| 
|                 | 
| Toggle-Button   | 
|                 | 
| (ActivityGroup: | 
| Activities      | 
| change in here) |
|                 | 
|-----------------|

Now, manually this all works fine, but the robotium test doesn't. When I attempt to click the toggle button on the second activity, I get an error message "junit.framework.AssertionFailedError: View can not be clicked!"

This is my test - very simple and small:

    solo.sleep(5000);
    solo.waitForActivity("StartTabsActivity", 10000);

    solo.clickOnButton("Toggle");
    // this will swap the activity inside the tabhost content section

    solo.sleep(5000);
    solo.waitForActivity("StatusListActivity", 5000);

    solo.assertCurrentActivity("Expected StatusList activity", "StatusListActivity");

    LogUtils.logD("robotium: button label: " + solo.getButton(1).getText()); 
    // ... outputs: robotium: button label: Toggle

    LogUtils.logD("robotium: button clickable: " + solo.getButton(1).isClickable()); 
    // ... outputs: robotium: button clickable: true

    solo.clickOnButton("Toggle");   
    // ... throws: junit.framework.AssertionFailedError: View can not be clicked!

What I don't understand here: I am checking that the button with "Toggle" label exists and is clickable, nevertheless, I'm getting an error saying "This view cannot be clicked.". And there's only one "Toggle" button in the respective current activity.

Related to this question I have another minor one: When I work with TabHost + ActivityGroup, will "solo.getCurrentActivity()" always return the embedded activity of the ActivityGroup, not the outer one? Can solo still access elements of the outer activity though? In my above case though, the toggle button is always part of the inner/embedded activity - in case that matters here.

A: 

Just got reply from robotium dev, that this is an issue that will be fixed in Robotium 1.8.

see http://groups.google.com/group/robotium-developers/browse_thread/thread/d02d8f27af261570

Mathias Lin