Change showMoreMenuItem() to showMenuIten() and make the logic to find menu right and clear. Fix issues when run on emulator 2.3.3.

This commit is contained in:
youtaol
2012-07-17 14:14:19 +08:00
parent a64a51bc16
commit 56663c53a4
4 changed files with 101 additions and 60 deletions
@@ -22,6 +22,9 @@ import android.annotation.TargetApi;
import android.app.Instrumentation;
import android.test.ActivityInstrumentationTestCase2;
import android.view.View;
import android.widget.ImageButton;
import java.util.ArrayList;
/**
* Tests the function of go to my location.
@@ -55,10 +58,23 @@ public class GoToMyLocationTest extends ActivityInstrumentationTestCase2<TrackLi
instrumentation.waitForIdleSync();
View myLocation = EndToEndTestUtils.SOLO.getCurrentActivity()
.findViewById(R.id.map_my_location);
// Find the My Location button in another if null.
if (myLocation == null) {
ArrayList<ImageButton> aa = EndToEndTestUtils.SOLO.getCurrentImageButtons();
for (ImageButton imageButton : aa) {
if (imageButton.getContentDescription() != null
&& imageButton.getContentDescription().equals(
activityMyTracks.getString(R.string.icon_my_location))) {
myLocation = imageButton;
break;
}
}
}
EndToEndTestUtils.SOLO.clickOnView(myLocation);
if (EndToEndTestUtils.isEmulator) {
EndToEndTestUtils.SOLO.waitForText(
activityMyTracks.getString(R.string.my_location_no_location), 1, EndToEndTestUtils.SHORT_WAIT_TIME);
activityMyTracks.getString(R.string.my_location_no_location), 1,
EndToEndTestUtils.SHORT_WAIT_TIME);
} else {
// TODO How to verify the location is shown on the map.
}