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/api/bluetooth/bluetooth_event_router.h" |
| 6 #include "chrome/test/base/testing_profile.h" |
| 7 #include "device/bluetooth/test/mock_bluetooth_adapter.h" |
| 8 #include "testing/gmock/include/gmock/gmock.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 |
| 11 namespace { |
| 12 |
| 13 const char* kAdapterAddress = "Mock Adapter address for testing"; |
| 14 const char* kName = "Mock Adapter name for testing"; |
| 15 |
| 16 } // namespace |
| 17 |
| 18 namespace extensions { |
| 19 |
| 20 class ExtensionBluetoothEventRouterTest : public testing::Test { |
| 21 public: |
| 22 ExtensionBluetoothEventRouterTest() |
| 23 : mock_adapter_(new testing::StrictMock<device::MockBluetoothAdapter>( |
| 24 kAdapterAddress, kName)), |
| 25 router_(&test_profile_) { |
| 26 router_.SetAdapterForTest(mock_adapter_); |
| 27 } |
| 28 |
| 29 protected: |
| 30 testing::StrictMock<device::MockBluetoothAdapter>* mock_adapter_; |
| 31 TestingProfile test_profile_; |
| 32 ExtensionBluetoothEventRouter router_; |
| 33 }; |
| 34 |
| 35 TEST_F(ExtensionBluetoothEventRouterTest, BluetoothEventListener) { |
| 36 router_.OnListenerAdded(); |
| 37 EXPECT_CALL(*mock_adapter_, RemoveObserver(testing::_)).Times(1); |
| 38 router_.OnListenerRemoved(); |
| 39 } |
| 40 |
| 41 TEST_F(ExtensionBluetoothEventRouterTest, MultipleBluetoothEventListeners) { |
| 42 router_.OnListenerAdded(); |
| 43 router_.OnListenerAdded(); |
| 44 router_.OnListenerAdded(); |
| 45 router_.OnListenerRemoved(); |
| 46 router_.OnListenerRemoved(); |
| 47 EXPECT_CALL(*mock_adapter_, RemoveObserver(testing::_)).Times(1); |
| 48 router_.OnListenerRemoved(); |
| 49 } |
| 50 |
| 51 } // namespace extensions |
OLD | NEW |