@@ -0,0 +1,2678 @@
+package sunmi.com.sunmiauto;%0A%0Aimport android.app.Instrumentation;%0Aimport android.os.Build;%0Aimport android.os.Environment;%0Aimport android.support.test.InstrumentationRegistry;%0Aimport android.support.test.uiautomator.UiDevice;%0Aimport android.util.Log;%0A%0Aimport java.io.File;%0A%0A/**%0A * Created by fengy on 2017/7/8.%0A */%0A%0Apublic class SunmiUtil %7B%0A%0A    static Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation();%0A    static UiDevice device = UiDevice.getInstance(instrumentation);%0A%0A    public static void screenshotCap(String tag) %7B%0A        StackTraceElement testClass = findTestClassTraceElement(Thread.currentThread().getStackTrace());%0A        String className = testClass.getClassName().replaceAll(%22%5B%5EA-Za-z0-9._-%5D%22, %22_%22);%0A        String methodName = testClass.getMethodName();%0A        Log.v(%22Extenrnal%22, Environment.getExternalStorageState());%0A        File dir = new File(Environment.getExternalStorageDirectory()%0A                + File.separator + %22app_spoon-screenshots%22 + File.separator%0A                + className + File.separator + methodName);%0A        Log.v(%22TEST%22, dir.getAbsolutePath());%0A        if (!dir.exists()) %7B%0A            dir.mkdirs();%0A        %7D%0A        String screenshotName = System.currentTimeMillis() + %22_%22 + tag + %22.png%22;%0A        File screenshotFile = new File(dir, screenshotName);%0A        device.takeScreenshot(screenshotFile, 0.2F, 50);%0A        sleep(2000);%0A    %7D%0A%0A%0A    public static StackTraceElement findTestClassTraceElement(StackTraceElement%5B%5D trace) %7B%0A        for (StackTraceElement e : trace) %7B%0A            Log.v(%22traceTest%22, e.getClassName() + %22:%22 + e.getMethodName());%0A        %7D%0A        for (int i = trace.length - 1; i %3E= 0; --i) %7B%0A            StackTraceElement element = trace%5Bi%5D;%0A            if (%22android.test.InstrumentationTestCase%22.equals(element.getClassName()) && %22runMethod%22.equals(element.getMethodName())) %7B%0A                if (Build.VERSION.SDK_INT %3E= 23) %7B%0A                    return trace%5Bi - 2%5D;%0A                %7D else %7B%0A                    return trace%5Bi - 3%5D;%0A                %7D%0A            %7D%0A%0A            if (%22org.junit.runners.model.FrameworkMethod$1%22.equals(element.getClassName()) && %22runReflectiveCall%22.equals(element.getMethodName())) %7B%0A                if (Build.VERSION.SDK_INT %3E= 23) %7B%0A                    return trace%5Bi - 2%5D;%0A                %7D else %7B%0A                    return trace%5Bi - 3%5D;%0A                %7D%0A            %7D%0A        %7D%0A%0A        throw new IllegalArgumentException(%22Could not find test class!%22);%0A    %7D%0A%0A    public static void sleep(int sleep) %7B%0A        try %7B%0A            Thread.sleep(sleep);%0A        %7D catch (InterruptedException e) %7B%0A            e.printStackTrace();%0A        %7D%0A    %7D%0A%7D%0A

Add SunmiUtil (include screenshotCap & sleep & findtrakstrack)