package com.github.ayltai.newspaper;

import android.content.Intent;
import android.support.test.InstrumentationRegistry;
import android.support.test.espresso.Espresso;
import android.support.test.espresso.assertion.ViewAssertions;
import android.support.test.espresso.matcher.ViewMatchers;
import android.support.test.filters.SmallTest;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;

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

import com.github.ayltai.newspaper.app.VideoActivity;

@SmallTest
@RunWith(AndroidJUnit4.class)
public final class VideoActivityTest {
    @Rule
    public ActivityTestRule<VideoActivity> testRule = new ActivityTestRule<VideoActivity>(VideoActivity.class) {
        @Override
        protected Intent getActivityIntent() {
            return VideoActivity.createIntent(InstrumentationRegistry.getInstrumentation().getTargetContext(), "http://techslides.com/demos/sample-videos/small.mp4", false, 0);
        }
    };

    @Test
    public void test() {
        Espresso.onView(Matchers.allOf(
            ViewMatchers.withClassName(Matchers.is("com.google.android.exoplayer2.ui.SimpleExoPlayerView")),
            ViewMatchers.withId(R.id.video),
            ViewMatchers.isDisplayed()))
            .check(ViewAssertions.matches(ViewMatchers.isDisplayed()));
    }
}

@@ -31,16 +31,38 @@
 paper;%0A%0A
+import java.io.File;%0A%0A
 import a
@@ -84,16 +84,61 @@
 Intent;%0A
+import android.support.annotation.CallSuper;%0A
 import a
@@ -526,24 +526,49 @@
 t.Matchers;%0A
+import org.junit.Before;%0A
 import org.j
@@ -688,16 +688,71 @@
 ctivity;
+%0Aimport com.github.ayltai.newspaper.util.MoreTestUtils;
 %0A%0A@Small
@@ -1204,16 +1204,16 @@
   %7D%0A
-
     %7D;%0A%0A
     
@@ -1208,16 +1208,255 @@
     %7D;%0A%0A
+    @CallSuper%0A    @Before%0A    public void setUp() %7B%0A        final File file = new File(%22/sdcard/tmp/code-coverage/connected%22);%0A        if (!file.exists()) file.mkdirs();%0A%0A        MoreTestUtils.sleep(MoreTestUtils.DURATION_MEDIUM);%0A    %7D%0A%0A
     @Tes

Prepare directory for instrumented tested