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

Unified Diff: android_webview/javatests/src/org/chromium/android_webview/test/AwContentsTest.java

Issue 10855171: Add a test runner for android_webview. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address feedback Created 8 years, 4 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: android_webview/javatests/src/org/chromium/android_webview/test/AwContentsTest.java
diff --git a/android_webview/javatests/src/org/chromium/android_webview/test/AwContentsTest.java b/android_webview/javatests/src/org/chromium/android_webview/test/AwContentsTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..ff88c3b7ae3be4fe6640abcb5f059e4742701a34
--- /dev/null
+++ b/android_webview/javatests/src/org/chromium/android_webview/test/AwContentsTest.java
@@ -0,0 +1,64 @@
+// Copyright (c) 2012 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.android_webview.test;
+
+import android.content.Context;
+import android.os.Handler;
+import android.os.Looper;
+import android.test.suitebuilder.annotation.SmallTest;
+import android.view.View;
+import android.widget.GridLayout;
+
+import org.chromium.android_webview.AndroidWebViewUtil;
+import org.chromium.android_webview.AwContents;
+import org.chromium.android_webview.AwWebContentsDelegate;
+import org.chromium.base.test.Feature;
+import org.chromium.content.browser.ContentViewCore;
+
+import java.util.concurrent.Semaphore;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * AwContents tests.
+ */
+public class AwContentsTest extends AndroidWebViewTestBase {
+ private AwWebContentsDelegate mAwWebContentsDelegate =
+ new AwWebContentsDelegate();
+
+ private AwContents createContents(Context context) {
+ GridLayout viewGroup = new GridLayout(context);
+
+ ContentViewCore contentViewCore = new ContentViewCore(
+ context, viewGroup, null, 0, ContentViewCore.PERSONALITY_VIEW);
+ AwContents awContents = new AwContents(viewGroup, null, contentViewCore,
+ mAwWebContentsDelegate, false, false);
+ return awContents;
+ }
+
+ @SmallTest
+ public void testCreateDestroy() throws Throwable {
+ final Throwable[] error = new Throwable[1];
+ final Semaphore s = new Semaphore(0);
+ final Context context = getActivity();
+
+ Runnable r = new Runnable() {
+ @Override
+ public void run() {
+ try {
+ createContents(context).destroy();
+ } catch (Throwable t) {
+ error[0] = t;
+ } finally {
+ s.release();
+ }
+ }
+ };
+ new Handler(Looper.getMainLooper()).post(r);
+ assertTrue(s.tryAcquire(10000, TimeUnit.MILLISECONDS));
+ if (error[0] != null) {
+ throw error[0];
+ }
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698