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

Side by Side Diff: chrome/browser/ui/bluetooth/bluetooth_chooser_controller_unittest.cc

Issue 2351083003: Update BluetoothChooserControllerTest to test IsConnected() and IsPaired() (Closed)
Patch Set: address comments 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
« no previous file with comments | « no previous file | no next file » | 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 #include <string> 5 #include <string>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "chrome/browser/ui/bluetooth/bluetooth_chooser_controller.h" 10 #include "chrome/browser/ui/bluetooth/bluetooth_chooser_controller.h"
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 TEST_F(BluetoothChooserControllerTest, AddDevice) { 81 TEST_F(BluetoothChooserControllerTest, AddDevice) {
82 EXPECT_CALL(mock_bluetooth_chooser_view_, OnOptionAdded(0)).Times(1); 82 EXPECT_CALL(mock_bluetooth_chooser_view_, OnOptionAdded(0)).Times(1);
83 bluetooth_chooser_controller_.AddOrUpdateDevice( 83 bluetooth_chooser_controller_.AddOrUpdateDevice(
84 "id_a", false /* should_update_name */, base::ASCIIToUTF16("a"), 84 "id_a", false /* should_update_name */, base::ASCIIToUTF16("a"),
85 true /* is_gatt_connected */, true /* is_paired */, 85 true /* is_gatt_connected */, true /* is_paired */,
86 -1 /* signal_strength_level */); 86 -1 /* signal_strength_level */);
87 EXPECT_EQ(1u, bluetooth_chooser_controller_.NumOptions()); 87 EXPECT_EQ(1u, bluetooth_chooser_controller_.NumOptions());
88 EXPECT_EQ(base::ASCIIToUTF16("a"), 88 EXPECT_EQ(base::ASCIIToUTF16("a"),
89 bluetooth_chooser_controller_.GetOption(0)); 89 bluetooth_chooser_controller_.GetOption(0));
90 EXPECT_EQ(-1, bluetooth_chooser_controller_.GetSignalStrengthLevel(0)); 90 EXPECT_EQ(-1, bluetooth_chooser_controller_.GetSignalStrengthLevel(0));
91 EXPECT_TRUE(bluetooth_chooser_controller_.IsConnected(0));
92 EXPECT_TRUE(bluetooth_chooser_controller_.IsPaired(0));
91 testing::Mock::VerifyAndClearExpectations(&mock_bluetooth_chooser_view_); 93 testing::Mock::VerifyAndClearExpectations(&mock_bluetooth_chooser_view_);
92 94
93 EXPECT_CALL(mock_bluetooth_chooser_view_, OnOptionAdded(1)).Times(1); 95 EXPECT_CALL(mock_bluetooth_chooser_view_, OnOptionAdded(1)).Times(1);
94 bluetooth_chooser_controller_.AddOrUpdateDevice( 96 bluetooth_chooser_controller_.AddOrUpdateDevice(
95 "id_b", false /* should_update_name */, base::ASCIIToUTF16("b"), 97 "id_b", false /* should_update_name */, base::ASCIIToUTF16("b"),
96 true /* is_gatt_connected */, true /* is_paired */, 98 true /* is_gatt_connected */, true /* is_paired */,
97 0 /* signal_strength_level */); 99 0 /* signal_strength_level */);
98 EXPECT_EQ(2u, bluetooth_chooser_controller_.NumOptions()); 100 EXPECT_EQ(2u, bluetooth_chooser_controller_.NumOptions());
99 EXPECT_EQ(base::ASCIIToUTF16("b"), 101 EXPECT_EQ(base::ASCIIToUTF16("b"),
100 bluetooth_chooser_controller_.GetOption(1)); 102 bluetooth_chooser_controller_.GetOption(1));
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 // strength level is -1, and in this case, should still use the previously 238 // strength level is -1, and in this case, should still use the previously
237 // stored signal strength level. So here the signal strength level is 239 // stored signal strength level. So here the signal strength level is
238 // still 1. 240 // still 1.
239 bluetooth_chooser_controller_.AddOrUpdateDevice( 241 bluetooth_chooser_controller_.AddOrUpdateDevice(
240 "id_a", false /* should_update_name */, base::ASCIIToUTF16("a"), 242 "id_a", false /* should_update_name */, base::ASCIIToUTF16("a"),
241 true /* is_gatt_connected */, true /* is_paired */, 243 true /* is_gatt_connected */, true /* is_paired */,
242 -1 /* signal_strength_level */); 244 -1 /* signal_strength_level */);
243 EXPECT_EQ(1, bluetooth_chooser_controller_.GetSignalStrengthLevel(0)); 245 EXPECT_EQ(1, bluetooth_chooser_controller_.GetSignalStrengthLevel(0));
244 } 246 }
245 247
248 TEST_F(BluetoothChooserControllerTest, UpdateConnectedStatus) {
249 bluetooth_chooser_controller_.AddOrUpdateDevice(
250 "id_a", false /* should_update_name */, base::ASCIIToUTF16("a"),
251 false /* is_gatt_connected */, false /* is_paired */,
252 1 /* signal_strength_level */);
253 EXPECT_FALSE(bluetooth_chooser_controller_.IsConnected(0));
254
255 EXPECT_CALL(mock_bluetooth_chooser_view_, OnOptionUpdated(0)).Times(1);
256 bluetooth_chooser_controller_.AddOrUpdateDevice(
257 "id_a", false /* should_update_name */, base::ASCIIToUTF16("a"),
258 true /* is_gatt_connected */, false /* is_paired */,
259 -1 /* signal_strength_level */);
260 EXPECT_TRUE(bluetooth_chooser_controller_.IsConnected(0));
261 }
262
263 TEST_F(BluetoothChooserControllerTest, UpdatePairedStatus) {
264 bluetooth_chooser_controller_.AddOrUpdateDevice(
265 "id_a", false /* should_update_name */, base::ASCIIToUTF16("a"),
266 true /* is_gatt_connected */, false /* is_paired */,
267 -1 /* signal_strength_level */);
268 EXPECT_FALSE(bluetooth_chooser_controller_.IsPaired(0));
269
270 EXPECT_CALL(mock_bluetooth_chooser_view_, OnOptionUpdated(0)).Times(1);
271 bluetooth_chooser_controller_.AddOrUpdateDevice(
272 "id_a", false /* should_update_name */, base::ASCIIToUTF16("a"),
273 true /* is_gatt_connected */, true /* is_paired */,
274 -1 /* signal_strength_level */);
275 EXPECT_TRUE(bluetooth_chooser_controller_.IsPaired(0));
276 }
277
246 TEST_F(BluetoothChooserControllerWithDevicesAddedTest, 278 TEST_F(BluetoothChooserControllerWithDevicesAddedTest,
247 InitialNoOptionsTextAndStatusText) { 279 InitialNoOptionsTextAndStatusText) {
248 EXPECT_EQ(l10n_util::GetStringUTF16( 280 EXPECT_EQ(l10n_util::GetStringUTF16(
249 IDS_BLUETOOTH_DEVICE_CHOOSER_NO_DEVICES_FOUND_PROMPT), 281 IDS_BLUETOOTH_DEVICE_CHOOSER_NO_DEVICES_FOUND_PROMPT),
250 bluetooth_chooser_controller_.GetNoOptionsText()); 282 bluetooth_chooser_controller_.GetNoOptionsText());
251 EXPECT_EQ(base::string16(), bluetooth_chooser_controller_.GetStatus()); 283 EXPECT_EQ(base::string16(), bluetooth_chooser_controller_.GetStatus());
252 } 284 }
253 285
254 TEST_F(BluetoothChooserControllerWithDevicesAddedTest, 286 TEST_F(BluetoothChooserControllerWithDevicesAddedTest,
255 BluetoothAdapterTurnedOff) { 287 BluetoothAdapterTurnedOff) {
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 EXPECT_EQ(content::BluetoothChooser::Event::CANCELLED, last_event_); 364 EXPECT_EQ(content::BluetoothChooser::Event::CANCELLED, last_event_);
333 EXPECT_EQ(std::string(), last_device_id_); 365 EXPECT_EQ(std::string(), last_device_id_);
334 } 366 }
335 367
336 TEST_F(BluetoothChooserControllerWithDevicesAddedTest, 368 TEST_F(BluetoothChooserControllerWithDevicesAddedTest,
337 CloseShouldCallEventHandler) { 369 CloseShouldCallEventHandler) {
338 bluetooth_chooser_controller_.Close(); 370 bluetooth_chooser_controller_.Close();
339 EXPECT_EQ(content::BluetoothChooser::Event::CANCELLED, last_event_); 371 EXPECT_EQ(content::BluetoothChooser::Event::CANCELLED, last_event_);
340 EXPECT_EQ(std::string(), last_device_id_); 372 EXPECT_EQ(std::string(), last_device_id_);
341 } 373 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698