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

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

Issue 10949030: This converts the Shill clients to allow propagation of shill errors (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Review changes Created 8 years, 3 months 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/bind.h" 5 #include "base/bind.h"
6 #include "base/values.h" 6 #include "base/values.h"
7 #include "chromeos/dbus/shill_client_unittest_base.h" 7 #include "chromeos/dbus/shill_client_unittest_base.h"
8 #include "chromeos/dbus/shill_service_client.h" 8 #include "chromeos/dbus/shill_service_client.h"
9 #include "dbus/message.h" 9 #include "dbus/message.h"
10 #include "dbus/object_path.h" 10 #include "dbus/object_path.h"
11 #include "dbus/values_util.h" 11 #include "dbus/values_util.h"
12 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
13 #include "third_party/cros_system_api/dbus/service_constants.h" 13 #include "third_party/cros_system_api/dbus/service_constants.h"
14 14
15 using testing::_;
16
15 namespace chromeos { 17 namespace chromeos {
16 18
17 namespace { 19 namespace {
18 20
19 const char kExampleServicePath[] = "/foo/bar"; 21 const char kExampleServicePath[] = "/foo/bar";
20 22
21 } // namespace 23 } // namespace
22 24
23 class ShillServiceClientTest : public ShillClientUnittestBase { 25 class ShillServiceClientTest : public ShillClientUnittestBase {
24 public: 26 public:
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); 103 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty());
102 104
103 // Set expectations. 105 // Set expectations.
104 const base::StringValue value(kValue); 106 const base::StringValue value(kValue);
105 PrepareForMethodCall(flimflam::kSetPropertyFunction, 107 PrepareForMethodCall(flimflam::kSetPropertyFunction,
106 base::Bind(&ExpectStringAndValueArguments, 108 base::Bind(&ExpectStringAndValueArguments,
107 flimflam::kPassphraseProperty, 109 flimflam::kPassphraseProperty,
108 &value), 110 &value),
109 response.get()); 111 response.get());
110 // Call method. 112 // Call method.
113 MockClosure mock_closure;
114 MockErrorCallback mock_error_callback;
111 client_->SetProperty(dbus::ObjectPath(kExampleServicePath), 115 client_->SetProperty(dbus::ObjectPath(kExampleServicePath),
112 flimflam::kPassphraseProperty, 116 flimflam::kPassphraseProperty,
113 value, 117 value,
114 base::Bind(&ExpectNoResultValue)); 118 mock_closure.GetCallback(),
119 mock_error_callback.GetCallback());
120 EXPECT_CALL(mock_closure, Run()).Times(1);
121 EXPECT_CALL(mock_error_callback, Run(_, _)).Times(0);
122
115 // Run the message loop. 123 // Run the message loop.
116 message_loop_.RunAllPending(); 124 message_loop_.RunAllPending();
117 } 125 }
118 126
119 TEST_F(ShillServiceClientTest, ClearProperty) { 127 TEST_F(ShillServiceClientTest, ClearProperty) {
120 // Create response. 128 // Create response.
121 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); 129 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty());
122 130
123 // Set expectations. 131 // Set expectations.
124 PrepareForMethodCall(flimflam::kClearPropertyFunction, 132 PrepareForMethodCall(flimflam::kClearPropertyFunction,
125 base::Bind(&ExpectStringArgument, 133 base::Bind(&ExpectStringArgument,
126 flimflam::kPassphraseProperty), 134 flimflam::kPassphraseProperty),
127 response.get()); 135 response.get());
128 // Call method. 136 // Call method.
137 MockClosure mock_closure;
138 MockErrorCallback mock_error_callback;
129 client_->ClearProperty(dbus::ObjectPath(kExampleServicePath), 139 client_->ClearProperty(dbus::ObjectPath(kExampleServicePath),
130 flimflam::kPassphraseProperty, 140 flimflam::kPassphraseProperty,
131 base::Bind(&ExpectNoResultValue)); 141 mock_closure.GetCallback(),
142 mock_error_callback.GetCallback());
143 EXPECT_CALL(mock_closure, Run()).Times(1);
144 EXPECT_CALL(mock_error_callback, Run(_, _)).Times(0);
145
132 // Run the message loop. 146 // Run the message loop.
133 message_loop_.RunAllPending(); 147 message_loop_.RunAllPending();
134 } 148 }
135 149
136 TEST_F(ShillServiceClientTest, Connect) { 150 TEST_F(ShillServiceClientTest, Connect) {
137 // Create response. 151 // Create response.
138 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); 152 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty());
139 153
140 // Set expectations. 154 // Set expectations.
141 MockClosure mock_closure; 155 MockClosure mock_closure;
(...skipping 13 matching lines...) Expand all
155 169
156 TEST_F(ShillServiceClientTest, Disconnect) { 170 TEST_F(ShillServiceClientTest, Disconnect) {
157 // Create response. 171 // Create response.
158 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); 172 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty());
159 173
160 // Set expectations. 174 // Set expectations.
161 PrepareForMethodCall(flimflam::kDisconnectFunction, 175 PrepareForMethodCall(flimflam::kDisconnectFunction,
162 base::Bind(&ExpectNoArgument), 176 base::Bind(&ExpectNoArgument),
163 response.get()); 177 response.get());
164 // Call method. 178 // Call method.
179 MockClosure mock_closure;
180 MockErrorCallback mock_error_callback;
165 client_->Disconnect(dbus::ObjectPath(kExampleServicePath), 181 client_->Disconnect(dbus::ObjectPath(kExampleServicePath),
166 base::Bind(&ExpectNoResultValue)); 182 mock_closure.GetCallback(),
183 mock_error_callback.GetCallback());
184 EXPECT_CALL(mock_closure, Run()).Times(1);
185 EXPECT_CALL(mock_error_callback, Run(_, _)).Times(0);
186
167 // Run the message loop. 187 // Run the message loop.
168 message_loop_.RunAllPending(); 188 message_loop_.RunAllPending();
169 } 189 }
170 190
171 TEST_F(ShillServiceClientTest, Remove) { 191 TEST_F(ShillServiceClientTest, Remove) {
172 // Create response. 192 // Create response.
173 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); 193 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty());
174 194
175 // Set expectations. 195 // Set expectations.
176 PrepareForMethodCall(flimflam::kRemoveServiceFunction, 196 PrepareForMethodCall(flimflam::kRemoveServiceFunction,
177 base::Bind(&ExpectNoArgument), 197 base::Bind(&ExpectNoArgument),
178 response.get()); 198 response.get());
179 // Call method. 199 // Call method.
200 MockClosure mock_closure;
201 MockErrorCallback mock_error_callback;
180 client_->Remove(dbus::ObjectPath(kExampleServicePath), 202 client_->Remove(dbus::ObjectPath(kExampleServicePath),
181 base::Bind(&ExpectNoResultValue)); 203 mock_closure.GetCallback(),
204 mock_error_callback.GetCallback());
205 EXPECT_CALL(mock_closure, Run()).Times(1);
206 EXPECT_CALL(mock_error_callback, Run(_, _)).Times(0);
207
182 // Run the message loop. 208 // Run the message loop.
183 message_loop_.RunAllPending(); 209 message_loop_.RunAllPending();
184 } 210 }
185 211
186 TEST_F(ShillServiceClientTest, ActivateCellularModem) { 212 TEST_F(ShillServiceClientTest, ActivateCellularModem) {
187 const char kCarrier[] = "carrier"; 213 const char kCarrier[] = "carrier";
188 // Create response. 214 // Create response.
189 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); 215 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty());
190 216
191 // Set expectations. 217 // Set expectations.
192 PrepareForMethodCall(flimflam::kActivateCellularModemFunction, 218 PrepareForMethodCall(flimflam::kActivateCellularModemFunction,
193 base::Bind(&ExpectStringArgument, kCarrier), 219 base::Bind(&ExpectStringArgument, kCarrier),
194 response.get()); 220 response.get());
195 // Call method. 221 // Call method.
222 MockClosure mock_closure;
223 MockErrorCallback mock_error_callback;
196 client_->ActivateCellularModem(dbus::ObjectPath(kExampleServicePath), 224 client_->ActivateCellularModem(dbus::ObjectPath(kExampleServicePath),
197 kCarrier, 225 kCarrier,
198 base::Bind(&ExpectNoResultValue)); 226 mock_closure.GetCallback(),
227 mock_error_callback.GetCallback());
228 EXPECT_CALL(mock_closure, Run()).Times(1);
229 EXPECT_CALL(mock_error_callback, Run(_, _)).Times(0);
230
199 // Run the message loop. 231 // Run the message loop.
200 message_loop_.RunAllPending(); 232 message_loop_.RunAllPending();
201 } 233 }
202 234
203 TEST_F(ShillServiceClientTest, CallActivateCellularModemAndBlock) { 235 TEST_F(ShillServiceClientTest, CallActivateCellularModemAndBlock) {
204 const char kCarrier[] = "carrier"; 236 const char kCarrier[] = "carrier";
205 // Create response. 237 // Create response.
206 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); 238 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty());
207 239
208 // Set expectations. 240 // Set expectations.
209 PrepareForMethodCall(flimflam::kActivateCellularModemFunction, 241 PrepareForMethodCall(flimflam::kActivateCellularModemFunction,
210 base::Bind(&ExpectStringArgument, kCarrier), 242 base::Bind(&ExpectStringArgument, kCarrier),
211 response.get()); 243 response.get());
212 // Call method. 244 // Call method.
213 const bool result = client_->CallActivateCellularModemAndBlock( 245 const bool result = client_->CallActivateCellularModemAndBlock(
214 dbus::ObjectPath(kExampleServicePath), kCarrier); 246 dbus::ObjectPath(kExampleServicePath), kCarrier);
215 EXPECT_TRUE(result); 247 EXPECT_TRUE(result);
216 } 248 }
217 249
218 } // namespace chromeos 250 } // namespace chromeos
OLDNEW
« chromeos/dbus/shill_service_client.cc ('K') | « chromeos/dbus/shill_service_client.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698