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

Side by Side Diff: chromeos/dbus/mock_dbus_thread_manager.cc

Issue 49773003: ChromeOS: Remove MockDBusThreadManager. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 | Annotate | Revision Log
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 "chromeos/dbus/mock_dbus_thread_manager.h"
6
7 #include "base/message_loop/message_loop.h"
8 #include "chromeos/dbus/dbus_thread_manager_observer.h"
9 #include "chromeos/dbus/fake_bluetooth_adapter_client.h"
10 #include "chromeos/dbus/fake_bluetooth_agent_manager_client.h"
11 #include "chromeos/dbus/fake_bluetooth_device_client.h"
12 #include "chromeos/dbus/fake_bluetooth_input_client.h"
13 #include "chromeos/dbus/fake_bluetooth_profile_manager_client.h"
14 #include "chromeos/dbus/fake_gsm_sms_client.h"
15 #include "chromeos/dbus/fake_nfc_adapter_client.h"
16 #include "chromeos/dbus/fake_nfc_device_client.h"
17 #include "chromeos/dbus/fake_nfc_manager_client.h"
18 #include "chromeos/dbus/fake_nfc_tag_client.h"
19 #include "chromeos/dbus/fake_shill_device_client.h"
20 #include "chromeos/dbus/fake_shill_ipconfig_client.h"
21 #include "chromeos/dbus/ibus/mock_ibus_client.h"
22 #include "chromeos/dbus/ibus/mock_ibus_engine_factory_service.h"
23 #include "chromeos/dbus/ibus/mock_ibus_engine_service.h"
24 #include "chromeos/dbus/mock_cryptohome_client.h"
25 #include "chromeos/dbus/mock_shill_manager_client.h"
26 #include "chromeos/dbus/mock_shill_profile_client.h"
27 #include "chromeos/dbus/mock_shill_service_client.h"
28 #include "chromeos/dbus/mock_session_manager_client.h"
29 #include "chromeos/dbus/power_policy_controller.h"
30
31 using ::testing::AnyNumber;
32 using ::testing::Invoke;
33 using ::testing::Return;
34 using ::testing::ReturnNull;
35 using ::testing::_;
36
37 namespace chromeos {
38
39 namespace {
40
41 void GetMockSystemSalt(
42 const CryptohomeClient::GetSystemSaltCallback& callback) {
43 const char kStubSystemSalt[] = "stub_system_salt";
44 base::MessageLoop::current()->PostTask(
45 FROM_HERE,
46 base::Bind(callback,
47 DBUS_METHOD_CALL_SUCCESS,
48 std::vector<uint8>(
49 kStubSystemSalt,
50 kStubSystemSalt + arraysize(kStubSystemSalt) - 1)));
51 }
52
53 } // namespace
54
55 MockDBusThreadManager::MockDBusThreadManager()
56 : fake_bluetooth_adapter_client_(new FakeBluetoothAdapterClient),
57 fake_bluetooth_agent_manager_client_(
58 new FakeBluetoothAgentManagerClient),
59 fake_bluetooth_device_client_(new FakeBluetoothDeviceClient),
60 fake_bluetooth_input_client_(new FakeBluetoothInputClient),
61 fake_bluetooth_profile_manager_client_(
62 new FakeBluetoothProfileManagerClient),
63 fake_gsm_sms_client_(new FakeGsmSMSClient),
64 fake_nfc_adapter_client_(new FakeNfcAdapterClient()),
65 fake_nfc_device_client_(new FakeNfcDeviceClient()),
66 fake_nfc_manager_client_(new FakeNfcManagerClient()),
67 fake_nfc_tag_client_(new FakeNfcTagClient()),
68 fake_shill_device_client_(new FakeShillDeviceClient),
69 fake_shill_ipconfig_client_(new FakeShillIPConfigClient),
70 mock_cryptohome_client_(new MockCryptohomeClient),
71 mock_shill_manager_client_(new MockShillManagerClient),
72 mock_shill_profile_client_(new MockShillProfileClient),
73 mock_shill_service_client_(new MockShillServiceClient),
74 mock_session_manager_client_(new MockSessionManagerClient) {
75 EXPECT_CALL(*this, GetCryptohomeClient())
76 .WillRepeatedly(Return(mock_cryptohome_client()));
77 EXPECT_CALL(*this, GetBluetoothAdapterClient())
78 .WillRepeatedly(Return(fake_bluetooth_adapter_client_.get()));
79 EXPECT_CALL(*this, GetBluetoothAgentManagerClient())
80 .WillRepeatedly(Return(fake_bluetooth_agent_manager_client()));
81 EXPECT_CALL(*this, GetBluetoothDeviceClient())
82 .WillRepeatedly(Return(fake_bluetooth_device_client_.get()));
83 EXPECT_CALL(*this, GetBluetoothInputClient())
84 .WillRepeatedly(Return(fake_bluetooth_input_client_.get()));
85 EXPECT_CALL(*this, GetBluetoothProfileManagerClient())
86 .WillRepeatedly(Return(fake_bluetooth_profile_manager_client()));
87 EXPECT_CALL(*this, GetNfcAdapterClient())
88 .WillRepeatedly(Return(fake_nfc_adapter_client()));
89 EXPECT_CALL(*this, GetNfcDeviceClient())
90 .WillRepeatedly(Return(fake_nfc_device_client()));
91 EXPECT_CALL(*this, GetNfcManagerClient())
92 .WillRepeatedly(Return(fake_nfc_manager_client()));
93 EXPECT_CALL(*this, GetNfcTagClient())
94 .WillRepeatedly(Return(fake_nfc_tag_client()));
95 EXPECT_CALL(*this, GetShillDeviceClient())
96 .WillRepeatedly(Return(fake_shill_device_client()));
97 EXPECT_CALL(*this, GetShillIPConfigClient())
98 .WillRepeatedly(Return(fake_shill_ipconfig_client()));
99 EXPECT_CALL(*this, GetShillManagerClient())
100 .WillRepeatedly(Return(mock_shill_manager_client()));
101 EXPECT_CALL(*this, GetShillProfileClient())
102 .WillRepeatedly(Return(mock_shill_profile_client()));
103 EXPECT_CALL(*this, GetShillServiceClient())
104 .WillRepeatedly(Return(mock_shill_service_client()));
105 EXPECT_CALL(*this, GetGsmSMSClient())
106 .WillRepeatedly(Return(fake_gsm_sms_client()));
107 EXPECT_CALL(*this, GetSessionManagerClient())
108 .WillRepeatedly(Return(mock_session_manager_client_.get()));
109
110 EXPECT_CALL(*this, GetSystemBus())
111 .WillRepeatedly(ReturnNull());
112
113 // These observers calls are used in ChromeBrowserMainPartsChromeos.
114 EXPECT_CALL(*mock_session_manager_client_.get(), AddObserver(_))
115 .Times(AnyNumber());
116 EXPECT_CALL(*mock_session_manager_client_.get(), RemoveObserver(_))
117 .Times(AnyNumber());
118 EXPECT_CALL(*mock_session_manager_client_.get(), HasObserver(_))
119 .Times(AnyNumber());
120
121 // Called from AsyncMethodCaller ctor and dtor.
122 EXPECT_CALL(*mock_cryptohome_client_.get(), SetAsyncCallStatusHandlers(_, _))
123 .Times(AnyNumber());
124 EXPECT_CALL(*mock_cryptohome_client_.get(), ResetAsyncCallStatusHandlers())
125 .Times(AnyNumber());
126 // Called from various locations.
127 EXPECT_CALL(*mock_cryptohome_client_.get(), GetSystemSalt(_))
128 .WillRepeatedly(Invoke(&GetMockSystemSalt));
129 EXPECT_CALL(*mock_cryptohome_client_.get(), TpmIsEnabled(_))
130 .Times(AnyNumber());
131
132 // Called from GeolocationHandler::Init().
133 EXPECT_CALL(*mock_shill_manager_client_.get(), GetProperties(_))
134 .Times(AnyNumber());
135 EXPECT_CALL(*mock_shill_manager_client_.get(), AddPropertyChangedObserver(_))
136 .Times(AnyNumber());
137 EXPECT_CALL(*mock_shill_manager_client_.get(),
138 RemovePropertyChangedObserver(_))
139 .Times(AnyNumber());
140 }
141
142 MockDBusThreadManager::~MockDBusThreadManager() {
143 FOR_EACH_OBSERVER(DBusThreadManagerObserver, observers_,
144 OnDBusThreadManagerDestroying(this));
145 }
146
147 void MockDBusThreadManager::AddObserver(DBusThreadManagerObserver* observer) {
148 DCHECK(observer);
149 observers_.AddObserver(observer);
150 }
151
152 void MockDBusThreadManager::RemoveObserver(
153 DBusThreadManagerObserver* observer) {
154 DCHECK(observer);
155 observers_.RemoveObserver(observer);
156 }
157
158 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698