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

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

Issue 2271413002: bluetooth: Implement RSSI indicator on android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bluetooth-impl-rssi-tx-power
Patch Set: Clean up Created 4 years, 3 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 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 207
208 TextViewWithClickableSpans statusView = 208 TextViewWithClickableSpans statusView =
209 (TextViewWithClickableSpans) dialog.findViewById(R.id.status); 209 (TextViewWithClickableSpans) dialog.findViewById(R.id.status);
210 final View items = dialog.findViewById(R.id.items); 210 final View items = dialog.findViewById(R.id.items);
211 final Button button = (Button) dialog.findViewById(R.id.positive); 211 final Button button = (Button) dialog.findViewById(R.id.positive);
212 final View progress = dialog.findViewById(R.id.progress); 212 final View progress = dialog.findViewById(R.id.progress);
213 213
214 ThreadUtils.runOnUiThreadBlocking(new Runnable() { 214 ThreadUtils.runOnUiThreadBlocking(new Runnable() {
215 @Override 215 @Override
216 public void run() { 216 public void run() {
217 mChooserDialog.addOrUpdateDevice("id-1", "Name 1"); 217 mChooserDialog.addOrUpdateDevice(
218 mChooserDialog.addOrUpdateDevice("id-2", "Name 2"); 218 "id-1", "Name 1", -1 /* No Signal Strength Level */);
219 mChooserDialog.addOrUpdateDevice(
220 "id-2", "Name 2", 1 /* Signal Strength Level: 1 */);
221 mChooserDialog.addOrUpdateDevice(
222 "id-3", "Name 3", 2 /* Signal Strength Level: 2 */);
219 } 223 }
220 }); 224 });
221 225
222 // After adding items to the dialog, the help message should be showing, 226 // After adding items to the dialog, the help message should be showing,
223 // the progress spinner should disappear, the Commit button should still 227 // the progress spinner should disappear, the Commit button should still
224 // be disabled (since nothing's selected), and the list view should 228 // be disabled (since nothing's selected), and the list view should
225 // show. 229 // show.
226 assertEquals(removeLinkTags(getActivity().getString(R.string.bluetooth_n ot_seeing_it)), 230 assertEquals(removeLinkTags(getActivity().getString(R.string.bluetooth_n ot_seeing_it)),
227 statusView.getText().toString()); 231 statusView.getText().toString());
228 assertFalse(button.isEnabled()); 232 assertFalse(button.isEnabled());
229 assertEquals(View.VISIBLE, items.getVisibility()); 233 assertEquals(View.VISIBLE, items.getVisibility());
230 assertEquals(View.GONE, progress.getVisibility()); 234 assertEquals(View.GONE, progress.getVisibility());
231 235
236 ItemChooserDialog.ItemAdapter itemAdapter =
237 mChooserDialog.mItemChooserDialog.getItemAdapterForTesting();
238
239 ItemChooserDialog.ItemChooserRow expectedItem1 =
240 new ItemChooserDialog.ItemChooserRow("id-1", "Name 1", null);
241 assertEquals(itemAdapter.getItem(0), expectedItem1);
242
243 ItemChooserDialog.ItemChooserRowIcon expectedIcon2 =
244 new ItemChooserDialog.ItemChooserRowIcon(
245 R.drawable.ic_signal_cellular_1_bar_grey600_24dp,
246 R.drawable.ic_signal_cellular_1_bar_white_24dp,
247 "Signal Strength Level: 1 bar");
248 ItemChooserDialog.ItemChooserRow expectedItem2 =
249 new ItemChooserDialog.ItemChooserRow("id-2", "Name 2", expectedI con2);
250 assertEquals(itemAdapter.getItem(1), expectedItem2);
251
252 ItemChooserDialog.ItemChooserRowIcon expectedIcon3 =
253 new ItemChooserDialog.ItemChooserRowIcon(
254 R.drawable.ic_signal_cellular_2_bar_grey600_24dp,
255 R.drawable.ic_signal_cellular_2_bar_white_24dp,
256 "Signal Strength Level: 2 bars");
257 ItemChooserDialog.ItemChooserRow expectedItem3 =
258 new ItemChooserDialog.ItemChooserRow("id-3", "Name 3", expectedI con3);
259 assertEquals(itemAdapter.getItem(2), expectedItem3);
260
232 selectItem(mChooserDialog, 2); 261 selectItem(mChooserDialog, 2);
233 262
234 assertEquals( 263 assertEquals(
235 BluetoothChooserDialog.DIALOG_FINISHED_SELECTED, mChooserDialog. mFinishedEventType); 264 BluetoothChooserDialog.DIALOG_FINISHED_SELECTED, mChooserDialog. mFinishedEventType);
236 assertEquals("id-2", mChooserDialog.mFinishedDeviceId); 265 assertEquals("id-2", mChooserDialog.mFinishedDeviceId);
237 } 266 }
238 267
239 @SmallTest 268 @SmallTest
240 public void testNoLocationPermission() throws InterruptedException { 269 public void testNoLocationPermission() throws InterruptedException {
241 ItemChooserDialog itemChooser = mChooserDialog.mItemChooserDialog; 270 ItemChooserDialog itemChooser = mChooserDialog.mItemChooserDialog;
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 } 426 }
398 427
399 public boolean mSystemLocationSettingsEnabled = true; 428 public boolean mSystemLocationSettingsEnabled = true;
400 429
401 @Override 430 @Override
402 public boolean isSystemLocationSettingEnabled() { 431 public boolean isSystemLocationSettingEnabled() {
403 return mSystemLocationSettingsEnabled; 432 return mSystemLocationSettingsEnabled;
404 } 433 }
405 } 434 }
406 } 435 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698