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

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

Issue 10915106: Renaming instances of "flimflam" with "shill", now that we're only (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Upload after merge 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
« no previous file with comments | « chromeos/dbus/shill_manager_client.cc ('k') | chromeos/dbus/shill_network_client.h » ('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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/values.h" 6 #include "base/values.h"
7 #include "chromeos/dbus/flimflam_client_unittest_base.h" 7 #include "chromeos/dbus/shill_client_unittest_base.h"
8 #include "chromeos/dbus/flimflam_manager_client.h" 8 #include "chromeos/dbus/shill_manager_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 namespace chromeos { 15 namespace chromeos {
16 16
17 namespace { 17 namespace {
18 18
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 flimflam::kSSIDProperty, 89 flimflam::kSSIDProperty,
90 base::Value::CreateStringValue("testssid")); 90 base::Value::CreateStringValue("testssid"));
91 properties->SetWithoutPathExpansion( 91 properties->SetWithoutPathExpansion(
92 flimflam::kSecurityProperty, 92 flimflam::kSecurityProperty,
93 base::Value::CreateStringValue(flimflam::kSecurityPsk)); 93 base::Value::CreateStringValue(flimflam::kSecurityPsk));
94 return properties; 94 return properties;
95 } 95 }
96 96
97 } // namespace 97 } // namespace
98 98
99 class FlimflamManagerClientTest : public FlimflamClientUnittestBase { 99 class ShillManagerClientTest : public ShillClientUnittestBase {
100 public: 100 public:
101 FlimflamManagerClientTest() 101 ShillManagerClientTest()
102 : FlimflamClientUnittestBase( 102 : ShillClientUnittestBase(
103 flimflam::kFlimflamManagerInterface, 103 flimflam::kFlimflamManagerInterface,
104 dbus::ObjectPath(flimflam::kFlimflamServicePath)) { 104 dbus::ObjectPath(flimflam::kFlimflamServicePath)) {
105 } 105 }
106 106
107 virtual void SetUp() { 107 virtual void SetUp() {
108 FlimflamClientUnittestBase::SetUp(); 108 ShillClientUnittestBase::SetUp();
109 // Create a client with the mock bus. 109 // Create a client with the mock bus.
110 client_.reset(FlimflamManagerClient::Create(REAL_DBUS_CLIENT_IMPLEMENTATION, 110 client_.reset(ShillManagerClient::Create(REAL_DBUS_CLIENT_IMPLEMENTATION,
111 mock_bus_)); 111 mock_bus_));
112 // Run the message loop to run the signal connection result callback. 112 // Run the message loop to run the signal connection result callback.
113 message_loop_.RunAllPending(); 113 message_loop_.RunAllPending();
114 } 114 }
115 115
116 virtual void TearDown() { 116 virtual void TearDown() {
117 FlimflamClientUnittestBase::TearDown(); 117 ShillClientUnittestBase::TearDown();
118 } 118 }
119 119
120 protected: 120 protected:
121 scoped_ptr<FlimflamManagerClient> client_; 121 scoped_ptr<ShillManagerClient> client_;
122 }; 122 };
123 123
124 TEST_F(FlimflamManagerClientTest, PropertyChanged) { 124 TEST_F(ShillManagerClientTest, PropertyChanged) {
125 // Create a signal. 125 // Create a signal.
126 base::FundamentalValue kOfflineMode(true); 126 base::FundamentalValue kOfflineMode(true);
127 dbus::Signal signal(flimflam::kFlimflamManagerInterface, 127 dbus::Signal signal(flimflam::kFlimflamManagerInterface,
128 flimflam::kMonitorPropertyChanged); 128 flimflam::kMonitorPropertyChanged);
129 dbus::MessageWriter writer(&signal); 129 dbus::MessageWriter writer(&signal);
130 writer.AppendString(flimflam::kOfflineModeProperty); 130 writer.AppendString(flimflam::kOfflineModeProperty);
131 dbus::AppendBasicTypeValueData(&writer, kOfflineMode); 131 dbus::AppendBasicTypeValueData(&writer, kOfflineMode);
132 132
133 // Set expectations. 133 // Set expectations.
134 client_->SetPropertyChangedHandler(base::Bind(&ExpectPropertyChanged, 134 client_->SetPropertyChangedHandler(base::Bind(&ExpectPropertyChanged,
135 flimflam::kOfflineModeProperty, 135 flimflam::kOfflineModeProperty,
136 &kOfflineMode)); 136 &kOfflineMode));
137 // Run the signal callback. 137 // Run the signal callback.
138 SendPropertyChangedSignal(&signal); 138 SendPropertyChangedSignal(&signal);
139 139
140 // Reset the handler. 140 // Reset the handler.
141 client_->ResetPropertyChangedHandler(); 141 client_->ResetPropertyChangedHandler();
142 } 142 }
143 143
144 TEST_F(FlimflamManagerClientTest, GetProperties) { 144 TEST_F(ShillManagerClientTest, GetProperties) {
145 // Create response. 145 // Create response.
146 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); 146 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty());
147 dbus::MessageWriter writer(response.get()); 147 dbus::MessageWriter writer(response.get());
148 dbus::MessageWriter array_writer(NULL); 148 dbus::MessageWriter array_writer(NULL);
149 writer.OpenArray("{sv}", &array_writer); 149 writer.OpenArray("{sv}", &array_writer);
150 dbus::MessageWriter entry_writer(NULL); 150 dbus::MessageWriter entry_writer(NULL);
151 array_writer.OpenDictEntry(&entry_writer); 151 array_writer.OpenDictEntry(&entry_writer);
152 entry_writer.AppendString(flimflam::kOfflineModeProperty); 152 entry_writer.AppendString(flimflam::kOfflineModeProperty);
153 entry_writer.AppendVariantOfBool(true); 153 entry_writer.AppendVariantOfBool(true);
154 array_writer.CloseContainer(&entry_writer); 154 array_writer.CloseContainer(&entry_writer);
155 writer.CloseContainer(&array_writer); 155 writer.CloseContainer(&array_writer);
156 156
157 // Create the expected value. 157 // Create the expected value.
158 base::DictionaryValue value; 158 base::DictionaryValue value;
159 value.SetWithoutPathExpansion(flimflam::kOfflineModeProperty, 159 value.SetWithoutPathExpansion(flimflam::kOfflineModeProperty,
160 base::Value::CreateBooleanValue(true)); 160 base::Value::CreateBooleanValue(true));
161 // Set expectations. 161 // Set expectations.
162 PrepareForMethodCall(flimflam::kGetPropertiesFunction, 162 PrepareForMethodCall(flimflam::kGetPropertiesFunction,
163 base::Bind(&ExpectNoArgument), 163 base::Bind(&ExpectNoArgument),
164 response.get()); 164 response.get());
165 // Call method. 165 // Call method.
166 client_->GetProperties(base::Bind(&ExpectDictionaryValueResult, 166 client_->GetProperties(base::Bind(&ExpectDictionaryValueResult,
167 &value)); 167 &value));
168 // Run the message loop. 168 // Run the message loop.
169 message_loop_.RunAllPending(); 169 message_loop_.RunAllPending();
170 } 170 }
171 171
172 TEST_F(FlimflamManagerClientTest, CallGetPropertiesAndBlock) { 172 TEST_F(ShillManagerClientTest, CallGetPropertiesAndBlock) {
173 // Create response. 173 // Create response.
174 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); 174 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty());
175 dbus::MessageWriter writer(response.get()); 175 dbus::MessageWriter writer(response.get());
176 dbus::MessageWriter array_writer(NULL); 176 dbus::MessageWriter array_writer(NULL);
177 writer.OpenArray("{sv}", &array_writer); 177 writer.OpenArray("{sv}", &array_writer);
178 dbus::MessageWriter entry_writer(NULL); 178 dbus::MessageWriter entry_writer(NULL);
179 array_writer.OpenDictEntry(&entry_writer); 179 array_writer.OpenDictEntry(&entry_writer);
180 entry_writer.AppendString(flimflam::kOfflineModeProperty); 180 entry_writer.AppendString(flimflam::kOfflineModeProperty);
181 entry_writer.AppendVariantOfBool(true); 181 entry_writer.AppendVariantOfBool(true);
182 array_writer.CloseContainer(&entry_writer); 182 array_writer.CloseContainer(&entry_writer);
183 writer.CloseContainer(&array_writer); 183 writer.CloseContainer(&array_writer);
184 184
185 // Create the expected value. 185 // Create the expected value.
186 base::DictionaryValue value; 186 base::DictionaryValue value;
187 value.SetWithoutPathExpansion(flimflam::kOfflineModeProperty, 187 value.SetWithoutPathExpansion(flimflam::kOfflineModeProperty,
188 base::Value::CreateBooleanValue(true)); 188 base::Value::CreateBooleanValue(true));
189 // Set expectations. 189 // Set expectations.
190 PrepareForMethodCall(flimflam::kGetPropertiesFunction, 190 PrepareForMethodCall(flimflam::kGetPropertiesFunction,
191 base::Bind(&ExpectNoArgument), 191 base::Bind(&ExpectNoArgument),
192 response.get()); 192 response.get());
193 // Call method. 193 // Call method.
194 scoped_ptr<base::DictionaryValue> result( 194 scoped_ptr<base::DictionaryValue> result(
195 client_->CallGetPropertiesAndBlock()); 195 client_->CallGetPropertiesAndBlock());
196 EXPECT_TRUE(value.Equals(result.get())); 196 EXPECT_TRUE(value.Equals(result.get()));
197 } 197 }
198 198
199 TEST_F(FlimflamManagerClientTest, SetProperty) { 199 TEST_F(ShillManagerClientTest, SetProperty) {
200 // Create response. 200 // Create response.
201 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); 201 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty());
202 // Set expectations. 202 // Set expectations.
203 base::StringValue value("portal list"); 203 base::StringValue value("portal list");
204 PrepareForMethodCall(flimflam::kSetPropertyFunction, 204 PrepareForMethodCall(flimflam::kSetPropertyFunction,
205 base::Bind(ExpectStringAndValueArguments, 205 base::Bind(ExpectStringAndValueArguments,
206 flimflam::kCheckPortalListProperty, 206 flimflam::kCheckPortalListProperty,
207 &value), 207 &value),
208 response.get()); 208 response.get());
209 // Call method. 209 // Call method.
210 client_->SetProperty(flimflam::kCheckPortalListProperty, 210 client_->SetProperty(flimflam::kCheckPortalListProperty,
211 value, 211 value,
212 base::Bind(&ExpectNoResultValue)); 212 base::Bind(&ExpectNoResultValue));
213 // Run the message loop. 213 // Run the message loop.
214 message_loop_.RunAllPending(); 214 message_loop_.RunAllPending();
215 } 215 }
216 216
217 TEST_F(FlimflamManagerClientTest, RequestScan) { 217 TEST_F(ShillManagerClientTest, RequestScan) {
218 // Create response. 218 // Create response.
219 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); 219 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty());
220 // Set expectations. 220 // Set expectations.
221 PrepareForMethodCall(flimflam::kRequestScanFunction, 221 PrepareForMethodCall(flimflam::kRequestScanFunction,
222 base::Bind(&ExpectStringArgument, flimflam::kTypeWifi), 222 base::Bind(&ExpectStringArgument, flimflam::kTypeWifi),
223 response.get()); 223 response.get());
224 // Call method. 224 // Call method.
225 client_->RequestScan(flimflam::kTypeWifi, base::Bind(&ExpectNoResultValue)); 225 client_->RequestScan(flimflam::kTypeWifi, base::Bind(&ExpectNoResultValue));
226 // Run the message loop. 226 // Run the message loop.
227 message_loop_.RunAllPending(); 227 message_loop_.RunAllPending();
228 } 228 }
229 229
230 TEST_F(FlimflamManagerClientTest, EnableTechnology) { 230 TEST_F(ShillManagerClientTest, EnableTechnology) {
231 // Create response. 231 // Create response.
232 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); 232 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty());
233 // Set expectations. 233 // Set expectations.
234 PrepareForMethodCall(flimflam::kEnableTechnologyFunction, 234 PrepareForMethodCall(flimflam::kEnableTechnologyFunction,
235 base::Bind(&ExpectStringArgument, flimflam::kTypeWifi), 235 base::Bind(&ExpectStringArgument, flimflam::kTypeWifi),
236 response.get()); 236 response.get());
237 // Call method. 237 // Call method.
238 client_->EnableTechnology(flimflam::kTypeWifi, 238 client_->EnableTechnology(flimflam::kTypeWifi,
239 base::Bind(&ExpectNoResultValue)); 239 base::Bind(&ExpectNoResultValue));
240 // Run the message loop. 240 // Run the message loop.
241 message_loop_.RunAllPending(); 241 message_loop_.RunAllPending();
242 } 242 }
243 243
244 TEST_F(FlimflamManagerClientTest, DisableTechnology) { 244 TEST_F(ShillManagerClientTest, DisableTechnology) {
245 // Create response. 245 // Create response.
246 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); 246 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty());
247 // Set expectations. 247 // Set expectations.
248 PrepareForMethodCall(flimflam::kDisableTechnologyFunction, 248 PrepareForMethodCall(flimflam::kDisableTechnologyFunction,
249 base::Bind(&ExpectStringArgument, flimflam::kTypeWifi), 249 base::Bind(&ExpectStringArgument, flimflam::kTypeWifi),
250 response.get()); 250 response.get());
251 // Call method. 251 // Call method.
252 client_->DisableTechnology(flimflam::kTypeWifi, 252 client_->DisableTechnology(flimflam::kTypeWifi,
253 base::Bind(&ExpectNoResultValue)); 253 base::Bind(&ExpectNoResultValue));
254 // Run the message loop. 254 // Run the message loop.
255 message_loop_.RunAllPending(); 255 message_loop_.RunAllPending();
256 } 256 }
257 257
258 TEST_F(FlimflamManagerClientTest, ConfigureService) { 258 TEST_F(ShillManagerClientTest, ConfigureService) {
259 // Create response. 259 // Create response.
260 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); 260 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty());
261 // Create the argument dictionary. 261 // Create the argument dictionary.
262 scoped_ptr<base::DictionaryValue> arg(CreateExampleProperties()); 262 scoped_ptr<base::DictionaryValue> arg(CreateExampleProperties());
263 // Set expectations. 263 // Set expectations.
264 PrepareForMethodCall(flimflam::kConfigureServiceFunction, 264 PrepareForMethodCall(flimflam::kConfigureServiceFunction,
265 base::Bind(&ExpectDictionaryValueArgument, arg.get()), 265 base::Bind(&ExpectDictionaryValueArgument, arg.get()),
266 response.get()); 266 response.get());
267 // Call method. 267 // Call method.
268 client_->ConfigureService(*arg, base::Bind(&ExpectNoResultValue)); 268 client_->ConfigureService(*arg, base::Bind(&ExpectNoResultValue));
269 // Run the message loop. 269 // Run the message loop.
270 message_loop_.RunAllPending(); 270 message_loop_.RunAllPending();
271 } 271 }
272 272
273 TEST_F(FlimflamManagerClientTest, GetService) { 273 TEST_F(ShillManagerClientTest, GetService) {
274 // Create response. 274 // Create response.
275 const dbus::ObjectPath object_path("/"); 275 const dbus::ObjectPath object_path("/");
276 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); 276 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty());
277 dbus::MessageWriter writer(response.get()); 277 dbus::MessageWriter writer(response.get());
278 writer.AppendObjectPath(object_path); 278 writer.AppendObjectPath(object_path);
279 // Create the argument dictionary. 279 // Create the argument dictionary.
280 scoped_ptr<base::DictionaryValue> arg(CreateExampleProperties()); 280 scoped_ptr<base::DictionaryValue> arg(CreateExampleProperties());
281 // Set expectations. 281 // Set expectations.
282 PrepareForMethodCall(flimflam::kGetServiceFunction, 282 PrepareForMethodCall(flimflam::kGetServiceFunction,
283 base::Bind(&ExpectDictionaryValueArgument, arg.get()), 283 base::Bind(&ExpectDictionaryValueArgument, arg.get()),
284 response.get()); 284 response.get());
285 // Call method. 285 // Call method.
286 client_->GetService(*arg, base::Bind(&ExpectObjectPathResult, object_path)); 286 client_->GetService(*arg, base::Bind(&ExpectObjectPathResult, object_path));
287 // Run the message loop. 287 // Run the message loop.
288 message_loop_.RunAllPending(); 288 message_loop_.RunAllPending();
289 } 289 }
290 290
291 } // namespace chromeos 291 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/dbus/shill_manager_client.cc ('k') | chromeos/dbus/shill_network_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698