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

Unified Diff: chrome/browser/ui/bluetooth/bluetooth_chooser_controller_unittest.cc

Issue 2351083003: Update BluetoothChooserControllerTest to test IsConnected() and IsPaired() (Closed)
Patch Set: updated BluetoothChooserControllerTest to test IsConnected() and IsPaired() 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/bluetooth/bluetooth_chooser_controller_unittest.cc
diff --git a/chrome/browser/ui/bluetooth/bluetooth_chooser_controller_unittest.cc b/chrome/browser/ui/bluetooth/bluetooth_chooser_controller_unittest.cc
index 6f5c7193a27e2e71ae107813a1149cbbe0ab0f07..a6d2dfd3e344f66f33e04d20474a17b7b41f6757 100644
--- a/chrome/browser/ui/bluetooth/bluetooth_chooser_controller_unittest.cc
+++ b/chrome/browser/ui/bluetooth/bluetooth_chooser_controller_unittest.cc
@@ -88,6 +88,8 @@ TEST_F(BluetoothChooserControllerTest, AddDevice) {
EXPECT_EQ(base::ASCIIToUTF16("a"),
bluetooth_chooser_controller_.GetOption(0));
EXPECT_EQ(-1, bluetooth_chooser_controller_.GetSignalStrengthLevel(0));
+ EXPECT_TRUE(bluetooth_chooser_controller_.IsConnected(0));
+ EXPECT_TRUE(bluetooth_chooser_controller_.IsPaired(0));
testing::Mock::VerifyAndClearExpectations(&mock_bluetooth_chooser_view_);
EXPECT_CALL(mock_bluetooth_chooser_view_, OnOptionAdded(1)).Times(1);
@@ -99,6 +101,8 @@ TEST_F(BluetoothChooserControllerTest, AddDevice) {
EXPECT_EQ(base::ASCIIToUTF16("b"),
bluetooth_chooser_controller_.GetOption(1));
EXPECT_EQ(0, bluetooth_chooser_controller_.GetSignalStrengthLevel(1));
+ EXPECT_TRUE(bluetooth_chooser_controller_.IsConnected(1));
Jeffrey Yasskin 2016/09/21 00:39:25 Only the first two EXPECT_TRUE(bluetooth_chooser_c
juncai 2016/09/21 17:43:15 Done.
+ EXPECT_TRUE(bluetooth_chooser_controller_.IsPaired(1));
testing::Mock::VerifyAndClearExpectations(&mock_bluetooth_chooser_view_);
EXPECT_CALL(mock_bluetooth_chooser_view_, OnOptionAdded(2)).Times(1);
@@ -110,6 +114,8 @@ TEST_F(BluetoothChooserControllerTest, AddDevice) {
EXPECT_EQ(base::ASCIIToUTF16("c"),
bluetooth_chooser_controller_.GetOption(2));
EXPECT_EQ(1, bluetooth_chooser_controller_.GetSignalStrengthLevel(2));
+ EXPECT_TRUE(bluetooth_chooser_controller_.IsConnected(2));
+ EXPECT_TRUE(bluetooth_chooser_controller_.IsPaired(2));
}
TEST_F(BluetoothChooserControllerTest, RemoveDevice) {
@@ -243,6 +249,36 @@ TEST_F(BluetoothChooserControllerTest, UpdateDeviceSignalStrengthLevel) {
EXPECT_EQ(1, bluetooth_chooser_controller_.GetSignalStrengthLevel(0));
}
+TEST_F(BluetoothChooserControllerTest, UpdateConnectedStatus) {
+ bluetooth_chooser_controller_.AddOrUpdateDevice(
+ "id_a", false /* should_update_name */, base::ASCIIToUTF16("a"),
+ false /* is_gatt_connected */, false /* is_paired */,
+ 1 /* signal_strength_level */);
+ EXPECT_FALSE(bluetooth_chooser_controller_.IsConnected(0));
+
+ EXPECT_CALL(mock_bluetooth_chooser_view_, OnOptionUpdated(0)).Times(1);
+ bluetooth_chooser_controller_.AddOrUpdateDevice(
+ "id_a", false /* should_update_name */, base::ASCIIToUTF16("a"),
+ true /* is_gatt_connected */, false /* is_paired */,
+ -1 /* signal_strength_level */);
+ EXPECT_TRUE(bluetooth_chooser_controller_.IsConnected(0));
+}
+
+TEST_F(BluetoothChooserControllerTest, UpdatePairedStatus) {
+ bluetooth_chooser_controller_.AddOrUpdateDevice(
+ "id_a", false /* should_update_name */, base::ASCIIToUTF16("a"),
+ true /* is_gatt_connected */, false /* is_paired */,
+ -1 /* signal_strength_level */);
+ EXPECT_FALSE(bluetooth_chooser_controller_.IsPaired(0));
+
+ EXPECT_CALL(mock_bluetooth_chooser_view_, OnOptionUpdated(0)).Times(1);
+ bluetooth_chooser_controller_.AddOrUpdateDevice(
+ "id_a", false /* should_update_name */, base::ASCIIToUTF16("a"),
+ true /* is_gatt_connected */, true /* is_paired */,
+ -1 /* signal_strength_level */);
+ EXPECT_TRUE(bluetooth_chooser_controller_.IsPaired(0));
+}
+
TEST_F(BluetoothChooserControllerWithDevicesAddedTest,
InitialNoOptionsTextAndStatusText) {
EXPECT_EQ(l10n_util::GetStringUTF16(
« 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