Change some code in getButtonOnScreen() in EndToEndTestUtils.

This commit is contained in:
youtaol
2012-08-02 19:53:06 +08:00
parent acdb140a4e
commit 2fa1f6daf4
3 changed files with 17 additions and 6 deletions
@@ -246,7 +246,8 @@ public class CreateAndSendTrackTest extends ActivityInstrumentationTestCase2<Tra
instrumentation.waitForIdleSync(); instrumentation.waitForIdleSync();
EndToEndTestUtils.stopRecording(false); EndToEndTestUtils.stopRecording(false);
instrumentation.waitForIdleSync(); instrumentation.waitForIdleSync();
EndToEndTestUtils.SOLO.clickOnText(activityMyTracks.getString(R.string.generic_save)); EndToEndTestUtils.getButtonOnScreen(activityMyTracks.getString(R.string.generic_save), true,
true);
instrumentation.waitForIdleSync(); instrumentation.waitForIdleSync();
EndToEndTestUtils.SOLO.goBack(); EndToEndTestUtils.SOLO.goBack();
instrumentation.waitForIdleSync(); instrumentation.waitForIdleSync();
@@ -25,6 +25,7 @@ import android.app.Activity;
import android.app.Instrumentation; import android.app.Instrumentation;
import android.content.Context; import android.content.Context;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.util.Log;
import android.view.KeyEvent; import android.view.KeyEvent;
import android.view.View; import android.view.View;
import android.view.inputmethod.InputMethodManager; import android.view.inputmethod.InputMethodManager;
@@ -495,6 +496,7 @@ public class EndToEndTestUtils {
SOLO.waitForText(buttonName); SOLO.waitForText(buttonName);
} }
// Find on action bar.
if (hasActionBar) { if (hasActionBar) {
ArrayList<View> allViews = SOLO.getViews(); ArrayList<View> allViews = SOLO.getViews();
for (View view : allViews) { for (View view : allViews) {
@@ -509,11 +511,14 @@ public class EndToEndTestUtils {
} }
} }
ArrayList<Button> currentButtons = SOLO.getCurrentButtons(); // Get all buttons and find.
for (Button oneButton : currentButtons) { if(button == null) {
String title = (String) oneButton.getText(); ArrayList<Button> currentButtons = SOLO.getCurrentButtons();
if (title.equalsIgnoreCase(buttonName)) { for (Button oneButton : currentButtons) {
button = oneButton; String title = (String) oneButton.getText();
if (title.equalsIgnoreCase(buttonName)) {
button = oneButton;
}
} }
} }
@@ -521,6 +526,10 @@ public class EndToEndTestUtils {
SOLO.clickOnView(button); SOLO.clickOnView(button);
} }
if (button == null && isClick) {
Log.d(LOG_TAG, "Don't find the button " + buttonName);
}
return button; return button;
} }
@@ -153,6 +153,7 @@ public class SettingTest extends ActivityInstrumentationTestCase2<TrackListActiv
EndToEndTestUtils.createTrackIfEmpty(5, false); EndToEndTestUtils.createTrackIfEmpty(5, false);
EndToEndTestUtils.resetAllSettings(activityMyTracks, true); EndToEndTestUtils.resetAllSettings(activityMyTracks, true);
ChangeStatsSettings(false, false, true, true, true); ChangeStatsSettings(false, false, true, true, true);
instrumentation.waitForIdleSync();
EndToEndTestUtils.SOLO.clickOnText(activityMyTracks.getString(R.string.track_detail_stats_tab)); EndToEndTestUtils.SOLO.clickOnText(activityMyTracks.getString(R.string.track_detail_stats_tab));
assertTrue(EndToEndTestUtils.SOLO.waitForText( assertTrue(EndToEndTestUtils.SOLO.waitForText(
activityMyTracks.getString(R.string.stats_min_elevation), 1, activityMyTracks.getString(R.string.stats_min_elevation), 1,