Code cleanup: MyLocationTest

This commit is contained in:
Jimmy Shih
2014-01-30 16:33:37 -08:00
parent 0e766261d1
commit 9a059add14
@@ -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,22 +43,8 @@ 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
@@ -65,4 +53,23 @@ public class GoToMyLocationTest extends ActivityInstrumentationTestCase2<TrackLi
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?
}
}
} }