import android.support.test.filters.LargeTest;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;

import com.hewgill.android.nzsldict.NZSLDictionary;
import com.hewgill.android.nzsldict.R;

import org.hamcrest.Matcher;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;

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.closeSoftKeyboard;
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.withId;
import static android.support.test.espresso.matcher.ViewMatchers.withText;
import static org.hamcrest.core.AllOf.allOf;
import static org.hamcrest.Matchers.instanceOf;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.not;

@RunWith(AndroidJUnit4.class)
@LargeTest
public class NZSLDictionaryTest {
    @Rule
    public ActivityTestRule<NZSLDictionary> mActivityRule = new ActivityTestRule<>(NZSLDictionary.class);

    @Test
    public void test_wordOfTheDay() {
        onView(withId(R.id.building_list_wotd_gloss)).check(matches(isDisplayed()));
    }

    @Test
    public void test_performingSearchShowsList() {
        onView(withId(R.id.building_list_search_box)).perform(typeText("Food"), closeSoftKeyboard());
        onView(withId(android.R.id.list)).check(matches(isDisplayed()));
        onView(withId(R.id.building_list_wotd_gloss)).check(matches(not(isDisplayed())));
    }

    @Test
    public void test_toggleHandshapeSearch() {
        onView(withId(R.id.toggle_search_mode)).perform(click());
        onView(withId(R.id.building_list_search_box))
                .check(matches(withText("(handshape search)")))
                .check(matches(not(isEnabled())));

        // TODO JM: Test should also assert that handshape view is present, but I cannot get
        // http://google.github.io/android-testing-support-library/docs/espresso/advanced/#matching-a-view-that-is-a-footerheader-in-a-listview
        // to work
    }


    @Test
    public void test_toggleNormalSearch() {
        onView(withId(R.id.toggle_search_mode))
                .perform(click())
                .perform(click()); // Toggle twice to switch back
        onView(withId(R.id.building_list_search_box))
                .check(matches(withText("")))
                .check(matches(isEnabled()));

        // TODO JM: Test should also assert that handshape view is present, but I cannot get
        // http://google.github.io/android-testing-support-library/docs/espresso/advanced/#matching-a-view-that-is-a-footerheader-in-a-listview
        // to work
    }

}

@@ -1,28 +1,119 @@
+import android.content.Intent;%0Aimport android.support.test.espresso.web.webdriver.Locator;%0A
 import android.support.test.
@@ -354,16 +354,41 @@
 atcher;%0A
+import org.junit.Before;%0A
 import o
@@ -1121,24 +1121,399 @@
 s.withText;%0A
+import static android.support.test.espresso.web.assertion.WebViewAssertions.webMatches;%0Aimport static android.support.test.espresso.web.sugar.Web.onWebView;%0Aimport static android.support.test.espresso.web.webdriver.DriverAtoms.findElement;%0Aimport static android.support.test.espresso.web.webdriver.DriverAtoms.getText;%0Aimport static org.hamcrest.CoreMatchers.containsString;%0A
 import stati
@@ -1841,16 +1841,30 @@
 estRule%3C
+NZSLDictionary
 %3E(NZSLDi
@@ -1877,18 +1877,324 @@
 ry.class
-);
+, false, false) %7B%0A        @Override%0A        protected void afterActivityLaunched() %7B%0A            // Enable JS!%0A            onWebView(withId(R.id.about_content)).forceJavascriptEnabled();%0A        %7D%0A    %7D;%0A%0A    @Before%0A    public void startActivity() %7B%0A        mActivityRule.launchActivity(new Intent());%0A    %7D
 %0A%0A    @T
@@ -3829,10 +3829,281 @@
 %0A    %7D%0A%0A
+    @Test%0A    public void test_aboutWebviewRenders() %7B%0A        onWebView(withId(R.id.about_content))%0A                .withElement(findElement(Locator.TAG_NAME, %22body%22))%0A                .check(webMatches(getText(), containsString(%22NZSL Dictionary Official App%22)));%0A    %7D%0A%0A
 %7D%0A

Add test asserting that webview is rendered on home screen