play around with UI-Tests

This commit is contained in:
Felix 2017-04-06 21:27:46 +02:00
parent dd1fbe86ea
commit ce20d1f2bd
3 changed files with 11 additions and 5 deletions

View file

@ -72,6 +72,7 @@ dependencies {
androidTestCompile ('com.android.support.test:runner:0.5') {
exclude module: 'support-annotations'
}
androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.2'
androidTestCompile 'org.hamcrest:hamcrest-library:1.3'
androidTestCompile 'com.squareup.okhttp3:mockwebserver:3.6.0'
androidTestCompile group: 'commons-io', name: 'commons-io', version: '2.0.1'

View file

@ -4,6 +4,7 @@ package de.nicidienase.chaosflix;
import android.content.Intent;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import android.support.test.uiautomator.UiDevice;
import android.test.suitebuilder.annotation.LargeTest;
import org.junit.Before;
@ -19,6 +20,8 @@ import de.nicidienase.chaosflix.activities.ConferencesActivity;
import de.nicidienase.chaosflix.network.MediaApiService;
import okhttp3.mockwebserver.MockWebServer;
import static android.support.test.InstrumentationRegistry.getInstrumentation;
@LargeTest
@RunWith(AndroidJUnit4.class)
public class ConferencesActivityTest {
@ -27,10 +30,13 @@ public class ConferencesActivityTest {
public ActivityTestRule<ConferencesActivity> mActivityTestRule
= new ActivityTestRule<>(ConferencesActivity.class, false, false);
private static MockWebServer server;
private UiDevice mDevice;
@Before
public void setup() throws IOException, TimeoutException {
mDevice = UiDevice.getInstance(getInstrumentation());
server = new MockWebServer();
server.start();
String serverUrl = server.url("").toString();
@ -45,10 +51,9 @@ public class ConferencesActivityTest {
@Test
public void conferencesActivityTest() throws InterruptedException {
while(true){
}
mDevice.pressDPadRight();
mDevice.pressDPadRight();
mDevice.pressDPadCenter();
}
}

View file

@ -93,7 +93,7 @@ public class MediaApiServiceTest {
}
@Test
public void test1() throws IOException {
public void testStreamingConferences() throws IOException {
server.enqueue(TestHelper.getResponseForRaw(R.raw.streams_v2_json));
service.getStreamingConferences()