forked from upstream-mirrors/OpenTracks
merge heads
This commit is contained in:
@@ -107,13 +107,13 @@ public class DeleteTest extends ActivityInstrumentationTestCase2<TrackListActivi
|
||||
public void testDeleteOneTrackUnderRecording() {
|
||||
EndToEndTestUtils.startRecording();
|
||||
instrumentation.waitForIdleSync();
|
||||
PauseRecordingTest.checkUnderRecording();
|
||||
EndToEndTestUtils.checkUnderRecording();
|
||||
instrumentation.waitForIdleSync();
|
||||
EndToEndTestUtils.findMenuItem(activityMyTracks.getString(R.string.menu_delete), true);
|
||||
EndToEndTestUtils
|
||||
.getButtonOnScreen(activityMyTracks.getString(R.string.generic_ok), true, true);
|
||||
instrumentation.waitForIdleSync();
|
||||
PauseRecordingTest.checkNotRecording();
|
||||
EndToEndTestUtils.checkNotRecording();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -18,6 +18,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.apps.mytracks.util.StringUtils;
|
||||
import com.google.android.maps.mytracks.R;
|
||||
import com.jayway.android.robotium.solo.Solo;
|
||||
|
||||
@@ -44,6 +45,8 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
/**
|
||||
* Provides utilities to smoke test.
|
||||
*
|
||||
@@ -804,6 +807,61 @@ public class EndToEndTestUtils {
|
||||
} catch (InterruptedException e) {
|
||||
Log.e(LOG_TAG, "Unable to sleep " + milliseconds, e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the recording is not started.
|
||||
*/
|
||||
static void checkNotRecording() {
|
||||
instrumentation.waitForIdleSync();
|
||||
Assert.assertEquals(activityMytracks.getString(R.string.icon_record_track), (String) SOLO
|
||||
.getCurrentActivity().findViewById(R.id.track_controller_record).getContentDescription());
|
||||
Assert.assertFalse(SOLO.getCurrentActivity().findViewById(R.id.track_controller_stop)
|
||||
.isEnabled());
|
||||
Assert.assertNull(findTextView(activityMytracks.getString(R.string.generic_recording)));
|
||||
Assert.assertNull(findTextView(activityMytracks.getString(R.string.generic_paused)));
|
||||
TextView totalTime = (TextView) activityMytracks.findViewById(R.id.track_controller_total_time);
|
||||
Assert.assertEquals(StringUtils.formatElapsedTimeWithHour(0), totalTime.getText().toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the MyTracks is under recording.
|
||||
*/
|
||||
static void checkUnderRecording() {
|
||||
instrumentation.waitForIdleSync();
|
||||
Assert.assertEquals(activityMytracks.getString(R.string.icon_pause_recording), (String) SOLO
|
||||
.getCurrentActivity().findViewById(R.id.track_controller_record).getContentDescription());
|
||||
Assert.assertTrue(SOLO.getCurrentActivity().findViewById(R.id.track_controller_stop)
|
||||
.isEnabled());
|
||||
Assert.assertNotNull(findTextView(activityMytracks.getString(R.string.generic_recording)));
|
||||
Assert.assertNull(findTextView(activityMytracks.getString(R.string.generic_paused)));
|
||||
|
||||
String totalTimeOld = ((TextView) SOLO.getCurrentActivity().findViewById(
|
||||
R.id.track_controller_total_time)).getText().toString();
|
||||
sleep(2000);
|
||||
String totalTimeNew = ((TextView) SOLO.getCurrentActivity().findViewById(
|
||||
R.id.track_controller_total_time)).getText().toString();
|
||||
Assert.assertFalse(totalTimeOld.equalsIgnoreCase(totalTimeNew));
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the recording is paused.
|
||||
*/
|
||||
static void checkUnderPaused() {
|
||||
instrumentation.waitForIdleSync();
|
||||
Assert.assertEquals(activityMytracks.getString(R.string.icon_record_track), (String) SOLO
|
||||
.getCurrentActivity().findViewById(R.id.track_controller_record).getContentDescription());
|
||||
Assert.assertTrue(SOLO.getCurrentActivity().findViewById(R.id.track_controller_stop)
|
||||
.isEnabled());
|
||||
Assert.assertNull(findTextView(activityMytracks.getString(R.string.generic_recording)));
|
||||
Assert.assertNotNull(findTextView(activityMytracks.getString(R.string.generic_paused)));
|
||||
|
||||
String totalTimeOld = ((TextView) activityMytracks
|
||||
.findViewById(R.id.track_controller_total_time)).getText().toString();
|
||||
sleep(2000);
|
||||
String totalTimeNew = ((TextView) activityMytracks
|
||||
.findViewById(R.id.track_controller_total_time)).getText().toString();
|
||||
Assert.assertTrue(totalTimeOld.equalsIgnoreCase(totalTimeNew));
|
||||
}
|
||||
|
||||
}
|
||||
+10
-80
@@ -19,14 +19,12 @@ 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.apps.mytracks.util.StringUtils;
|
||||
import com.google.android.maps.mytracks.R;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.Instrumentation;
|
||||
import android.location.Location;
|
||||
import android.test.ActivityInstrumentationTestCase2;
|
||||
import android.widget.TextView;
|
||||
|
||||
|
||||
/**
|
||||
* Tests the pause and resume of recording.
|
||||
@@ -57,22 +55,22 @@ public class PauseRecordingTest extends ActivityInstrumentationTestCase2<TrackLi
|
||||
public void testPauseRecording_stopAfterPause() {
|
||||
int gpsSignalNumber = 3;
|
||||
|
||||
checkNotRecording();
|
||||
EndToEndTestUtils.checkNotRecording();
|
||||
// Start recording
|
||||
EndToEndTestUtils.startRecording();
|
||||
checkUnderRecording();
|
||||
EndToEndTestUtils.checkUnderRecording();
|
||||
EndToEndTestUtils.sendGps(gpsSignalNumber);
|
||||
|
||||
// Pause
|
||||
EndToEndTestUtils.pauseRecording();
|
||||
checkUnderPaused();
|
||||
EndToEndTestUtils.checkUnderPaused();
|
||||
EndToEndTestUtils.sendGps(gpsSignalNumber, gpsSignalNumber);
|
||||
|
||||
// Stop
|
||||
EndToEndTestUtils.stopRecording(true);
|
||||
checkPointsInPausedTrack(gpsSignalNumber, 1, 0);
|
||||
EndToEndTestUtils.SOLO.goBack();
|
||||
checkNotRecording();
|
||||
EndToEndTestUtils.checkNotRecording();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -81,15 +79,15 @@ public class PauseRecordingTest extends ActivityInstrumentationTestCase2<TrackLi
|
||||
public void testPauseRecording_stopAfterResume() {
|
||||
int gpsSignalNumber = 3;
|
||||
|
||||
checkNotRecording();
|
||||
EndToEndTestUtils.checkNotRecording();
|
||||
// Start recording
|
||||
EndToEndTestUtils.startRecording();
|
||||
checkUnderRecording();
|
||||
EndToEndTestUtils.checkUnderRecording();
|
||||
EndToEndTestUtils.sendGps(gpsSignalNumber);
|
||||
|
||||
// Pause
|
||||
EndToEndTestUtils.pauseRecording();
|
||||
checkUnderPaused();
|
||||
EndToEndTestUtils.checkUnderPaused();
|
||||
|
||||
// Send Gps signal after pause.
|
||||
// Add 10 to make these signals are apparently different.
|
||||
@@ -97,14 +95,14 @@ public class PauseRecordingTest extends ActivityInstrumentationTestCase2<TrackLi
|
||||
|
||||
// Resume
|
||||
EndToEndTestUtils.resumeRecording();
|
||||
checkUnderRecording();
|
||||
EndToEndTestUtils.checkUnderRecording();
|
||||
EndToEndTestUtils.sendGps(gpsSignalNumber, gpsSignalNumber);
|
||||
|
||||
// Stop
|
||||
EndToEndTestUtils.stopRecording(true);
|
||||
checkPointsInPausedTrack(gpsSignalNumber * 2, 1, 1);
|
||||
EndToEndTestUtils.SOLO.goBack();
|
||||
checkNotRecording();
|
||||
EndToEndTestUtils.checkNotRecording();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -149,72 +147,4 @@ public class PauseRecordingTest extends ActivityInstrumentationTestCase2<TrackLi
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the recording is not started.
|
||||
*/
|
||||
static void checkNotRecording() {
|
||||
EndToEndTestUtils.instrumentation.waitForIdleSync();
|
||||
assertEquals(
|
||||
EndToEndTestUtils.activityMytracks.getString(R.string.icon_record_track),
|
||||
(String) EndToEndTestUtils.SOLO.getCurrentActivity()
|
||||
.findViewById(R.id.track_controller_record).getContentDescription());
|
||||
assertFalse(EndToEndTestUtils.SOLO.getCurrentActivity()
|
||||
.findViewById(R.id.track_controller_stop).isEnabled());
|
||||
assertNull(EndToEndTestUtils.findTextView(EndToEndTestUtils.activityMytracks
|
||||
.getString(R.string.generic_recording)));
|
||||
assertNull(EndToEndTestUtils.findTextView(EndToEndTestUtils.activityMytracks
|
||||
.getString(R.string.generic_paused)));
|
||||
TextView totalTime = (TextView) EndToEndTestUtils.activityMytracks
|
||||
.findViewById(R.id.track_controller_total_time);
|
||||
assertEquals(StringUtils.formatElapsedTimeWithHour(0), totalTime.getText().toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the MyTracks is under recording.
|
||||
*/
|
||||
static void checkUnderRecording() {
|
||||
EndToEndTestUtils.instrumentation.waitForIdleSync();
|
||||
assertEquals(
|
||||
EndToEndTestUtils.activityMytracks.getString(R.string.icon_pause_recording),
|
||||
(String) EndToEndTestUtils.SOLO.getCurrentActivity()
|
||||
.findViewById(R.id.track_controller_record).getContentDescription());
|
||||
assertTrue(EndToEndTestUtils.SOLO.getCurrentActivity().findViewById(R.id.track_controller_stop)
|
||||
.isEnabled());
|
||||
assertNotNull(EndToEndTestUtils.findTextView(EndToEndTestUtils.activityMytracks
|
||||
.getString(R.string.generic_recording)));
|
||||
assertNull(EndToEndTestUtils.findTextView(EndToEndTestUtils.activityMytracks
|
||||
.getString(R.string.generic_paused)));
|
||||
|
||||
String totalTimeOld = ((TextView) EndToEndTestUtils.SOLO.getCurrentActivity().findViewById(
|
||||
R.id.track_controller_total_time)).getText().toString();
|
||||
EndToEndTestUtils.sleep(2000);
|
||||
String totalTimeNew = ((TextView) EndToEndTestUtils.SOLO.getCurrentActivity().findViewById(
|
||||
R.id.track_controller_total_time)).getText().toString();
|
||||
assertFalse(totalTimeOld.equalsIgnoreCase(totalTimeNew));
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the recording is paused.
|
||||
*/
|
||||
static void checkUnderPaused() {
|
||||
EndToEndTestUtils.instrumentation.waitForIdleSync();
|
||||
assertEquals(
|
||||
EndToEndTestUtils.activityMytracks.getString(R.string.icon_record_track),
|
||||
(String) EndToEndTestUtils.SOLO.getCurrentActivity()
|
||||
.findViewById(R.id.track_controller_record).getContentDescription());
|
||||
assertTrue(EndToEndTestUtils.SOLO.getCurrentActivity().findViewById(R.id.track_controller_stop)
|
||||
.isEnabled());
|
||||
assertNull(EndToEndTestUtils.findTextView(EndToEndTestUtils.activityMytracks
|
||||
.getString(R.string.generic_recording)));
|
||||
assertNotNull(EndToEndTestUtils.findTextView(EndToEndTestUtils.activityMytracks
|
||||
.getString(R.string.generic_paused)));
|
||||
|
||||
String totalTimeOld = ((TextView) EndToEndTestUtils.activityMytracks
|
||||
.findViewById(R.id.track_controller_total_time)).getText().toString();
|
||||
EndToEndTestUtils.sleep(2000);
|
||||
String totalTimeNew = ((TextView) EndToEndTestUtils.activityMytracks
|
||||
.findViewById(R.id.track_controller_total_time)).getText().toString();
|
||||
assertTrue(totalTimeOld.equalsIgnoreCase(totalTimeNew));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user