forked from upstream-mirrors/OpenTracks
Merge heads
This commit is contained in:
+83
-102
@@ -88,80 +88,20 @@ public class CreateAndSendTrackTest extends ActivityInstrumentationTestCase2<Tra
|
|||||||
/**
|
/**
|
||||||
* Check all services and send to google.
|
* Check all services and send to google.
|
||||||
*/
|
*/
|
||||||
public void testCreateAndSendTrack_Send() {
|
public void testCreateAndSendTrack_send() {
|
||||||
EndToEndTestUtils.createTrackIfEmpty(1, false);
|
EndToEndTestUtils.createTrackIfEmpty(1, false);
|
||||||
instrumentation.waitForIdleSync();
|
instrumentation.waitForIdleSync();
|
||||||
EndToEndTestUtils.findMenuItem(activityMyTracks.getString(R.string.menu_send_google), true);
|
checkSendTrackToGoogle();
|
||||||
EndToEndTestUtils.SOLO.waitForText(activityMyTracks.getString(R.string.send_google_title));
|
}
|
||||||
ArrayList<CheckBox> checkBoxs = EndToEndTestUtils.SOLO.getCurrentCheckBoxes();
|
|
||||||
for (int i = 0; i < checkBoxs.size(); i++) {
|
|
||||||
if (!checkBoxs.get(i).isChecked()) {
|
|
||||||
EndToEndTestUtils.SOLO.clickOnCheckBox(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (checkBoxs.size() < 3) {
|
/**
|
||||||
EndToEndTestUtils.SOLO.scrollDown();
|
* Check all services and send to google.
|
||||||
checkBoxs = EndToEndTestUtils.SOLO.getCurrentCheckBoxes();
|
*/
|
||||||
|
public void testCreateAndSendTrack_sendPausedTrack() {
|
||||||
// Choose all Google service.
|
EndToEndTestUtils.deleteAllTracks();
|
||||||
for (int i = 0; i < checkBoxs.size(); i++) {
|
EndToEndTestUtils.createTrackWithPause(3);
|
||||||
if (!checkBoxs.get(i).isChecked()) {
|
|
||||||
EndToEndTestUtils.SOLO.clickOnCheckBox(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
instrumentation.waitForIdleSync();
|
instrumentation.waitForIdleSync();
|
||||||
EndToEndTestUtils.getButtonOnScreen(activityMyTracks.getString(R.string.send_google_send_now),
|
checkSendTrackToGoogle();
|
||||||
true, true);
|
|
||||||
|
|
||||||
// Check whether no account is binded with this device.
|
|
||||||
if (EndToEndTestUtils.SOLO.waitForText(
|
|
||||||
activityMyTracks.getString(R.string.send_google_no_account_title), 1,
|
|
||||||
EndToEndTestUtils.SHORT_WAIT_TIME)) {
|
|
||||||
EndToEndTestUtils.getButtonOnScreen(activityMyTracks.getString(R.string.generic_ok), true,
|
|
||||||
true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check whether need to choose account.
|
|
||||||
if (EndToEndTestUtils.SOLO.waitForText(
|
|
||||||
activityMyTracks.getString(R.string.send_google_choose_account_title), 1,
|
|
||||||
EndToEndTestUtils.SHORT_WAIT_TIME)) {
|
|
||||||
EndToEndTestUtils.getButtonOnScreen(activityMyTracks.getString(R.string.generic_ok), false,
|
|
||||||
true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check whether no account permission.
|
|
||||||
if (EndToEndTestUtils.SOLO.waitForText(
|
|
||||||
activityMyTracks.getString(R.string.send_google_no_account_permission), 1,
|
|
||||||
EndToEndTestUtils.SHORT_WAIT_TIME)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Following check the process of "Send to Google".
|
|
||||||
assertTrue(EndToEndTestUtils.SOLO.waitForText(activityMyTracks
|
|
||||||
.getString(R.string.generic_progress_title)));
|
|
||||||
// Waiting the send is finish.
|
|
||||||
while (EndToEndTestUtils.SOLO.waitForText(
|
|
||||||
activityMyTracks.getString(R.string.generic_progress_title), 1,
|
|
||||||
EndToEndTestUtils.SHORT_WAIT_TIME)) {}
|
|
||||||
|
|
||||||
// Check whether the result dialog is display.
|
|
||||||
assertTrue(EndToEndTestUtils.SOLO.waitForText(activityMyTracks
|
|
||||||
.getString(R.string.share_track_share_url)));
|
|
||||||
EndToEndTestUtils
|
|
||||||
.getButtonOnScreen(activityMyTracks.getString(R.string.generic_ok), true, true);
|
|
||||||
|
|
||||||
// Check whether all data is correct on Google Map, Documents, and
|
|
||||||
// Spreadsheet.
|
|
||||||
assertTrue(GoogleUtils.deleteMap(EndToEndTestUtils.trackName, activityMyTracks));
|
|
||||||
assertTrue(GoogleUtils.searchFusionTableByTitle(EndToEndTestUtils.TRACK_NAME_PREFIX,
|
|
||||||
activityMyTracks));
|
|
||||||
assertTrue(GoogleUtils.deleteTrackInSpreadSheet(EndToEndTestUtils.trackName, activityMyTracks));
|
|
||||||
assertTrue(GoogleUtils.dropFusionTables(EndToEndTestUtils.trackName, activityMyTracks));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -217,7 +157,7 @@ public class CreateAndSendTrackTest extends ActivityInstrumentationTestCase2<Tra
|
|||||||
EndToEndTestUtils.startRecording();
|
EndToEndTestUtils.startRecording();
|
||||||
instrumentation.waitForIdleSync();
|
instrumentation.waitForIdleSync();
|
||||||
// Send Gps before send marker.
|
// Send Gps before send marker.
|
||||||
EndToEndTestUtils.sendGps(2);
|
EndToEndTestUtils.sendGps(2, 0);
|
||||||
if (EndToEndTestUtils.hasActionBar) {
|
if (EndToEndTestUtils.hasActionBar) {
|
||||||
// Check the title is Recording.
|
// Check the title is Recording.
|
||||||
assertTrue(EndToEndTestUtils.SOLO.searchText(activityMyTracks
|
assertTrue(EndToEndTestUtils.SOLO.searchText(activityMyTracks
|
||||||
@@ -225,7 +165,7 @@ public class CreateAndSendTrackTest extends ActivityInstrumentationTestCase2<Tra
|
|||||||
}
|
}
|
||||||
|
|
||||||
createWaypoint();
|
createWaypoint();
|
||||||
EndToEndTestUtils.sendGps(2);
|
EndToEndTestUtils.sendGps(2, 2);
|
||||||
// Back to tracks list.
|
// Back to tracks list.
|
||||||
EndToEndTestUtils.SOLO.goBack();
|
EndToEndTestUtils.SOLO.goBack();
|
||||||
instrumentation.waitForIdleSync();
|
instrumentation.waitForIdleSync();
|
||||||
@@ -292,7 +232,7 @@ public class CreateAndSendTrackTest extends ActivityInstrumentationTestCase2<Tra
|
|||||||
EndToEndTestUtils
|
EndToEndTestUtils
|
||||||
.getButtonOnScreen(activityMyTracks.getString(R.string.generic_ok), true, true);
|
.getButtonOnScreen(activityMyTracks.getString(R.string.generic_ok), true, true);
|
||||||
// Send Gps to give a distance more than one kilometer or one mile.
|
// Send Gps to give a distance more than one kilometer or one mile.
|
||||||
EndToEndTestUtils.sendGps(20);
|
EndToEndTestUtils.sendGps(20, 0);
|
||||||
assertTrue(EndToEndTestUtils.findMenuItem(activityMyTracks.getString(R.string.menu_markers),
|
assertTrue(EndToEndTestUtils.findMenuItem(activityMyTracks.getString(R.string.menu_markers),
|
||||||
true));
|
true));
|
||||||
instrumentation.waitForIdleSync();
|
instrumentation.waitForIdleSync();
|
||||||
@@ -306,38 +246,79 @@ public class CreateAndSendTrackTest extends ActivityInstrumentationTestCase2<Tra
|
|||||||
EndToEndTestUtils.stopRecording(true);
|
EndToEndTestUtils.stopRecording(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests the pause recording feature.
|
* Checks the process of sending track to google.
|
||||||
*/
|
*/
|
||||||
public void testPauseRecording() {
|
private void checkSendTrackToGoogle() {
|
||||||
EndToEndTestUtils.startRecording();
|
EndToEndTestUtils.findMenuItem(activityMyTracks.getString(R.string.menu_send_google), true);
|
||||||
assertNotNull(EndToEndTestUtils.SOLO.getButton(activityMyTracks
|
EndToEndTestUtils.SOLO.waitForText(activityMyTracks.getString(R.string.send_google_title));
|
||||||
.getString(R.string.menu_pause_track)));
|
ArrayList<CheckBox> checkBoxs = EndToEndTestUtils.SOLO.getCurrentCheckBoxes();
|
||||||
assertNotNull(EndToEndTestUtils.SOLO.getButton(activityMyTracks
|
for (int i = 0; i < checkBoxs.size(); i++) {
|
||||||
.getString(R.string.menu_stop_recording)));
|
if (!checkBoxs.get(i).isChecked()) {
|
||||||
EndToEndTestUtils.SOLO.goBack();
|
EndToEndTestUtils.SOLO.clickOnCheckBox(i);
|
||||||
assertNotNull(EndToEndTestUtils.SOLO.getButton(activityMyTracks
|
}
|
||||||
.getString(R.string.menu_pause_track)));
|
}
|
||||||
assertNotNull(EndToEndTestUtils.SOLO.getButton(activityMyTracks
|
|
||||||
.getString(R.string.menu_stop_recording)));
|
|
||||||
|
|
||||||
// Pause
|
if (checkBoxs.size() < 3) {
|
||||||
EndToEndTestUtils.getButtonOnScreen(activityMyTracks.getString(R.string.menu_pause_track),
|
EndToEndTestUtils.SOLO.scrollDown();
|
||||||
false, true);
|
checkBoxs = EndToEndTestUtils.SOLO.getCurrentCheckBoxes();
|
||||||
assertNotNull(EndToEndTestUtils.SOLO.getButton(activityMyTracks
|
|
||||||
.getString(R.string.menu_record_track)));
|
// Choose all Google service.
|
||||||
assertNotNull(EndToEndTestUtils.SOLO.getButton(activityMyTracks
|
for (int i = 0; i < checkBoxs.size(); i++) {
|
||||||
.getString(R.string.menu_stop_recording)));
|
if (!checkBoxs.get(i).isChecked()) {
|
||||||
// Resume
|
EndToEndTestUtils.SOLO.clickOnCheckBox(i);
|
||||||
EndToEndTestUtils.getButtonOnScreen(activityMyTracks.getString(R.string.menu_record_track),
|
}
|
||||||
false, true);
|
}
|
||||||
assertNotNull(EndToEndTestUtils.SOLO.getButton(activityMyTracks
|
}
|
||||||
.getString(R.string.menu_pause_track)));
|
instrumentation.waitForIdleSync();
|
||||||
assertNotNull(EndToEndTestUtils.SOLO.getButton(activityMyTracks
|
EndToEndTestUtils.getButtonOnScreen(activityMyTracks.getString(R.string.send_google_send_now),
|
||||||
.getString(R.string.menu_stop_recording)));
|
true, true);
|
||||||
// Stop
|
|
||||||
EndToEndTestUtils.stopRecording(true);
|
// Check whether no account is binded with this device.
|
||||||
|
if (EndToEndTestUtils.SOLO.waitForText(
|
||||||
|
activityMyTracks.getString(R.string.send_google_no_account_title), 1,
|
||||||
|
EndToEndTestUtils.SHORT_WAIT_TIME)) {
|
||||||
|
EndToEndTestUtils.getButtonOnScreen(activityMyTracks.getString(R.string.generic_ok), true,
|
||||||
|
true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check whether need to choose account.
|
||||||
|
if (EndToEndTestUtils.SOLO.waitForText(
|
||||||
|
activityMyTracks.getString(R.string.send_google_choose_account_title), 1,
|
||||||
|
EndToEndTestUtils.SHORT_WAIT_TIME)) {
|
||||||
|
EndToEndTestUtils.getButtonOnScreen(activityMyTracks.getString(R.string.generic_ok), false,
|
||||||
|
true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check whether no account permission.
|
||||||
|
if (EndToEndTestUtils.SOLO.waitForText(
|
||||||
|
activityMyTracks.getString(R.string.send_google_no_account_permission), 1,
|
||||||
|
EndToEndTestUtils.SHORT_WAIT_TIME)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Following check the process of "Send to Google".
|
||||||
|
assertTrue(EndToEndTestUtils.SOLO.waitForText(activityMyTracks
|
||||||
|
.getString(R.string.generic_progress_title)));
|
||||||
|
// Waiting the send is finish.
|
||||||
|
while (EndToEndTestUtils.SOLO.waitForText(
|
||||||
|
activityMyTracks.getString(R.string.generic_progress_title), 1,
|
||||||
|
EndToEndTestUtils.SHORT_WAIT_TIME)) {}
|
||||||
|
|
||||||
|
// Check whether the result dialog is display.
|
||||||
|
assertTrue(EndToEndTestUtils.SOLO.waitForText(activityMyTracks
|
||||||
|
.getString(R.string.share_track_share_url)));
|
||||||
|
EndToEndTestUtils
|
||||||
|
.getButtonOnScreen(activityMyTracks.getString(R.string.generic_ok), true, true);
|
||||||
|
|
||||||
|
// Check whether all data is correct on Google Map, Documents, and
|
||||||
|
// Spreadsheet.
|
||||||
|
assertTrue(GoogleUtils.deleteMap(EndToEndTestUtils.trackName, activityMyTracks));
|
||||||
|
assertTrue(GoogleUtils.searchFusionTableByTitle(EndToEndTestUtils.TRACK_NAME_PREFIX,
|
||||||
|
activityMyTracks));
|
||||||
|
assertTrue(GoogleUtils.deleteTrackInSpreadSheet(EndToEndTestUtils.trackName, activityMyTracks));
|
||||||
|
assertTrue(GoogleUtils.dropFusionTables(EndToEndTestUtils.trackName, activityMyTracks));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+26
-10
@@ -59,10 +59,10 @@ public class EndToEndTestUtils {
|
|||||||
private static final int ORIENTATION_LANDSCAPE = 0;
|
private static final int ORIENTATION_LANDSCAPE = 0;
|
||||||
// Pause 200ms between each send.
|
// Pause 200ms between each send.
|
||||||
static int PAUSE = 200;
|
static int PAUSE = 200;
|
||||||
private static final float START_LONGITUDE = 51;
|
static final double START_LONGITUDE = 51;
|
||||||
private static final float START_LATITUDE = -1.3f;
|
static final double START_LATITUDE = -1.3f;
|
||||||
private static final float DELTA_LONGITUDE = 0.0005f;
|
static final double DELTA_LONGITUDE = 0.0005f;
|
||||||
private static final float DELTA_LADITUDE = 0.0005f;
|
static final double DELTA_LADITUDE = 0.0005f;
|
||||||
private static final String NO_GPS_MESSAGE_PREFIX = "GPS is not available";
|
private static final String NO_GPS_MESSAGE_PREFIX = "GPS is not available";
|
||||||
|
|
||||||
private static final String MOREOPTION_CLASSNAME = "com.android.internal.view.menu.ActionMenuPresenter$OverflowMenuButton";
|
private static final String MOREOPTION_CLASSNAME = "com.android.internal.view.menu.ActionMenuPresenter$OverflowMenuButton";
|
||||||
@@ -163,8 +163,9 @@ public class EndToEndTestUtils {
|
|||||||
* Sends Gps data to emulator.
|
* Sends Gps data to emulator.
|
||||||
*
|
*
|
||||||
* @param number send times
|
* @param number send times
|
||||||
|
* @param numberBofore is used to compute the start latitude and longitude
|
||||||
*/
|
*/
|
||||||
public static void sendGps(int number) {
|
public static void sendGps(int number, int numberBofore) {
|
||||||
if (number < 1) {
|
if (number < 1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -178,13 +179,13 @@ public class EndToEndTestUtils {
|
|||||||
try {
|
try {
|
||||||
socket = new Socket(ANDROID_LOCAL_IP, emulatorPort);
|
socket = new Socket(ANDROID_LOCAL_IP, emulatorPort);
|
||||||
out = new PrintStream(socket.getOutputStream());
|
out = new PrintStream(socket.getOutputStream());
|
||||||
float longitude = START_LONGITUDE;
|
double longitude = START_LONGITUDE + numberBofore * DELTA_LONGITUDE;
|
||||||
float latitude = START_LATITUDE;
|
double latitude = START_LATITUDE + numberBofore * DELTA_LADITUDE;
|
||||||
for (int i = 0; i < number; i++) {
|
for (int i = 0; i < number; i++) {
|
||||||
Thread.sleep(PAUSE);
|
out.println("geo fix " + longitude + " " + latitude);
|
||||||
out.println("geo fix " + latitude + " " + longitude);
|
|
||||||
longitude += DELTA_LONGITUDE;
|
longitude += DELTA_LONGITUDE;
|
||||||
latitude += DELTA_LADITUDE;
|
latitude += DELTA_LADITUDE;
|
||||||
|
Thread.sleep(PAUSE);
|
||||||
}
|
}
|
||||||
// Wait the GPS signal can be obtained by MyTracks.
|
// Wait the GPS signal can be obtained by MyTracks.
|
||||||
Thread.sleep(SHORT_WAIT_TIME);
|
Thread.sleep(SHORT_WAIT_TIME);
|
||||||
@@ -302,11 +303,26 @@ public class EndToEndTestUtils {
|
|||||||
*/
|
*/
|
||||||
static void createSimpleTrack(int numberOfGpsData) {
|
static void createSimpleTrack(int numberOfGpsData) {
|
||||||
startRecording();
|
startRecording();
|
||||||
sendGps(numberOfGpsData);
|
sendGps(numberOfGpsData, 0);
|
||||||
instrumentation.waitForIdleSync();
|
instrumentation.waitForIdleSync();
|
||||||
stopRecording(true);
|
stopRecording(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a track which contains pause during recording.
|
||||||
|
*
|
||||||
|
* @param numberOfGpsData number of simulated Gps data before pause and after resume
|
||||||
|
*/
|
||||||
|
public static void createTrackWithPause(int numberOfGpsData) {
|
||||||
|
EndToEndTestUtils.startRecording();
|
||||||
|
EndToEndTestUtils.sendGps(numberOfGpsData, 0);
|
||||||
|
EndToEndTestUtils.findMenuItem(activityMytracks.getString(R.string.menu_pause_track), true);
|
||||||
|
EndToEndTestUtils.findMenuItem(activityMytracks.getString(R.string.menu_record_track), true);
|
||||||
|
EndToEndTestUtils.sendGps(numberOfGpsData, numberOfGpsData);
|
||||||
|
EndToEndTestUtils.stopRecording(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if there is no track in track list. For some tests need at least one
|
* Checks if there is no track in track list. For some tests need at least one
|
||||||
* track, the method can save time to create a new track.
|
* track, the method can save time to create a new track.
|
||||||
|
|||||||
+35
-8
@@ -49,14 +49,8 @@ public class ExportAndImportTest extends ActivityInstrumentationTestCase2<TrackL
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests export and import tracks.
|
* Tests export and import tracks after creating a track with Gps signal and
|
||||||
* <ul>
|
* an empty track.
|
||||||
* <li>Create two tracks, one of them is empty(Have no Gps data).</li>
|
|
||||||
* <li>Tests import when there is no track file.</li>
|
|
||||||
* <li>Tests export tracks to Gpx files.</li>
|
|
||||||
* <li>Tests import files to tracks.</li>
|
|
||||||
* <li>Tests export tracks to Kml files.</li>
|
|
||||||
* </ul>
|
|
||||||
*/
|
*/
|
||||||
public void testExportAndImportTracks() {
|
public void testExportAndImportTracks() {
|
||||||
// Create a new track with 3 gps data.
|
// Create a new track with 3 gps data.
|
||||||
@@ -67,6 +61,39 @@ public class ExportAndImportTest extends ActivityInstrumentationTestCase2<TrackL
|
|||||||
instrumentation.waitForIdleSync();
|
instrumentation.waitForIdleSync();
|
||||||
EndToEndTestUtils.SOLO.goBack();
|
EndToEndTestUtils.SOLO.goBack();
|
||||||
instrumentation.waitForIdleSync();
|
instrumentation.waitForIdleSync();
|
||||||
|
checkExportAndImport();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests export and import tracks after creating a track with Gps signal and
|
||||||
|
* an empty track. Both tracks are paused during recording.
|
||||||
|
*/
|
||||||
|
public void testExportAndImportTracks_pause() {
|
||||||
|
EndToEndTestUtils.deleteAllTracks();
|
||||||
|
// Create a new track with 3 gps data.
|
||||||
|
EndToEndTestUtils.createTrackWithPause(3);
|
||||||
|
instrumentation.waitForIdleSync();
|
||||||
|
EndToEndTestUtils.SOLO.goBack();
|
||||||
|
|
||||||
|
// Create a empty track.
|
||||||
|
EndToEndTestUtils.createTrackWithPause(0);
|
||||||
|
instrumentation.waitForIdleSync();
|
||||||
|
EndToEndTestUtils.SOLO.goBack();
|
||||||
|
instrumentation.waitForIdleSync();
|
||||||
|
checkExportAndImport();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests export and import tracks.
|
||||||
|
* <ul>
|
||||||
|
* <li>Create two tracks, one of them is empty(Have no Gps data).</li>
|
||||||
|
* <li>Tests import when there is no track file.</li>
|
||||||
|
* <li>Tests export tracks to Gpx files.</li>
|
||||||
|
* <li>Tests import files to tracks.</li>
|
||||||
|
* <li>Tests export tracks to Kml files.</li>
|
||||||
|
* </ul>
|
||||||
|
*/
|
||||||
|
private void checkExportAndImport() {
|
||||||
// Delete all exported gpx and kml tracks.
|
// Delete all exported gpx and kml tracks.
|
||||||
EndToEndTestUtils.deleteExportedFiles(EndToEndTestUtils.GPX);
|
EndToEndTestUtils.deleteExportedFiles(EndToEndTestUtils.GPX);
|
||||||
EndToEndTestUtils.deleteExportedFiles(EndToEndTestUtils.KML);
|
EndToEndTestUtils.deleteExportedFiles(EndToEndTestUtils.KML);
|
||||||
|
|||||||
+1
-1
@@ -73,7 +73,7 @@ public class GoToMyLocationTest extends ActivityInstrumentationTestCase2<TrackLi
|
|||||||
*/
|
*/
|
||||||
public static void findAndClickMyLocation(Activity activity) {
|
public static void findAndClickMyLocation(Activity activity) {
|
||||||
EndToEndTestUtils.createTrackIfEmpty(1, false);
|
EndToEndTestUtils.createTrackIfEmpty(1, false);
|
||||||
EndToEndTestUtils.sendGps(30);
|
EndToEndTestUtils.sendGps(30, 0);
|
||||||
|
|
||||||
View myLocation = EndToEndTestUtils.SOLO.getCurrentActivity()
|
View myLocation = EndToEndTestUtils.SOLO.getCurrentActivity()
|
||||||
.findViewById(R.id.map_my_location);
|
.findViewById(R.id.map_my_location);
|
||||||
|
|||||||
+175
@@ -0,0 +1,175 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2012 Google Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||||
|
* use this file except in compliance with the License. You may obtain a copy of
|
||||||
|
* the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
* License for the specific language governing permissions and limitations under
|
||||||
|
* the License.
|
||||||
|
*/
|
||||||
|
package com.google.android.apps.mytracks.endtoendtest;
|
||||||
|
|
||||||
|
import com.google.android.apps.mytracks.TrackListActivity;
|
||||||
|
import com.google.android.apps.mytracks.content.MyTracksProviderUtils;
|
||||||
|
import com.google.android.apps.mytracks.content.MyTracksProviderUtils.LocationIterator;
|
||||||
|
import com.google.android.apps.mytracks.services.TrackRecordingService;
|
||||||
|
import com.google.android.maps.mytracks.R;
|
||||||
|
|
||||||
|
import android.annotation.TargetApi;
|
||||||
|
import android.app.Instrumentation;
|
||||||
|
import android.location.Location;
|
||||||
|
import android.test.ActivityInstrumentationTestCase2;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests the pause and resume of recording.
|
||||||
|
*
|
||||||
|
* @author Youtao Liu
|
||||||
|
*/
|
||||||
|
public class PauseRecordingTest extends ActivityInstrumentationTestCase2<TrackListActivity> {
|
||||||
|
|
||||||
|
private Instrumentation instrumentation;
|
||||||
|
private TrackListActivity activityMyTracks;
|
||||||
|
|
||||||
|
@TargetApi(15)
|
||||||
|
public PauseRecordingTest() {
|
||||||
|
super(TrackListActivity.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void setUp() throws Exception {
|
||||||
|
super.setUp();
|
||||||
|
instrumentation = getInstrumentation();
|
||||||
|
activityMyTracks = getActivity();
|
||||||
|
EndToEndTestUtils.setupForAllTest(instrumentation, activityMyTracks);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests the pause recording feature. Stops the recording after pause.
|
||||||
|
*/
|
||||||
|
public void testPauseRecording_stopAfterPause() {
|
||||||
|
int gpsSignalNumber = 3;
|
||||||
|
|
||||||
|
// Start recording
|
||||||
|
EndToEndTestUtils.startRecording();
|
||||||
|
assertNotNull(EndToEndTestUtils.findMenuItem(
|
||||||
|
activityMyTracks.getString(R.string.menu_pause_track), false));
|
||||||
|
assertNotNull(EndToEndTestUtils.findMenuItem(
|
||||||
|
activityMyTracks.getString(R.string.menu_stop_recording), false));
|
||||||
|
EndToEndTestUtils.SOLO.goBack();
|
||||||
|
assertNotNull(EndToEndTestUtils.findMenuItem(
|
||||||
|
activityMyTracks.getString(R.string.menu_pause_track), false));
|
||||||
|
assertNotNull(EndToEndTestUtils.findMenuItem(
|
||||||
|
activityMyTracks.getString(R.string.menu_stop_recording), false));
|
||||||
|
EndToEndTestUtils.sendGps(gpsSignalNumber, 0);
|
||||||
|
|
||||||
|
// Pause
|
||||||
|
EndToEndTestUtils.findMenuItem(activityMyTracks.getString(R.string.menu_pause_track), true);
|
||||||
|
assertNotNull(EndToEndTestUtils.findMenuItem(
|
||||||
|
activityMyTracks.getString(R.string.menu_record_track), false));
|
||||||
|
assertNotNull(EndToEndTestUtils.findMenuItem(
|
||||||
|
activityMyTracks.getString(R.string.menu_stop_recording), false));
|
||||||
|
EndToEndTestUtils.sendGps(gpsSignalNumber, gpsSignalNumber);
|
||||||
|
|
||||||
|
// Stop
|
||||||
|
EndToEndTestUtils.stopRecording(true);
|
||||||
|
checkPointsInPausedTrack(gpsSignalNumber, 1, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests the pause recording feature. Stops the recording after resume.
|
||||||
|
*/
|
||||||
|
public void testPauseRecording_stopAfterResume() {
|
||||||
|
int gpsSignalNumber = 3;
|
||||||
|
|
||||||
|
// Start recording
|
||||||
|
EndToEndTestUtils.startRecording();
|
||||||
|
assertNotNull(EndToEndTestUtils.findMenuItem(
|
||||||
|
activityMyTracks.getString(R.string.menu_pause_track), false));
|
||||||
|
assertNotNull(EndToEndTestUtils.findMenuItem(
|
||||||
|
activityMyTracks.getString(R.string.menu_stop_recording), false));
|
||||||
|
EndToEndTestUtils.SOLO.goBack();
|
||||||
|
assertNotNull(EndToEndTestUtils.findMenuItem(
|
||||||
|
activityMyTracks.getString(R.string.menu_pause_track), false));
|
||||||
|
assertNotNull(EndToEndTestUtils.findMenuItem(
|
||||||
|
activityMyTracks.getString(R.string.menu_stop_recording), false));
|
||||||
|
EndToEndTestUtils.sendGps(gpsSignalNumber, 0);
|
||||||
|
|
||||||
|
// Pause
|
||||||
|
EndToEndTestUtils.findMenuItem(activityMyTracks.getString(R.string.menu_pause_track), true);
|
||||||
|
assertNotNull(EndToEndTestUtils.findMenuItem(
|
||||||
|
activityMyTracks.getString(R.string.menu_record_track), false));
|
||||||
|
assertNotNull(EndToEndTestUtils.findMenuItem(
|
||||||
|
activityMyTracks.getString(R.string.menu_stop_recording), false));
|
||||||
|
|
||||||
|
// Send Gps signal after pause.
|
||||||
|
int defaultPause = EndToEndTestUtils.PAUSE;
|
||||||
|
EndToEndTestUtils.PAUSE = 10;
|
||||||
|
// Add 100 to make these signals are apparently different.
|
||||||
|
EndToEndTestUtils.sendGps(gpsSignalNumber, gpsSignalNumber + 100);
|
||||||
|
EndToEndTestUtils.PAUSE = defaultPause;
|
||||||
|
|
||||||
|
// Resume
|
||||||
|
EndToEndTestUtils.findMenuItem(activityMyTracks.getString(R.string.menu_record_track), true);
|
||||||
|
assertNotNull(EndToEndTestUtils.findMenuItem(
|
||||||
|
activityMyTracks.getString(R.string.menu_pause_track), false));
|
||||||
|
assertNotNull(EndToEndTestUtils.findMenuItem(
|
||||||
|
activityMyTracks.getString(R.string.menu_stop_recording), false));
|
||||||
|
EndToEndTestUtils.sendGps(gpsSignalNumber, gpsSignalNumber);
|
||||||
|
|
||||||
|
// Stop
|
||||||
|
EndToEndTestUtils.stopRecording(true);
|
||||||
|
checkPointsInPausedTrack(gpsSignalNumber * 2, 1, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check the points in the last track.
|
||||||
|
*
|
||||||
|
* @param expectPointNumber the number of location points
|
||||||
|
* @param expectPauseNumber the number of pause points
|
||||||
|
* @param expectResumeNumber the number of resume points
|
||||||
|
*/
|
||||||
|
private void checkPointsInPausedTrack(int expectPointNumber, int expectPauseNumber,
|
||||||
|
int expectResumeNumber) {
|
||||||
|
if (EndToEndTestUtils.isEmulator) {
|
||||||
|
int numberOfPoints = 0;
|
||||||
|
int numberOfPausePoint = 0;
|
||||||
|
int numberOfResumePoint = 0;
|
||||||
|
|
||||||
|
MyTracksProviderUtils providerUtils = MyTracksProviderUtils.Factory.get(activityMyTracks
|
||||||
|
.getApplicationContext());
|
||||||
|
long trackId = providerUtils.getLastTrack().getId();
|
||||||
|
LocationIterator points = providerUtils.getTrackPointLocationIterator(trackId, 0, false,
|
||||||
|
MyTracksProviderUtils.DEFAULT_LOCATION_FACTORY);
|
||||||
|
while (points.hasNext()) {
|
||||||
|
Location onePoint = points.next();
|
||||||
|
double latitude = onePoint.getLatitude();
|
||||||
|
double longitude = onePoint.getLongitude();
|
||||||
|
if (latitude == TrackRecordingService.PAUSE_LATITUDE) {
|
||||||
|
numberOfPausePoint++;
|
||||||
|
} else if (latitude == TrackRecordingService.RESUME_LATITUDE) {
|
||||||
|
numberOfResumePoint++;
|
||||||
|
} else {
|
||||||
|
System.out.println(latitude + ":" + longitude);
|
||||||
|
assertEquals(
|
||||||
|
numberOfPoints,
|
||||||
|
(int) ((latitude - EndToEndTestUtils.START_LATITUDE) / EndToEndTestUtils.DELTA_LADITUDE + 0.5));
|
||||||
|
assertEquals(
|
||||||
|
numberOfPoints,
|
||||||
|
(int) ((longitude - EndToEndTestUtils.START_LONGITUDE) / EndToEndTestUtils.DELTA_LONGITUDE + 0.5));
|
||||||
|
numberOfPoints++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
assertEquals(expectPointNumber, numberOfPoints);
|
||||||
|
assertEquals(expectPauseNumber, numberOfPausePoint);
|
||||||
|
assertEquals(expectResumeNumber, numberOfResumePoint);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -125,9 +125,9 @@ public class SettingTest extends ActivityInstrumentationTestCase2<TrackListActiv
|
|||||||
EndToEndTestUtils.startRecording();
|
EndToEndTestUtils.startRecording();
|
||||||
// Test just change preferred units when display CHART tab.
|
// Test just change preferred units when display CHART tab.
|
||||||
EndToEndTestUtils.SOLO.clickOnText(activityMyTracks.getString(R.string.track_detail_chart_tab));
|
EndToEndTestUtils.SOLO.clickOnText(activityMyTracks.getString(R.string.track_detail_chart_tab));
|
||||||
EndToEndTestUtils.sendGps(3);
|
EndToEndTestUtils.sendGps(3, 0);
|
||||||
ChangeStatsSettings(true, false, false, false, false);
|
ChangeStatsSettings(true, false, false, false, false);
|
||||||
EndToEndTestUtils.sendGps(3);
|
EndToEndTestUtils.sendGps(3, 3);
|
||||||
EndToEndTestUtils.stopRecording(true);
|
EndToEndTestUtils.stopRecording(true);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -139,9 +139,9 @@ public class SettingTest extends ActivityInstrumentationTestCase2<TrackListActiv
|
|||||||
EndToEndTestUtils.startRecording();
|
EndToEndTestUtils.startRecording();
|
||||||
// Test change preferred units and preferred rate when display STATS tab.
|
// Test change preferred units and preferred rate when display STATS tab.
|
||||||
EndToEndTestUtils.SOLO.clickOnText(activityMyTracks.getString(R.string.track_detail_stats_tab));
|
EndToEndTestUtils.SOLO.clickOnText(activityMyTracks.getString(R.string.track_detail_stats_tab));
|
||||||
EndToEndTestUtils.sendGps(3);
|
EndToEndTestUtils.sendGps(3, 0);
|
||||||
ChangeStatsSettings(true, true, false, false, false);
|
ChangeStatsSettings(true, true, false, false, false);
|
||||||
EndToEndTestUtils.sendGps(3);
|
EndToEndTestUtils.sendGps(3, 3);
|
||||||
EndToEndTestUtils.stopRecording(true);
|
EndToEndTestUtils.stopRecording(true);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user