summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPallavi Angampally <pallavi@google.com>2017-03-13 16:26:26 -0700
committerPallavi Angampally <pallavi@google.com>2017-03-14 11:45:23 -0700
commitb92e55102d2f205634e38dd60c5919ab29de6a0f (patch)
treedb3010103e348648c63b7389f2b0ec00889e6f87
parent1cd9ba989a924ad6a7e970488358dd7258f5b341 (diff)
downloadadt-infra-b92e55102d2f205634e38dd60c5919ab29de6a0f.tar.gz
Test: functionality of navigation overview in Maps
Change-Id: I1fc99cb7f50613f5922d1d8dd4215339ccda4536
-rw-r--r--system_image_uitests/app/src/androidTest/java/com/android/devtools/systemimage/uitest/smoke/MapsTest.java151
-rw-r--r--system_image_uitests/app/src/main/java/com/android/devtools/systemimage/uitest/common/Res.java4
2 files changed, 155 insertions, 0 deletions
diff --git a/system_image_uitests/app/src/androidTest/java/com/android/devtools/systemimage/uitest/smoke/MapsTest.java b/system_image_uitests/app/src/androidTest/java/com/android/devtools/systemimage/uitest/smoke/MapsTest.java
new file mode 100644
index 00000000..b7daf595
--- /dev/null
+++ b/system_image_uitests/app/src/androidTest/java/com/android/devtools/systemimage/uitest/smoke/MapsTest.java
@@ -0,0 +1,151 @@
+/*
+* Copyright (c) 2016 The Android Open Source Project
+*
+* 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.android.devtools.systemimage.uitest.smoke;
+
+import android.app.Instrumentation;
+import android.support.test.runner.AndroidJUnit4;
+import android.support.test.uiautomator.UiDevice;
+import android.support.test.uiautomator.UiObject;
+import android.support.test.uiautomator.UiScrollable;
+import android.support.test.uiautomator.UiSelector;
+import android.widget.EditText;
+import android.widget.ListView;
+import android.widget.ScrollView;
+import android.widget.TextView;
+
+import com.android.devtools.systemimage.uitest.annotations.TestInfo;
+import com.android.devtools.systemimage.uitest.common.Res;
+import com.android.devtools.systemimage.uitest.framework.SystemImageTestFramework;
+import com.android.devtools.systemimage.uitest.utils.AppLauncher;
+
+import org.junit.Assert;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Sanity test for Maps App
+ */
+
+@RunWith(AndroidJUnit4.class)
+public class MapsTest {
+ private static final String QUERY_STRING = "San Francisco";
+
+ @Rule
+ public final SystemImageTestFramework testFramework = new SystemImageTestFramework();
+
+ /**
+ * Verify the functionality of navigation overview in Google Maps app.
+ * <p>
+ * This is run to qualify releases. Please involve the test team in substantial changes.
+ * <p>
+ * TR ID: T145493594
+ * <p>
+ * <pre>
+ * Test Steps:
+ * 1. Launch emulator avd.
+ * 2. Open Maps app.
+ * 3. Accept terms and condition.
+ * 4. Tap on search bar.
+ * 5. Enter search query, "San Francisco", select it from the auto fill results.
+ * 6. "San Francisco" location card opens.
+ * 7. Select "San Francisco".
+ * 8. Tap on the Drive icon.
+ * Verify:
+ * 1. Map points to San Francisco location.
+ * 2. Navigation overview is displayed.
+ * </pre>
+ */
+ @Test
+ @TestInfo(id = "145493594")
+ public void testMapsApp() throws Exception {
+ Instrumentation instrumentation = testFramework.getInstrumentation();
+ UiDevice mDevice = testFramework.getDevice();
+
+ AppLauncher.launch(instrumentation, "Maps");
+ UiObject acceptButton =
+ mDevice.findObject(new UiSelector().textContains("ACCEPT & CONTINUE"));
+
+ // "Accept & Continue" occurs only on first time Maps gets launched.
+ if (acceptButton.exists()) {
+ acceptButton.clickAndWaitForNewWindow();
+ }
+
+ // SKIP button only exist's occurs only on first time Maps gets launched.
+ UiObject skipText = mDevice.findObject(new UiSelector().textContains("SKIP"));
+ if (skipText.exists()) {
+ skipText.clickAndWaitForNewWindow();
+ }
+
+ // "Got IT" only exist's only on first time Maps gets launched.
+ UiObject gotItTutorialButton = mDevice.findObject(new UiSelector().textContains("GOT IT"));
+ if (gotItTutorialButton.exists()) {
+ gotItTutorialButton.clickAndWaitForNewWindow();
+ }
+
+ UiObject searchUiObject = mDevice.findObject(new UiSelector().
+ resourceIdMatches(Res.SEARCH_TEXT_BOX));
+
+ // Adding extra wait to avoid the system freeze on API 24.
+ searchUiObject.waitForExists(TimeUnit.SECONDS.toMillis(3L));
+ searchUiObject.clickAndWaitForNewWindow();
+
+ UiObject searchEditText;
+ UiObject selectedLocation;
+
+ if(testFramework.getApi() > 19) {
+ searchEditText =
+ searchUiObject.getChild(new UiSelector().className(EditText.class.getName()));
+ searchEditText.setText(QUERY_STRING);
+ UiScrollable scrollView =
+ new UiScrollable(new UiSelector().className(ScrollView.class.getName()));
+ scrollView.scrollIntoView(new UiSelector().text(QUERY_STRING));
+ selectedLocation =
+ scrollView.getChildByText(new UiSelector()
+ .className(TextView.class.getName()), QUERY_STRING);
+ Assert.assertTrue(selectedLocation.exists());
+ selectedLocation.clickAndWaitForNewWindow();
+
+ // Verify the Query String is present after completing search.
+ UiObject searchTextView =
+ searchUiObject.getChild(new UiSelector().className(TextView.class.getName()));
+ Assert.assertTrue(searchTextView.getText().contains(QUERY_STRING));
+ } else {
+ searchEditText =
+ mDevice.findObject(new UiSelector().className(EditText.class.getName()));
+ searchEditText.setText(QUERY_STRING);
+ UiScrollable listViewSelector =
+ new UiScrollable(new UiSelector().className(ListView.class.getName()));
+ selectedLocation =
+ listViewSelector.getChildByText(new UiSelector()
+ .className(TextView.class.getName()), QUERY_STRING);
+ selectedLocation.clickAndWaitForNewWindow();
+
+ // Verify the Query String is present after completing search.
+ Assert.assertTrue(searchEditText.getText().contains(QUERY_STRING));
+ }
+
+ // Verify the directions/route link exists and clicking on it opens the directions page
+ // verify query string is pre filled in the destination("to") field.
+ UiObject directions =
+ mDevice.findObject(new UiSelector().descriptionMatches(".*Directions.*|.*Route.*"));
+ directions.clickAndWaitForNewWindow();
+ UiObject destination = mDevice.findObject(new UiSelector().textContains(QUERY_STRING));
+ Assert.assertTrue(destination.exists());
+ }
+} \ No newline at end of file
diff --git a/system_image_uitests/app/src/main/java/com/android/devtools/systemimage/uitest/common/Res.java b/system_image_uitests/app/src/main/java/com/android/devtools/systemimage/uitest/common/Res.java
index adc13b56..43171f17 100644
--- a/system_image_uitests/app/src/main/java/com/android/devtools/systemimage/uitest/common/Res.java
+++ b/system_image_uitests/app/src/main/java/com/android/devtools/systemimage/uitest/common/Res.java
@@ -78,6 +78,10 @@ public class Res {
public static final String NOW_SIGNIN_SCREEN_RES =
"com.google.android.googlequicksearchbox\\d*:id/header_title";
+ public static final String SEARCH_TEXT_BOX =
+ "(com.google.android.apps.maps:id|com.google.android.apps.gmm:id)" +
+ "/(search_omnibox_text_box|textbox|edit_textbox)";
+
// Third-party application resource IDs
public static final String APP_IMAGE_VIEW_ID =
"com.example.android.rs.hellocompute:id/displayin";