mirror of
https://codeberg.org/OpenTracksApp/OpenTracks.git
synced 2026-10-02 17:43:06 +02:00
Merge heads
This commit is contained in:
+2
-2
@@ -116,8 +116,8 @@ public class EndToEndTestUtils {
|
||||
MILE_MULTILINGUAL.put("zh", "英里");
|
||||
}
|
||||
|
||||
static Solo SOLO;
|
||||
static Instrumentation instrumentation;
|
||||
public static Solo SOLO;
|
||||
public static Instrumentation instrumentation;
|
||||
static TrackListActivity activityMytracks;
|
||||
// Check whether the UI has an action bar which is related with the version of
|
||||
// Android OS.
|
||||
|
||||
+5
-4
@@ -13,9 +13,10 @@
|
||||
* License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
package com.google.android.apps.mytracks.endtoendtest;
|
||||
package com.google.android.apps.mytracks.endtoendtest.others;
|
||||
|
||||
import com.google.android.apps.mytracks.TrackListActivity;
|
||||
import com.google.android.apps.mytracks.endtoendtest.EndToEndTestUtils;
|
||||
import com.google.android.maps.mytracks.R;
|
||||
|
||||
import android.app.Instrumentation;
|
||||
@@ -43,7 +44,7 @@ public class SensorTest extends ActivityInstrumentationTestCase2<TrackListActivi
|
||||
|
||||
private Instrumentation instrumentation;
|
||||
private TrackListActivity activityMyTracks;
|
||||
private final String disableMessage= "Sensor test is disabled";
|
||||
public static final String DISABLE_MESSAGE = "This test is disabled";
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
@@ -59,7 +60,7 @@ public class SensorTest extends ActivityInstrumentationTestCase2<TrackListActivi
|
||||
*/
|
||||
public void testConnectZephyrBluetoothSensor() {
|
||||
if (!testSensor) {
|
||||
Log.i(EndToEndTestUtils.LOG_TAG, disableMessage);
|
||||
Log.i(EndToEndTestUtils.LOG_TAG, DISABLE_MESSAGE);
|
||||
return;
|
||||
}
|
||||
EndToEndTestUtils.findMenuItem(activityMyTracks.getString(R.string.menu_settings), true);
|
||||
@@ -82,7 +83,7 @@ public class SensorTest extends ActivityInstrumentationTestCase2<TrackListActivi
|
||||
*/
|
||||
public void testConnectPolarBluetoothSensor() {
|
||||
if (!testSensor) {
|
||||
Log.i(EndToEndTestUtils.LOG_TAG, disableMessage);
|
||||
Log.i(EndToEndTestUtils.LOG_TAG, DISABLE_MESSAGE);
|
||||
return;
|
||||
}
|
||||
EndToEndTestUtils.findMenuItem(activityMyTracks.getString(R.string.menu_settings), true);
|
||||
+134
@@ -0,0 +1,134 @@
|
||||
/*
|
||||
* 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.others;
|
||||
|
||||
import com.google.android.apps.mytracks.TrackListActivity;
|
||||
import com.google.android.apps.mytracks.endtoendtest.EndToEndTestUtils;
|
||||
import com.google.android.maps.mytracks.R;
|
||||
|
||||
import android.app.Instrumentation;
|
||||
import android.test.ActivityInstrumentationTestCase2;
|
||||
import android.util.Log;
|
||||
|
||||
/**
|
||||
* Tests Rotation of MyTracks.
|
||||
*
|
||||
* @author Youtao Liu
|
||||
*/
|
||||
public class StressTest extends ActivityInstrumentationTestCase2<TrackListActivity> {
|
||||
|
||||
/**
|
||||
* Set to false as default.
|
||||
*/
|
||||
public static boolean testStress = false;
|
||||
public static final int MINUTES_FOR_EACH_TEST = 30;
|
||||
public static final int MILLI_SECOND_IN_ONE_MINUTE = 60 * 1000;
|
||||
long startTime = 0;
|
||||
int trackNumber;
|
||||
|
||||
public StressTest() {
|
||||
super(TrackListActivity.class);
|
||||
}
|
||||
|
||||
private Instrumentation instrumentation;
|
||||
private TrackListActivity activityMyTracks;
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
instrumentation = getInstrumentation();
|
||||
activityMyTracks = getActivity();
|
||||
EndToEndTestUtils.setupForDebug(instrumentation, activityMyTracks);
|
||||
startTime = System.currentTimeMillis();
|
||||
EndToEndTestUtils.emulatorPort = 5568;
|
||||
}
|
||||
|
||||
/**
|
||||
* Records tracks and delete them when there are more than 30 tracks..
|
||||
*/
|
||||
public void testRecordAndDeleteTracks() {
|
||||
if (!testStress) {
|
||||
Log.i(EndToEndTestUtils.LOG_TAG, SensorTest.DISABLE_MESSAGE);
|
||||
return;
|
||||
}
|
||||
for (int i = 0; (System.currentTimeMillis() - startTime) / MILLI_SECOND_IN_ONE_MINUTE < MINUTES_FOR_EACH_TEST; i++) {
|
||||
EndToEndTestUtils.startRecording();
|
||||
// Points in a tracks keep increasing.
|
||||
EndToEndTestUtils.sendGps(i * 10, 0, 10);
|
||||
EndToEndTestUtils.stopRecording(true);
|
||||
EndToEndTestUtils.SOLO.goBack();
|
||||
EndToEndTestUtils.instrumentation.waitForIdleSync();
|
||||
trackNumber = EndToEndTestUtils.SOLO.getCurrentListViews().get(0).getCount();
|
||||
if (trackNumber > 30) {
|
||||
EndToEndTestUtils.deleteAllTracks();
|
||||
}
|
||||
logStatus(i);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Rotates screen when display map view.
|
||||
*/
|
||||
public void testRotateMapViewInTrackDetailActivity() {
|
||||
if (!testStress) {
|
||||
Log.i(EndToEndTestUtils.LOG_TAG, SensorTest.DISABLE_MESSAGE);
|
||||
return;
|
||||
}
|
||||
EndToEndTestUtils.startRecording();
|
||||
for (int i = 0; (System.currentTimeMillis() - startTime) / MILLI_SECOND_IN_ONE_MINUTE < MINUTES_FOR_EACH_TEST; i++) {
|
||||
EndToEndTestUtils.sendGps(10, i * 10);
|
||||
EndToEndTestUtils.rotateCurrentActivity();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Switches view between CHART, MAP and STAT.
|
||||
*/
|
||||
public void testSwitchTabs() {
|
||||
if (!testStress) {
|
||||
Log.i(EndToEndTestUtils.LOG_TAG, SensorTest.DISABLE_MESSAGE);
|
||||
return;
|
||||
}
|
||||
EndToEndTestUtils.startRecording();
|
||||
int i = 0;
|
||||
while ((System.currentTimeMillis() - startTime) / MILLI_SECOND_IN_ONE_MINUTE < MINUTES_FOR_EACH_TEST) {
|
||||
EndToEndTestUtils.SOLO.clickOnText(activityMyTracks.getString(R.string.track_detail_map_tab));
|
||||
instrumentation.waitForIdleSync();
|
||||
EndToEndTestUtils.SOLO.clickOnText(activityMyTracks
|
||||
.getString(R.string.track_detail_chart_tab));
|
||||
instrumentation.waitForIdleSync();
|
||||
EndToEndTestUtils.SOLO.clickOnText(activityMyTracks
|
||||
.getString(R.string.track_detail_stats_tab));
|
||||
instrumentation.waitForIdleSync();
|
||||
logStatus(++i);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays log message.
|
||||
*
|
||||
* @param times this test has been run
|
||||
*/
|
||||
private void logStatus(int times) {
|
||||
Log.i(EndToEndTestUtils.LOG_TAG, "This test has run "
|
||||
+ times
|
||||
+ " times and will be finished in "
|
||||
+ (MINUTES_FOR_EACH_TEST - (System.currentTimeMillis() - startTime)
|
||||
/ MILLI_SECOND_IN_ONE_MINUTE) + " minutes!");
|
||||
Log.i(EndToEndTestUtils.LOG_TAG, "There are " + trackNumber + " tracks!");
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user