OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/memory/ref_counted.h" | 6 #include "base/memory/ref_counted.h" |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "chrome/browser/extensions/extension_apitest.h" | 8 #include "chrome/browser/extensions/extension_apitest.h" |
9 #include "device/bluetooth/test/mock_bluetooth_adapter.h" | 9 #include "device/bluetooth/test/mock_bluetooth_adapter.h" |
10 #include "device/bluetooth/test/mock_bluetooth_device.h" | 10 #include "device/bluetooth/test/mock_bluetooth_device.h" |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 | 113 |
114 protected: | 114 protected: |
115 std::string adapter_name_; | 115 std::string adapter_name_; |
116 bool adapter_powered_; | 116 bool adapter_powered_; |
117 bool adapter_discoverable_; | 117 bool adapter_discoverable_; |
118 | 118 |
119 scoped_refptr<NiceMock<MockBluetoothAdapter> > mock_adapter_; | 119 scoped_refptr<NiceMock<MockBluetoothAdapter> > mock_adapter_; |
120 scoped_ptr<NiceMock<MockBluetoothDevice> > mock_device_; | 120 scoped_ptr<NiceMock<MockBluetoothDevice> > mock_device_; |
121 }; | 121 }; |
122 | 122 |
| 123 ACTION_TEMPLATE(InvokeCallbackArgument, |
| 124 HAS_1_TEMPLATE_PARAMS(int, k), |
| 125 AND_0_VALUE_PARAMS()) { |
| 126 ::std::tr1::get<k>(args).Run(); |
| 127 } |
| 128 |
123 IN_PROC_BROWSER_TEST_F(BluetoothPrivateApiTest, SetAdapterState) { | 129 IN_PROC_BROWSER_TEST_F(BluetoothPrivateApiTest, SetAdapterState) { |
124 ON_CALL(*mock_adapter_.get(), GetName()) | 130 ON_CALL(*mock_adapter_.get(), GetName()) |
125 .WillByDefault(ReturnPointee(&adapter_name_)); | 131 .WillByDefault(ReturnPointee(&adapter_name_)); |
126 ON_CALL(*mock_adapter_.get(), IsPowered()) | 132 ON_CALL(*mock_adapter_.get(), IsPowered()) |
127 .WillByDefault(ReturnPointee(&adapter_powered_)); | 133 .WillByDefault(ReturnPointee(&adapter_powered_)); |
128 ON_CALL(*mock_adapter_.get(), IsDiscoverable()) | 134 ON_CALL(*mock_adapter_.get(), IsDiscoverable()) |
129 .WillByDefault(ReturnPointee(&adapter_discoverable_)); | 135 .WillByDefault(ReturnPointee(&adapter_discoverable_)); |
130 | 136 |
131 EXPECT_CALL(*mock_adapter_.get(), SetName("Dome", _, _)).WillOnce( | 137 EXPECT_CALL(*mock_adapter_.get(), SetName("Dome", _, _)).WillOnce( |
132 WithArgs<0, 1>(Invoke(this, &BluetoothPrivateApiTest::SetName))); | 138 WithArgs<0, 1>(Invoke(this, &BluetoothPrivateApiTest::SetName))); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 AddPairingDelegate( | 182 AddPairingDelegate( |
177 _, device::BluetoothAdapter::PAIRING_DELEGATE_PRIORITY_HIGH)) | 183 _, device::BluetoothAdapter::PAIRING_DELEGATE_PRIORITY_HIGH)) |
178 .WillOnce(WithoutArgs( | 184 .WillOnce(WithoutArgs( |
179 Invoke(this, &BluetoothPrivateApiTest::DispatchPasskeyPairingEvent))); | 185 Invoke(this, &BluetoothPrivateApiTest::DispatchPasskeyPairingEvent))); |
180 EXPECT_CALL(*mock_device_, ExpectingPasskey()).WillRepeatedly(Return(true)); | 186 EXPECT_CALL(*mock_device_, ExpectingPasskey()).WillRepeatedly(Return(true)); |
181 EXPECT_CALL(*mock_device_, SetPasskey(900531)); | 187 EXPECT_CALL(*mock_device_, SetPasskey(900531)); |
182 ASSERT_TRUE(RunComponentExtensionTest("bluetooth_private/passkey_pairing")) | 188 ASSERT_TRUE(RunComponentExtensionTest("bluetooth_private/passkey_pairing")) |
183 << message_; | 189 << message_; |
184 } | 190 } |
185 | 191 |
| 192 IN_PROC_BROWSER_TEST_F(BluetoothPrivateApiTest, DisconnectAll) { |
| 193 EXPECT_CALL(*mock_device_, IsConnected()) |
| 194 .Times(6) |
| 195 .WillOnce(Return(false)) |
| 196 .WillOnce(Return(true)) |
| 197 .WillOnce(Return(false)) |
| 198 .WillRepeatedly(Return(true)); |
| 199 EXPECT_CALL(*mock_device_, Disconnect(_, _)) |
| 200 .Times(3) |
| 201 .WillOnce(InvokeCallbackArgument<1>()) |
| 202 .WillOnce(InvokeCallbackArgument<1>()) |
| 203 .WillOnce(InvokeCallbackArgument<0>()); |
| 204 ASSERT_TRUE(RunComponentExtensionTest("bluetooth_private/disconnect")) |
| 205 << message_; |
| 206 } |
| 207 |
186 } // namespace extensions | 208 } // namespace extensions |
OLD | NEW |