package dynoapps.exchange_rates;

import android.app.Activity;
import android.app.Instrumentation;
import android.support.test.rule.ActivityTestRule;

import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

import tools.fastlane.screengrab.Screengrab;
import tools.fastlane.screengrab.locale.LocaleTestRule;

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.assertion.ViewAssertions.matches;
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static junit.framework.Assert.assertNotNull;

/**
 * Created by erdemmac on 16/12/2016.
 */

@RunWith(JUnit4.class)
public class JUnit4StyleTests {
    @ClassRule
    public static final LocaleTestRule localeTestRule = new LocaleTestRule();

    @Rule
    public ActivityTestRule<SplashActivity> activityRule = new ActivityTestRule<>(SplashActivity.class);

    @Test
    public void testTakeScreenshot() {
        onView(withId(R.id.iv_splash)).check(matches(isDisplayed()));

        Screengrab.screenshot("splash_activity");

        // register next activity that need to be monitored.
        Instrumentation.ActivityMonitor activityMonitor = getInstrumentation().addMonitor(LandingActivity.class.getName(), null, false);
        //Watch for the timeout
        Activity nextActivity = getInstrumentation().waitForMonitorWithTimeout(activityMonitor, 5000);
        // next activity is opened and captured.
        assertNotNull(nextActivity);

        Screengrab.screenshot("landing_activity");


        onView(withId(R.id.menu_add_alarm))
                .perform(click());

        Screengrab.screenshot("menu_item_alarm");
    }


    @Test
    public void testTakeMoreScreenshots() {
//        onView(withId(R.id.nav_button)).perform(click());
//
//        Screengrab.screenshot("anotherActivity");
//
//        onView(withId(R.id.show_dialog_button)).perform(click());
//
//        Screengrab.screenshot("anotherActivity-dialog");

//        onView(withText(android.R.string.ok)).perform(click());
    }
}
@@ -330,16 +330,80 @@
 engrab;%0A
+import tools.fastlane.screengrab.UiAutomatorScreenshotStrategy;%0A
 import t
@@ -1304,16 +1304,17 @@
 hot() %7B%0A
+%0A
         
@@ -1757,9 +1757,9 @@
 or, 
-5
+4
 000)
@@ -2027,16 +2027,53 @@
 m_alarm%22
+, new UiAutomatorScreenshotStrategy()
 );%0A    %7D

Fix dialog screengreb. Add more screenshots.