OLD | NEW |
---|---|
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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
141 | 141 |
142 /** | 142 /** |
143 * The messages include <link> ... </link> sections that are used to create | 143 * The messages include <link> ... </link> sections that are used to create |
144 * clickable spans. For testing the messages, this function returns the raw | 144 * clickable spans. For testing the messages, this function returns the raw |
145 * string without the tags. | 145 * 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("</?link>", ""); |
149 } | 149 } |
150 | 150 |
151 /** | |
152 * The messages include <link1> ... </link1>, <link2> ... </link2> sections | |
153 * that are used to create clickable spans. For testing the messages, this | |
154 * function returns the raw string without the tags. | |
155 */ | |
156 private static String removeMultipleLinkTags(String message) { | |
newt (away)
2016/03/17 01:53:20
Why not combine this into the method above?
juncai
2016/03/17 18:21:35
Done.
| |
157 return message.replaceAll("</?link1>", "").replaceAll("</?link2>", ""); | |
158 } | |
159 | |
151 @SmallTest | 160 @SmallTest |
152 public void testCancel() throws InterruptedException { | 161 public void testCancel() throws InterruptedException { |
153 ItemChooserDialog itemChooser = mChooserDialog.mItemChooserDialog; | 162 ItemChooserDialog itemChooser = mChooserDialog.mItemChooserDialog; |
154 Dialog dialog = itemChooser.getDialogForTesting(); | 163 Dialog dialog = itemChooser.getDialogForTesting(); |
155 assertTrue(dialog.isShowing()); | 164 assertTrue(dialog.isShowing()); |
156 | 165 |
157 TextViewWithClickableSpans statusView = | 166 TextViewWithClickableSpans statusView = |
158 (TextViewWithClickableSpans) dialog.findViewById(R.id.status); | 167 (TextViewWithClickableSpans) dialog.findViewById(R.id.status); |
159 final ListView items = (ListView) dialog.findViewById(R.id.items); | 168 final ListView items = (ListView) dialog.findViewById(R.id.items); |
160 final Button button = (Button) dialog.findViewById(R.id.positive); | 169 final Button button = (Button) dialog.findViewById(R.id.positive); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
195 public void run() { | 204 public void run() { |
196 mChooserDialog.addDevice("id-1", "Name 1"); | 205 mChooserDialog.addDevice("id-1", "Name 1"); |
197 mChooserDialog.addDevice("id-2", "Name 2"); | 206 mChooserDialog.addDevice("id-2", "Name 2"); |
198 } | 207 } |
199 }); | 208 }); |
200 | 209 |
201 // After adding items to the dialog, the help message should be showing, | 210 // After adding items to the dialog, the help message should be showing, |
202 // the progress spinner should disappear, the Commit button should still | 211 // the progress spinner should disappear, the Commit button should still |
203 // be disabled (since nothing's selected), and the list view should | 212 // be disabled (since nothing's selected), and the list view should |
204 // show. | 213 // show. |
205 assertEquals(removeLinkTags(getActivity().getString(R.string.bluetooth_n ot_seeing_it)), | 214 assertEquals(removeMultipleLinkTags(getActivity().getString( |
215 R.string.bluetooth_not_seeing_it_idle_some_found)), | |
206 statusView.getText().toString()); | 216 statusView.getText().toString()); |
207 assertFalse(button.isEnabled()); | 217 assertFalse(button.isEnabled()); |
208 assertEquals(View.VISIBLE, items.getVisibility()); | 218 assertEquals(View.VISIBLE, items.getVisibility()); |
209 assertEquals(View.GONE, progress.getVisibility()); | 219 assertEquals(View.GONE, progress.getVisibility()); |
210 | 220 |
211 selectItem(mChooserDialog, 2); | 221 selectItem(mChooserDialog, 2); |
212 | 222 |
213 assertEquals( | 223 assertEquals( |
214 BluetoothChooserDialog.DIALOG_FINISHED_SELECTED, mChooserDialog. mFinishedEventType); | 224 BluetoothChooserDialog.DIALOG_FINISHED_SELECTED, mChooserDialog. mFinishedEventType); |
215 assertEquals("id-2", mChooserDialog.mFinishedDeviceId); | 225 assertEquals("id-2", mChooserDialog.mFinishedDeviceId); |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
302 @Override | 312 @Override |
303 public void requestPermissions(String[] permissions, PermissionCallback callback) { | 313 public void requestPermissions(String[] permissions, PermissionCallback callback) { |
304 mPermissionsRequested = permissions; | 314 mPermissionsRequested = permissions; |
305 if (permissions.length == 1 | 315 if (permissions.length == 1 |
306 && permissions[0].equals(Manifest.permission.ACCESS_COARSE_L OCATION)) { | 316 && permissions[0].equals(Manifest.permission.ACCESS_COARSE_L OCATION)) { |
307 mCallback = callback; | 317 mCallback = callback; |
308 } | 318 } |
309 } | 319 } |
310 } | 320 } |
311 } | 321 } |
OLD | NEW |