package de.nenick.espressomacchiato.tools;

import android.Manifest;
import android.support.test.InstrumentationRegistry;

import org.junit.Test;

import java.io.File;

import de.nenick.espressomacchiato.test.views.BaseActivity;
import de.nenick.espressomacchiato.testbase.EspressoTestCase;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;

public class EspScreenshotToolTest extends EspressoTestCase<BaseActivity> {

    @Test
    public void testScreenshot() {
        EspPermissionsTool.ensurePermissions(getActivity(), Manifest.permission.WRITE_EXTERNAL_STORAGE);
        EspScreenshotTool.takeWithName("test screen");
        File screenshot = new File(InstrumentationRegistry.getTargetContext().getFilesDir(), "test-screenshots/test screen.png");
        assertThat(screenshot.exists(), is(true));

        //noinspection ResultOfMethodCallIgnored
        //screenshot.delete();
    }
}
@@ -114,16 +114,48 @@
 egistry;
+%0Aimport android.widget.TextView;
 %0A%0Aimport
@@ -496,48 +496,292 @@
     
-@Test%0A    public void testScreenshot() %7B
+public static final String PICTURE_TEST_SCREEN = %22Picture Test Screen%22;%0A%0A    @Test%0A    public void testScreenshot() %7B%0A        TextView textView = new TextView(getActivity());%0A        textView.setText(PICTURE_TEST_SCREEN);%0A        addViewToActivity(textView, BaseActivity.rootLayout);%0A
 %0A   
@@ -881,16 +881,44 @@
 TORAGE);
+%0A%0A        EspWait.forIdle();
 %0A       
@@ -961,16 +961,20 @@
 t screen
+shot
 %22);%0A    
@@ -1091,16 +1091,20 @@
 t screen
+shot
 .png%22);%0A
@@ -1157,89 +1157,8 @@
 e));
-%0A%0A        //noinspection ResultOfMethodCallIgnored%0A        //screenshot.delete();
 %0A   

add some text for test screenshot