OLD | NEW |
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/logging.h" | 6 #include "base/logging.h" |
7 #include "base/memory/ref_counted.h" | 7 #include "base/memory/ref_counted.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "dbus/message.h" | 10 #include "dbus/message.h" |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 // payload to |response_string_|. | 70 // payload to |response_string_|. |
71 if (response) { | 71 if (response) { |
72 dbus::MessageReader reader(response); | 72 dbus::MessageReader reader(response); |
73 ASSERT_TRUE(reader.PopString(&response_string_)); | 73 ASSERT_TRUE(reader.PopString(&response_string_)); |
74 } | 74 } |
75 message_loop_.Quit(); | 75 message_loop_.Quit(); |
76 }; | 76 }; |
77 | 77 |
78 protected: | 78 protected: |
79 std::string response_string_; | 79 std::string response_string_; |
80 MessageLoop message_loop_; | 80 base::MessageLoop message_loop_; |
81 scoped_refptr<dbus::MockBus> mock_bus_; | 81 scoped_refptr<dbus::MockBus> mock_bus_; |
82 scoped_refptr<dbus::MockObjectProxy> mock_proxy_; | 82 scoped_refptr<dbus::MockObjectProxy> mock_proxy_; |
83 | 83 |
84 private: | 84 private: |
85 // Returns a response for the given method call. Used to implement | 85 // Returns a response for the given method call. Used to implement |
86 // CallMethodAndBlock() for |mock_proxy_|. | 86 // CallMethodAndBlock() for |mock_proxy_|. |
87 dbus::Response* CreateMockProxyResponse(dbus::MethodCall* method_call, | 87 dbus::Response* CreateMockProxyResponse(dbus::MethodCall* method_call, |
88 int timeout_ms) { | 88 int timeout_ms) { |
89 if (method_call->GetInterface() == "org.chromium.TestInterface" && | 89 if (method_call->GetInterface() == "org.chromium.TestInterface" && |
90 method_call->GetMember() == "Echo") { | 90 method_call->GetMember() == "Echo") { |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 // Call the method. | 172 // Call the method. |
173 proxy->CallMethod(&method_call, | 173 proxy->CallMethod(&method_call, |
174 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, | 174 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, |
175 base::Bind(&MockTest::OnResponse, | 175 base::Bind(&MockTest::OnResponse, |
176 base::Unretained(this))); | 176 base::Unretained(this))); |
177 // Run the message loop to let OnResponse be called. | 177 // Run the message loop to let OnResponse be called. |
178 message_loop_.Run(); | 178 message_loop_.Run(); |
179 | 179 |
180 EXPECT_EQ(kHello, response_string_); | 180 EXPECT_EQ(kHello, response_string_); |
181 } | 181 } |
OLD | NEW |