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

Side by Side Diff: content/public/test/android/javatests/src/org/chromium/content/browser/test/util/UiUtils.java

Issue 12717011: [Android] Remove unused function. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « build/android/findbugs_filter/findbugs_known_bugs.txt ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.content.browser.test.util; 5 package org.chromium.content.browser.test.util;
6 6
7 import android.app.Activity; 7 import android.app.Activity;
8 import android.app.Instrumentation; 8 import android.app.Instrumentation;
9 import android.view.View;
10 9
11 import java.lang.reflect.Field; 10 import junit.framework.Assert;
11
12 import java.util.concurrent.Semaphore; 12 import java.util.concurrent.Semaphore;
13 import java.util.concurrent.TimeUnit; 13 import java.util.concurrent.TimeUnit;
14 14
15 import junit.framework.Assert;
16
17 /** 15 /**
18 * Collection of UI utilities. 16 * Collection of UI utilities.
19 */ 17 */
20 public class UiUtils { 18 public class UiUtils {
21 private static final int WAIT_FOR_RESPONSE_MS = 10000; // timeout to wait f or runOnUiThread() 19 private static final int WAIT_FOR_RESPONSE_MS = 10000; // timeout to wait f or runOnUiThread()
22 20
23 /** 21 /**
24 * Runs the runnable on the UI thread. 22 * Runs the runnable on the UI thread.
25 * 23 *
26 * @param activity The activity on which the runnable must run. 24 * @param activity The activity on which the runnable must run.
(...skipping 19 matching lines...) Expand all
46 * Waits for the UI thread to settle down. 44 * Waits for the UI thread to settle down.
47 * <p> 45 * <p>
48 * Waits for an extra period of time after the UI loop is idle. 46 * Waits for an extra period of time after the UI loop is idle.
49 * 47 *
50 * @param instrumentation Instrumentation object used by the test. 48 * @param instrumentation Instrumentation object used by the test.
51 */ 49 */
52 public static void settleDownUI(Instrumentation instrumentation) throws Inte rruptedException { 50 public static void settleDownUI(Instrumentation instrumentation) throws Inte rruptedException {
53 instrumentation.waitForIdleSync(); 51 instrumentation.waitForIdleSync();
54 Thread.sleep(1000); 52 Thread.sleep(1000);
55 } 53 }
56
57 /**
58 * Find the parent View for the Id across all activities, as dialogs
59 * will be displayed in a separate activity. Note that in the case
60 * of several views sharing the same ID across activities, this will
61 * return the first view found.
62 *
63 * @param viewId The Id of the view.
64 * @return the view which contains the given id or null if no view with the given id exists.
65 */
66 public static View findParentViewForIdAcrossActivities(int viewId) {
67 View[] availableViews = null;
68 try {
69 Class<?> windowManager = Class.forName("android.view.WindowManagerIm pl");
70
71 Field viewsField = windowManager.getDeclaredField("mViews");
72 Field instanceField = windowManager.getDeclaredField("sWindowManager ");
73 viewsField.setAccessible(true);
74 instanceField.setAccessible(true);
75 Object instance = instanceField.get(null);
76 availableViews = (View[]) viewsField.get(instance);
77 } catch(Exception e) {
78 Assert.fail("Could not fetch the available views.");
79 }
80
81 if (availableViews == null || availableViews.length == 0) {
82 return null;
83 }
84
85 for (View view : availableViews) {
86 if (view.findViewById(viewId) != null) {
87 return view;
88 }
89 }
90
91 return null;
92 }
93 } 54 }
OLDNEW
« no previous file with comments | « build/android/findbugs_filter/findbugs_known_bugs.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698