Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(445)

Unified Diff: webrtc/examples/androidtests/src/org/appspot/apprtc/test/ConnectActivityStubbedInputOutputTest.java

Issue 2741743002: IdlingResource for destroy() VideoFileRenderer (Closed)
Patch Set: Merge branch 'master' into idling_busy_resource Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/examples/androidtests/src/org/appspot/apprtc/test/ConnectActivityStubbedInputOutputTest.java
diff --git a/webrtc/examples/androidtests/src/org/appspot/apprtc/test/ConnectActivityStubbedInputOutputTest.java b/webrtc/examples/androidtests/src/org/appspot/apprtc/test/ConnectActivityStubbedInputOutputTest.java
index ebb445bc793ec6b7332521b5914e8d32cd77d016..98a77696a8bc767392ce3eb3665ca72efe811851 100644
--- a/webrtc/examples/androidtests/src/org/appspot/apprtc/test/ConnectActivityStubbedInputOutputTest.java
+++ b/webrtc/examples/androidtests/src/org/appspot/apprtc/test/ConnectActivityStubbedInputOutputTest.java
@@ -18,7 +18,10 @@ import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Environment;
+import android.support.test.espresso.contrib.CountingIdlingResource;
+import android.support.test.espresso.Espresso;
import android.support.test.espresso.IdlingPolicies;
+import android.support.test.espresso.IdlingResource;
import android.support.test.filters.LargeTest;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
@@ -28,6 +31,8 @@ import java.util.concurrent.TimeUnit;
import org.appspot.apprtc.CallActivity;
import org.appspot.apprtc.ConnectActivity;
import org.appspot.apprtc.R;
+import org.junit.After;
+import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -42,13 +47,19 @@ public class ConnectActivityStubbedInputOutputTest {
private static final String TAG = "ConnectActivityStubbedInputOutputTest";
@Rule
- public ActivityTestRule<ConnectActivity> rule =
- new ActivityTestRule<ConnectActivity>(ConnectActivity.class) {
+ public ActivityTestRule<CallActivity> rule =
+ new ActivityTestRule<CallActivity>(CallActivity.class) {
@Override
protected Intent getActivityIntent() {
- Context context = InstrumentationRegistry.getInstrumentation().getTargetContext();
- Intent intent = new Intent("android.intent.action.VIEW", Uri.parse("https://appr.tc"),
- context, ConnectActivity.class);
+ Context context =
+ InstrumentationRegistry
+ .getContext(); // InstrumentationRegistry.getInstrumentation().getTargetContext();
+ Intent intent = new Intent("android.intent.action.VIEW", Uri.parse("https://appr.tc"));
+ // context, IdlingResourceCallActivity.class);
kjellander_webrtc 2017/03/10 10:40:38 Please remove commented code.
+ // intent.setClassName(
+ // "org.appsport.apprtc.test", "org.appsport.apprtc.test.IdlingResourceCallActivity2");
+ // Intent intent = new Intent("android.intent.action.VIEW", Uri.parse("https://appr.tc"),
+ // context, IdlingResourceCallActivity.class);
intent.putExtra(CallActivity.EXTRA_USE_VALUES_FROM_INTENT, true);
@@ -72,6 +83,37 @@ public class ConnectActivityStubbedInputOutputTest {
}
};
+ private static class BusyResource implements CallActivity.CountingResource {
+ CountingIdlingResource countingIdlingResource = new CountingIdlingResource("BusyResource");
+
+ @Override
+ public void increment() {
+ countingIdlingResource.increment();
+ }
+
+ @Override
+ public void decrement() {
+ countingIdlingResource.decrement();
+ }
+ }
+ private IdlingResource idlingResource;
+
+ @Before
+ public void registerIdlingResource() {
+ // idlingResource = rule.getActivity().getIdlingResource();
+ BusyResource busyR = new BusyResource();
+ idlingResource = busyR.countingIdlingResource;
+ rule.getActivity().setCountingResource(busyR);
+ Espresso.registerIdlingResources(idlingResource);
+ }
+
+ @After
+ public void unregisterIdlingResources() {
+ if (idlingResource != null) {
+ Espresso.unregisterIdlingResources(idlingResource);
+ }
+ }
+
@Test
public void testLoopback() throws InterruptedException {
// The time to write down the data during closing of the program can take a while.
@@ -81,6 +123,6 @@ public class ConnectActivityStubbedInputOutputTest {
Thread.sleep(10000);
// Click on hang-up button.
- onView(withId(R.id.button_call_disconnect)).perform(click());
+ // onView(withId(R.id.button_call_disconnect)).perform(click());
kjellander_webrtc 2017/03/10 10:40:38 Should this be restored?
}
}

Powered by Google App Engine
This is Rietveld 408576698