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/extensions/extension_test_message_listener.h" | 12 #include "chrome/browser/extensions/extension_test_message_listener.h" |
13 #include "chrome/browser/ui/browser.h" | 13 #include "chrome/browser/ui/browser.h" |
14 #include "chrome/test/base/ui_test_utils.h" | 14 #include "chrome/test/base/ui_test_utils.h" |
15 #include "device/bluetooth/bluetooth_adapter.h" | 15 #include "device/bluetooth/bluetooth_adapter.h" |
16 #include "device/bluetooth/bluetooth_uuid.h" | 16 #include "device/bluetooth/bluetooth_uuid.h" |
17 #include "device/bluetooth/test/mock_bluetooth_adapter.h" | 17 #include "device/bluetooth/test/mock_bluetooth_adapter.h" |
18 #include "device/bluetooth/test/mock_bluetooth_device.h" | 18 #include "device/bluetooth/test/mock_bluetooth_device.h" |
19 #include "device/bluetooth/test/mock_bluetooth_discovery_session.h" | 19 #include "device/bluetooth/test/mock_bluetooth_discovery_session.h" |
20 #include "extensions/browser/api/bluetooth/bluetooth_api.h" | 20 #include "extensions/browser/api/bluetooth/bluetooth_api.h" |
21 #include "extensions/browser/api/bluetooth/bluetooth_event_router.h" | 21 #include "extensions/browser/api/bluetooth/bluetooth_event_router.h" |
| 22 #include "extensions/common/test_util.h" |
22 #include "extensions/test/result_catcher.h" | 23 #include "extensions/test/result_catcher.h" |
23 #include "testing/gmock/include/gmock/gmock.h" | 24 #include "testing/gmock/include/gmock/gmock.h" |
24 | 25 |
25 using device::BluetoothAdapter; | 26 using device::BluetoothAdapter; |
26 using device::BluetoothDevice; | 27 using device::BluetoothDevice; |
27 using device::BluetoothDiscoverySession; | 28 using device::BluetoothDiscoverySession; |
28 using device::BluetoothUUID; | 29 using device::BluetoothUUID; |
29 using device::MockBluetoothAdapter; | 30 using device::MockBluetoothAdapter; |
30 using device::MockBluetoothDevice; | 31 using device::MockBluetoothDevice; |
31 using device::MockBluetoothDiscoverySession; | 32 using device::MockBluetoothDiscoverySession; |
32 using extensions::Extension; | 33 using extensions::Extension; |
33 using extensions::ResultCatcher; | 34 using extensions::ResultCatcher; |
34 | 35 |
35 namespace utils = extension_function_test_utils; | 36 namespace utils = extension_function_test_utils; |
36 namespace api = extensions::core_api; | 37 namespace api = extensions::core_api; |
37 | 38 |
38 namespace { | 39 namespace { |
39 | 40 |
40 static const char* kAdapterAddress = "A1:A2:A3:A4:A5:A6"; | 41 static const char* kAdapterAddress = "A1:A2:A3:A4:A5:A6"; |
41 static const char* kName = "whatsinaname"; | 42 static const char* kName = "whatsinaname"; |
42 | 43 |
43 class BluetoothApiTest : public ExtensionApiTest { | 44 class BluetoothApiTest : public ExtensionApiTest { |
44 public: | 45 public: |
45 BluetoothApiTest() {} | 46 BluetoothApiTest() {} |
46 | 47 |
47 virtual void SetUpOnMainThread() OVERRIDE { | 48 virtual void SetUpOnMainThread() OVERRIDE { |
48 ExtensionApiTest::SetUpOnMainThread(); | 49 ExtensionApiTest::SetUpOnMainThread(); |
49 empty_extension_ = utils::CreateEmptyExtension(); | 50 empty_extension_ = extensions::test_util::CreateEmptyExtension(); |
50 SetUpMockAdapter(); | 51 SetUpMockAdapter(); |
51 } | 52 } |
52 | 53 |
53 virtual void TearDownOnMainThread() OVERRIDE { | 54 virtual void TearDownOnMainThread() OVERRIDE { |
54 EXPECT_CALL(*mock_adapter_, RemoveObserver(testing::_)); | 55 EXPECT_CALL(*mock_adapter_, RemoveObserver(testing::_)); |
55 } | 56 } |
56 | 57 |
57 void SetUpMockAdapter() { | 58 void SetUpMockAdapter() { |
58 // The browser will clean this up when it is torn down | 59 // The browser will clean this up when it is torn down |
59 mock_adapter_ = new testing::StrictMock<MockBluetoothAdapter>(); | 60 mock_adapter_ = new testing::StrictMock<MockBluetoothAdapter>(); |
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
452 // Load and wait for setup | 453 // Load and wait for setup |
453 ExtensionTestMessageListener listener("ready", true); | 454 ExtensionTestMessageListener listener("ready", true); |
454 ASSERT_TRUE( | 455 ASSERT_TRUE( |
455 LoadExtension(test_data_dir_.AppendASCII("bluetooth/device_info"))); | 456 LoadExtension(test_data_dir_.AppendASCII("bluetooth/device_info"))); |
456 EXPECT_TRUE(listener.WaitUntilSatisfied()); | 457 EXPECT_TRUE(listener.WaitUntilSatisfied()); |
457 | 458 |
458 listener.Reply("go"); | 459 listener.Reply("go"); |
459 | 460 |
460 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); | 461 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); |
461 } | 462 } |
OLD | NEW |