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

Unified Diff: blimp/client/app/android/javatests/src/org/chromium/blimp/BlimpNativeInstrumentationTestCase.java

Issue 2059443002: Java versions of BlimpContents[,Observer] and BlimpNavigationController (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@chrome-with-blimp
Patch Set: fixed gn order thing and fixed java visibility Created 4 years, 6 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: blimp/client/app/android/javatests/src/org/chromium/blimp/BlimpNativeInstrumentationTestCase.java
diff --git a/blimp/client/app/android/javatests/src/org/chromium/blimp/BlimpNativeInstrumentationTestCase.java b/blimp/client/app/android/javatests/src/org/chromium/blimp/BlimpNativeInstrumentationTestCase.java
new file mode 100644
index 0000000000000000000000000000000000000000..072313e41120577b74de244a0ea0cbccbf79ec0b
--- /dev/null
+++ b/blimp/client/app/android/javatests/src/org/chromium/blimp/BlimpNativeInstrumentationTestCase.java
@@ -0,0 +1,35 @@
+// Copyright 2016 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.blimp;
+
+import android.test.InstrumentationTestCase;
+
+import org.chromium.base.library_loader.ProcessInitException;
+
+import java.util.concurrent.Semaphore;
+
+/**
+ * Base class for loading native library in tests. The setUp() methods must be invoked, and
+ * subclasses can call {@link #waitUntilNativeIsReady()} in the start of each test-method.
+ */
+public class BlimpNativeInstrumentationTestCase extends InstrumentationTestCase {
+ private final Semaphore mNativeReadySemaphore = new Semaphore(0);
+ private boolean mSuccess = false;
+
+ public void setUp() throws ProcessInitException {
David Trainor- moved to gerrit 2016/06/20 17:24:22 is this @Override?
nyquist 2016/06/21 20:27:20 Why, yes it is, good sir.
+ BlimpLibraryLoader.startAsync(
+ getInstrumentation().getTargetContext(), new BlimpLibraryLoader.Callback() {
+ public void onStartupComplete(boolean success) {
+ mSuccess = success;
+ mNativeReadySemaphore.release();
+ }
+ });
+ }
+
+ protected final void waitUntilNativeIsReady() throws InterruptedException {
David Trainor- moved to gerrit 2016/06/20 17:24:22 javadoc
nyquist 2016/06/21 20:27:20 Done.
+ mNativeReadySemaphore.acquire();
+ if (!mSuccess) throw new RuntimeException("Native startup failed");
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698