forked from upstream-mirrors/OpenTracks
Move method findAndClickMyLocation from GoToMyLocationTest to EndToEndTestUtils.
This commit is contained in:
+27
-1
@@ -300,7 +300,7 @@ public class EndToEndTestUtils {
|
||||
instrumentation.waitForIdleSync();
|
||||
// Check the status of real phone. For emulator, we would fix GPS signal.
|
||||
if (!isEmulator) {
|
||||
GoToMyLocationTest.findAndClickMyLocation(activityMyTracks);
|
||||
EndToEndTestUtils.findAndClickMyLocation(activityMyTracks);
|
||||
hasGpsSingal = !SOLO.waitForText(NO_GPS_MESSAGE_PREFIX, 1, SHORT_WAIT_TIME);
|
||||
SOLO.goBack();
|
||||
}
|
||||
@@ -974,4 +974,30 @@ public class EndToEndTestUtils {
|
||||
while (SOLO.waitForText(text, 1, VERY_SHORT_WAIT_TIME)) {}
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the My Location view and click it.
|
||||
*
|
||||
* @param activity
|
||||
*/
|
||||
public static void findAndClickMyLocation(Activity activity) {
|
||||
createTrackIfEmpty(1, false);
|
||||
sendGps(30);
|
||||
|
||||
View myLocation = SOLO.getCurrentActivity()
|
||||
.findViewById(R.id.map_my_location);
|
||||
// Find the My Location button in another if null.
|
||||
if (myLocation == null) {
|
||||
ArrayList<ImageButton> aa = SOLO.getCurrentImageButtons();
|
||||
for (ImageButton imageButton : aa) {
|
||||
if (imageButton.getContentDescription() != null
|
||||
&& imageButton.getContentDescription().equals(
|
||||
activity.getString(R.string.icon_my_location))) {
|
||||
myLocation = imageButton;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
SOLO.clickOnView(myLocation);
|
||||
}
|
||||
}
|
||||
+1
-31
@@ -19,13 +19,9 @@ import com.google.android.apps.mytracks.TrackListActivity;
|
||||
import com.google.android.apps.mytracks.util.GoogleLocationUtils;
|
||||
import com.google.android.maps.mytracks.R;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Instrumentation;
|
||||
import android.test.ActivityInstrumentationTestCase2;
|
||||
import android.view.View;
|
||||
import android.widget.ImageButton;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Tests the function of go to my location.
|
||||
@@ -53,7 +49,7 @@ public class GoToMyLocationTest extends ActivityInstrumentationTestCase2<TrackLi
|
||||
* Tests the menu My Location.
|
||||
*/
|
||||
public void testGotoMyLocation() {
|
||||
findAndClickMyLocation(activityMyTracks);
|
||||
EndToEndTestUtils.findAndClickMyLocation(activityMyTracks);
|
||||
if (EndToEndTestUtils.isEmulator) {
|
||||
String setting = activityMyTracks.getString(
|
||||
GoogleLocationUtils.isAvailable(activityMyTracks) ? R.string.gps_google_location_settings
|
||||
@@ -66,32 +62,6 @@ public class GoToMyLocationTest extends ActivityInstrumentationTestCase2<TrackLi
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the My Location view and click it.
|
||||
*
|
||||
* @param activity
|
||||
*/
|
||||
public static void findAndClickMyLocation(Activity activity) {
|
||||
EndToEndTestUtils.createTrackIfEmpty(1, false);
|
||||
EndToEndTestUtils.sendGps(30);
|
||||
|
||||
View myLocation = EndToEndTestUtils.SOLO.getCurrentActivity()
|
||||
.findViewById(R.id.map_my_location);
|
||||
// Find the My Location button in another if null.
|
||||
if (myLocation == null) {
|
||||
ArrayList<ImageButton> aa = EndToEndTestUtils.SOLO.getCurrentImageButtons();
|
||||
for (ImageButton imageButton : aa) {
|
||||
if (imageButton.getContentDescription() != null
|
||||
&& imageButton.getContentDescription().equals(
|
||||
activity.getString(R.string.icon_my_location))) {
|
||||
myLocation = imageButton;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
EndToEndTestUtils.SOLO.clickOnView(myLocation);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
EndToEndTestUtils.SOLO.finishOpenedActivities();
|
||||
|
||||
Reference in New Issue
Block a user