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

Unified Diff: android_webview/javatests/src/org/chromium/android_webview/test/AndroidWebViewTestRunnerActivity.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/AndroidWebViewTestRunnerActivity.java
diff --git a/android_webview/javatests/src/org/chromium/android_webview/test/AndroidWebViewTestRunnerActivity.java b/android_webview/javatests/src/org/chromium/android_webview/test/AndroidWebViewTestRunnerActivity.java
new file mode 100644
index 0000000000000000000000000000000000000000..4d78a6a8b781c0a2fa9aa9e05ab3b3a4ea1415ac
--- /dev/null
+++ b/android_webview/javatests/src/org/chromium/android_webview/test/AndroidWebViewTestRunnerActivity.java
@@ -0,0 +1,94 @@
+// 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.app.Activity;
+import android.content.ContentUris;
+import android.content.res.Configuration;
+import android.os.Bundle;
+import android.util.Log;
+import android.view.ViewGroup.LayoutParams;
+import android.view.WindowManager;
+import android.widget.LinearLayout;
+
+import org.chromium.content.browser.ContentView;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+/*
+ * This is a lightweight activity for tests that only require ContentView functionality.
+ */
+public class AndroidWebViewTestRunnerActivity extends Activity {
+
+ private LinearLayout mLinearLayout;
+ private List<ContentView> mContentViews = new ArrayList<ContentView>();
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ // TODO(joth): When SW-renderer is available, we'll want to enable this on a per-test
+ // basis.
+ // BUG=http://b/5996811
+ boolean hardwareAccelerated = true;
+ Log.i("AndroidWebViewTestRunnerActivity", "Is " + (hardwareAccelerated ? "" : "NOT ")
+ + "hardware accelerated");
+
+ if (hardwareAccelerated) {
+ getWindow().setFlags(
+ WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED,
+ WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED);
+ }
+
+ mLinearLayout = new LinearLayout(this);
+ mLinearLayout.setOrientation(LinearLayout.VERTICAL);
+ mLinearLayout.setShowDividers(LinearLayout.SHOW_DIVIDER_MIDDLE);
+ mLinearLayout.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,
+ LayoutParams.WRAP_CONTENT));
+
+ setContentView(mLinearLayout);
+ }
+
+ /**
+ * Set the ContentViews to be added to the current LinearLayout.
+ *
+ * This will destroy the ContentView instances that are being removed from the LinearLayout, so
+ * care must be taken to not reference those instances.
+ */
+ public void setContentViewList(Collection<ContentView> contentViews) {
+ mLinearLayout.removeAllViews();
+
+ Set<ContentView> toBeDeleted = new HashSet<ContentView>(mContentViews);
+ toBeDeleted.removeAll(contentViews);
+ for (ContentView c : toBeDeleted) {
+ c.destroy();
+ }
+
+ for (ContentView c : contentViews) {
+ c.setLayoutParams(new LinearLayout.LayoutParams(
+ LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 1f));
+ mLinearLayout.addView(c);
+ }
+ mContentViews.clear();
+ mContentViews.addAll(contentViews);
+ }
+
+ public void setContentViews(ContentView... contentViews) {
+ setContentViewList(Arrays.asList(contentViews));
+ }
+
+ public int getNumberOfContentViews() {
+ return mContentViews.size();
+ }
+
+ public ContentView getContentView() {
+ return mContentViews.get(0);
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698