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

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

Issue 16998003: Update CrOS to use scoped_refptr<T>::get() rather than implicit "operator T*" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 7 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « chromeos/dbus/dbus_thread_manager.cc ('k') | chromeos/dbus/ibus/ibus_client_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "chromeos/dbus/gsm_sms_client.h" 5 #include "chromeos/dbus/gsm_sms_client.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "dbus/message.h" 10 #include "dbus/message.h"
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 options.bus_type = dbus::Bus::SYSTEM; 75 options.bus_type = dbus::Bus::SYSTEM;
76 mock_bus_ = new dbus::MockBus(options); 76 mock_bus_ = new dbus::MockBus(options);
77 77
78 // Create a mock proxy. 78 // Create a mock proxy.
79 mock_proxy_ = new dbus::MockObjectProxy(mock_bus_.get(), 79 mock_proxy_ = new dbus::MockObjectProxy(mock_bus_.get(),
80 kServiceName, 80 kServiceName,
81 dbus::ObjectPath(kObjectPath)); 81 dbus::ObjectPath(kObjectPath));
82 82
83 // Set an expectation so mock_proxy's ConnectToSignal() will use 83 // Set an expectation so mock_proxy's ConnectToSignal() will use
84 // OnConnectToSignal() to run the callback. 84 // OnConnectToSignal() to run the callback.
85 EXPECT_CALL(*mock_proxy_, ConnectToSignal( 85 EXPECT_CALL(*mock_proxy_.get(),
86 modemmanager::kModemManagerSMSInterface, 86 ConnectToSignal(modemmanager::kModemManagerSMSInterface,
87 modemmanager::kSMSReceivedSignal, _, _)) 87 modemmanager::kSMSReceivedSignal,
88 _,
89 _))
88 .WillRepeatedly(Invoke(this, &GsmSMSClientTest::OnConnectToSignal)); 90 .WillRepeatedly(Invoke(this, &GsmSMSClientTest::OnConnectToSignal));
89 91
90 // Set an expectation so mock_bus's GetObjectProxy() for the given 92 // Set an expectation so mock_bus's GetObjectProxy() for the given
91 // service name and the object path will return mock_proxy_. 93 // service name and the object path will return mock_proxy_.
92 EXPECT_CALL(*mock_bus_, GetObjectProxy(kServiceName, 94 EXPECT_CALL(*mock_bus_.get(),
93 dbus::ObjectPath(kObjectPath))) 95 GetObjectProxy(kServiceName, dbus::ObjectPath(kObjectPath)))
94 .WillOnce(Return(mock_proxy_.get())); 96 .WillOnce(Return(mock_proxy_.get()));
95 97
96 // ShutdownAndBlock() will be called in TearDown(). 98 // ShutdownAndBlock() will be called in TearDown().
97 EXPECT_CALL(*mock_bus_, ShutdownAndBlock()).WillOnce(Return()); 99 EXPECT_CALL(*mock_bus_.get(), ShutdownAndBlock()).WillOnce(Return());
98 100
99 // Create a client with the mock bus. 101 // Create a client with the mock bus.
100 client_.reset(GsmSMSClient::Create(REAL_DBUS_CLIENT_IMPLEMENTATION, 102 client_.reset(
101 mock_bus_)); 103 GsmSMSClient::Create(REAL_DBUS_CLIENT_IMPLEMENTATION, mock_bus_.get()));
102 } 104 }
103 105
104 virtual void TearDown() OVERRIDE { 106 virtual void TearDown() OVERRIDE {
105 mock_bus_->ShutdownAndBlock(); 107 mock_bus_->ShutdownAndBlock();
106 } 108 }
107 109
108 // Handles Delete method call. 110 // Handles Delete method call.
109 void OnDelete(dbus::MethodCall* method_call, 111 void OnDelete(dbus::MethodCall* method_call,
110 int timeout_ms, 112 int timeout_ms,
111 const dbus::ObjectProxy::ResponseCallback& callback) { 113 const dbus::ObjectProxy::ResponseCallback& callback) {
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 // Reset handler. 216 // Reset handler.
215 client_->ResetSmsReceivedHandler(kServiceName, dbus::ObjectPath(kObjectPath)); 217 client_->ResetSmsReceivedHandler(kServiceName, dbus::ObjectPath(kObjectPath));
216 // Send signal again. 218 // Send signal again.
217 sms_received_callback_.Run(&signal); 219 sms_received_callback_.Run(&signal);
218 } 220 }
219 221
220 TEST_F(GsmSMSClientTest, Delete) { 222 TEST_F(GsmSMSClientTest, Delete) {
221 // Set expectations. 223 // Set expectations.
222 const uint32 kIndex = 42; 224 const uint32 kIndex = 42;
223 expected_index_ = kIndex; 225 expected_index_ = kIndex;
224 EXPECT_CALL(*mock_proxy_, CallMethod(_, _, _)) 226 EXPECT_CALL(*mock_proxy_.get(), CallMethod(_, _, _))
225 .WillOnce(Invoke(this, &GsmSMSClientTest::OnDelete)); 227 .WillOnce(Invoke(this, &GsmSMSClientTest::OnDelete));
226 MockDeleteCallback callback; 228 MockDeleteCallback callback;
227 EXPECT_CALL(callback, Run()).Times(1); 229 EXPECT_CALL(callback, Run()).Times(1);
228 // Create response. 230 // Create response.
229 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); 231 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty());
230 response_ = response.get(); 232 response_ = response.get();
231 // Call Delete. 233 // Call Delete.
232 client_->Delete(kServiceName, dbus::ObjectPath(kObjectPath), kIndex, 234 client_->Delete(kServiceName, dbus::ObjectPath(kObjectPath), kIndex,
233 base::Bind(&MockDeleteCallback::Run, 235 base::Bind(&MockDeleteCallback::Run,
234 base::Unretained(&callback))); 236 base::Unretained(&callback)));
235 237
236 // Run the message loop. 238 // Run the message loop.
237 message_loop_.RunUntilIdle(); 239 message_loop_.RunUntilIdle();
238 } 240 }
239 241
240 TEST_F(GsmSMSClientTest, Get) { 242 TEST_F(GsmSMSClientTest, Get) {
241 // Set expectations. 243 // Set expectations.
242 const uint32 kIndex = 42; 244 const uint32 kIndex = 42;
243 expected_index_ = kIndex; 245 expected_index_ = kIndex;
244 EXPECT_CALL(*mock_proxy_, CallMethod(_, _, _)) 246 EXPECT_CALL(*mock_proxy_.get(), CallMethod(_, _, _))
245 .WillOnce(Invoke(this, &GsmSMSClientTest::OnGet)); 247 .WillOnce(Invoke(this, &GsmSMSClientTest::OnGet));
246 MockGetCallback callback; 248 MockGetCallback callback;
247 EXPECT_CALL(callback, Run(_)) 249 EXPECT_CALL(callback, Run(_))
248 .WillOnce(Invoke(this, &GsmSMSClientTest::CheckResult)); 250 .WillOnce(Invoke(this, &GsmSMSClientTest::CheckResult));
249 // Create response. 251 // Create response.
250 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); 252 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty());
251 dbus::MessageWriter writer(response.get()); 253 dbus::MessageWriter writer(response.get());
252 dbus::MessageWriter array_writer(NULL); 254 dbus::MessageWriter array_writer(NULL);
253 writer.OpenArray("{sv}", &array_writer); 255 writer.OpenArray("{sv}", &array_writer);
254 dbus::MessageWriter entry_writer(NULL); 256 dbus::MessageWriter entry_writer(NULL);
(...skipping 17 matching lines...) Expand all
272 // Call Delete. 274 // Call Delete.
273 client_->Get(kServiceName, dbus::ObjectPath(kObjectPath), kIndex, 275 client_->Get(kServiceName, dbus::ObjectPath(kObjectPath), kIndex,
274 base::Bind(&MockGetCallback::Run, base::Unretained(&callback))); 276 base::Bind(&MockGetCallback::Run, base::Unretained(&callback)));
275 277
276 // Run the message loop. 278 // Run the message loop.
277 message_loop_.RunUntilIdle(); 279 message_loop_.RunUntilIdle();
278 } 280 }
279 281
280 TEST_F(GsmSMSClientTest, List) { 282 TEST_F(GsmSMSClientTest, List) {
281 // Set expectations. 283 // Set expectations.
282 EXPECT_CALL(*mock_proxy_, CallMethod(_, _, _)) 284 EXPECT_CALL(*mock_proxy_.get(), CallMethod(_, _, _))
283 .WillOnce(Invoke(this, &GsmSMSClientTest::OnList)); 285 .WillOnce(Invoke(this, &GsmSMSClientTest::OnList));
284 MockListCallback callback; 286 MockListCallback callback;
285 EXPECT_CALL(callback, Run(_)) 287 EXPECT_CALL(callback, Run(_))
286 .WillOnce(Invoke(this, &GsmSMSClientTest::CheckResult)); 288 .WillOnce(Invoke(this, &GsmSMSClientTest::CheckResult));
287 // Create response. 289 // Create response.
288 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); 290 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty());
289 dbus::MessageWriter writer(response.get()); 291 dbus::MessageWriter writer(response.get());
290 dbus::MessageWriter array_writer(NULL); 292 dbus::MessageWriter array_writer(NULL);
291 writer.OpenArray("a{sv}", &array_writer); 293 writer.OpenArray("a{sv}", &array_writer);
292 dbus::MessageWriter sub_array_writer(NULL); 294 dbus::MessageWriter sub_array_writer(NULL);
(...skipping 22 matching lines...) Expand all
315 // Call List. 317 // Call List.
316 client_->List(kServiceName, dbus::ObjectPath(kObjectPath), 318 client_->List(kServiceName, dbus::ObjectPath(kObjectPath),
317 base::Bind(&MockListCallback::Run, 319 base::Bind(&MockListCallback::Run,
318 base::Unretained(&callback))); 320 base::Unretained(&callback)));
319 321
320 // Run the message loop. 322 // Run the message loop.
321 message_loop_.RunUntilIdle(); 323 message_loop_.RunUntilIdle();
322 } 324 }
323 325
324 } // namespace chromeos 326 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/dbus/dbus_thread_manager.cc ('k') | chromeos/dbus/ibus/ibus_client_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698