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

Side by Side Diff: chromeos/dbus/shill_client_unittest_base.h

Issue 681723003: Add new shill client for VPN (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixes nit from Steven Created 6 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
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 #ifndef CHROMEOS_DBUS_SHILL_CLIENT_UNITTEST_BASE_H_ 5 #ifndef CHROMEOS_DBUS_SHILL_CLIENT_UNITTEST_BASE_H_
6 #define CHROMEOS_DBUS_SHILL_CLIENT_UNITTEST_BASE_H_ 6 #define CHROMEOS_DBUS_SHILL_CLIENT_UNITTEST_BASE_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/message_loop/message_loop.h" 12 #include "base/message_loop/message_loop.h"
13 #include "chromeos/dbus/dbus_method_call_status.h" 13 #include "chromeos/dbus/dbus_method_call_status.h"
14 #include "chromeos/dbus/shill_client_helper.h" 14 #include "chromeos/dbus/shill_client_helper.h"
15 #include "chromeos/dbus/shill_property_changed_observer.h" 15 #include "chromeos/dbus/shill_property_changed_observer.h"
16 #include "chromeos/dbus/shill_third_party_vpn_observer.h"
16 #include "dbus/mock_bus.h" 17 #include "dbus/mock_bus.h"
17 #include "dbus/mock_object_proxy.h" 18 #include "dbus/mock_object_proxy.h"
18 #include "dbus/object_proxy.h" 19 #include "dbus/object_proxy.h"
19 #include "testing/gtest/include/gtest/gtest.h" 20 #include "testing/gtest/include/gtest/gtest.h"
20 21
21 using ::testing::MatcherInterface; 22 using ::testing::MatcherInterface;
22 using ::testing::MatchResultListener; 23 using ::testing::MatchResultListener;
23 using ::testing::Matcher; 24 using ::testing::Matcher;
24 using ::testing::MakeMatcher; 25 using ::testing::MakeMatcher;
25 26
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 protected: 108 protected:
108 // A callback to intercept and check the method call arguments. 109 // A callback to intercept and check the method call arguments.
109 typedef base::Callback<void( 110 typedef base::Callback<void(
110 dbus::MessageReader* reader)> ArgumentCheckCallback; 111 dbus::MessageReader* reader)> ArgumentCheckCallback;
111 112
112 // Sets expectations for called method name and arguments, and sets response. 113 // Sets expectations for called method name and arguments, and sets response.
113 void PrepareForMethodCall(const std::string& method_name, 114 void PrepareForMethodCall(const std::string& method_name,
114 const ArgumentCheckCallback& argument_checker, 115 const ArgumentCheckCallback& argument_checker,
115 dbus::Response* response); 116 dbus::Response* response);
116 117
118 // Sends platform message signal to the tested client.
119 void SendPlatformMessageSignal(dbus::Signal* signal);
120
121 // Sends packet received signal to the tested client.
122 void SendPacketReceievedSignal(dbus::Signal* signal);
123
117 // Sends property changed signal to the tested client. 124 // Sends property changed signal to the tested client.
118 void SendPropertyChangedSignal(dbus::Signal* signal); 125 void SendPropertyChangedSignal(dbus::Signal* signal);
119 126
120 // Checks the name and the value which are sent by PropertyChanged signal. 127 // Checks the name and the value which are sent by PropertyChanged signal.
121 static void ExpectPropertyChanged(const std::string& expected_name, 128 static void ExpectPropertyChanged(const std::string& expected_name,
122 const base::Value* expected_value, 129 const base::Value* expected_value,
123 const std::string& name, 130 const std::string& name,
124 const base::Value& value); 131 const base::Value& value);
125 132
126 // Expects the reader to be empty. 133 // Expects the reader to be empty.
127 static void ExpectNoArgument(dbus::MessageReader* reader); 134 static void ExpectNoArgument(dbus::MessageReader* reader);
128 135
136 // Expects the reader to have a uint32_t
137 static void ExpectUint32Argument(uint32_t expected_value,
138 dbus::MessageReader* reader);
139
140 // Expects the reader to have an array of bytes
141 static void ExpectArrayOfBytesArgument(
142 const std::string& expected_bytes,
143 dbus::MessageReader* reader);
144
129 // Expects the reader to have a string. 145 // Expects the reader to have a string.
130 static void ExpectStringArgument(const std::string& expected_string, 146 static void ExpectStringArgument(const std::string& expected_string,
131 dbus::MessageReader* reader); 147 dbus::MessageReader* reader);
132 148
133 static void ExpectArrayOfStringsArgument( 149 static void ExpectArrayOfStringsArgument(
134 const std::vector<std::string>& expected_strings, 150 const std::vector<std::string>& expected_strings,
135 dbus::MessageReader* reader); 151 dbus::MessageReader* reader);
136 152
137 // Expects the reader to have a Value. 153 // Expects the reader to have a Value.
138 static void ExpectValueArgument(const base::Value* expected_value, 154 static void ExpectValueArgument(const base::Value* expected_value,
139 dbus::MessageReader* reader); 155 dbus::MessageReader* reader);
140 156
141 // Expects the reader to have a string and a Value. 157 // Expects the reader to have a string and a Value.
142 static void ExpectStringAndValueArguments(const std::string& expected_string, 158 static void ExpectStringAndValueArguments(const std::string& expected_string,
143 const base::Value* expected_value, 159 const base::Value* expected_value,
144 dbus::MessageReader* reader); 160 dbus::MessageReader* reader);
145 161
146 // Expects the reader to have a string-to-variant dictionary. 162 // Expects the reader to have a string-to-variant dictionary.
147 static void ExpectDictionaryValueArgument( 163 static void ExpectDictionaryValueArgument(
148 const base::DictionaryValue* expected_dictionary, 164 const base::DictionaryValue* expected_dictionary,
165 bool string_valued,
149 dbus::MessageReader* reader); 166 dbus::MessageReader* reader);
150 167
151 // Creates a DictionaryValue with example Service properties. The caller owns 168 // Creates a DictionaryValue with example Service properties. The caller owns
152 // the result. 169 // the result.
153 static base::DictionaryValue* CreateExampleServiceProperties(); 170 static base::DictionaryValue* CreateExampleServiceProperties();
154 171
155 // Expects the call status to be SUCCESS. 172 // Expects the call status to be SUCCESS.
156 static void ExpectNoResultValue(DBusMethodCallStatus call_status); 173 static void ExpectNoResultValue(DBusMethodCallStatus call_status);
157 174
158 // Checks the result and expects the call status to be SUCCESS. 175 // Checks the result and expects the call status to be SUCCESS.
(...skipping 25 matching lines...) Expand all
184 const base::DictionaryValue& result); 201 const base::DictionaryValue& result);
185 202
186 // A message loop to emulate asynchronous behavior. 203 // A message loop to emulate asynchronous behavior.
187 base::MessageLoop message_loop_; 204 base::MessageLoop message_loop_;
188 // The mock bus. 205 // The mock bus.
189 scoped_refptr<dbus::MockBus> mock_bus_; 206 scoped_refptr<dbus::MockBus> mock_bus_;
190 207
191 private: 208 private:
192 // Checks the requested interface name and signal name. 209 // Checks the requested interface name and signal name.
193 // Used to implement the mock proxy. 210 // Used to implement the mock proxy.
194 void OnConnectToSignal( 211 void OnConnectToPlatformMessage(
195 const std::string& interface_name, 212 const std::string& interface_name,
196 const std::string& signal_name, 213 const std::string& signal_name,
197 const dbus::ObjectProxy::SignalCallback& signal_callback, 214 const dbus::ObjectProxy::SignalCallback& signal_callback,
215 const dbus::ObjectProxy::OnConnectedCallback& on_connected_callback);
216
217 // Checks the requested interface name and signal name.
218 // Used to implement the mock proxy.
219 void OnConnectToPacketReceived(
220 const std::string& interface_name,
221 const std::string& signal_name,
222 const dbus::ObjectProxy::SignalCallback& signal_callback,
223 const dbus::ObjectProxy::OnConnectedCallback& on_connected_callback);
224
225 // Checks the requested interface name and signal name.
226 // Used to implement the mock proxy.
227 void OnConnectToPropertyChanged(
228 const std::string& interface_name,
229 const std::string& signal_name,
230 const dbus::ObjectProxy::SignalCallback& signal_callback,
198 const dbus::ObjectProxy::OnConnectedCallback& on_connected_callback); 231 const dbus::ObjectProxy::OnConnectedCallback& on_connected_callback);
199 232
200 // Checks the content of the method call and returns the response. 233 // Checks the content of the method call and returns the response.
201 // Used to implement the mock proxy. 234 // Used to implement the mock proxy.
202 void OnCallMethod( 235 void OnCallMethod(
203 dbus::MethodCall* method_call, 236 dbus::MethodCall* method_call,
204 int timeout_ms, 237 int timeout_ms,
205 const dbus::ObjectProxy::ResponseCallback& response_callback); 238 const dbus::ObjectProxy::ResponseCallback& response_callback);
206 239
207 // Checks the content of the method call and returns the response. 240 // Checks the content of the method call and returns the response.
208 // Used to implement the mock proxy. 241 // Used to implement the mock proxy.
209 void OnCallMethodWithErrorCallback( 242 void OnCallMethodWithErrorCallback(
210 dbus::MethodCall* method_call, 243 dbus::MethodCall* method_call,
211 int timeout_ms, 244 int timeout_ms,
212 const dbus::ObjectProxy::ResponseCallback& response_callback, 245 const dbus::ObjectProxy::ResponseCallback& response_callback,
213 const dbus::ObjectProxy::ErrorCallback& error_callback); 246 const dbus::ObjectProxy::ErrorCallback& error_callback);
214 247
215 // The interface name. 248 // The interface name.
216 const std::string interface_name_; 249 const std::string interface_name_;
217 // The object path. 250 // The object path.
218 const dbus::ObjectPath object_path_; 251 const dbus::ObjectPath object_path_;
219 // The mock object proxy. 252 // The mock object proxy.
220 scoped_refptr<dbus::MockObjectProxy> mock_proxy_; 253 scoped_refptr<dbus::MockObjectProxy> mock_proxy_;
254 // The PlatformMessage signal handler given by the tested client.
255 dbus::ObjectProxy::SignalCallback platform_message_handler_;
256 // The PacketReceived signal handler given by the tested client.
257 dbus::ObjectProxy::SignalCallback packet_receieved__handler_;
221 // The PropertyChanged signal handler given by the tested client. 258 // The PropertyChanged signal handler given by the tested client.
222 dbus::ObjectProxy::SignalCallback property_changed_handler_; 259 dbus::ObjectProxy::SignalCallback property_changed_handler_;
223 // The name of the method which is expected to be called. 260 // The name of the method which is expected to be called.
224 std::string expected_method_name_; 261 std::string expected_method_name_;
225 // The response which the mock object proxy returns. 262 // The response which the mock object proxy returns.
226 dbus::Response* response_; 263 dbus::Response* response_;
227 // A callback to intercept and check the method call arguments. 264 // A callback to intercept and check the method call arguments.
228 ArgumentCheckCallback argument_checker_; 265 ArgumentCheckCallback argument_checker_;
229 }; 266 };
230 267
231 } // namespace chromeos 268 } // namespace chromeos
232 269
233 #endif // CHROMEOS_DBUS_SHILL_CLIENT_UNITTEST_BASE_H_ 270 #endif // CHROMEOS_DBUS_SHILL_CLIENT_UNITTEST_BASE_H_
OLDNEW
« no previous file with comments | « chromeos/dbus/fake_shill_third_party_vpn_driver_client.cc ('k') | chromeos/dbus/shill_client_unittest_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698