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

Side by Side Diff: chrome/android/javatests/src/org/chromium/chrome/browser/media/RouterTestUtils.java

Issue 1844793004: [MediaRouter, Android] Don't ignore device selection dialog failures in MediaRouter integration tes… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: undo remove comments Created 4 years, 8 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
« no previous file with comments | « no previous file | chrome/android/javatests/src/org/chromium/chrome/browser/media/router/MediaRouterIntegrationTest.java » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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.chrome.browser.media; 5 package org.chromium.chrome.browser.media;
6 6
7 import android.app.Dialog; 7 import android.app.Dialog;
8 import android.app.Instrumentation; 8 import android.app.Instrumentation;
9 import android.os.SystemClock; 9 import android.os.SystemClock;
10 import android.support.v4.app.DialogFragment; 10 import android.support.v4.app.DialogFragment;
(...skipping 19 matching lines...) Expand all
30 private static final String TAG = "RouterTestUtils"; 30 private static final String TAG = "RouterTestUtils";
31 31
32 public static View waitForRouteButton( 32 public static View waitForRouteButton(
33 final ChromeActivity activity, final String chromecastName, 33 final ChromeActivity activity, final String chromecastName,
34 int maxTimeoutMs, int intervalMs) { 34 int maxTimeoutMs, int intervalMs) {
35 return waitForView(new Callable<View>() { 35 return waitForView(new Callable<View>() {
36 @Override 36 @Override
37 public View call() { 37 public View call() {
38 Dialog mediaRouteListDialog = getDialog(activity); 38 Dialog mediaRouteListDialog = getDialog(activity);
39 if (mediaRouteListDialog == null) { 39 if (mediaRouteListDialog == null) {
40 Log.w(TAG, "Cannot find choose device dialog"); 40 Log.w(TAG, "Cannot find device selection dialog");
41 return null; 41 return null;
42 } 42 }
43 View mediaRouteList = 43 View mediaRouteList =
44 mediaRouteListDialog.findViewById(R.id.mr_chooser_li st); 44 mediaRouteListDialog.findViewById(R.id.mr_chooser_li st);
45 if (mediaRouteList == null) { 45 if (mediaRouteList == null) {
46 Log.w(TAG, "Cannot find device list"); 46 Log.w(TAG, "Cannot find device list");
47 return null; 47 return null;
48 } 48 }
49 ArrayList<View> routesWanted = new ArrayList<View>(); 49 ArrayList<View> routesWanted = new ArrayList<View>();
50 mediaRouteList.findViewsWithText(routesWanted, chromecastNam e, 50 mediaRouteList.findViewsWithText(routesWanted, chromecastNam e,
51 View.FIND_VIEWS_WITH_TEXT); 51 View.FIND_VIEWS_WITH_TEXT);
52 if (routesWanted.size() == 0) { 52 if (routesWanted.size() == 0) {
53 Log.w(TAG, "Cannot find wanted device"); 53 Log.w(TAG, "Cannot find wanted device");
54 return null; 54 return null;
55 } 55 }
56 56 Log.i(TAG, "Found wanted device");
57 return routesWanted.get(0); 57 return routesWanted.get(0);
58 } 58 }
59 }, maxTimeoutMs, intervalMs); 59 }, maxTimeoutMs, intervalMs);
60 } 60 }
61 61
62 public static Dialog waitForDialog( 62 public static Dialog waitForDialog(
63 final ChromeActivity activity, 63 final ChromeActivity activity,
64 int maxTimeoutMs, int intervalMs) { 64 int maxTimeoutMs, int intervalMs) {
65 try { 65 try {
66 CriteriaHelper.pollUiThread(new Criteria() { 66 CriteriaHelper.pollUiThread(new Criteria() {
67 @Override 67 @Override
68 public boolean isSatisfied() { 68 public boolean isSatisfied() {
69 try { 69 try {
70 return getDialog(activity) != null; 70 if (getDialog(activity) != null) {
71 Log.i(TAG, "Found device selection dialog");
72 return true;
73 } else {
74 Log.w(TAG, "Cannot find device selection dialog" );
75 return false;
76 }
71 } catch (Exception e) { 77 } catch (Exception e) {
72 return false; 78 return false;
73 } 79 }
74 } 80 }
75 }, maxTimeoutMs, intervalMs); 81 }, maxTimeoutMs, intervalMs);
76 return getDialog(activity); 82 return getDialog(activity);
77 } catch (Exception e) { 83 } catch (Exception e) {
78 return null; 84 return null;
79 } 85 }
80 } 86 }
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 * 188 *
183 * @param instrumentation Instrumentation object used by the test. 189 * @param instrumentation Instrumentation object used by the test.
184 * @param v The view the coordinates are relative to. 190 * @param v The view the coordinates are relative to.
185 */ 191 */
186 public static void mouseSingleClickView(Instrumentation instrumentation, Vie w v) { 192 public static void mouseSingleClickView(Instrumentation instrumentation, Vie w v) {
187 int x = v.getWidth() / 2; 193 int x = v.getWidth() / 2;
188 int y = v.getHeight() / 2; 194 int y = v.getHeight() / 2;
189 mouseSingleClickView(instrumentation, v, x, y); 195 mouseSingleClickView(instrumentation, v, x, y);
190 } 196 }
191 } 197 }
OLDNEW
« no previous file with comments | « no previous file | chrome/android/javatests/src/org/chromium/chrome/browser/media/router/MediaRouterIntegrationTest.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698