mirror of
https://codeberg.org/OpenTracksApp/OpenTracks.git
synced 2026-10-02 09:33:06 +02:00
merge heads
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
+22
-7
@@ -22,6 +22,7 @@ import android.app.Instrumentation;
|
||||
import android.test.ActivityInstrumentationTestCase2;
|
||||
import android.view.KeyEvent;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.EditText;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@@ -93,18 +94,24 @@ public class CreateAndSendTrackTest extends ActivityInstrumentationTestCase2<Tra
|
||||
EndToEndTestUtils.findMenuItem(activityMyTracks.getString(R.string.menu_edit), true);
|
||||
|
||||
String newTrackName = EndToEndTestUtils.TRACK_NAME_PREFIX + "_new" + System.currentTimeMillis();
|
||||
String newType = "type" + newTrackName;
|
||||
String newType = "type" + newTrackName;
|
||||
String newDesc = "desc" + newTrackName;
|
||||
|
||||
instrumentation.waitForIdleSync();
|
||||
EndToEndTestUtils.rotateAllActivities();
|
||||
sendKeys(KeyEvent.KEYCODE_DEL);
|
||||
EndToEndTestUtils.SOLO.enterText(0, newTrackName);
|
||||
sendKeys(KeyEvent.KEYCODE_TAB);
|
||||
EndToEndTestUtils.SOLO.enterText(1, newType);
|
||||
sendKeys(KeyEvent.KEYCODE_TAB);
|
||||
EndToEndTestUtils.SOLO.enterText(2, newDesc);
|
||||
|
||||
ArrayList<EditText> editTexts = EndToEndTestUtils.SOLO.getCurrentEditTexts();
|
||||
|
||||
EndToEndTestUtils.SOLO.enterText(editTexts.get(0), newTrackName);
|
||||
EndToEndTestUtils.SOLO.enterText(editTexts.get(1), newType);
|
||||
// In landscape, there are only two visible edit texts.
|
||||
if (editTexts.size() > 2) {
|
||||
EndToEndTestUtils.SOLO.enterText(editTexts.get(2), newDesc);
|
||||
} else {
|
||||
EndToEndTestUtils.SOLO.scrollDown();
|
||||
editTexts = EndToEndTestUtils.SOLO.getCurrentEditTexts();
|
||||
EndToEndTestUtils.SOLO.enterText(editTexts.get(editTexts.size() - 1), newDesc);
|
||||
}
|
||||
EndToEndTestUtils.SOLO.clickOnButton(activityMyTracks.getString(R.string.generic_save));
|
||||
instrumentation.waitForIdleSync();
|
||||
// Go back to track list.
|
||||
@@ -136,6 +143,10 @@ public class CreateAndSendTrackTest extends ActivityInstrumentationTestCase2<Tra
|
||||
EndToEndTestUtils.stopRecording(false);
|
||||
EndToEndTestUtils.trackName = EndToEndTestUtils.TRACK_NAME_PREFIX + System.currentTimeMillis();
|
||||
EndToEndTestUtils.SOLO.enterText(0, EndToEndTestUtils.trackName);
|
||||
if(!EndToEndTestUtils.isEmulator) {
|
||||
// Close soft keyboard.
|
||||
EndToEndTestUtils.SOLO.goBack();
|
||||
}
|
||||
EndToEndTestUtils.SOLO.clickOnButton(activityMyTracks.getString(R.string.generic_save));
|
||||
|
||||
instrumentation.waitForIdleSync();
|
||||
@@ -182,6 +193,10 @@ public class CreateAndSendTrackTest extends ActivityInstrumentationTestCase2<Tra
|
||||
// Rotate when show insert page.
|
||||
EndToEndTestUtils.rotateAllActivities();
|
||||
EndToEndTestUtils.SOLO.enterText(0, WAYPOINT_NAME);
|
||||
if(!EndToEndTestUtils.isEmulator) {
|
||||
// Close soft keyboard.
|
||||
EndToEndTestUtils.SOLO.goBack();
|
||||
}
|
||||
EndToEndTestUtils.SOLO.clickOnButton(activityMyTracks.getString(R.string.generic_add));
|
||||
assertTrue(EndToEndTestUtils.SOLO.searchText(WAYPOINT_NAME));
|
||||
|
||||
|
||||
@@ -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;
|
||||
@@ -73,6 +74,7 @@ public class EndToEndTestUtils {
|
||||
// Check whether the UI has an action bar which is related with the version of
|
||||
// Android OS.
|
||||
static boolean hasActionBar = false;
|
||||
static boolean isEmulator = true;
|
||||
static boolean isCheckedFirstLaunch = false;
|
||||
|
||||
private EndToEndTestUtils() {}
|
||||
@@ -86,6 +88,11 @@ public class EndToEndTestUtils {
|
||||
if (number < 1) {
|
||||
return;
|
||||
}
|
||||
// If it's a real device, does not send simulated GPS signal.
|
||||
if (!isEmulator) {
|
||||
return;
|
||||
}
|
||||
|
||||
PrintStream out = null;
|
||||
Socket socket = null;
|
||||
try {
|
||||
@@ -111,6 +118,13 @@ public class EndToEndTestUtils {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the status whether the test is run on an emulator or not.
|
||||
*/
|
||||
static void setIsEmulator() {
|
||||
isEmulator = android.os.Build.MODEL.equals("google_sdk");
|
||||
}
|
||||
|
||||
/**
|
||||
* A setup for all end-to-end tests.
|
||||
@@ -119,6 +133,7 @@ public class EndToEndTestUtils {
|
||||
* @param activityMyTracks the startup activity
|
||||
*/
|
||||
static void setupForAllTest(Instrumentation instrumentation, TrackListActivity activityMyTracks) {
|
||||
setIsEmulator();
|
||||
EndToEndTestUtils.INSTRUMENTATION = instrumentation;
|
||||
EndToEndTestUtils.ACTIVITYMYTRACKS = activityMyTracks;
|
||||
EndToEndTestUtils.SOLO = new Solo(EndToEndTestUtils.INSTRUMENTATION,
|
||||
@@ -304,6 +319,10 @@ public class EndToEndTestUtils {
|
||||
EndToEndTestUtils.trackName = EndToEndTestUtils.TRACK_NAME_PREFIX
|
||||
+ System.currentTimeMillis();
|
||||
SOLO.enterText(0, trackName);
|
||||
if(!EndToEndTestUtils.isEmulator) {
|
||||
// Close soft keyboard.
|
||||
EndToEndTestUtils.SOLO.goBack();
|
||||
}
|
||||
SOLO.clickLongOnText(ACTIVITYMYTRACKS.getString(R.string.generic_save));
|
||||
}
|
||||
}
|
||||
@@ -485,4 +504,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<TextView> 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<View> views = EndToEndTestUtils.SOLO.getViews();
|
||||
for (View view : views) {
|
||||
if (view instanceof ChartView) {
|
||||
return (ChartView) view;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
+5
-3
@@ -50,14 +50,16 @@ public class GoToMyLocationTest extends ActivityInstrumentationTestCase2<TrackLi
|
||||
public void testGotoMyLocation() {
|
||||
EndToEndTestUtils.createTrackIfEmpty(1, false);
|
||||
EndToEndTestUtils.sendGps(30);
|
||||
instrumentation.waitForIdleSync();
|
||||
View myLocation = EndToEndTestUtils.SOLO.getCurrentActivity()
|
||||
.findViewById(R.id.map_my_location);
|
||||
EndToEndTestUtils.SOLO.clickOnView(myLocation);
|
||||
if (!EndToEndTestUtils.SOLO.waitForText(
|
||||
activityMyTracks.getString(R.string.my_location_no_location), 1, 1000)) {
|
||||
if (EndToEndTestUtils.isEmulator) {
|
||||
EndToEndTestUtils.SOLO.waitForText(
|
||||
activityMyTracks.getString(R.string.my_location_no_location), 1, 1000);
|
||||
} else {
|
||||
// TODO How to verify the location is shown on the map.
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -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 ActivityInstrumentationTestCase2<TrackListActiv
|
||||
* <li>Changes the setting of Sharing.</li>
|
||||
* </ul>
|
||||
*/
|
||||
public void testSetting() {
|
||||
public void testChangeAndReset() {
|
||||
EndToEndTestUtils.findMenuItem(activityMyTracks.getString(R.string.menu_settings), true);
|
||||
instrumentation.waitForIdleSync();
|
||||
// Rotate on the settings page.
|
||||
@@ -81,13 +82,13 @@ public class SettingTest extends ActivityInstrumentationTestCase2<TrackListActiv
|
||||
// Change a setting of sharing.
|
||||
EndToEndTestUtils.SOLO.clickOnText(activityMyTracks.getString(R.string.settings_sharing));
|
||||
assertTrue(EndToEndTestUtils.SOLO.waitForText(
|
||||
activityMyTracks.getString(R.string.settings_sharing_map_public), 1, 5000));
|
||||
activityMyTracks.getString(R.string.settings_sharing_allow_access), 1, 5000));
|
||||
ArrayList<CheckBox> sharingCheckBoxs = EndToEndTestUtils.SOLO.getCurrentCheckBoxes();
|
||||
boolean newMapsPublic = sharingCheckBoxs.get(0).isChecked();
|
||||
EndToEndTestUtils.SOLO.clickOnCheckBox(0);
|
||||
instrumentation.waitForIdleSync();
|
||||
assertTrue(EndToEndTestUtils.SOLO.waitForText(
|
||||
activityMyTracks.getString(R.string.settings_sharing_map_public), 1, 5000));
|
||||
activityMyTracks.getString(R.string.settings_sharing_allow_access), 1, 5000));
|
||||
assertEquals(!newMapsPublic, sharingCheckBoxs.get(0).isChecked());
|
||||
EndToEndTestUtils.SOLO.goBack();
|
||||
|
||||
@@ -110,6 +111,95 @@ public class SettingTest extends ActivityInstrumentationTestCase2<TrackListActiv
|
||||
assertEquals(newMapsPublic, sharingCheckBoxs.get(0).isChecked());
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the change of preferred units.
|
||||
*/
|
||||
public void testChangePreferredUnits() {
|
||||
EndToEndTestUtils.createTrackIfEmpty(5, false);
|
||||
// Change it and verify it.
|
||||
ChangePreferredUnits();
|
||||
// Change it back and verify it.
|
||||
ChangePreferredUnits();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the change of stats settings during recording on chart view.
|
||||
*/
|
||||
public void testChangeStatsSettings_underRecording_chart() {
|
||||
EndToEndTestUtils.startRecording();
|
||||
// Test just change preferred units when display CHART tab.
|
||||
EndToEndTestUtils.SOLO.clickOnText(activityMyTracks.getString(R.string.track_detail_chart_tab));
|
||||
EndToEndTestUtils.sendGps(3);
|
||||
ChangeStatsSettings(true, false);
|
||||
EndToEndTestUtils.sendGps(3);
|
||||
EndToEndTestUtils.stopRecording(true);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the change of stats settings during recording on stats view.
|
||||
*/
|
||||
public void testChangeStatsSettings_underRecording_stats() {
|
||||
EndToEndTestUtils.startRecording();
|
||||
// Test change preferred units and preferred rate when display STATS tab.
|
||||
EndToEndTestUtils.SOLO.clickOnText(activityMyTracks.getString(R.string.track_detail_stats_tab));
|
||||
EndToEndTestUtils.sendGps(3);
|
||||
ChangeStatsSettings(true, true);
|
||||
EndToEndTestUtils.sendGps(3);
|
||||
EndToEndTestUtils.stopRecording(true);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes settings of preferred units and preferred rate.
|
||||
*
|
||||
* @param changeUnits is change the preferred unit
|
||||
* @param changeRate is change the preferred rate
|
||||
*/
|
||||
private void ChangeStatsSettings(boolean changeUnits, boolean changeRate) {
|
||||
EndToEndTestUtils.findMenuItem(activityMyTracks.getString(R.string.menu_settings), true);
|
||||
EndToEndTestUtils.SOLO.clickOnText(activityMyTracks.getString(R.string.track_detail_stats_tab));
|
||||
assertTrue(EndToEndTestUtils.SOLO.waitForText(activityMyTracks
|
||||
.getString(R.string.settings_stats_units_title)));
|
||||
|
||||
// Change preferred units.
|
||||
if (changeUnits) {
|
||||
EndToEndTestUtils.SOLO.clickOnText(activityMyTracks
|
||||
.getString(R.string.settings_stats_units_title));
|
||||
}
|
||||
if (changeRate) {
|
||||
EndToEndTestUtils.SOLO.clickOnText(activityMyTracks
|
||||
.getString(R.string.settings_stats_rate_title));
|
||||
}
|
||||
EndToEndTestUtils.SOLO.goBack();
|
||||
EndToEndTestUtils.SOLO.goBack();
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes PreferredUnits and verifies the change.
|
||||
*/
|
||||
private void ChangePreferredUnits() {
|
||||
EndToEndTestUtils.findMenuItem(activityMyTracks.getString(R.string.menu_settings), true);
|
||||
EndToEndTestUtils.SOLO.clickOnText(activityMyTracks.getString(R.string.track_detail_stats_tab));
|
||||
assertTrue(EndToEndTestUtils.SOLO.waitForText(activityMyTracks
|
||||
.getString(R.string.settings_stats_units_title)));
|
||||
|
||||
boolean isImperial = EndToEndTestUtils.findTextView(activityMyTracks
|
||||
.getString(R.string.settings_stats_units_imperial), EndToEndTestUtils.SOLO
|
||||
.getCurrentListViews().get(0)) != null;
|
||||
|
||||
// Change preferred units.
|
||||
EndToEndTestUtils.SOLO.clickOnText(activityMyTracks
|
||||
.getString(R.string.settings_stats_units_title));
|
||||
isImperial = !isImperial;
|
||||
EndToEndTestUtils.SOLO.goBack();
|
||||
EndToEndTestUtils.SOLO.goBack();
|
||||
EndToEndTestUtils.SOLO.clickOnText(activityMyTracks.getString(R.string.track_detail_chart_tab));
|
||||
instrumentation.waitForIdleSync();
|
||||
ChartView chartView = EndToEndTestUtils.getChartView();
|
||||
assertEquals(!isImperial, chartView.isMetricUnits());
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the backup.
|
||||
*/
|
||||
@@ -164,8 +254,12 @@ public class SettingTest extends ActivityInstrumentationTestCase2<TrackListActiv
|
||||
EndToEndTestUtils.SOLO.clickOnText(activityMyTracks
|
||||
.getString(R.string.settings_recording_default_activity));
|
||||
EndToEndTestUtils.SOLO.enterText(0, DEFAULTACTIVITY);
|
||||
if(!EndToEndTestUtils.isEmulator) {
|
||||
// Close soft keyboard.
|
||||
EndToEndTestUtils.SOLO.goBack();
|
||||
}
|
||||
EndToEndTestUtils.SOLO.clickOnText(activityMyTracks.getString(R.string.generic_ok));
|
||||
|
||||
|
||||
EndToEndTestUtils.SOLO.goBack();
|
||||
EndToEndTestUtils.SOLO.goBack();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user