diff --git a/MyTracks/src/com/google/android/apps/mytracks/ChartView.java b/MyTracks/src/com/google/android/apps/mytracks/ChartView.java index 2e417ec74..932188c5d 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/ChartView.java +++ b/MyTracks/src/com/google/android/apps/mytracks/ChartView.java @@ -22,6 +22,7 @@ import com.google.android.apps.mytracks.util.IntentUtils; import com.google.android.apps.mytracks.util.StringUtils; import com.google.android.apps.mytracks.util.UnitConversions; import com.google.android.maps.mytracks.R; +import com.google.common.annotations.VisibleForTesting; import android.content.Context; import android.content.Intent; @@ -999,4 +1000,14 @@ public class ChartView extends View { return false; } } + + /** + * Returns the status of metricUnits. + * + * @return the status of metricUnits + */ + @VisibleForTesting + public boolean isMetricUnits() { + return metricUnits; + } } diff --git a/MyTracksTest/src/com/google/android/apps/mytracks/endtoendtest/EndToEndTestUtils.java b/MyTracksTest/src/com/google/android/apps/mytracks/endtoendtest/EndToEndTestUtils.java index 29cead52b..fdd60e030 100644 --- a/MyTracksTest/src/com/google/android/apps/mytracks/endtoendtest/EndToEndTestUtils.java +++ b/MyTracksTest/src/com/google/android/apps/mytracks/endtoendtest/EndToEndTestUtils.java @@ -15,6 +15,7 @@ */ package com.google.android.apps.mytracks.endtoendtest; +import com.google.android.apps.mytracks.ChartView; import com.google.android.apps.mytracks.TrackListActivity; import com.google.android.apps.mytracks.util.FileUtils; import com.google.android.maps.mytracks.R; @@ -485,4 +486,37 @@ public class EndToEndTestUtils { } return null; } + + /** + * Finds a text view with specified test in a view. + * + * @param findText text to find + * @param parent which text view in in + * @return the text view, null means can not find it + */ + static TextView findTextView(String findText, View parent) { + ArrayList textViews = EndToEndTestUtils.SOLO.getCurrentTextViews(parent); + for (TextView textView : textViews) { + String text = (String) textView.getText(); + if (textView.isShown() && text.endsWith(findText)) { + return textView; + } + } + return null; + } + + /** + * Gets the ChartView. + * + * @return the ChartView or null if not find + */ + static ChartView getChartView() { + ArrayList views = EndToEndTestUtils.SOLO.getViews(); + for (View view : views) { + if (view instanceof ChartView) { + return (ChartView) view; + } + } + return null; + } } diff --git a/MyTracksTest/src/com/google/android/apps/mytracks/endtoendtest/SettingTest.java b/MyTracksTest/src/com/google/android/apps/mytracks/endtoendtest/SettingTest.java index aa3c25315..4b3d31b94 100644 --- a/MyTracksTest/src/com/google/android/apps/mytracks/endtoendtest/SettingTest.java +++ b/MyTracksTest/src/com/google/android/apps/mytracks/endtoendtest/SettingTest.java @@ -15,6 +15,7 @@ */ package com.google.android.apps.mytracks.endtoendtest; +import com.google.android.apps.mytracks.ChartView; import com.google.android.apps.mytracks.TrackListActivity; import com.google.android.maps.mytracks.R; @@ -57,7 +58,7 @@ public class SettingTest extends ActivityInstrumentationTestCase2Changes the setting of Sharing. * */ - public void testSetting() { + public void testChangeAndReset() { EndToEndTestUtils.findMenuItem(activityMyTracks.getString(R.string.menu_settings), true); instrumentation.waitForIdleSync(); // Rotate on the settings page. @@ -110,6 +111,95 @@ public class SettingTest extends ActivityInstrumentationTestCase2