WIP, check pwa page action draft
authorNevin Chen <cnevinchen@gmail.com>
Thu, 07 Dec 2017 17:52:22 +0800
changeset 708918 2f3c8ee7d4cdcbdd2b1039669ac3e4313dd1fb3b
parent 708917 4594af36865115ecbfd438530e0434907178a11f
child 709238 7acd8f54bd6eb577c47d6e125f5e7c632f90ac2b
push id92480
push userbmo:cnevinchen@gmail.com
push dateThu, 07 Dec 2017 09:53:01 +0000
milestone59.0a1
WIP, check pwa page action MozReview-Commit-ID: 6d8lcGEE25e
mobile/android/app/build.gradle
mobile/android/app/src/androidTest/java/org/mozilla/gecko/EspressoBrowserAppTest.java
--- a/mobile/android/app/build.gradle
+++ b/mobile/android/app/build.gradle
@@ -82,16 +82,19 @@ android {
     flavorDimensions "audience", "skin"
 
     productFlavors {
         espresso{
             dimension "audience"
 
             testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner'
             testInstrumentationRunnerArgument 'annotation', 'org.mozilla.gecko.EspressoOnly'
+            testOptions {
+                animationsDisabled = true
+            }
         }
         // For API 21+ - with pre-dexing, this will be faster for local development.
         local {
             dimension "audience"
 
             // For pre-dexing, setting `minSdkVersion 21` allows the Android gradle plugin to
             // pre-DEX each module and produce an APK that can be tested on
             // Android Lollipop without time consuming DEX merging processes.
--- a/mobile/android/app/src/androidTest/java/org/mozilla/gecko/EspressoBrowserAppTest.java
+++ b/mobile/android/app/src/androidTest/java/org/mozilla/gecko/EspressoBrowserAppTest.java
@@ -1,22 +1,64 @@
 package org.mozilla.gecko;
 
+import android.support.test.espresso.IdlingPolicies;
 import android.support.test.rule.ActivityTestRule;
 import android.support.test.runner.AndroidJUnit4;
+import android.widget.EditText;
 
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
+import java.util.concurrent.TimeUnit;
+
+import static android.support.test.InstrumentationRegistry.getInstrumentation;
+import static android.support.test.espresso.Espresso.onView;
+import static android.support.test.espresso.action.ViewActions.click;
+import static android.support.test.espresso.action.ViewActions.pressImeActionButton;
+import static android.support.test.espresso.action.ViewActions.replaceText;
+import static android.support.test.espresso.action.ViewActions.typeText;
+import static android.support.test.espresso.assertion.ViewAssertions.matches;
+import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
+import static android.support.test.espresso.matcher.ViewMatchers.isEnabled;
+import static android.support.test.espresso.matcher.ViewMatchers.supportsInputMethods;
+import static android.support.test.espresso.matcher.ViewMatchers.withId;
+import static android.support.test.espresso.matcher.ViewMatchers.withParent;
+import static android.support.test.espresso.matcher.ViewMatchers.withTagValue;
+import static android.support.test.espresso.matcher.ViewMatchers.withText;
+import static org.hamcrest.Matchers.allOf;
+import static org.hamcrest.Matchers.is;
+import static org.mozilla.gecko.toolbar.PageActionLayout.PageAction.UUID_PAGE_ACTION_PWA;
+
 @EspressoOnly
 @RunWith(AndroidJUnit4.class)
 public class EspressoBrowserAppTest {
 
+    protected static final String WEB_FORM_URL = "file:///android_asset/pwa_test_site/index.html";
+
+
     @Rule
     public ActivityTestRule<BrowserApp> mActivityRule =
             new ActivityTestRule(BrowserApp.class);
 
     @Test
-    public void listGoesOverTheFold() {
+    public void loadUrl() {
+        // Enter url
+        onView(withId(R.id.url_bar_title_scroll_view)).perform(click());
+//        final EditText titleInput = (EditText) mActivityRule.getActivity().findViewById(R.id.url_edit_text);
+//        getInstrumentation().runOnMainSync(new Runnable() {
+//            public void run() {
+//                titleInput.setText("Engineer");
+//            }
+//        });
+
+        onView(withId(R.id.url_edit_text)).perform(click(), replaceText(WEB_FORM_URL), pressImeActionButton());
+
+        onView(withId(R.id.page_action_layout)).check(matches(isDisplayed()));
+
+        onView(allOf(
+                withParent(withId(R.id.page_action_layout)),
+                withTagValue(is((Object) UUID_PAGE_ACTION_PWA))))
+                .check(matches(isDisplayed()));
 
     }
 }