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

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

Issue 1989813002: Convert LooperExecutorTest in AppRTC Demo into JUnit test (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 7 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/LooperExecutorTest.java
diff --git a/webrtc/examples/androidtests/src/org/appspot/apprtc/test/LooperExecutorTest.java b/webrtc/examples/androidtests/src/org/appspot/apprtc/test/LooperExecutorTest.java
deleted file mode 100644
index 60d3c1cbc07dd5d5630d844990c73624efed9fa3..0000000000000000000000000000000000000000
--- a/webrtc/examples/androidtests/src/org/appspot/apprtc/test/LooperExecutorTest.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright 2015 The WebRTC Project Authors. All rights reserved.
- *
- * Use of this source code is governed by a BSD-style license
- * that can be found in the LICENSE file in the root of the source
- * tree. An additional intellectual property rights grant can be found
- * in the file PATENTS. All contributing project authors may
- * be found in the AUTHORS file in the root of the source tree.
- */
-
-package org.appspot.apprtc.test;
-
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-import org.appspot.apprtc.util.LooperExecutor;
-
-import android.test.InstrumentationTestCase;
-import android.test.suitebuilder.annotation.SmallTest;
-import android.util.Log;
-
-public class LooperExecutorTest extends InstrumentationTestCase {
- private static final String TAG = "LooperTest";
- private static final int WAIT_TIMEOUT = 5000;
-
- @SmallTest
- public void testLooperExecutor() throws InterruptedException {
- Log.d(TAG, "testLooperExecutor");
- final int counter[] = new int[1];
- final int expectedCounter = 10;
- final CountDownLatch looperDone = new CountDownLatch(1);
-
- Runnable counterIncRunnable = new Runnable() {
- @Override
- public void run() {
- counter[0]++;
- Log.d(TAG, "Run " + counter[0]);
- }
- };
- LooperExecutor executor = new LooperExecutor();
-
- // Try to execute a counter increment task before starting an executor.
- executor.execute(counterIncRunnable);
-
- // Start the executor and run expected amount of counter increment task.
- executor.requestStart();
- for (int i = 0; i < expectedCounter; i++) {
- executor.execute(counterIncRunnable);
- }
- executor.execute(new Runnable() {
- @Override
- public void run() {
- looperDone.countDown();
- }
- });
- executor.requestStop();
-
- // Try to execute a task after stopping the executor.
- executor.execute(counterIncRunnable);
-
- // Wait for final looper task and make sure the counter increment task
- // is executed expected amount of times.
- looperDone.await(WAIT_TIMEOUT, TimeUnit.MILLISECONDS);
- assertTrue (looperDone.getCount() == 0);
- assertTrue (counter[0] == expectedCounter);
-
- Log.d(TAG, "testLooperExecutor done");
- }
-}

Powered by Google App Engine
This is Rietveld 408576698