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

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

Powered by Google App Engine
This is Rietveld 408576698