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 "chromeos/dbus/bluetooth_out_of_band_client.h" | 17 #include "chromeos/dbus/bluetooth_out_of_band_client.h" |
| 18 #include "chromeos/dbus/bluetooth_out_of_band_pairing_data.h" |
18 #include "chrome/test/base/ui_test_utils.h" | 19 #include "chrome/test/base/ui_test_utils.h" |
19 #include "testing/gmock/include/gmock/gmock.h" | 20 #include "testing/gmock/include/gmock/gmock.h" |
20 | 21 |
21 using extensions::Extension; | 22 using extensions::Extension; |
22 | 23 |
23 namespace utils = extension_function_test_utils; | 24 namespace utils = extension_function_test_utils; |
24 namespace api = extensions::api; | 25 namespace api = extensions::api; |
25 | 26 |
26 namespace { | 27 namespace { |
27 | 28 |
(...skipping 11 matching lines...) Expand all Loading... |
39 event_router()->SetAdapterForTest(mock_adapter_); | 40 event_router()->SetAdapterForTest(mock_adapter_); |
40 | 41 |
41 device1_.reset(new testing::NiceMock<chromeos::MockBluetoothDevice>( | 42 device1_.reset(new testing::NiceMock<chromeos::MockBluetoothDevice>( |
42 mock_adapter_, "d1", "11:12:13:14:15:16", | 43 mock_adapter_, "d1", "11:12:13:14:15:16", |
43 true /* paired */, false /* bonded */, true /* connected */)); | 44 true /* paired */, false /* bonded */, true /* connected */)); |
44 device2_.reset(new testing::NiceMock<chromeos::MockBluetoothDevice>( | 45 device2_.reset(new testing::NiceMock<chromeos::MockBluetoothDevice>( |
45 mock_adapter_, "d2", "21:22:23:24:25:26", | 46 mock_adapter_, "d2", "21:22:23:24:25:26", |
46 false /* paired */, true /* bonded */, false /* connected */)); | 47 false /* paired */, true /* bonded */, false /* connected */)); |
47 } | 48 } |
48 | 49 |
| 50 virtual void CleanUpOnMainThread() OVERRIDE { |
| 51 EXPECT_CALL(*mock_adapter_, RemoveObserver(testing::_)); |
| 52 } |
| 53 |
49 void expectBooleanResult(bool expected, | 54 void expectBooleanResult(bool expected, |
50 UIThreadExtensionFunction* function) { | 55 UIThreadExtensionFunction* function) { |
51 scoped_ptr<base::Value> result( | 56 scoped_ptr<base::Value> result( |
52 utils::RunFunctionAndReturnSingleResult(function, "[]", browser())); | 57 utils::RunFunctionAndReturnSingleResult(function, "[]", browser())); |
53 ASSERT_TRUE(result.get() != NULL); | 58 ASSERT_TRUE(result.get() != NULL); |
54 ASSERT_EQ(base::Value::TYPE_BOOLEAN, result->GetType()); | 59 ASSERT_EQ(base::Value::TYPE_BOOLEAN, result->GetType()); |
55 bool boolean_value; | 60 bool boolean_value; |
56 result->GetAsBoolean(&boolean_value); | 61 result->GetAsBoolean(&boolean_value); |
57 EXPECT_EQ(expected, boolean_value); | 62 EXPECT_EQ(expected, boolean_value); |
58 } | 63 } |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 chromeos::kBluetoothOutOfBandPairingDataSize); | 106 chromeos::kBluetoothOutOfBandPairingDataSize); |
102 return data; | 107 return data; |
103 } | 108 } |
104 | 109 |
105 static bool CallClosure(const base::Closure& callback) { | 110 static bool CallClosure(const base::Closure& callback) { |
106 callback.Run(); | 111 callback.Run(); |
107 return true; | 112 return true; |
108 } | 113 } |
109 | 114 |
110 static void CallOutOfBandPairingDataCallback( | 115 static void CallOutOfBandPairingDataCallback( |
111 const chromeos::BluetoothAdapter::BluetoothOutOfBandPairingDataCallback& | 116 const chromeos::BluetoothAdapter::BluetoothOutOfBandPairingDataCallback& |
112 callback, | 117 callback, |
113 const chromeos::BluetoothAdapter::ErrorCallback& error_callback) { | 118 const chromeos::BluetoothAdapter::ErrorCallback& error_callback) { |
114 callback.Run(GetOutOfBandPairingData()); | 119 callback.Run(GetOutOfBandPairingData()); |
115 } | 120 } |
116 | 121 |
117 template <bool Value> | 122 template <bool Value> |
118 static void CallProvidesServiceCallback( | 123 static void CallProvidesServiceCallback( |
119 const std::string& name, | 124 const std::string& name, |
120 const chromeos::BluetoothDevice::ProvidesServiceCallback& callback) { | 125 const chromeos::BluetoothDevice::ProvidesServiceCallback& callback) { |
121 callback.Run(Value); | 126 callback.Run(Value); |
122 } | 127 } |
123 | 128 |
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 GURL page_url = | 439 GURL page_url = |
435 extension->GetResourceURL("test_getdevices_concurrently.html"); | 440 extension->GetResourceURL("test_getdevices_concurrently.html"); |
436 ui_test_utils::NavigateToURL(browser(), page_url); | 441 ui_test_utils::NavigateToURL(browser(), page_url); |
437 EXPECT_TRUE(listener.WaitUntilSatisfied()); | 442 EXPECT_TRUE(listener.WaitUntilSatisfied()); |
438 | 443 |
439 callback.Run(false); | 444 callback.Run(false); |
440 listener.Reply("go"); | 445 listener.Reply("go"); |
441 | 446 |
442 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); | 447 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); |
443 } | 448 } |
OLD | NEW |