forked from upstream-mirrors/OpenTracks
Code cleanup: MyLocationTest
This commit is contained in:
+28
-21
@@ -13,27 +13,29 @@
|
|||||||
* License for the specific language governing permissions and limitations under
|
* License for the specific language governing permissions and limitations under
|
||||||
* the License.
|
* the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.google.android.apps.mytracks.endtoendtest.common;
|
package com.google.android.apps.mytracks.endtoendtest.common;
|
||||||
|
|
||||||
import com.google.android.apps.mytracks.TrackListActivity;
|
import com.google.android.apps.mytracks.TrackListActivity;
|
||||||
import com.google.android.apps.mytracks.endtoendtest.EndToEndTestUtils;
|
import com.google.android.apps.mytracks.endtoendtest.EndToEndTestUtils;
|
||||||
import com.google.android.apps.mytracks.util.GoogleLocationUtils;
|
import com.google.android.apps.mytracks.util.GoogleLocationUtils;
|
||||||
|
import com.google.android.maps.mytracks.R;
|
||||||
|
|
||||||
import android.app.Instrumentation;
|
import android.app.Instrumentation;
|
||||||
import android.test.ActivityInstrumentationTestCase2;
|
import android.test.ActivityInstrumentationTestCase2;
|
||||||
|
import android.view.View;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests the function of go to my location.
|
* Tests the my location button.
|
||||||
*
|
*
|
||||||
* @author Youtao Liu
|
* @author Youtao Liu
|
||||||
*/
|
*/
|
||||||
public class GoToMyLocationTest extends ActivityInstrumentationTestCase2<TrackListActivity> {
|
public class MyLocationTest extends ActivityInstrumentationTestCase2<TrackListActivity> {
|
||||||
|
|
||||||
private Instrumentation instrumentation;
|
private Instrumentation instrumentation;
|
||||||
private TrackListActivity activityMyTracks;
|
private TrackListActivity trackListActivity;
|
||||||
|
|
||||||
public GoToMyLocationTest() {
|
public MyLocationTest() {
|
||||||
super(TrackListActivity.class);
|
super(TrackListActivity.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -41,28 +43,33 @@ public class GoToMyLocationTest extends ActivityInstrumentationTestCase2<TrackLi
|
|||||||
protected void setUp() throws Exception {
|
protected void setUp() throws Exception {
|
||||||
super.setUp();
|
super.setUp();
|
||||||
instrumentation = getInstrumentation();
|
instrumentation = getInstrumentation();
|
||||||
activityMyTracks = getActivity();
|
trackListActivity = getActivity();
|
||||||
EndToEndTestUtils.setupForAllTest(instrumentation, activityMyTracks);
|
EndToEndTestUtils.setupForAllTest(instrumentation, trackListActivity);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Tests the menu My Location.
|
|
||||||
*/
|
|
||||||
public void testGotoMyLocation() {
|
|
||||||
EndToEndTestUtils.findAndClickMyLocation(activityMyTracks);
|
|
||||||
if (EndToEndTestUtils.isEmulator) {
|
|
||||||
EndToEndTestUtils.SOLO.waitForText(
|
|
||||||
GoogleLocationUtils.getGpsDisabledMyLocationMessage(activityMyTracks), 1,
|
|
||||||
EndToEndTestUtils.SHORT_WAIT_TIME);
|
|
||||||
} else {
|
|
||||||
// TODO How to verify the location is shown on the map.
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void tearDown() throws Exception {
|
protected void tearDown() throws Exception {
|
||||||
EndToEndTestUtils.SOLO.finishOpenedActivities();
|
EndToEndTestUtils.SOLO.finishOpenedActivities();
|
||||||
super.tearDown();
|
super.tearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests the my location button.
|
||||||
|
*/
|
||||||
|
public void testMyLocation() {
|
||||||
|
EndToEndTestUtils.deleteAllTracks();
|
||||||
|
EndToEndTestUtils.createSimpleTrack(1, false);
|
||||||
|
View myLocation = EndToEndTestUtils.SOLO.getCurrentActivity()
|
||||||
|
.findViewById(R.id.map_my_location);
|
||||||
|
EndToEndTestUtils.SOLO.clickOnView(myLocation);
|
||||||
|
instrumentation.waitForIdleSync();
|
||||||
|
|
||||||
|
if (EndToEndTestUtils.isEmulator) {
|
||||||
|
EndToEndTestUtils.SOLO.waitForText(
|
||||||
|
GoogleLocationUtils.getGpsDisabledMyLocationMessage(trackListActivity), 1,
|
||||||
|
EndToEndTestUtils.SHORT_WAIT_TIME);
|
||||||
|
} else {
|
||||||
|
// TODO How to verify my location is shown on the map?
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user