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 "chrome/browser/chromeos/bluetooth/bluetooth_adapter.h" | 7 #include "chrome/browser/chromeos/bluetooth/bluetooth_adapter.h" |
8 #include "chrome/browser/chromeos/bluetooth/test/mock_bluetooth_adapter.h" | 8 #include "chrome/browser/chromeos/bluetooth/test/mock_bluetooth_adapter.h" |
9 #include "chrome/browser/chromeos/bluetooth/test/mock_bluetooth_device.h" | 9 #include "chrome/browser/chromeos/bluetooth/test/mock_bluetooth_device.h" |
10 #include "chrome/browser/chromeos/extensions/bluetooth_event_router.h" | 10 #include "chrome/browser/chromeos/extensions/bluetooth_event_router.h" |
11 #include "chrome/browser/extensions/api/bluetooth/bluetooth_api.h" | 11 #include "chrome/browser/extensions/api/bluetooth/bluetooth_api.h" |
12 #include "chrome/browser/extensions/extension_apitest.h" | 12 #include "chrome/browser/extensions/extension_apitest.h" |
13 #include "chrome/browser/extensions/extension_function_test_utils.h" | 13 #include "chrome/browser/extensions/extension_function_test_utils.h" |
14 #include "chrome/browser/extensions/extension_service.h" | 14 #include "chrome/browser/extensions/extension_service.h" |
15 #include "chrome/browser/extensions/extension_test_message_listener.h" | 15 #include "chrome/browser/extensions/extension_test_message_listener.h" |
16 #include "chrome/browser/ui/browser.h" | 16 #include "chrome/browser/ui/browser.h" |
| 17 #include "chrome/common/chrome_switches.h" |
| 18 #include "chrome/test/base/ui_test_utils.h" |
17 #include "chromeos/dbus/bluetooth_out_of_band_client.h" | 19 #include "chromeos/dbus/bluetooth_out_of_band_client.h" |
18 #include "chromeos/dbus/bluetooth_out_of_band_pairing_data.h" | 20 #include "chromeos/dbus/bluetooth_out_of_band_pairing_data.h" |
19 #include "chrome/test/base/ui_test_utils.h" | |
20 #include "testing/gmock/include/gmock/gmock.h" | 21 #include "testing/gmock/include/gmock/gmock.h" |
21 | 22 |
22 using extensions::Extension; | 23 using extensions::Extension; |
23 | 24 |
24 namespace utils = extension_function_test_utils; | 25 namespace utils = extension_function_test_utils; |
25 namespace api = extensions::api; | 26 namespace api = extensions::api; |
26 | 27 |
27 namespace { | 28 namespace { |
28 | 29 |
29 static const char* kAdapterAddress = "A1:A2:A3:A4:A5:A6"; | 30 static const char* kAdapterAddress = "A1:A2:A3:A4:A5:A6"; |
30 static const char* kName = "whatsinaname"; | 31 static const char* kName = "whatsinaname"; |
31 | 32 |
32 class BluetoothApiTest : public PlatformAppApiTest { | 33 class BluetoothApiTest : public ExtensionApiTest { |
33 public: | 34 public: |
34 BluetoothApiTest() : empty_extension_(utils::CreateEmptyExtension()) {} | 35 BluetoothApiTest() : empty_extension_(utils::CreateEmptyExtension()) {} |
35 | 36 |
| 37 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
| 38 ExtensionApiTest::SetUpCommandLine(command_line); |
| 39 command_line->AppendSwitch(switches::kEnableExperimentalExtensionApis); |
| 40 } |
| 41 |
36 virtual void SetUpOnMainThread() OVERRIDE { | 42 virtual void SetUpOnMainThread() OVERRIDE { |
37 // The browser will clean this up when it is torn down | 43 // The browser will clean this up when it is torn down |
38 mock_adapter_ = new testing::StrictMock<chromeos::MockBluetoothAdapter>( | 44 mock_adapter_ = new testing::StrictMock<chromeos::MockBluetoothAdapter>( |
39 kAdapterAddress, kName); | 45 kAdapterAddress, kName); |
40 event_router()->SetAdapterForTest(mock_adapter_); | 46 event_router()->SetAdapterForTest(mock_adapter_); |
41 | 47 |
42 device1_.reset(new testing::NiceMock<chromeos::MockBluetoothDevice>( | 48 device1_.reset(new testing::NiceMock<chromeos::MockBluetoothDevice>( |
43 mock_adapter_, "d1", "11:12:13:14:15:16", | 49 mock_adapter_, "d1", "11:12:13:14:15:16", |
44 true /* paired */, false /* bonded */, true /* connected */)); | 50 true /* paired */, false /* bonded */, true /* connected */)); |
45 device2_.reset(new testing::NiceMock<chromeos::MockBluetoothDevice>( | 51 device2_.reset(new testing::NiceMock<chromeos::MockBluetoothDevice>( |
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
435 GURL page_url = | 441 GURL page_url = |
436 extension->GetResourceURL("test_getdevices_concurrently.html"); | 442 extension->GetResourceURL("test_getdevices_concurrently.html"); |
437 ui_test_utils::NavigateToURL(browser(), page_url); | 443 ui_test_utils::NavigateToURL(browser(), page_url); |
438 EXPECT_TRUE(listener.WaitUntilSatisfied()); | 444 EXPECT_TRUE(listener.WaitUntilSatisfied()); |
439 | 445 |
440 callback.Run(false); | 446 callback.Run(false); |
441 listener.Reply("go"); | 447 listener.Reply("go"); |
442 | 448 |
443 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); | 449 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); |
444 } | 450 } |
OLD | NEW |