Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(74)

Side by Side Diff: extensions/browser/api/bluetooth/bluetooth_event_router_unittest.cc

Issue 2801403002: MD Settings: Bluetooth: Fix adapter state and discovery (Closed)
Patch Set: Fix test Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/run_loop.h" 12 #include "base/run_loop.h"
13 #include "content/public/test/test_browser_context.h" 13 #include "content/public/test/test_browser_context.h"
14 #include "content/public/test/test_browser_thread_bundle.h" 14 #include "content/public/test/test_browser_thread_bundle.h"
15 #include "device/bluetooth/bluetooth_common.h" 15 #include "device/bluetooth/bluetooth_common.h"
16 #include "device/bluetooth/bluetooth_uuid.h" 16 #include "device/bluetooth/bluetooth_uuid.h"
17 #include "device/bluetooth/test/mock_bluetooth_adapter.h" 17 #include "device/bluetooth/test/mock_bluetooth_adapter.h"
18 #include "extensions/browser/event_router.h"
18 #include "extensions/browser/extension_registry.h" 19 #include "extensions/browser/extension_registry.h"
19 #include "extensions/browser/extensions_test.h" 20 #include "extensions/browser/extensions_test.h"
20 #include "extensions/common/api/bluetooth.h" 21 #include "extensions/common/api/bluetooth.h"
21 #include "extensions/common/extension_builder.h" 22 #include "extensions/common/extension_builder.h"
22 #include "testing/gmock/include/gmock/gmock.h" 23 #include "testing/gmock/include/gmock/gmock.h"
23 #include "testing/gtest/include/gtest/gtest.h" 24 #include "testing/gtest/include/gtest/gtest.h"
24 25
25 namespace { 26 namespace {
26 27
27 const char kTestExtensionId[] = "test extension id"; 28 const char kTestExtensionId[] = "test extension id";
(...skipping 24 matching lines...) Expand all
52 ExtensionsTest::TearDown(); 53 ExtensionsTest::TearDown();
53 } 54 }
54 55
55 protected: 56 protected:
56 content::TestBrowserThreadBundle test_browser_thread_bundle_; 57 content::TestBrowserThreadBundle test_browser_thread_bundle_;
57 testing::StrictMock<device::MockBluetoothAdapter>* mock_adapter_; 58 testing::StrictMock<device::MockBluetoothAdapter>* mock_adapter_;
58 std::unique_ptr<BluetoothEventRouter> router_; 59 std::unique_ptr<BluetoothEventRouter> router_;
59 }; 60 };
60 61
61 TEST_F(BluetoothEventRouterTest, BluetoothEventListener) { 62 TEST_F(BluetoothEventRouterTest, BluetoothEventListener) {
62 router_->OnListenerAdded(); 63 EventListenerInfo info("", "", GURL(), nullptr);
64 router_->OnListenerAdded(info);
63 EXPECT_CALL(*mock_adapter_, RemoveObserver(testing::_)).Times(1); 65 EXPECT_CALL(*mock_adapter_, RemoveObserver(testing::_)).Times(1);
64 router_->OnListenerRemoved(); 66 router_->OnListenerRemoved(info);
65 } 67 }
66 68
67 TEST_F(BluetoothEventRouterTest, MultipleBluetoothEventListeners) { 69 TEST_F(BluetoothEventRouterTest, MultipleBluetoothEventListeners) {
68 router_->OnListenerAdded(); 70 EventListenerInfo info("", "", GURL(), nullptr);
rkc 2017/04/12 17:58:52 Can we expand this test (or add additional tests)
stevenjb 2017/04/12 18:08:56 It would be a fair bit of work to add a meaningful
69 router_->OnListenerAdded(); 71 router_->OnListenerAdded(info);
70 router_->OnListenerAdded(); 72 router_->OnListenerAdded(info);
71 router_->OnListenerRemoved(); 73 router_->OnListenerAdded(info);
72 router_->OnListenerRemoved(); 74 router_->OnListenerRemoved(info);
75 router_->OnListenerRemoved(info);
73 EXPECT_CALL(*mock_adapter_, RemoveObserver(testing::_)).Times(1); 76 EXPECT_CALL(*mock_adapter_, RemoveObserver(testing::_)).Times(1);
74 router_->OnListenerRemoved(); 77 router_->OnListenerRemoved(info);
75 } 78 }
76 79
77 TEST_F(BluetoothEventRouterTest, UnloadExtension) { 80 TEST_F(BluetoothEventRouterTest, UnloadExtension) {
78 scoped_refptr<const Extension> extension = 81 scoped_refptr<const Extension> extension =
79 ExtensionBuilder() 82 ExtensionBuilder()
80 .SetManifest(DictionaryBuilder() 83 .SetManifest(DictionaryBuilder()
81 .Set("name", "BT event router test") 84 .Set("name", "BT event router test")
82 .Set("version", "1.0") 85 .Set("version", "1.0")
83 .Set("manifest_version", 2) 86 .Set("manifest_version", 2)
84 .Build()) 87 .Build())
(...skipping 27 matching lines...) Expand all
112 testing::_, testing::_)).Times(1); 115 testing::_, testing::_)).Times(1);
113 116
114 router_->StartDiscoverySession(mock_adapter_, kTestExtensionId, 117 router_->StartDiscoverySession(mock_adapter_, kTestExtensionId,
115 base::Bind(&base::DoNothing), 118 base::Bind(&base::DoNothing),
116 base::Bind(&base::DoNothing)); 119 base::Bind(&base::DoNothing));
117 120
118 EXPECT_CALL(*mock_adapter_, RemoveObserver(testing::_)).Times(1); 121 EXPECT_CALL(*mock_adapter_, RemoveObserver(testing::_)).Times(1);
119 } 122 }
120 123
121 } // namespace extensions 124 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698