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

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

Issue 11360200: Decouple bluetooth_event_router from extension_system. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Removed socket checks from creating and removing adapters. Created 8 years, 1 month 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
(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 "device/bluetooth/test/mock_bluetooth_socket.h"
bryeung 2012/11/13 16:16:15 you can remove all of the socket code from this no
youngki 2012/11/13 17:01:30 Done.
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
17 const int kSocketId = 1;
18 const int kAnotherSocketId = 2;
19
20 } // namespace
21
22 namespace extensions {
23
24 class ExtensionBluetoothEventRouterTest : public testing::Test {
25 public:
26 ExtensionBluetoothEventRouterTest()
27 : mock_adapter_(new testing::StrictMock<device::MockBluetoothAdapter>(
28 kAdapterAddress, kName)),
29 mock_socket_(new testing::NiceMock<device::MockBluetoothSocket>()),
30 mock_another_socket_(
31 new testing::NiceMock<device::MockBluetoothSocket>()),
32 router_(&test_profile_) {
33 router_.SetAdapterForTest(mock_adapter_);
34 }
35
36 protected:
37 testing::StrictMock<device::MockBluetoothAdapter>* mock_adapter_;
38 testing::NiceMock<device::MockBluetoothSocket>* mock_socket_;
39 testing::NiceMock<device::MockBluetoothSocket>* mock_another_socket_;
40 TestingProfile test_profile_;
41 ExtensionBluetoothEventRouter router_;
42 };
43
44 TEST_F(ExtensionBluetoothEventRouterTest, BluetoothEventListener) {
45 router_.OnListenerAdded();
46 EXPECT_CALL(*mock_adapter_, RemoveObserver(testing::_)).Times(1);
47 router_.OnListenerRemoved();
48 }
49
50 TEST_F(ExtensionBluetoothEventRouterTest, MultipleBluetoothEventListeners) {
51 router_.OnListenerAdded();
52 router_.OnListenerAdded();
53 router_.OnListenerAdded();
54 router_.OnListenerRemoved();
55 router_.OnListenerRemoved();
56 EXPECT_CALL(*mock_adapter_, RemoveObserver(testing::_)).Times(1);
57 router_.OnListenerRemoved();
58 }
59
60 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698