OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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.h> | 5 #include <string.h> |
6 | 6 |
7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "chrome/browser/extensions/extension_apitest.h" | 9 #include "chrome/browser/extensions/extension_apitest.h" |
10 #include "chrome/browser/extensions/extension_function_test_utils.h" | 10 #include "chrome/browser/extensions/extension_function_test_utils.h" |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 ResultCatcher catcher; | 148 ResultCatcher catcher; |
149 catcher.RestrictToBrowserContext(browser()->profile()); | 149 catcher.RestrictToBrowserContext(browser()->profile()); |
150 | 150 |
151 ASSERT_TRUE(LoadExtension( | 151 ASSERT_TRUE(LoadExtension( |
152 test_data_dir_.AppendASCII("bluetooth/device_events"))); | 152 test_data_dir_.AppendASCII("bluetooth/device_events"))); |
153 | 153 |
154 ExtensionTestMessageListener events_received("ready", true); | 154 ExtensionTestMessageListener events_received("ready", true); |
155 event_router()->DeviceAdded(mock_adapter_, device1_.get()); | 155 event_router()->DeviceAdded(mock_adapter_, device1_.get()); |
156 event_router()->DeviceAdded(mock_adapter_, device2_.get()); | 156 event_router()->DeviceAdded(mock_adapter_, device2_.get()); |
157 | 157 |
158 EXPECT_CALL(*device2_.get(), GetDeviceName()) | 158 EXPECT_CALL(*device2_, GetDeviceName()) |
159 .WillRepeatedly(testing::Return("the real d2")); | 159 .WillRepeatedly(testing::Return("the real d2")); |
160 EXPECT_CALL(*device2_.get(), GetNameForDisplay()) | 160 EXPECT_CALL(*device2_, GetNameForDisplay()) |
161 .WillRepeatedly(testing::Return(base::UTF8ToUTF16("the real d2"))); | 161 .WillRepeatedly(testing::Return(base::UTF8ToUTF16("the real d2"))); |
162 event_router()->DeviceChanged(mock_adapter_, device2_.get()); | 162 event_router()->DeviceChanged(mock_adapter_, device2_.get()); |
163 | 163 |
164 event_router()->DeviceAdded(mock_adapter_, device3_.get()); | 164 event_router()->DeviceAdded(mock_adapter_, device3_.get()); |
165 event_router()->DeviceRemoved(mock_adapter_, device1_.get()); | 165 event_router()->DeviceRemoved(mock_adapter_, device1_.get()); |
166 EXPECT_TRUE(events_received.WaitUntilSatisfied()); | 166 EXPECT_TRUE(events_received.WaitUntilSatisfied()); |
167 events_received.Reply("go"); | 167 events_received.Reply("go"); |
168 | 168 |
169 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); | 169 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); |
170 } | 170 } |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); | 403 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); |
404 } | 404 } |
405 | 405 |
406 IN_PROC_BROWSER_TEST_F(BluetoothApiTest, DeviceInfo) { | 406 IN_PROC_BROWSER_TEST_F(BluetoothApiTest, DeviceInfo) { |
407 ResultCatcher catcher; | 407 ResultCatcher catcher; |
408 catcher.RestrictToBrowserContext(browser()->profile()); | 408 catcher.RestrictToBrowserContext(browser()->profile()); |
409 | 409 |
410 // Set up the first device object to reflect a real-world device. | 410 // Set up the first device object to reflect a real-world device. |
411 BluetoothAdapter::ConstDeviceList devices; | 411 BluetoothAdapter::ConstDeviceList devices; |
412 | 412 |
413 EXPECT_CALL(*device1_.get(), GetAddress()) | 413 EXPECT_CALL(*device1_, GetAddress()) |
414 .WillRepeatedly(testing::Return("A4:17:31:00:00:00")); | 414 .WillRepeatedly(testing::Return("A4:17:31:00:00:00")); |
415 EXPECT_CALL(*device1_.get(), GetDeviceName()) | 415 EXPECT_CALL(*device1_, GetDeviceName()) |
416 .WillRepeatedly(testing::Return("Chromebook Pixel")); | 416 .WillRepeatedly(testing::Return("Chromebook Pixel")); |
417 EXPECT_CALL(*device1_.get(), GetNameForDisplay()) | 417 EXPECT_CALL(*device1_, GetNameForDisplay()) |
418 .WillRepeatedly(testing::Return(base::UTF8ToUTF16("Chromebook Pixel"))); | 418 .WillRepeatedly(testing::Return(base::UTF8ToUTF16("Chromebook Pixel"))); |
419 EXPECT_CALL(*device1_.get(), GetBluetoothClass()) | 419 EXPECT_CALL(*device1_, GetBluetoothClass()) |
420 .WillRepeatedly(testing::Return(0x080104)); | 420 .WillRepeatedly(testing::Return(0x080104)); |
421 EXPECT_CALL(*device1_.get(), GetDeviceType()) | 421 EXPECT_CALL(*device1_, GetDeviceType()) |
422 .WillRepeatedly(testing::Return(BluetoothDevice::DEVICE_COMPUTER)); | 422 .WillRepeatedly(testing::Return(BluetoothDevice::DEVICE_COMPUTER)); |
423 EXPECT_CALL(*device1_.get(), GetVendorIDSource()) | 423 EXPECT_CALL(*device1_, GetVendorIDSource()) |
424 .WillRepeatedly(testing::Return(BluetoothDevice::VENDOR_ID_BLUETOOTH)); | 424 .WillRepeatedly(testing::Return(BluetoothDevice::VENDOR_ID_BLUETOOTH)); |
425 EXPECT_CALL(*device1_.get(), GetVendorID()) | 425 EXPECT_CALL(*device1_, GetVendorID()).WillRepeatedly(testing::Return(0x00E0)); |
426 .WillRepeatedly(testing::Return(0x00E0)); | 426 EXPECT_CALL(*device1_, GetProductID()) |
427 EXPECT_CALL(*device1_.get(), GetProductID()) | 427 .WillRepeatedly(testing::Return(0x240A)); |
428 .WillRepeatedly(testing::Return(0x240A)); | 428 EXPECT_CALL(*device1_, GetDeviceID()).WillRepeatedly(testing::Return(0x0400)); |
429 EXPECT_CALL(*device1_.get(), GetDeviceID()) | |
430 .WillRepeatedly(testing::Return(0x0400)); | |
431 | 429 |
432 BluetoothDevice::UUIDList uuids; | 430 BluetoothDevice::UUIDList uuids; |
433 uuids.push_back(BluetoothUUID("1105")); | 431 uuids.push_back(BluetoothUUID("1105")); |
434 uuids.push_back(BluetoothUUID("1106")); | 432 uuids.push_back(BluetoothUUID("1106")); |
435 | 433 |
436 EXPECT_CALL(*device1_.get(), GetUUIDs()) | 434 EXPECT_CALL(*device1_, GetUUIDs()).WillOnce(testing::Return(uuids)); |
437 .WillOnce(testing::Return(uuids)); | |
438 | 435 |
439 devices.push_back(device1_.get()); | 436 devices.push_back(device1_.get()); |
440 | 437 |
441 // Leave the second largely empty so we can check a device without | 438 // Leave the second largely empty so we can check a device without |
442 // available information. | 439 // available information. |
443 devices.push_back(device2_.get()); | 440 devices.push_back(device2_.get()); |
444 | 441 |
445 EXPECT_CALL(*mock_adapter_, GetDevices()) | 442 EXPECT_CALL(*mock_adapter_, GetDevices()) |
446 .Times(1) | 443 .Times(1) |
447 .WillRepeatedly(testing::Return(devices)); | 444 .WillRepeatedly(testing::Return(devices)); |
448 | 445 |
449 // Load and wait for setup | 446 // Load and wait for setup |
450 ExtensionTestMessageListener listener("ready", true); | 447 ExtensionTestMessageListener listener("ready", true); |
451 ASSERT_TRUE( | 448 ASSERT_TRUE( |
452 LoadExtension(test_data_dir_.AppendASCII("bluetooth/device_info"))); | 449 LoadExtension(test_data_dir_.AppendASCII("bluetooth/device_info"))); |
453 EXPECT_TRUE(listener.WaitUntilSatisfied()); | 450 EXPECT_TRUE(listener.WaitUntilSatisfied()); |
454 | 451 |
455 listener.Reply("go"); | 452 listener.Reply("go"); |
456 | 453 |
457 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); | 454 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); |
458 } | 455 } |
OLD | NEW |