Chromium Code Reviews| 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 "extensions/browser/api/bluetooth/bluetooth_event_router.h" | 5 #include "extensions/browser/api/bluetooth/bluetooth_event_router.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| 11 #include "base/memory/ptr_util.h" | |
| 11 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 12 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
| 13 #include "base/run_loop.h" | 14 #include "base/run_loop.h" |
| 14 #include "content/public/test/test_browser_context.h" | 15 #include "content/public/test/test_browser_context.h" |
| 15 #include "content/public/test/test_browser_thread.h" | 16 #include "content/public/test/test_browser_thread.h" |
| 16 #include "device/bluetooth/bluetooth_common.h" | 17 #include "device/bluetooth/bluetooth_common.h" |
| 17 #include "device/bluetooth/bluetooth_uuid.h" | 18 #include "device/bluetooth/bluetooth_uuid.h" |
| 18 #include "device/bluetooth/test/mock_bluetooth_adapter.h" | 19 #include "device/bluetooth/test/mock_bluetooth_adapter.h" |
| 19 #include "extensions/browser/extension_registry.h" | 20 #include "extensions/browser/extension_registry.h" |
| 20 #include "extensions/browser/extensions_test.h" | 21 #include "extensions/browser/extensions_test.h" |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 35 } // namespace | 36 } // namespace |
| 36 | 37 |
| 37 namespace extensions { | 38 namespace extensions { |
| 38 | 39 |
| 39 namespace bluetooth = api::bluetooth; | 40 namespace bluetooth = api::bluetooth; |
| 40 | 41 |
| 41 class BluetoothEventRouterTest : public ExtensionsTest { | 42 class BluetoothEventRouterTest : public ExtensionsTest { |
| 42 public: | 43 public: |
| 43 BluetoothEventRouterTest() | 44 BluetoothEventRouterTest() |
| 44 : ui_thread_(content::BrowserThread::UI, &message_loop_), | 45 : ui_thread_(content::BrowserThread::UI, &message_loop_), |
| 45 mock_adapter_(new testing::StrictMock<device::MockBluetoothAdapter>()), | 46 mock_adapter_(new testing::StrictMock<device::MockBluetoothAdapter>()) { |
|
karandeepb
2017/04/06 03:29:24
Seems this is leaked. Intentional?
| |
| 46 router_(new BluetoothEventRouter(browser_context())) { | 47 } |
| 48 | |
| 49 void SetUp() override { | |
| 50 ExtensionsTest::SetUp(); | |
| 51 router_ = base::MakeUnique<BluetoothEventRouter>(browser_context()); | |
| 47 router_->SetAdapterForTest(mock_adapter_); | 52 router_->SetAdapterForTest(mock_adapter_); |
| 48 } | 53 } |
| 49 | 54 |
| 50 void TearDown() override { | 55 void TearDown() override { |
| 51 // It's important to destroy the router before the browser context keyed | 56 // It's important to destroy the router before the browser context keyed |
| 52 // services so it removes itself as an ExtensionRegistry observer. | 57 // services so it removes itself as an ExtensionRegistry observer. |
| 53 router_.reset(NULL); | 58 router_.reset(NULL); |
| 54 ExtensionsTest::TearDown(); | 59 ExtensionsTest::TearDown(); |
| 55 } | 60 } |
| 56 | 61 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 116 testing::_, testing::_)).Times(1); | 121 testing::_, testing::_)).Times(1); |
| 117 | 122 |
| 118 router_->StartDiscoverySession(mock_adapter_, kTestExtensionId, | 123 router_->StartDiscoverySession(mock_adapter_, kTestExtensionId, |
| 119 base::Bind(&base::DoNothing), | 124 base::Bind(&base::DoNothing), |
| 120 base::Bind(&base::DoNothing)); | 125 base::Bind(&base::DoNothing)); |
| 121 | 126 |
| 122 EXPECT_CALL(*mock_adapter_, RemoveObserver(testing::_)).Times(1); | 127 EXPECT_CALL(*mock_adapter_, RemoveObserver(testing::_)).Times(1); |
| 123 } | 128 } |
| 124 | 129 |
| 125 } // namespace extensions | 130 } // namespace extensions |
| OLD | NEW |