2017-03-08 13 views

답변

0

ActivityInstrumentationTestCase2을 사용하고 필요하면 Espresso 및 UiAutomator를 사용할 수 있습니다.

public class SampleActivityTests extends ActivityInstrumentationTestCase2<SampleActivity> { 

    private UiDevice mDevice; 

    public SampleActivityTests() { 
     super(SampleActivity.class); 
    } 

    @Override 
    public void setUp() throws Exception { 
     super.setUp(); 
     getActivity(); 
     mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation()); 
    } 

    public void testAddNote() throws InterruptedException { 
     // Take a screenshot when app becomes visible. 
     onView(isRoot()); 
     ScreenShotter.takeScreenshot("sample 1", getActivity()); 
     mDevice.pressDPadLeft(); 
     mDevice.pressDPadLeft(); 
     ScreenShotter.takeScreenshot("sample 2", getActivity()); 
    } 
} 
+0

좋아 나는이에보고 드리도록하겠습니다, 감사 –

+0

코드는, 일을 컴파일 및 실행하고, 그러나 그들은 빈/블랙 스크린이었다 내 2 개 스크린 샷을했다. 테스트 비디오의 어떤 단계에서도 화면이 검은 색 이었기 때문에 내가 사용하고있는 게임 라이브러리 일 수도 있습니다. 여기에서 [AndroidLauncher]를 사용합니다 (AndroidLauncher) (https://github.com/libgdx/libgdx/blob/9b8f20b2d0e96e53f0f2b98dc8f6131c810aae71/extensions/gdx-setup/src/com/badlogic/gdx/setup/resources/android/src/ AndroidLauncher) Activity를 확장 했으므로 작동한다고 가정했으나 –