OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "chrome/browser/extensions/bluetooth_event_router.h" | |
6 #include "chrome/browser/extensions/event_names.h" | |
7 #include "chrome/test/base/testing_profile.h" | |
8 #include "device/bluetooth/test/mock_bluetooth_adapter.h" | |
9 #include "testing/gmock/include/gmock/gmock.h" | |
10 #include "testing/gtest/include/gtest/gtest.h" | |
11 | |
12 namespace { | |
13 | |
14 const char* kAdapterAddress = "Mock Adapter address for testing"; | |
15 const char* kName = "Mock Adapter name for testing"; | |
16 const char* kNonBluetoothEventName = "Non bluetooth event name"; | |
miket_OOO
2012/11/06 02:04:09
add vertical whitespace to balance the namespace {
youngki
2012/11/06 16:18:54
Done.
| |
17 } // namespace | |
18 | |
19 namespace extensions { | |
20 | |
21 class ExtensionBluetoothEventRouterTest : public testing::Test { | |
22 public: | |
23 ExtensionBluetoothEventRouterTest() | |
24 : mock_adapter_(new testing::StrictMock<device::MockBluetoothAdapter>( | |
25 kAdapterAddress, kName)), | |
26 router_(&profile_, mock_adapter_) { | |
27 } | |
28 | |
29 virtual ~ExtensionBluetoothEventRouterTest() { | |
30 EXPECT_CALL(*mock_adapter_, RemoveObserver(testing::_)); | |
31 } | |
32 | |
33 protected: | |
34 TestingProfile profile_; | |
35 testing::StrictMock<device::MockBluetoothAdapter>* mock_adapter_; | |
36 ExtensionBluetoothEventRouter router_; | |
37 }; | |
38 | |
39 TEST_F(ExtensionBluetoothEventRouterTest, GetAdapter) { | |
40 EXPECT_EQ(mock_adapter_, router_.adapter()); | |
41 } | |
42 | |
43 TEST_F(ExtensionBluetoothEventRouterTest, GetMutableAdapter) { | |
44 EXPECT_CALL(*mock_adapter_, AddObserver(testing::_)) | |
45 .WillOnce(testing::Return()); | |
46 EXPECT_EQ(mock_adapter_, router_.GetMutableAdapter()); | |
miket_OOO
2012/11/06 02:04:09
More on earlier comment: it seems that if you run
youngki
2012/11/06 16:18:54
Added a test case to make sure that AddObserver is
| |
47 } | |
48 | |
49 TEST_F(ExtensionBluetoothEventRouterTest, BluetoothEventListenerAdded) { | |
50 EXPECT_CALL(*mock_adapter_, AddObserver(testing::_)) | |
51 .WillOnce(testing::Return()); | |
52 router_.OnEventListenerAdded( | |
53 extensions::event_names::kBluetoothOnAvailabilityChanged); | |
54 } | |
55 | |
56 TEST_F(ExtensionBluetoothEventRouterTest, NonBluetoothEventListenerAdded) { | |
57 router_.OnEventListenerAdded(kNonBluetoothEventName); | |
58 } | |
59 | |
60 } // namespace extensions | |
OLD | NEW |