summaryrefslogtreecommitdiff
path: root/base/test/android/java/src/org/chromium/base/TestUiThread.java
diff options
context:
space:
mode:
Diffstat (limited to 'base/test/android/java/src/org/chromium/base/TestUiThread.java')
-rw-r--r--base/test/android/java/src/org/chromium/base/TestUiThread.java49
1 files changed, 0 insertions, 49 deletions
diff --git a/base/test/android/java/src/org/chromium/base/TestUiThread.java b/base/test/android/java/src/org/chromium/base/TestUiThread.java
deleted file mode 100644
index 77f96606ad..0000000000
--- a/base/test/android/java/src/org/chromium/base/TestUiThread.java
+++ /dev/null
@@ -1,49 +0,0 @@
-// Copyright 2015 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-package org.chromium.base;
-
-import android.os.Looper;
-
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-import javax.annotation.concurrent.ThreadSafe;
-
-/**
- * Set up a thread as the Chromium UI Thread, and run its looper. This is is intended for C++ unit
- * tests (e.g. the net unit tests) that don't run with the UI thread as their main looper, but test
- * code that, on Android, uses UI thread events, so need a running UI thread.
- */
-@ThreadSafe
-public class TestUiThread {
- private static final AtomicBoolean sStarted = new AtomicBoolean(false);
- private static final String TAG = Log.makeTag("TestUiThread");
-
- @CalledByNative
- private static void loop() {
- // @{link ThreadUtils#setUiThread(Looper)} can only be called once in a test run, so do this
- // once, and leave it running.
- if (sStarted.getAndSet(true)) return;
-
- final CountDownLatch startLatch = new CountDownLatch(1);
- new Thread(new Runnable() {
-
- @Override
- public void run() {
- Looper.prepare();
- ThreadUtils.setUiThread(Looper.myLooper());
- startLatch.countDown();
- Looper.loop();
- }
-
- }).start();
-
- try {
- startLatch.await();
- } catch (InterruptedException e) {
- Log.e(TAG, "Failed to set UI Thread");
- }
- }
-}