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/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
13 #include "base/run_loop.h" | 13 #include "base/run_loop.h" |
14 #include "content/public/browser/notification_service.h" | 14 #include "content/public/browser/notification_service.h" |
15 #include "content/public/test/test_browser_context.h" | 15 #include "content/public/test/test_browser_context.h" |
16 #include "content/public/test/test_browser_thread.h" | 16 #include "content/public/test/test_browser_thread.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" |
21 #include "extensions/common/api/bluetooth.h" | 22 #include "extensions/common/api/bluetooth.h" |
22 #include "extensions/common/extension_builder.h" | 23 #include "extensions/common/extension_builder.h" |
23 #include "testing/gmock/include/gmock/gmock.h" | 24 #include "testing/gmock/include/gmock/gmock.h" |
24 #include "testing/gtest/include/gtest/gtest.h" | 25 #include "testing/gtest/include/gtest/gtest.h" |
25 | 26 |
26 namespace { | 27 namespace { |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 ExtensionRegistry::Get(browser_context())->TriggerOnUnloaded( | 95 ExtensionRegistry::Get(browser_context())->TriggerOnUnloaded( |
95 extension.get(), UnloadedExtensionInfo::REASON_DISABLE); | 96 extension.get(), UnloadedExtensionInfo::REASON_DISABLE); |
96 | 97 |
97 EXPECT_CALL(*mock_adapter_, RemoveObserver(testing::_)).Times(1); | 98 EXPECT_CALL(*mock_adapter_, RemoveObserver(testing::_)).Times(1); |
98 } | 99 } |
99 | 100 |
100 // This test check that calling SetDiscoveryFilter before StartDiscoverySession | 101 // This test check that calling SetDiscoveryFilter before StartDiscoverySession |
101 // for given extension will start session with proper filter. | 102 // for given extension will start session with proper filter. |
102 TEST_F(BluetoothEventRouterTest, SetDiscoveryFilter) { | 103 TEST_F(BluetoothEventRouterTest, SetDiscoveryFilter) { |
103 std::unique_ptr<device::BluetoothDiscoveryFilter> discovery_filter( | 104 std::unique_ptr<device::BluetoothDiscoveryFilter> discovery_filter( |
104 new device::BluetoothDiscoveryFilter( | 105 new device::BluetoothDiscoveryFilter(device::BLUETOOTH_TRANSPORT_LE)); |
105 device::BluetoothDiscoveryFilter::Transport::TRANSPORT_LE)); | |
106 | 106 |
107 discovery_filter->SetRSSI(-80); | 107 discovery_filter->SetRSSI(-80); |
108 discovery_filter->AddUUID(device::BluetoothUUID("1000")); | 108 discovery_filter->AddUUID(device::BluetoothUUID("1000")); |
109 | 109 |
110 device::BluetoothDiscoveryFilter df( | 110 device::BluetoothDiscoveryFilter df(device::BLUETOOTH_TRANSPORT_LE); |
111 device::BluetoothDiscoveryFilter::Transport::TRANSPORT_LE); | |
112 df.CopyFrom(*discovery_filter); | 111 df.CopyFrom(*discovery_filter); |
113 | 112 |
114 router_->SetDiscoveryFilter(std::move(discovery_filter), mock_adapter_, | 113 router_->SetDiscoveryFilter(std::move(discovery_filter), mock_adapter_, |
115 kTestExtensionId, base::Bind(&base::DoNothing), | 114 kTestExtensionId, base::Bind(&base::DoNothing), |
116 base::Bind(&base::DoNothing)); | 115 base::Bind(&base::DoNothing)); |
117 | 116 |
118 EXPECT_CALL(*mock_adapter_, StartDiscoverySessionWithFilterRaw( | 117 EXPECT_CALL(*mock_adapter_, StartDiscoverySessionWithFilterRaw( |
119 testing::Pointee(IsFilterEqual(&df)), | 118 testing::Pointee(IsFilterEqual(&df)), |
120 testing::_, testing::_)).Times(1); | 119 testing::_, testing::_)).Times(1); |
121 | 120 |
122 router_->StartDiscoverySession(mock_adapter_, kTestExtensionId, | 121 router_->StartDiscoverySession(mock_adapter_, kTestExtensionId, |
123 base::Bind(&base::DoNothing), | 122 base::Bind(&base::DoNothing), |
124 base::Bind(&base::DoNothing)); | 123 base::Bind(&base::DoNothing)); |
125 | 124 |
126 EXPECT_CALL(*mock_adapter_, RemoveObserver(testing::_)).Times(1); | 125 EXPECT_CALL(*mock_adapter_, RemoveObserver(testing::_)).Times(1); |
127 } | 126 } |
128 | 127 |
129 } // namespace extensions | 128 } // namespace extensions |
OLD | NEW |