forked from upstream-mirrors/OpenTracks
Change some code style of smoke test case. Add some checks in some tests when the screen is rotated.
This commit is contained in:
+81
-26
@@ -1,12 +1,12 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012 Google Inc.
|
* Copyright 2012 Google Inc.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
* 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
|
* use this file except in compliance with the License. You may obtain a copy of
|
||||||
* the License at
|
* the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
@@ -22,6 +22,7 @@ import com.google.android.maps.MapView;
|
|||||||
import com.google.android.maps.mytracks.R;
|
import com.google.android.maps.mytracks.R;
|
||||||
import com.jayway.android.robotium.solo.Solo;
|
import com.jayway.android.robotium.solo.Solo;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
import android.app.Instrumentation;
|
import android.app.Instrumentation;
|
||||||
import android.test.ActivityInstrumentationTestCase2;
|
import android.test.ActivityInstrumentationTestCase2;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
@@ -53,7 +54,7 @@ public class MyTracksSmokeTest extends ActivityInstrumentationTestCase2<TrackLis
|
|||||||
private Instrumentation instrumentation;
|
private Instrumentation instrumentation;
|
||||||
private TrackListActivity activityMyTracks;
|
private TrackListActivity activityMyTracks;
|
||||||
private Solo solo;
|
private Solo solo;
|
||||||
private boolean isFirstLaunch = false;
|
private boolean checkedFirstLaunch = false;
|
||||||
// Check whether the UI has an action bar which is related with the version of
|
// Check whether the UI has an action bar which is related with the version of
|
||||||
// Android OS.
|
// Android OS.
|
||||||
private boolean hasActionBar = false;
|
private boolean hasActionBar = false;
|
||||||
@@ -71,12 +72,12 @@ public class MyTracksSmokeTest extends ActivityInstrumentationTestCase2<TrackLis
|
|||||||
solo = new Solo(instrumentation, activityMyTracks);
|
solo = new Solo(instrumentation, activityMyTracks);
|
||||||
// Checks if open MyTracks first time after install. If so, there would be a
|
// Checks if open MyTracks first time after install. If so, there would be a
|
||||||
// welcome view with accept buttons. And makes sure only check once.
|
// welcome view with accept buttons. And makes sure only check once.
|
||||||
if (!isFirstLaunch) {
|
if (!checkedFirstLaunch) {
|
||||||
if ((getButtonOnScreen(activityMyTracks.getString(R.string.eula_accept)) != null)) {
|
if ((getButtonOnScreen(activityMyTracks.getString(R.string.eula_accept)) != null)) {
|
||||||
verifyFirstLaunch();
|
verifyFirstLaunch();
|
||||||
}
|
}
|
||||||
setHasActionBar();
|
setHasActionBar();
|
||||||
isFirstLaunch = true;
|
checkedFirstLaunch = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Makes every track name is unique to make sure every check can be trusted.
|
// Makes every track name is unique to make sure every check can be trusted.
|
||||||
@@ -90,11 +91,12 @@ public class MyTracksSmokeTest extends ActivityInstrumentationTestCase2<TrackLis
|
|||||||
*/
|
*/
|
||||||
public void testSwitchViewsAndMenusOfView() {
|
public void testSwitchViewsAndMenusOfView() {
|
||||||
createSimpleTrack(3);
|
createSimpleTrack(3);
|
||||||
|
|
||||||
solo.goBack();
|
solo.goBack();
|
||||||
solo.clickOnText(trackName);
|
solo.clickOnText(trackName);
|
||||||
|
|
||||||
solo.clickOnText(activityMyTracks.getString(R.string.track_detail_chart_tab));
|
solo.clickOnText(activityMyTracks.getString(R.string.track_detail_chart_tab));
|
||||||
|
rotateAllActivities();
|
||||||
sendKeys(KeyEvent.KEYCODE_MENU);
|
sendKeys(KeyEvent.KEYCODE_MENU);
|
||||||
findMenuItem(activityMyTracks.getString(R.string.menu_chart_settings), true);
|
findMenuItem(activityMyTracks.getString(R.string.menu_chart_settings), true);
|
||||||
assertTrue(solo.searchText(activityMyTracks.getString(R.string.chart_settings_by_distance)));
|
assertTrue(solo.searchText(activityMyTracks.getString(R.string.chart_settings_by_distance)));
|
||||||
@@ -122,6 +124,7 @@ public class MyTracksSmokeTest extends ActivityInstrumentationTestCase2<TrackLis
|
|||||||
sendKeys(KeyEvent.KEYCODE_MENU);
|
sendKeys(KeyEvent.KEYCODE_MENU);
|
||||||
findMenuItem(activityMyTracks.getString(R.string.menu_send_google), true);
|
findMenuItem(activityMyTracks.getString(R.string.menu_send_google), true);
|
||||||
solo.waitForText(activityMyTracks.getString(R.string.send_google_title));
|
solo.waitForText(activityMyTracks.getString(R.string.send_google_title));
|
||||||
|
rotateCurrentActivity();
|
||||||
|
|
||||||
ArrayList<CheckBox> checkBoxs = solo.getCurrentCheckBoxes();
|
ArrayList<CheckBox> checkBoxs = solo.getCurrentCheckBoxes();
|
||||||
for (int i = 0; i < checkBoxs.size(); i++) {
|
for (int i = 0; i < checkBoxs.size(); i++) {
|
||||||
@@ -176,10 +179,13 @@ public class MyTracksSmokeTest extends ActivityInstrumentationTestCase2<TrackLis
|
|||||||
instrumentation.waitForIdleSync();
|
instrumentation.waitForIdleSync();
|
||||||
sendKeys(KeyEvent.KEYCODE_MENU);
|
sendKeys(KeyEvent.KEYCODE_MENU);
|
||||||
findMenuItem(activityMyTracks.getString(R.string.menu_edit), true);
|
findMenuItem(activityMyTracks.getString(R.string.menu_edit), true);
|
||||||
|
|
||||||
String newTrackName = TRACK_NAME_PREFIX + "_new" + System.currentTimeMillis();
|
String newTrackName = TRACK_NAME_PREFIX + "_new" + System.currentTimeMillis();
|
||||||
String newType = "type" + newTrackName;
|
String newType = "type" + newTrackName;
|
||||||
String newDesc = "desc" + newTrackName;
|
String newDesc = "desc" + newTrackName;
|
||||||
|
|
||||||
|
instrumentation.waitForIdleSync();
|
||||||
|
rotateAllActivities();
|
||||||
sendKeys(KeyEvent.KEYCODE_DEL);
|
sendKeys(KeyEvent.KEYCODE_DEL);
|
||||||
solo.enterText(0, newTrackName);
|
solo.enterText(0, newTrackName);
|
||||||
sendKeys(KeyEvent.KEYCODE_TAB);
|
sendKeys(KeyEvent.KEYCODE_TAB);
|
||||||
@@ -188,6 +194,7 @@ public class MyTracksSmokeTest extends ActivityInstrumentationTestCase2<TrackLis
|
|||||||
solo.enterText(2, newDesc);
|
solo.enterText(2, newDesc);
|
||||||
|
|
||||||
solo.clickOnButton(activityMyTracks.getString(R.string.generic_save));
|
solo.clickOnButton(activityMyTracks.getString(R.string.generic_save));
|
||||||
|
instrumentation.waitForIdleSync();
|
||||||
// Goes back to track list.
|
// Goes back to track list.
|
||||||
solo.goBack();
|
solo.goBack();
|
||||||
|
|
||||||
@@ -212,30 +219,40 @@ public class MyTracksSmokeTest extends ActivityInstrumentationTestCase2<TrackLis
|
|||||||
sendKeys(KeyEvent.KEYCODE_MENU);
|
sendKeys(KeyEvent.KEYCODE_MENU);
|
||||||
findMenuItem(activityMyTracks.getString(R.string.menu_settings), true);
|
findMenuItem(activityMyTracks.getString(R.string.menu_settings), true);
|
||||||
instrumentation.waitForIdleSync();
|
instrumentation.waitForIdleSync();
|
||||||
|
// Rotates on the settings page.
|
||||||
// Reset all settings at first.
|
rotateAllActivities();
|
||||||
|
solo.waitForText(activityMyTracks.getString(R.string.settings_reset));
|
||||||
|
// Resets all settings at first.
|
||||||
solo.clickOnText(activityMyTracks.getString(R.string.settings_reset));
|
solo.clickOnText(activityMyTracks.getString(R.string.settings_reset));
|
||||||
solo.clickOnButton(activityMyTracks.getString(R.string.generic_ok));
|
solo.clickOnButton(activityMyTracks.getString(R.string.generic_ok));
|
||||||
// Change a setting of display.
|
// Changes a setting of display.
|
||||||
solo.clickOnText(activityMyTracks.getString(R.string.settings_display));
|
solo.clickOnText(activityMyTracks.getString(R.string.settings_display));
|
||||||
solo.waitForText(activityMyTracks.getString(R.string.settings_display_metric));
|
solo.waitForText(activityMyTracks.getString(R.string.settings_display_metric));
|
||||||
|
// Rotates on a sub setting page.
|
||||||
|
rotateAllActivities();
|
||||||
|
solo.waitForText(activityMyTracks.getString(R.string.settings_display_metric));
|
||||||
ArrayList<CheckBox> displayCheckBoxs = solo.getCurrentCheckBoxes();
|
ArrayList<CheckBox> displayCheckBoxs = solo.getCurrentCheckBoxes();
|
||||||
boolean useMetric = displayCheckBoxs.get(0).isChecked();
|
boolean useMetric = displayCheckBoxs.get(0).isChecked();
|
||||||
solo.clickOnCheckBox(0);
|
solo.clickOnCheckBox(0);
|
||||||
solo.goBack();
|
solo.goBack();
|
||||||
// Change a setting of sharing.
|
// Changes a setting of sharing.
|
||||||
solo.clickOnText(activityMyTracks.getString(R.string.settings_sharing));
|
solo.clickOnText(activityMyTracks.getString(R.string.settings_sharing));
|
||||||
solo.waitForText(activityMyTracks.getString(R.string.settings_sharing_allow_access));
|
solo.waitForText(activityMyTracks.getString(R.string.settings_sharing_allow_access));
|
||||||
ArrayList<CheckBox> sharingCheckBoxs = solo.getCurrentCheckBoxes();
|
ArrayList<CheckBox> sharingCheckBoxs = solo.getCurrentCheckBoxes();
|
||||||
boolean newMapsPublic = sharingCheckBoxs.get(0).isChecked();
|
boolean newMapsPublic = sharingCheckBoxs.get(0).isChecked();
|
||||||
solo.clickOnCheckBox(0);
|
solo.clickOnCheckBox(0);
|
||||||
|
// Rotates on a sub setting page when the value of a checkbox is changed.
|
||||||
|
instrumentation.waitForIdleSync();
|
||||||
|
rotateAllActivities();
|
||||||
|
solo.waitForText(activityMyTracks.getString(R.string.settings_sharing_allow_access));
|
||||||
|
assertEquals(!newMapsPublic, sharingCheckBoxs.get(0).isChecked());
|
||||||
solo.goBack();
|
solo.goBack();
|
||||||
|
|
||||||
// Reset all settings.
|
// Resets all settings.
|
||||||
solo.clickOnText(activityMyTracks.getString(R.string.settings_reset));
|
solo.clickOnText(activityMyTracks.getString(R.string.settings_reset));
|
||||||
solo.clickOnButton(activityMyTracks.getString(R.string.generic_ok));
|
solo.clickOnButton(activityMyTracks.getString(R.string.generic_ok));
|
||||||
|
|
||||||
// Check settings.
|
// Checks settings.
|
||||||
solo.clickOnText(activityMyTracks.getString(R.string.settings_display));
|
solo.clickOnText(activityMyTracks.getString(R.string.settings_display));
|
||||||
solo.waitForText(activityMyTracks.getString(R.string.settings_display_metric));
|
solo.waitForText(activityMyTracks.getString(R.string.settings_display_metric));
|
||||||
displayCheckBoxs = solo.getCurrentCheckBoxes();
|
displayCheckBoxs = solo.getCurrentCheckBoxes();
|
||||||
@@ -256,20 +273,22 @@ public class MyTracksSmokeTest extends ActivityInstrumentationTestCase2<TrackLis
|
|||||||
findMenuItem(activityMyTracks.getString(R.string.menu_delete_all), true);
|
findMenuItem(activityMyTracks.getString(R.string.menu_delete_all), true);
|
||||||
solo.clickOnButton(activityMyTracks.getString(R.string.generic_ok));
|
solo.clickOnButton(activityMyTracks.getString(R.string.generic_ok));
|
||||||
instrumentation.waitForIdleSync();
|
instrumentation.waitForIdleSync();
|
||||||
|
|
||||||
startRecording();
|
startRecording();
|
||||||
instrumentation.waitForIdleSync();
|
instrumentation.waitForIdleSync();
|
||||||
SmokeTestUtils.sendGps(2);
|
SmokeTestUtils.sendGps(2);
|
||||||
createWaypointAndStatistics();
|
createWaypointAndStatistics();
|
||||||
SmokeTestUtils.sendGps(2);
|
SmokeTestUtils.sendGps(2);
|
||||||
// Back to tracks list.
|
// Backs to tracks list.
|
||||||
solo.goBack();
|
solo.goBack();
|
||||||
|
instrumentation.waitForIdleSync();
|
||||||
|
rotateAllActivities();
|
||||||
stopRecording(false);
|
stopRecording(false);
|
||||||
solo.enterText(0, trackName);
|
solo.enterText(0, trackName);
|
||||||
solo.clickOnButton(activityMyTracks.getString(R.string.generic_save));
|
solo.clickOnButton(activityMyTracks.getString(R.string.generic_save));
|
||||||
|
|
||||||
instrumentation.waitForIdleSync();
|
instrumentation.waitForIdleSync();
|
||||||
// Check the new track
|
// Checks the new track
|
||||||
assertTrue(solo.waitForText(trackName, 1, 5000, true, false));
|
assertTrue(solo.waitForText(trackName, 1, 5000, true, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -287,6 +306,8 @@ public class MyTracksSmokeTest extends ActivityInstrumentationTestCase2<TrackLis
|
|||||||
|
|
||||||
solo.sendKey(KeyEvent.KEYCODE_MENU);
|
solo.sendKey(KeyEvent.KEYCODE_MENU);
|
||||||
findMenuItem(activityMyTracks.getString(R.string.menu_delete_all), true);
|
findMenuItem(activityMyTracks.getString(R.string.menu_delete_all), true);
|
||||||
|
instrumentation.waitForIdleSync();
|
||||||
|
rotateAllActivities();
|
||||||
solo.clickOnButton(activityMyTracks.getString(R.string.generic_ok));
|
solo.clickOnButton(activityMyTracks.getString(R.string.generic_ok));
|
||||||
instrumentation.waitForIdleSync();
|
instrumentation.waitForIdleSync();
|
||||||
// There is no track now.
|
// There is no track now.
|
||||||
@@ -338,6 +359,7 @@ public class MyTracksSmokeTest extends ActivityInstrumentationTestCase2<TrackLis
|
|||||||
findMenuItem(activityMyTracks.getString(R.string.menu_export_all), true);
|
findMenuItem(activityMyTracks.getString(R.string.menu_export_all), true);
|
||||||
solo.clickOnText(String.format(activityMyTracks.getString(R.string.menu_export_all_format),
|
solo.clickOnText(String.format(activityMyTracks.getString(R.string.menu_export_all_format),
|
||||||
GPX.toUpperCase()));
|
GPX.toUpperCase()));
|
||||||
|
rotateAllActivities();
|
||||||
solo.waitForText(activityMyTracks.getString(R.string.export_success));
|
solo.waitForText(activityMyTracks.getString(R.string.export_success));
|
||||||
// Checks export file.
|
// Checks export file.
|
||||||
assertEquals(gpxFilesNumber + trackNumber, getExportedFiles(GPX).length);
|
assertEquals(gpxFilesNumber + trackNumber, getExportedFiles(GPX).length);
|
||||||
@@ -349,6 +371,7 @@ public class MyTracksSmokeTest extends ActivityInstrumentationTestCase2<TrackLis
|
|||||||
|
|
||||||
sendKeys(KeyEvent.KEYCODE_MENU);
|
sendKeys(KeyEvent.KEYCODE_MENU);
|
||||||
findMenuItem(activityMyTracks.getString(R.string.menu_import_all), true);
|
findMenuItem(activityMyTracks.getString(R.string.menu_import_all), true);
|
||||||
|
rotateAllActivities();
|
||||||
// Waits for the prefix of import success string is much faster than wait
|
// Waits for the prefix of import success string is much faster than wait
|
||||||
// the whole string.
|
// the whole string.
|
||||||
solo.waitForText(activityMyTracks.getString(R.string.import_success).split("%")[0]);
|
solo.waitForText(activityMyTracks.getString(R.string.import_success).split("%")[0]);
|
||||||
@@ -384,32 +407,39 @@ public class MyTracksSmokeTest extends ActivityInstrumentationTestCase2<TrackLis
|
|||||||
if (!findMenuItem(activityMyTracks.getString(R.string.menu_satellite_mode), false)) {
|
if (!findMenuItem(activityMyTracks.getString(R.string.menu_satellite_mode), false)) {
|
||||||
isMapMode = false;
|
isMapMode = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Switches to satellite mode if it's map mode now..
|
// Switches to satellite mode if it's map mode now..
|
||||||
solo.clickOnText(activityMyTracks.getString(isMapMode ? R.string.menu_satellite_mode
|
solo.clickOnText(activityMyTracks.getString(isMapMode ? R.string.menu_satellite_mode
|
||||||
: R.string.menu_map_mode));
|
: R.string.menu_map_mode));
|
||||||
|
|
||||||
isMapMode = !isMapMode;
|
isMapMode = !isMapMode;
|
||||||
|
|
||||||
ArrayList<View> allViews = solo.getViews();
|
ArrayList<View> allViews = solo.getViews();
|
||||||
for (View view : allViews) {
|
for (View view : allViews) {
|
||||||
if (view instanceof MapView) {
|
if (view instanceof MapView) {
|
||||||
assertFalse(isMapMode ? ((MapView) view).isSatellite() : !(((MapView) view).isSatellite()));
|
assertEquals(isMapMode, !(((MapView) view).isSatellite()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
instrumentation.waitForIdleSync();
|
instrumentation.waitForIdleSync();
|
||||||
// Switches back.
|
|
||||||
sendKeys(KeyEvent.KEYCODE_MENU);
|
solo.sendKey(KeyEvent.KEYCODE_MENU);
|
||||||
|
findMenuItem(activityMyTracks.getString(R.string.menu_help), false);
|
||||||
instrumentation.waitForIdleSync();
|
instrumentation.waitForIdleSync();
|
||||||
|
rotateAllActivities();
|
||||||
|
|
||||||
|
// Switches back.
|
||||||
solo.clickOnText(activityMyTracks.getString(isMapMode ? R.string.menu_satellite_mode
|
solo.clickOnText(activityMyTracks.getString(isMapMode ? R.string.menu_satellite_mode
|
||||||
: R.string.menu_map_mode));
|
: R.string.menu_map_mode));
|
||||||
isMapMode = !isMapMode;
|
isMapMode = !isMapMode;
|
||||||
allViews = solo.getViews();
|
allViews = solo.getViews();
|
||||||
for (View view : allViews) {
|
for (View view : allViews) {
|
||||||
if (view instanceof MapView) {
|
if (view instanceof MapView) {
|
||||||
assertFalse(isMapMode ? ((MapView) view).isSatellite() : !(((MapView) view).isSatellite()));
|
assertEquals(isMapMode, !(((MapView) view).isSatellite()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Waits for the TrackDetailActivity, or the stop button will can not be
|
||||||
|
// found in next step.
|
||||||
|
solo.waitForText(activityMyTracks.getString(R.string.track_detail_chart_tab), 0, 1000);
|
||||||
stopRecording(true);
|
stopRecording(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -454,7 +484,10 @@ public class MyTracksSmokeTest extends ActivityInstrumentationTestCase2<TrackLis
|
|||||||
|
|
||||||
solo.clickOnButton(activityMyTracks.getString(R.string.marker_list_insert_waypoint));
|
solo.clickOnButton(activityMyTracks.getString(R.string.marker_list_insert_waypoint));
|
||||||
solo.clickOnText(activityMyTracks.getString(R.string.marker_detail_marker_name));
|
solo.clickOnText(activityMyTracks.getString(R.string.marker_detail_marker_name));
|
||||||
|
instrumentation.waitForIdleSync();
|
||||||
|
rotateAllActivities();
|
||||||
solo.enterText(0, WAYPOINT_NAME);
|
solo.enterText(0, WAYPOINT_NAME);
|
||||||
|
|
||||||
solo.clickOnButton(activityMyTracks.getString(R.string.generic_save));
|
solo.clickOnButton(activityMyTracks.getString(R.string.generic_save));
|
||||||
|
|
||||||
solo.clickOnButton(activityMyTracks.getString(R.string.marker_list_insert_statistics));
|
solo.clickOnButton(activityMyTracks.getString(R.string.marker_list_insert_statistics));
|
||||||
@@ -502,7 +535,8 @@ public class MyTracksSmokeTest extends ActivityInstrumentationTestCase2<TrackLis
|
|||||||
*/
|
*/
|
||||||
private void startRecording() {
|
private void startRecording() {
|
||||||
if (hasActionBar) {
|
if (hasActionBar) {
|
||||||
Button startButton = getButtonOnScreen(activityMyTracks.getString(R.string.menu_record_track));
|
Button startButton =
|
||||||
|
getButtonOnScreen(activityMyTracks.getString(R.string.menu_record_track));
|
||||||
// In case a track is recording.
|
// In case a track is recording.
|
||||||
if (startButton == null) {
|
if (startButton == null) {
|
||||||
stopRecording(true);
|
stopRecording(true);
|
||||||
@@ -552,8 +586,8 @@ public class MyTracksSmokeTest extends ActivityInstrumentationTestCase2<TrackLis
|
|||||||
* @param trackKind the kind of track
|
* @param trackKind the kind of track
|
||||||
*/
|
*/
|
||||||
private void deleteExportedFiles(String trackKind) {
|
private void deleteExportedFiles(String trackKind) {
|
||||||
File[] allFiles = (new File(FileUtils.buildExternalDirectoryPath(trackKind.toLowerCase())))
|
File[] allFiles =
|
||||||
.listFiles();
|
(new File(FileUtils.buildExternalDirectoryPath(trackKind.toLowerCase()))).listFiles();
|
||||||
if (allFiles != null) {
|
if (allFiles != null) {
|
||||||
for (File oneFile : allFiles) {
|
for (File oneFile : allFiles) {
|
||||||
oneFile.delete();
|
oneFile.delete();
|
||||||
@@ -590,6 +624,7 @@ public class MyTracksSmokeTest extends ActivityInstrumentationTestCase2<TrackLis
|
|||||||
instrumentation.waitForIdleSync();
|
instrumentation.waitForIdleSync();
|
||||||
solo.clickOnText(activityMyTracks.getString(R.string.menu_save));
|
solo.clickOnText(activityMyTracks.getString(R.string.menu_save));
|
||||||
solo.clickOnText(trackKind.toUpperCase());
|
solo.clickOnText(trackKind.toUpperCase());
|
||||||
|
rotateAllActivities();
|
||||||
solo.waitForText(activityMyTracks.getString(R.string.generic_success_title));
|
solo.waitForText(activityMyTracks.getString(R.string.generic_success_title));
|
||||||
assertEquals(1, getExportedFiles(trackKind).length);
|
assertEquals(1, getExportedFiles(trackKind).length);
|
||||||
}
|
}
|
||||||
@@ -603,8 +638,8 @@ public class MyTracksSmokeTest extends ActivityInstrumentationTestCase2<TrackLis
|
|||||||
private Button getButtonOnScreen(String buttonName) {
|
private Button getButtonOnScreen(String buttonName) {
|
||||||
ArrayList<Button> currentButtons = solo.getCurrentButtons();
|
ArrayList<Button> currentButtons = solo.getCurrentButtons();
|
||||||
for (Button button : currentButtons) {
|
for (Button button : currentButtons) {
|
||||||
if (((String) button.getText()).equalsIgnoreCase(buttonName)) {
|
if (((String) button.getText()).equalsIgnoreCase(buttonName)) {
|
||||||
return button;
|
return button;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@@ -632,6 +667,26 @@ public class MyTracksSmokeTest extends ActivityInstrumentationTestCase2<TrackLis
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Rotates the current activity.
|
||||||
|
*/
|
||||||
|
private void rotateCurrentActivity() {
|
||||||
|
SmokeTestUtils.rotateActivity(solo.getCurrentActivity());
|
||||||
|
instrumentation.waitForIdleSync();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Rotates the all activities.
|
||||||
|
*/
|
||||||
|
private void rotateAllActivities() {
|
||||||
|
ArrayList<Activity> allActivities = solo.getAllOpenedActivities();
|
||||||
|
for (Activity activity : allActivities) {
|
||||||
|
SmokeTestUtils.rotateActivity(activity);
|
||||||
|
}
|
||||||
|
|
||||||
|
instrumentation.waitForIdleSync();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finds an item in the menu with the option to click the item.
|
* Finds an item in the menu with the option to click the item.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012 Google Inc.
|
* Copyright 2012 Google Inc.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
* 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
|
* use this file except in compliance with the License. You may obtain a copy of
|
||||||
* the License at
|
* the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
@@ -15,6 +15,9 @@
|
|||||||
*/
|
*/
|
||||||
package com.google.android.apps.mytracks.smoketest;
|
package com.google.android.apps.mytracks.smoketest;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.res.Configuration;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
@@ -29,6 +32,9 @@ public class SmokeTestUtils {
|
|||||||
private static final String ANDROID_LOCAL_IP = "10.0.2.2";
|
private static final String ANDROID_LOCAL_IP = "10.0.2.2";
|
||||||
// usually 5554.
|
// usually 5554.
|
||||||
private static final int ANDROID_LOCAL_PORT = 5554;
|
private static final int ANDROID_LOCAL_PORT = 5554;
|
||||||
|
|
||||||
|
private static final int ORIENTATION_PORTRAIT = 1;
|
||||||
|
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;
|
private static final float START_LONGITUDE = 51;
|
||||||
@@ -36,7 +42,8 @@ public class SmokeTestUtils {
|
|||||||
private static final float DELTA_LONGITUDE = 0.0005f;
|
private static final float DELTA_LONGITUDE = 0.0005f;
|
||||||
private static final float DELTA_LADITUDE = 0.0005f;
|
private static final float DELTA_LADITUDE = 0.0005f;
|
||||||
|
|
||||||
private SmokeTestUtils() {}
|
private SmokeTestUtils() {
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sends Gps data to emulator.
|
* Sends Gps data to emulator.
|
||||||
@@ -44,10 +51,13 @@ public class SmokeTestUtils {
|
|||||||
* @param number send times
|
* @param number send times
|
||||||
*/
|
*/
|
||||||
public static void sendGps(int number) {
|
public static void sendGps(int number) {
|
||||||
if (number < 1) return;
|
if (number < 1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
PrintStream out = null;
|
PrintStream out = null;
|
||||||
|
Socket socket = null;
|
||||||
try {
|
try {
|
||||||
Socket socket = new Socket(ANDROID_LOCAL_IP, ANDROID_LOCAL_PORT);
|
socket = new Socket(ANDROID_LOCAL_IP, ANDROID_LOCAL_PORT);
|
||||||
out = new PrintStream(socket.getOutputStream());
|
out = new PrintStream(socket.getOutputStream());
|
||||||
float longitude = START_LONGITUDE;
|
float longitude = START_LONGITUDE;
|
||||||
float latitude = START_LATITUDE;
|
float latitude = START_LATITUDE;
|
||||||
@@ -57,8 +67,6 @@ public class SmokeTestUtils {
|
|||||||
longitude += DELTA_LONGITUDE;
|
longitude += DELTA_LONGITUDE;
|
||||||
latitude += DELTA_LADITUDE;
|
latitude += DELTA_LADITUDE;
|
||||||
}
|
}
|
||||||
out.close();
|
|
||||||
socket.close();
|
|
||||||
} catch (UnknownHostException e) {
|
} catch (UnknownHostException e) {
|
||||||
System.exit(-1);
|
System.exit(-1);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@@ -71,4 +79,19 @@ public class SmokeTestUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Rotates the given activity.
|
||||||
|
*
|
||||||
|
* @param activity a given activity.
|
||||||
|
* @return current orientation of the activity.
|
||||||
|
*/
|
||||||
|
public static int rotateActivity(Activity activity) {
|
||||||
|
if (activity.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
|
||||||
|
activity.setRequestedOrientation(ORIENTATION_LANDSCAPE);
|
||||||
|
} else {
|
||||||
|
activity.setRequestedOrientation(ORIENTATION_PORTRAIT);
|
||||||
|
}
|
||||||
|
return activity.getRequestedOrientation();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user