Change code style of SettingTest.testChangePreferredUnits.

This commit is contained in:
youtaol
2012-06-12 11:23:51 +08:00
parent 27aa9d6471
commit 2909d8a9c3
3 changed files with 21 additions and 11 deletions
@@ -119,8 +119,7 @@ public class ChartView extends View {
private int effectiveHeight = 0;
private boolean chartByDistance = true;
@VisibleForTesting
public boolean metricUnits = true;
private boolean metricUnits = true;
private boolean reportSpeed = true;
private boolean showPointer = false;
@@ -1001,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;
}
}
@@ -498,7 +498,9 @@ public class EndToEndTestUtils {
ArrayList<TextView> textViews = EndToEndTestUtils.SOLO.getCurrentTextViews(parent);
for (TextView textView : textViews) {
String text = (String) textView.getText();
if (textView.isShown() && text.endsWith(findText)) { return textView; }
if (textView.isShown() && text.endsWith(findText)) {
return textView;
}
}
return null;
}
@@ -511,7 +513,9 @@ public class EndToEndTestUtils {
static ChartView getChartView() {
ArrayList<View> views = EndToEndTestUtils.SOLO.getViews();
for (View view : views) {
if (view instanceof ChartView) { return (ChartView) view; }
if (view instanceof ChartView) {
return (ChartView) view;
}
}
return null;
}
@@ -131,14 +131,11 @@ public class SettingTest extends ActivityInstrumentationTestCase2<TrackListActiv
assertTrue(EndToEndTestUtils.SOLO.waitForText(activityMyTracks
.getString(R.string.settings_stats_units_title)));
boolean isImperial = !(EndToEndTestUtils.findTextView(activityMyTracks
boolean isImperial = EndToEndTestUtils.findTextView(activityMyTracks
.getString(R.string.settings_stats_units_imperial), EndToEndTestUtils.SOLO
.getCurrentListViews().get(0)) == null);
assertEquals(isImperial, EndToEndTestUtils.findTextView(activityMyTracks
.getString(R.string.settings_stats_units_metric), EndToEndTestUtils.SOLO
.getCurrentListViews().get(0)) == null);
.getCurrentListViews().get(0)) != null;
// Changes status
// Change preferred units.
EndToEndTestUtils.SOLO.clickOnText(activityMyTracks
.getString(R.string.settings_stats_units_title));
isImperial = !isImperial;
@@ -147,7 +144,7 @@ public class SettingTest extends ActivityInstrumentationTestCase2<TrackListActiv
EndToEndTestUtils.SOLO.clickOnText(activityMyTracks.getString(R.string.track_detail_chart_tab));
instrumentation.waitForIdleSync();
ChartView chartView = EndToEndTestUtils.getChartView();
assertEquals(!isImperial, chartView.metricUnits);
assertEquals(!isImperial, chartView.isMetricUnits());
}
/**