| 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 28 matching lines...) Expand all Loading... |
| 39 | 39 |
| 40 class BluetoothPrivateApiTest : public ExtensionApiTest { | 40 class BluetoothPrivateApiTest : public ExtensionApiTest { |
| 41 public: | 41 public: |
| 42 BluetoothPrivateApiTest() | 42 BluetoothPrivateApiTest() |
| 43 : adapter_name_(kAdapterName), | 43 : adapter_name_(kAdapterName), |
| 44 adapter_powered_(false), | 44 adapter_powered_(false), |
| 45 adapter_discoverable_(false) {} | 45 adapter_discoverable_(false) {} |
| 46 | 46 |
| 47 virtual ~BluetoothPrivateApiTest() {} | 47 virtual ~BluetoothPrivateApiTest() {} |
| 48 | 48 |
| 49 virtual void SetUpOnMainThread() OVERRIDE { | 49 virtual void SetUpOnMainThread() override { |
| 50 CommandLine::ForCurrentProcess()->AppendSwitchASCII( | 50 CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
| 51 switches::kWhitelistedExtensionID, kTestExtensionId); | 51 switches::kWhitelistedExtensionID, kTestExtensionId); |
| 52 mock_adapter_ = new NiceMock<MockBluetoothAdapter>(); | 52 mock_adapter_ = new NiceMock<MockBluetoothAdapter>(); |
| 53 event_router()->SetAdapterForTest(mock_adapter_.get()); | 53 event_router()->SetAdapterForTest(mock_adapter_.get()); |
| 54 mock_device_.reset(new NiceMock<MockBluetoothDevice>(mock_adapter_.get(), | 54 mock_device_.reset(new NiceMock<MockBluetoothDevice>(mock_adapter_.get(), |
| 55 0, | 55 0, |
| 56 kDeviceName, | 56 kDeviceName, |
| 57 "11:12:13:14:15:16", | 57 "11:12:13:14:15:16", |
| 58 false, | 58 false, |
| 59 false)); | 59 false)); |
| 60 ON_CALL(*mock_adapter_.get(), GetDevice(mock_device_->GetAddress())) | 60 ON_CALL(*mock_adapter_.get(), GetDevice(mock_device_->GetAddress())) |
| 61 .WillByDefault(Return(mock_device_.get())); | 61 .WillByDefault(Return(mock_device_.get())); |
| 62 ON_CALL(*mock_adapter_.get(), IsPresent()).WillByDefault(Return(true)); | 62 ON_CALL(*mock_adapter_.get(), IsPresent()).WillByDefault(Return(true)); |
| 63 } | 63 } |
| 64 | 64 |
| 65 virtual void TearDownOnMainThread() OVERRIDE {} | 65 virtual void TearDownOnMainThread() override {} |
| 66 | 66 |
| 67 BluetoothEventRouter* event_router() { | 67 BluetoothEventRouter* event_router() { |
| 68 return BluetoothAPI::Get(browser()->profile())->event_router(); | 68 return BluetoothAPI::Get(browser()->profile())->event_router(); |
| 69 } | 69 } |
| 70 | 70 |
| 71 void SetName(const std::string& name, const base::Closure& callback) { | 71 void SetName(const std::string& name, const base::Closure& callback) { |
| 72 adapter_name_ = name; | 72 adapter_name_ = name; |
| 73 callback.Run(); | 73 callback.Run(); |
| 74 } | 74 } |
| 75 | 75 |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 _, device::BluetoothAdapter::PAIRING_DELEGATE_PRIORITY_HIGH)) | 177 _, device::BluetoothAdapter::PAIRING_DELEGATE_PRIORITY_HIGH)) |
| 178 .WillOnce(WithoutArgs( | 178 .WillOnce(WithoutArgs( |
| 179 Invoke(this, &BluetoothPrivateApiTest::DispatchPasskeyPairingEvent))); | 179 Invoke(this, &BluetoothPrivateApiTest::DispatchPasskeyPairingEvent))); |
| 180 EXPECT_CALL(*mock_device_, ExpectingPasskey()).WillRepeatedly(Return(true)); | 180 EXPECT_CALL(*mock_device_, ExpectingPasskey()).WillRepeatedly(Return(true)); |
| 181 EXPECT_CALL(*mock_device_, SetPasskey(900531)); | 181 EXPECT_CALL(*mock_device_, SetPasskey(900531)); |
| 182 ASSERT_TRUE(RunComponentExtensionTest("bluetooth_private/passkey_pairing")) | 182 ASSERT_TRUE(RunComponentExtensionTest("bluetooth_private/passkey_pairing")) |
| 183 << message_; | 183 << message_; |
| 184 } | 184 } |
| 185 | 185 |
| 186 } // namespace extensions | 186 } // namespace extensions |
| OLD | NEW |