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

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

Issue 2821973003: bluetooth: Add RSSI icon for bluetooth choosers. (Closed)
Patch Set: #757575 -> @color/google_grey_600 Created 3 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.Intent; 9 import android.content.Intent;
10 import android.content.pm.PackageManager; 10 import android.content.pm.PackageManager;
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 219
220 TextViewWithClickableSpans statusView = 220 TextViewWithClickableSpans statusView =
221 (TextViewWithClickableSpans) dialog.findViewById(R.id.status); 221 (TextViewWithClickableSpans) dialog.findViewById(R.id.status);
222 final View items = dialog.findViewById(R.id.items); 222 final View items = dialog.findViewById(R.id.items);
223 final Button button = (Button) dialog.findViewById(R.id.positive); 223 final Button button = (Button) dialog.findViewById(R.id.positive);
224 final View progress = dialog.findViewById(R.id.progress); 224 final View progress = dialog.findViewById(R.id.progress);
225 225
226 ThreadUtils.runOnUiThreadBlocking(new Runnable() { 226 ThreadUtils.runOnUiThreadBlocking(new Runnable() {
227 @Override 227 @Override
228 public void run() { 228 public void run() {
229 mChooserDialog.addOrUpdateDevice("id-1", "Name 1", false /* isGA TTConnected */); 229 // Add non-connected device with no signal strength.
230 mChooserDialog.addOrUpdateDevice("id-2", "Name 2", true /* isGAT TConnected */); 230 mChooserDialog.addOrUpdateDevice("id-1", "Name 1", false /* isGA TTConnected */,
231 -1 /* signalStrengthLevel */);
232 // Add connected device with no signal strength.
233 mChooserDialog.addOrUpdateDevice(
234 "id-2", "Name 2", true /* isGATTConnected */, -1 /* sign alStrengthLevel */);
235 // Add non-connected device with signal strength level 1.
236 mChooserDialog.addOrUpdateDevice(
237 "id-3", "Name 3", false /* isGATTConnected */, 1 /* sign alStrengthLevel */);
238 // Add connected device with signal strength level 1.
239 mChooserDialog.addOrUpdateDevice(
240 "id-4", "Name 4", true /* isGATTConnected */, 1 /* signa lStrengthLevel */);
231 } 241 }
232 }); 242 });
233 243
234 // After adding items to the dialog, the help message should be showing, 244 // After adding items to the dialog, the help message should be showing,
235 // the progress spinner should disappear, the Commit button should still 245 // the progress spinner should disappear, the Commit button should still
236 // be disabled (since nothing's selected), and the list view should 246 // be disabled (since nothing's selected), and the list view should
237 // show. 247 // show.
238 assertEquals(removeLinkTags(getActivity().getString(R.string.bluetooth_s earching)), 248 assertEquals(removeLinkTags(getActivity().getString(R.string.bluetooth_s earching)),
239 statusView.getText().toString()); 249 statusView.getText().toString());
240 assertFalse(button.isEnabled()); 250 assertFalse(button.isEnabled());
241 assertEquals(View.VISIBLE, items.getVisibility()); 251 assertEquals(View.VISIBLE, items.getVisibility());
242 assertEquals(View.GONE, progress.getVisibility()); 252 assertEquals(View.GONE, progress.getVisibility());
243 253
244 ItemChooserDialog.ItemAdapter itemAdapter = 254 ItemChooserDialog.ItemAdapter itemAdapter =
245 mChooserDialog.mItemChooserDialog.getItemAdapterForTesting(); 255 mChooserDialog.mItemChooserDialog.getItemAdapterForTesting();
246 assertTrue(itemAdapter.getItem(0).hasSameContents( 256 assertTrue(itemAdapter.getItem(0).hasSameContents(
247 "id-1", "Name 1", null /* icon */, null /* iconDescription */)); 257 "id-1", "Name 1", null /* icon */, null /* iconDescription */));
248 assertTrue(itemAdapter.getItem(1).hasSameContents("id-2", "Name 2", 258 assertTrue(itemAdapter.getItem(1).hasSameContents("id-2", "Name 2",
249 mChooserDialog.mConnectedIcon, mChooserDialog.mConnectedIconDesc ription)); 259 mChooserDialog.mConnectedIcon, mChooserDialog.mConnectedIconDesc ription));
260 assertTrue(itemAdapter.getItem(2).hasSameContents("id-3", "Name 3",
261 mChooserDialog.mSignalStrengthLevelIcon[1],
262 getActivity().getResources().getQuantityString(
263 R.plurals.signal_strength_level_n_bars, 1, 1)));
264 // We show the connected icon even if the device has a signal strength.
265 assertTrue(itemAdapter.getItem(3).hasSameContents("id-4", "Name 4",
266 mChooserDialog.mConnectedIcon, mChooserDialog.mConnectedIconDesc ription));
250 267
251 selectItem(mChooserDialog, 2); 268 selectItem(mChooserDialog, 2);
252 269
253 assertEquals( 270 assertEquals(
254 BluetoothChooserDialog.DIALOG_FINISHED_SELECTED, mChooserDialog. mFinishedEventType); 271 BluetoothChooserDialog.DIALOG_FINISHED_SELECTED, mChooserDialog. mFinishedEventType);
255 assertEquals("id-2", mChooserDialog.mFinishedDeviceId); 272 assertEquals("id-2", mChooserDialog.mFinishedDeviceId);
256 } 273 }
257 274
258 @LargeTest 275 @LargeTest
259 public void testNoLocationPermission() { 276 public void testNoLocationPermission() {
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 } 487 }
471 488
472 public boolean mSystemLocationSettingsEnabled = true; 489 public boolean mSystemLocationSettingsEnabled = true;
473 490
474 @Override 491 @Override
475 public boolean isSystemLocationSettingEnabled() { 492 public boolean isSystemLocationSettingEnabled() {
476 return mSystemLocationSettingsEnabled; 493 return mSystemLocationSettingsEnabled;
477 } 494 }
478 } 495 }
479 } 496 }
OLDNEW
« no previous file with comments | « chrome/android/java/strings/android_chrome_strings.grd ('k') | chrome/browser/ui/android/bluetooth_chooser_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698