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" |
11 #include "chrome/browser/extensions/extension_service.h" | 11 #include "chrome/browser/extensions/extension_service.h" |
12 #include "chrome/browser/ui/browser.h" | 12 #include "chrome/browser/ui/browser.h" |
13 #include "chrome/test/base/ui_test_utils.h" | 13 #include "chrome/test/base/ui_test_utils.h" |
14 #include "device/bluetooth/bluetooth_adapter.h" | 14 #include "device/bluetooth/bluetooth_adapter.h" |
15 #include "device/bluetooth/bluetooth_uuid.h" | 15 #include "device/bluetooth/bluetooth_uuid.h" |
16 #include "device/bluetooth/test/mock_bluetooth_adapter.h" | 16 #include "device/bluetooth/test/mock_bluetooth_adapter.h" |
17 #include "device/bluetooth/test/mock_bluetooth_device.h" | 17 #include "device/bluetooth/test/mock_bluetooth_device.h" |
18 #include "device/bluetooth/test/mock_bluetooth_discovery_session.h" | 18 #include "device/bluetooth/test/mock_bluetooth_discovery_session.h" |
19 #include "extensions/browser/api/bluetooth/bluetooth_api.h" | 19 #include "extensions/browser/api/bluetooth/bluetooth_api.h" |
20 #include "extensions/browser/api/bluetooth/bluetooth_event_router.h" | 20 #include "extensions/browser/api/bluetooth/bluetooth_event_router.h" |
21 #include "extensions/common/test_util.h" | 21 #include "extensions/common/test_util.h" |
22 #include "extensions/test/extension_test_message_listener.h" | 22 #include "extensions/test/extension_test_message_listener.h" |
23 #include "extensions/test/result_catcher.h" | 23 #include "extensions/test/result_catcher.h" |
24 #include "testing/gmock/include/gmock/gmock.h" | 24 #include "testing/gmock/include/gmock/gmock.h" |
25 | 25 |
26 using device::BluetoothAdapter; | 26 using device::BluetoothAdapter; |
27 using device::BluetoothDevice; | 27 using device::BluetoothDevice; |
| 28 using device::BluetoothDeviceType; |
28 using device::BluetoothDiscoverySession; | 29 using device::BluetoothDiscoverySession; |
29 using device::BluetoothUUID; | 30 using device::BluetoothUUID; |
30 using device::MockBluetoothAdapter; | 31 using device::MockBluetoothAdapter; |
31 using device::MockBluetoothDevice; | 32 using device::MockBluetoothDevice; |
32 using device::MockBluetoothDiscoverySession; | 33 using device::MockBluetoothDiscoverySession; |
33 using extensions::Extension; | 34 using extensions::Extension; |
34 using extensions::ResultCatcher; | 35 using extensions::ResultCatcher; |
35 | 36 |
36 namespace utils = extension_function_test_utils; | 37 namespace utils = extension_function_test_utils; |
37 namespace api = extensions::api; | 38 namespace api = extensions::api; |
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
413 EXPECT_CALL(*device1_, GetAddress()) | 414 EXPECT_CALL(*device1_, GetAddress()) |
414 .WillRepeatedly(testing::Return("A4:17:31:00:00:00")); | 415 .WillRepeatedly(testing::Return("A4:17:31:00:00:00")); |
415 EXPECT_CALL(*device1_, GetName()) | 416 EXPECT_CALL(*device1_, GetName()) |
416 .WillRepeatedly( | 417 .WillRepeatedly( |
417 testing::Return(base::Optional<std::string>("Chromebook Pixel"))); | 418 testing::Return(base::Optional<std::string>("Chromebook Pixel"))); |
418 EXPECT_CALL(*device1_, GetNameForDisplay()) | 419 EXPECT_CALL(*device1_, GetNameForDisplay()) |
419 .WillRepeatedly(testing::Return(base::UTF8ToUTF16("Chromebook Pixel"))); | 420 .WillRepeatedly(testing::Return(base::UTF8ToUTF16("Chromebook Pixel"))); |
420 EXPECT_CALL(*device1_, GetBluetoothClass()) | 421 EXPECT_CALL(*device1_, GetBluetoothClass()) |
421 .WillRepeatedly(testing::Return(0x080104)); | 422 .WillRepeatedly(testing::Return(0x080104)); |
422 EXPECT_CALL(*device1_, GetDeviceType()) | 423 EXPECT_CALL(*device1_, GetDeviceType()) |
423 .WillRepeatedly(testing::Return(BluetoothDevice::DEVICE_COMPUTER)); | 424 .WillRepeatedly(testing::Return(BluetoothDeviceType::COMPUTER)); |
424 EXPECT_CALL(*device1_, GetVendorIDSource()) | 425 EXPECT_CALL(*device1_, GetVendorIDSource()) |
425 .WillRepeatedly(testing::Return(BluetoothDevice::VENDOR_ID_BLUETOOTH)); | 426 .WillRepeatedly(testing::Return(BluetoothDevice::VENDOR_ID_BLUETOOTH)); |
426 EXPECT_CALL(*device1_, GetVendorID()).WillRepeatedly(testing::Return(0x00E0)); | 427 EXPECT_CALL(*device1_, GetVendorID()).WillRepeatedly(testing::Return(0x00E0)); |
427 EXPECT_CALL(*device1_, GetProductID()) | 428 EXPECT_CALL(*device1_, GetProductID()) |
428 .WillRepeatedly(testing::Return(0x240A)); | 429 .WillRepeatedly(testing::Return(0x240A)); |
429 EXPECT_CALL(*device1_, GetDeviceID()).WillRepeatedly(testing::Return(0x0400)); | 430 EXPECT_CALL(*device1_, GetDeviceID()).WillRepeatedly(testing::Return(0x0400)); |
430 | 431 |
431 BluetoothDevice::UUIDSet uuids; | 432 BluetoothDevice::UUIDSet uuids; |
432 uuids.insert(BluetoothUUID("1105")); | 433 uuids.insert(BluetoothUUID("1105")); |
433 uuids.insert(BluetoothUUID("1106")); | 434 uuids.insert(BluetoothUUID("1106")); |
(...skipping 13 matching lines...) Expand all Loading... |
447 // Load and wait for setup | 448 // Load and wait for setup |
448 ExtensionTestMessageListener listener("ready", true); | 449 ExtensionTestMessageListener listener("ready", true); |
449 ASSERT_TRUE( | 450 ASSERT_TRUE( |
450 LoadExtension(test_data_dir_.AppendASCII("bluetooth/device_info"))); | 451 LoadExtension(test_data_dir_.AppendASCII("bluetooth/device_info"))); |
451 EXPECT_TRUE(listener.WaitUntilSatisfied()); | 452 EXPECT_TRUE(listener.WaitUntilSatisfied()); |
452 | 453 |
453 listener.Reply("go"); | 454 listener.Reply("go"); |
454 | 455 |
455 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); | 456 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); |
456 } | 457 } |
OLD | NEW |