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

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

Issue 1739523002: WebUsb Android chooser UI (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase and added NoUnderlineClickableSpan.java to ui/android/BUILD.gn 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
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; 5 package org.chromium.chrome.browser;
6 6
7 import android.Manifest; 7 import android.Manifest;
8 import android.app.Dialog; 8 import android.app.Dialog;
9 import android.content.pm.PackageManager; 9 import android.content.pm.PackageManager;
10 import android.test.MoreAsserts; 10 import android.test.MoreAsserts;
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 133
134 CriteriaHelper.pollUiThread(new Criteria() { 134 CriteriaHelper.pollUiThread(new Criteria() {
135 @Override 135 @Override
136 public boolean isSatisfied() { 136 public boolean isSatisfied() {
137 return chooserDialog.mFinishedEventType != -1; 137 return chooserDialog.mFinishedEventType != -1;
138 } 138 }
139 }); 139 });
140 } 140 }
141 141
142 /** 142 /**
143 * The messages include <link> ... </link> sections that are used to create 143 * The messages include <link> ... </link> or <link1> ... </link1>, <link2> ... </link2>
144 * clickable spans. For testing the messages, this function returns the raw 144 * sections that are used to create clickable spans. For testing the message s, this function
145 * string without the tags. 145 * returns the raw string without the tags.
146 */ 146 */
147 private static String removeLinkTags(String message) { 147 private static String removeLinkTags(String message) {
148 return message.replaceAll("</?link>", ""); 148 return message.replaceAll("</?link1>", "").replaceAll(
149 "</?link2>", "").replaceAll("</?link>", "");
149 } 150 }
150 151
151 @SmallTest 152 @SmallTest
152 public void testCancel() throws InterruptedException { 153 public void testCancel() throws InterruptedException {
153 ItemChooserDialog itemChooser = mChooserDialog.mItemChooserDialog; 154 ItemChooserDialog itemChooser = mChooserDialog.mItemChooserDialog;
154 Dialog dialog = itemChooser.getDialogForTesting(); 155 Dialog dialog = itemChooser.getDialogForTesting();
155 assertTrue(dialog.isShowing()); 156 assertTrue(dialog.isShowing());
156 157
157 TextViewWithClickableSpans statusView = 158 TextViewWithClickableSpans statusView =
158 (TextViewWithClickableSpans) dialog.findViewById(R.id.status); 159 (TextViewWithClickableSpans) dialog.findViewById(R.id.status);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 public void run() { 196 public void run() {
196 mChooserDialog.addDevice("id-1", "Name 1"); 197 mChooserDialog.addDevice("id-1", "Name 1");
197 mChooserDialog.addDevice("id-2", "Name 2"); 198 mChooserDialog.addDevice("id-2", "Name 2");
198 } 199 }
199 }); 200 });
200 201
201 // After adding items to the dialog, the help message should be showing, 202 // After adding items to the dialog, the help message should be showing,
202 // the progress spinner should disappear, the Commit button should still 203 // the progress spinner should disappear, the Commit button should still
203 // be disabled (since nothing's selected), and the list view should 204 // be disabled (since nothing's selected), and the list view should
204 // show. 205 // show.
205 assertEquals(removeLinkTags(getActivity().getString(R.string.bluetooth_n ot_seeing_it)), 206 assertEquals(removeLinkTags(getActivity().getString(
207 R.string.bluetooth_not_seeing_it_idle_some_found)),
206 statusView.getText().toString()); 208 statusView.getText().toString());
207 assertFalse(button.isEnabled()); 209 assertFalse(button.isEnabled());
208 assertEquals(View.VISIBLE, items.getVisibility()); 210 assertEquals(View.VISIBLE, items.getVisibility());
209 assertEquals(View.GONE, progress.getVisibility()); 211 assertEquals(View.GONE, progress.getVisibility());
210 212
211 selectItem(mChooserDialog, 2); 213 selectItem(mChooserDialog, 2);
212 214
213 assertEquals( 215 assertEquals(
214 BluetoothChooserDialog.DIALOG_FINISHED_SELECTED, mChooserDialog. mFinishedEventType); 216 BluetoothChooserDialog.DIALOG_FINISHED_SELECTED, mChooserDialog. mFinishedEventType);
215 assertEquals("id-2", mChooserDialog.mFinishedDeviceId); 217 assertEquals("id-2", mChooserDialog.mFinishedDeviceId);
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 @Override 304 @Override
303 public void requestPermissions(String[] permissions, PermissionCallback callback) { 305 public void requestPermissions(String[] permissions, PermissionCallback callback) {
304 mPermissionsRequested = permissions; 306 mPermissionsRequested = permissions;
305 if (permissions.length == 1 307 if (permissions.length == 1
306 && permissions[0].equals(Manifest.permission.ACCESS_COARSE_L OCATION)) { 308 && permissions[0].equals(Manifest.permission.ACCESS_COARSE_L OCATION)) {
307 mCallback = callback; 309 mCallback = callback;
308 } 310 }
309 } 311 }
310 } 312 }
311 } 313 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698