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> | 5 #include <string> |
6 | 6 |
7 #include "base/memory/ref_counted.h" | 7 #include "base/memory/ref_counted.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
11 #include "content/public/browser/notification_service.h" | 11 #include "content/public/browser/notification_service.h" |
12 #include "content/public/test/test_browser_context.h" | 12 #include "content/public/test/test_browser_context.h" |
13 #include "content/public/test/test_browser_thread.h" | 13 #include "content/public/test/test_browser_thread.h" |
14 #include "device/bluetooth/bluetooth_uuid.h" | 14 #include "device/bluetooth/bluetooth_uuid.h" |
15 #include "device/bluetooth/test/mock_bluetooth_adapter.h" | 15 #include "device/bluetooth/test/mock_bluetooth_adapter.h" |
16 #include "extensions/browser/api/bluetooth/bluetooth_event_router.h" | 16 #include "extensions/browser/api/bluetooth/bluetooth_event_router.h" |
17 #include "extensions/browser/extension_registry.h" | 17 #include "extensions/browser/extension_registry.h" |
18 #include "extensions/browser/extensions_test.h" | 18 #include "extensions/browser/extensions_test.h" |
19 #include "extensions/common/api/bluetooth.h" | 19 #include "extensions/common/api/bluetooth.h" |
20 #include "extensions/common/extension_builder.h" | 20 #include "extensions/common/extension_builder.h" |
21 #include "testing/gmock/include/gmock/gmock.h" | 21 #include "testing/gmock/include/gmock/gmock.h" |
22 #include "testing/gtest/include/gtest/gtest.h" | 22 #include "testing/gtest/include/gtest/gtest.h" |
23 | 23 |
24 namespace { | 24 namespace { |
25 | 25 |
26 const char kTestExtensionId[] = "test extension id"; | 26 const char kTestExtensionId[] = "test extension id"; |
27 const device::BluetoothUUID kAudioProfileUuid("1234"); | 27 const device::BluetoothUUID kAudioProfileUuid("1234"); |
28 const device::BluetoothUUID kHealthProfileUuid("4321"); | 28 const device::BluetoothUUID kHealthProfileUuid("4321"); |
29 | 29 |
30 MATCHER_P(IsFilterEqual, a, "") { | |
31 return arg.Equals(*a); | |
32 } | |
30 } // namespace | 33 } // namespace |
31 | 34 |
32 namespace extensions { | 35 namespace extensions { |
33 | 36 |
34 namespace bluetooth = core_api::bluetooth; | 37 namespace bluetooth = core_api::bluetooth; |
35 | 38 |
36 class BluetoothEventRouterTest : public ExtensionsTest { | 39 class BluetoothEventRouterTest : public ExtensionsTest { |
37 public: | 40 public: |
38 BluetoothEventRouterTest() | 41 BluetoothEventRouterTest() |
39 : ui_thread_(content::BrowserThread::UI, &message_loop_), | 42 : ui_thread_(content::BrowserThread::UI, &message_loop_), |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
84 .Set("manifest_version", 2)) | 87 .Set("manifest_version", 2)) |
85 .SetID(kTestExtensionId) | 88 .SetID(kTestExtensionId) |
86 .Build(); | 89 .Build(); |
87 | 90 |
88 ExtensionRegistry::Get(browser_context())->TriggerOnUnloaded( | 91 ExtensionRegistry::Get(browser_context())->TriggerOnUnloaded( |
89 extension.get(), UnloadedExtensionInfo::REASON_DISABLE); | 92 extension.get(), UnloadedExtensionInfo::REASON_DISABLE); |
90 | 93 |
91 EXPECT_CALL(*mock_adapter_, RemoveObserver(testing::_)).Times(1); | 94 EXPECT_CALL(*mock_adapter_, RemoveObserver(testing::_)).Times(1); |
92 } | 95 } |
93 | 96 |
97 // This test check that calling SetDiscoveryFitler before StartDiscoverySession | |
armansito
2015/04/16 19:13:55
nit: s/SetDiscoveryFitler/SetDiscoveryFilter/
Not
jpawlowski1
2015/04/16 19:36:28
Done.
| |
98 // for given extension will start session with proper filter. | |
99 TEST_F(BluetoothEventRouterTest, SetDiscoveryFilter) { | |
100 scoped_ptr<device::BluetoothDiscoveryFilter> discovery_filter( | |
101 new device::BluetoothDiscoveryFilter( | |
102 device::BluetoothDiscoveryFilter::Transport::TRANSPORT_LE)); | |
103 | |
104 discovery_filter->SetRSSI(-80); | |
105 discovery_filter->AddUUID(device::BluetoothUUID("1000")); | |
106 | |
107 device::BluetoothDiscoveryFilter df( | |
108 device::BluetoothDiscoveryFilter::Transport::TRANSPORT_LE); | |
109 df.CopyFrom(*discovery_filter); | |
110 | |
111 router_->SetDiscoveryFilter(discovery_filter.Pass(), mock_adapter_, | |
112 kTestExtensionId, base::Bind(&base::DoNothing), | |
113 base::Bind(&base::DoNothing)); | |
114 | |
115 EXPECT_CALL(*mock_adapter_, StartDiscoverySessionWithFilterRaw( | |
116 testing::Pointee(IsFilterEqual(&df)), | |
117 testing::_, testing::_)).Times(1); | |
118 | |
119 router_->StartDiscoverySession(mock_adapter_, kTestExtensionId, | |
120 base::Bind(&base::DoNothing), | |
121 base::Bind(&base::DoNothing)); | |
122 | |
123 EXPECT_CALL(*mock_adapter_, RemoveObserver(testing::_)).Times(1); | |
armansito
2015/04/16 19:13:55
You'll also want test cases to bluetooth_private_a
jpawlowski1
2015/04/16 19:36:27
this code is not yet connected to bluetooth privat
| |
124 } | |
125 | |
94 } // namespace extensions | 126 } // namespace extensions |
OLD | NEW |