| 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/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_device_client.h" | 8 #include "chromeos/dbus/shill_device_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 20 matching lines...) Expand all Loading... |
| 39 ASSERT_TRUE(reader->PopString(&arg1)); | 39 ASSERT_TRUE(reader->PopString(&arg1)); |
| 40 EXPECT_EQ(expected_string1, arg1); | 40 EXPECT_EQ(expected_string1, arg1); |
| 41 std::string arg2; | 41 std::string arg2; |
| 42 ASSERT_TRUE(reader->PopString(&arg2)); | 42 ASSERT_TRUE(reader->PopString(&arg2)); |
| 43 EXPECT_EQ(expected_string2, arg2); | 43 EXPECT_EQ(expected_string2, arg2); |
| 44 EXPECT_FALSE(reader->HasMoreData()); | 44 EXPECT_FALSE(reader->HasMoreData()); |
| 45 } | 45 } |
| 46 | 46 |
| 47 } // namespace | 47 } // namespace |
| 48 | 48 |
| 49 class FlimflamDeviceClientTest : public FlimflamClientUnittestBase { | 49 class ShillDeviceClientTest : public ShillClientUnittestBase { |
| 50 public: | 50 public: |
| 51 FlimflamDeviceClientTest() | 51 ShillDeviceClientTest() |
| 52 : FlimflamClientUnittestBase(flimflam::kFlimflamDeviceInterface, | 52 : ShillClientUnittestBase(flimflam::kFlimflamDeviceInterface, |
| 53 dbus::ObjectPath(kExampleDevicePath)) { | 53 dbus::ObjectPath(kExampleDevicePath)) { |
| 54 } | 54 } |
| 55 | 55 |
| 56 virtual void SetUp() { | 56 virtual void SetUp() { |
| 57 FlimflamClientUnittestBase::SetUp(); | 57 ShillClientUnittestBase::SetUp(); |
| 58 // Create a client with the mock bus. | 58 // Create a client with the mock bus. |
| 59 client_.reset(FlimflamDeviceClient::Create(REAL_DBUS_CLIENT_IMPLEMENTATION, | 59 client_.reset(ShillDeviceClient::Create(REAL_DBUS_CLIENT_IMPLEMENTATION, |
| 60 mock_bus_)); | 60 mock_bus_)); |
| 61 // Run the message loop to run the signal connection result callback. | 61 // Run the message loop to run the signal connection result callback. |
| 62 message_loop_.RunAllPending(); | 62 message_loop_.RunAllPending(); |
| 63 } | 63 } |
| 64 | 64 |
| 65 virtual void TearDown() { | 65 virtual void TearDown() { |
| 66 FlimflamClientUnittestBase::TearDown(); | 66 ShillClientUnittestBase::TearDown(); |
| 67 } | 67 } |
| 68 | 68 |
| 69 protected: | 69 protected: |
| 70 scoped_ptr<FlimflamDeviceClient> client_; | 70 scoped_ptr<ShillDeviceClient> client_; |
| 71 }; | 71 }; |
| 72 | 72 |
| 73 TEST_F(FlimflamDeviceClientTest, PropertyChanged) { | 73 TEST_F(ShillDeviceClientTest, PropertyChanged) { |
| 74 const bool kValue = true; | 74 const bool kValue = true; |
| 75 // Create a signal. | 75 // Create a signal. |
| 76 dbus::Signal signal(flimflam::kFlimflamDeviceInterface, | 76 dbus::Signal signal(flimflam::kFlimflamDeviceInterface, |
| 77 flimflam::kMonitorPropertyChanged); | 77 flimflam::kMonitorPropertyChanged); |
| 78 dbus::MessageWriter writer(&signal); | 78 dbus::MessageWriter writer(&signal); |
| 79 writer.AppendString(flimflam::kCellularAllowRoamingProperty); | 79 writer.AppendString(flimflam::kCellularAllowRoamingProperty); |
| 80 writer.AppendVariantOfBool(kValue); | 80 writer.AppendVariantOfBool(kValue); |
| 81 | 81 |
| 82 // Set expectations. | 82 // Set expectations. |
| 83 const base::FundamentalValue value(kValue); | 83 const base::FundamentalValue value(kValue); |
| 84 client_->SetPropertyChangedHandler( | 84 client_->SetPropertyChangedHandler( |
| 85 dbus::ObjectPath(kExampleDevicePath), | 85 dbus::ObjectPath(kExampleDevicePath), |
| 86 base::Bind(&ExpectPropertyChanged, | 86 base::Bind(&ExpectPropertyChanged, |
| 87 flimflam::kCellularAllowRoamingProperty, | 87 flimflam::kCellularAllowRoamingProperty, |
| 88 &value)); | 88 &value)); |
| 89 // Run the signal callback. | 89 // Run the signal callback. |
| 90 SendPropertyChangedSignal(&signal); | 90 SendPropertyChangedSignal(&signal); |
| 91 | 91 |
| 92 // Reset the handler. | 92 // Reset the handler. |
| 93 client_->ResetPropertyChangedHandler(dbus::ObjectPath(kExampleDevicePath)); | 93 client_->ResetPropertyChangedHandler(dbus::ObjectPath(kExampleDevicePath)); |
| 94 } | 94 } |
| 95 | 95 |
| 96 TEST_F(FlimflamDeviceClientTest, GetProperties) { | 96 TEST_F(ShillDeviceClientTest, GetProperties) { |
| 97 const bool kValue = true; | 97 const bool kValue = true; |
| 98 // Create response. | 98 // Create response. |
| 99 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); | 99 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); |
| 100 dbus::MessageWriter writer(response.get()); | 100 dbus::MessageWriter writer(response.get()); |
| 101 dbus::MessageWriter array_writer(NULL); | 101 dbus::MessageWriter array_writer(NULL); |
| 102 writer.OpenArray("{sv}", &array_writer); | 102 writer.OpenArray("{sv}", &array_writer); |
| 103 dbus::MessageWriter entry_writer(NULL); | 103 dbus::MessageWriter entry_writer(NULL); |
| 104 array_writer.OpenDictEntry(&entry_writer); | 104 array_writer.OpenDictEntry(&entry_writer); |
| 105 entry_writer.AppendString(flimflam::kCellularAllowRoamingProperty); | 105 entry_writer.AppendString(flimflam::kCellularAllowRoamingProperty); |
| 106 entry_writer.AppendVariantOfBool(kValue); | 106 entry_writer.AppendVariantOfBool(kValue); |
| 107 array_writer.CloseContainer(&entry_writer); | 107 array_writer.CloseContainer(&entry_writer); |
| 108 writer.CloseContainer(&array_writer); | 108 writer.CloseContainer(&array_writer); |
| 109 | 109 |
| 110 // Set expectations. | 110 // Set expectations. |
| 111 base::DictionaryValue value; | 111 base::DictionaryValue value; |
| 112 value.SetWithoutPathExpansion(flimflam::kCellularAllowRoamingProperty, | 112 value.SetWithoutPathExpansion(flimflam::kCellularAllowRoamingProperty, |
| 113 base::Value::CreateBooleanValue(kValue)); | 113 base::Value::CreateBooleanValue(kValue)); |
| 114 PrepareForMethodCall(flimflam::kGetPropertiesFunction, | 114 PrepareForMethodCall(flimflam::kGetPropertiesFunction, |
| 115 base::Bind(&ExpectNoArgument), | 115 base::Bind(&ExpectNoArgument), |
| 116 response.get()); | 116 response.get()); |
| 117 // Call method. | 117 // Call method. |
| 118 client_->GetProperties(dbus::ObjectPath(kExampleDevicePath), | 118 client_->GetProperties(dbus::ObjectPath(kExampleDevicePath), |
| 119 base::Bind(&ExpectDictionaryValueResult, &value)); | 119 base::Bind(&ExpectDictionaryValueResult, &value)); |
| 120 // Run the message loop. | 120 // Run the message loop. |
| 121 message_loop_.RunAllPending(); | 121 message_loop_.RunAllPending(); |
| 122 } | 122 } |
| 123 | 123 |
| 124 TEST_F(FlimflamDeviceClientTest, CallGetPropertiesAndBlock) { | 124 TEST_F(ShillDeviceClientTest, CallGetPropertiesAndBlock) { |
| 125 const bool kValue = true; | 125 const bool kValue = true; |
| 126 // Create response. | 126 // Create response. |
| 127 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); | 127 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); |
| 128 dbus::MessageWriter writer(response.get()); | 128 dbus::MessageWriter writer(response.get()); |
| 129 dbus::MessageWriter array_writer(NULL); | 129 dbus::MessageWriter array_writer(NULL); |
| 130 writer.OpenArray("{sv}", &array_writer); | 130 writer.OpenArray("{sv}", &array_writer); |
| 131 dbus::MessageWriter entry_writer(NULL); | 131 dbus::MessageWriter entry_writer(NULL); |
| 132 array_writer.OpenDictEntry(&entry_writer); | 132 array_writer.OpenDictEntry(&entry_writer); |
| 133 entry_writer.AppendString(flimflam::kCellularAllowRoamingProperty); | 133 entry_writer.AppendString(flimflam::kCellularAllowRoamingProperty); |
| 134 entry_writer.AppendVariantOfBool(kValue); | 134 entry_writer.AppendVariantOfBool(kValue); |
| 135 array_writer.CloseContainer(&entry_writer); | 135 array_writer.CloseContainer(&entry_writer); |
| 136 writer.CloseContainer(&array_writer); | 136 writer.CloseContainer(&array_writer); |
| 137 | 137 |
| 138 // Set expectations. | 138 // Set expectations. |
| 139 base::DictionaryValue value; | 139 base::DictionaryValue value; |
| 140 value.SetWithoutPathExpansion(flimflam::kCellularAllowRoamingProperty, | 140 value.SetWithoutPathExpansion(flimflam::kCellularAllowRoamingProperty, |
| 141 base::Value::CreateBooleanValue(kValue)); | 141 base::Value::CreateBooleanValue(kValue)); |
| 142 PrepareForMethodCall(flimflam::kGetPropertiesFunction, | 142 PrepareForMethodCall(flimflam::kGetPropertiesFunction, |
| 143 base::Bind(&ExpectNoArgument), | 143 base::Bind(&ExpectNoArgument), |
| 144 response.get()); | 144 response.get()); |
| 145 // Call method. | 145 // Call method. |
| 146 scoped_ptr<base::DictionaryValue> result( | 146 scoped_ptr<base::DictionaryValue> result( |
| 147 client_->CallGetPropertiesAndBlock(dbus::ObjectPath(kExampleDevicePath))); | 147 client_->CallGetPropertiesAndBlock(dbus::ObjectPath(kExampleDevicePath))); |
| 148 ASSERT_TRUE(result.get()); | 148 ASSERT_TRUE(result.get()); |
| 149 EXPECT_TRUE(result->Equals(&value)); | 149 EXPECT_TRUE(result->Equals(&value)); |
| 150 } | 150 } |
| 151 | 151 |
| 152 TEST_F(FlimflamDeviceClientTest, ProposeScan) { | 152 TEST_F(ShillDeviceClientTest, ProposeScan) { |
| 153 // Create response. | 153 // Create response. |
| 154 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); | 154 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); |
| 155 | 155 |
| 156 // Set expectations. | 156 // Set expectations. |
| 157 PrepareForMethodCall(flimflam::kProposeScanFunction, | 157 PrepareForMethodCall(flimflam::kProposeScanFunction, |
| 158 base::Bind(&ExpectNoArgument), | 158 base::Bind(&ExpectNoArgument), |
| 159 response.get()); | 159 response.get()); |
| 160 // Call method. | 160 // Call method. |
| 161 client_->ProposeScan(dbus::ObjectPath(kExampleDevicePath), | 161 client_->ProposeScan(dbus::ObjectPath(kExampleDevicePath), |
| 162 base::Bind(&ExpectNoResultValue)); | 162 base::Bind(&ExpectNoResultValue)); |
| 163 // Run the message loop. | 163 // Run the message loop. |
| 164 message_loop_.RunAllPending(); | 164 message_loop_.RunAllPending(); |
| 165 } | 165 } |
| 166 | 166 |
| 167 TEST_F(FlimflamDeviceClientTest, SetProperty) { | 167 TEST_F(ShillDeviceClientTest, SetProperty) { |
| 168 const bool kValue = true; | 168 const bool kValue = true; |
| 169 // Create response. | 169 // Create response. |
| 170 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); | 170 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); |
| 171 | 171 |
| 172 // Set expectations. | 172 // Set expectations. |
| 173 const base::FundamentalValue value(kValue); | 173 const base::FundamentalValue value(kValue); |
| 174 PrepareForMethodCall(flimflam::kSetPropertyFunction, | 174 PrepareForMethodCall(flimflam::kSetPropertyFunction, |
| 175 base::Bind(&ExpectStringAndValueArguments, | 175 base::Bind(&ExpectStringAndValueArguments, |
| 176 flimflam::kCellularAllowRoamingProperty, | 176 flimflam::kCellularAllowRoamingProperty, |
| 177 &value), | 177 &value), |
| 178 response.get()); | 178 response.get()); |
| 179 // Call method. | 179 // Call method. |
| 180 client_->SetProperty(dbus::ObjectPath(kExampleDevicePath), | 180 client_->SetProperty(dbus::ObjectPath(kExampleDevicePath), |
| 181 flimflam::kCellularAllowRoamingProperty, | 181 flimflam::kCellularAllowRoamingProperty, |
| 182 value, | 182 value, |
| 183 base::Bind(&ExpectNoResultValue)); | 183 base::Bind(&ExpectNoResultValue)); |
| 184 // Run the message loop. | 184 // Run the message loop. |
| 185 message_loop_.RunAllPending(); | 185 message_loop_.RunAllPending(); |
| 186 } | 186 } |
| 187 | 187 |
| 188 TEST_F(FlimflamDeviceClientTest, ClearProperty) { | 188 TEST_F(ShillDeviceClientTest, ClearProperty) { |
| 189 // Create response. | 189 // Create response. |
| 190 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); | 190 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); |
| 191 | 191 |
| 192 // Set expectations. | 192 // Set expectations. |
| 193 PrepareForMethodCall(flimflam::kClearPropertyFunction, | 193 PrepareForMethodCall(flimflam::kClearPropertyFunction, |
| 194 base::Bind(&ExpectStringArgument, | 194 base::Bind(&ExpectStringArgument, |
| 195 flimflam::kCellularAllowRoamingProperty), | 195 flimflam::kCellularAllowRoamingProperty), |
| 196 response.get()); | 196 response.get()); |
| 197 // Call method. | 197 // Call method. |
| 198 client_->ClearProperty(dbus::ObjectPath(kExampleDevicePath), | 198 client_->ClearProperty(dbus::ObjectPath(kExampleDevicePath), |
| 199 flimflam::kCellularAllowRoamingProperty, | 199 flimflam::kCellularAllowRoamingProperty, |
| 200 base::Bind(&ExpectNoResultValue)); | 200 base::Bind(&ExpectNoResultValue)); |
| 201 // Run the message loop. | 201 // Run the message loop. |
| 202 message_loop_.RunAllPending(); | 202 message_loop_.RunAllPending(); |
| 203 } | 203 } |
| 204 | 204 |
| 205 TEST_F(FlimflamDeviceClientTest, AddIPConfig) { | 205 TEST_F(ShillDeviceClientTest, AddIPConfig) { |
| 206 const dbus::ObjectPath expected_result("/result/path"); | 206 const dbus::ObjectPath expected_result("/result/path"); |
| 207 // Create response. | 207 // Create response. |
| 208 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); | 208 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); |
| 209 dbus::MessageWriter writer(response.get()); | 209 dbus::MessageWriter writer(response.get()); |
| 210 writer.AppendObjectPath(expected_result); | 210 writer.AppendObjectPath(expected_result); |
| 211 | 211 |
| 212 // Set expectations. | 212 // Set expectations. |
| 213 PrepareForMethodCall(flimflam::kAddIPConfigFunction, | 213 PrepareForMethodCall(flimflam::kAddIPConfigFunction, |
| 214 base::Bind(&ExpectStringArgument, flimflam::kTypeDHCP), | 214 base::Bind(&ExpectStringArgument, flimflam::kTypeDHCP), |
| 215 response.get()); | 215 response.get()); |
| 216 // Call method. | 216 // Call method. |
| 217 client_->AddIPConfig(dbus::ObjectPath(kExampleDevicePath), | 217 client_->AddIPConfig(dbus::ObjectPath(kExampleDevicePath), |
| 218 flimflam::kTypeDHCP, | 218 flimflam::kTypeDHCP, |
| 219 base::Bind(&ExpectObjectPathResult, expected_result)); | 219 base::Bind(&ExpectObjectPathResult, expected_result)); |
| 220 // Run the message loop. | 220 // Run the message loop. |
| 221 message_loop_.RunAllPending(); | 221 message_loop_.RunAllPending(); |
| 222 } | 222 } |
| 223 | 223 |
| 224 TEST_F(FlimflamDeviceClientTest, CallAddIPConfigAndBlock) { | 224 TEST_F(ShillDeviceClientTest, CallAddIPConfigAndBlock) { |
| 225 const dbus::ObjectPath expected_result("/result/path"); | 225 const dbus::ObjectPath expected_result("/result/path"); |
| 226 // Create response. | 226 // Create response. |
| 227 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); | 227 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); |
| 228 dbus::MessageWriter writer(response.get()); | 228 dbus::MessageWriter writer(response.get()); |
| 229 writer.AppendObjectPath(expected_result); | 229 writer.AppendObjectPath(expected_result); |
| 230 | 230 |
| 231 // Set expectations. | 231 // Set expectations. |
| 232 PrepareForMethodCall(flimflam::kAddIPConfigFunction, | 232 PrepareForMethodCall(flimflam::kAddIPConfigFunction, |
| 233 base::Bind(&ExpectStringArgument, flimflam::kTypeDHCP), | 233 base::Bind(&ExpectStringArgument, flimflam::kTypeDHCP), |
| 234 response.get()); | 234 response.get()); |
| 235 // Call method. | 235 // Call method. |
| 236 const dbus::ObjectPath result = client_->CallAddIPConfigAndBlock( | 236 const dbus::ObjectPath result = client_->CallAddIPConfigAndBlock( |
| 237 dbus::ObjectPath(kExampleDevicePath), flimflam::kTypeDHCP); | 237 dbus::ObjectPath(kExampleDevicePath), flimflam::kTypeDHCP); |
| 238 EXPECT_EQ(expected_result, result); | 238 EXPECT_EQ(expected_result, result); |
| 239 } | 239 } |
| 240 | 240 |
| 241 TEST_F(FlimflamDeviceClientTest, RequirePin) { | 241 TEST_F(ShillDeviceClientTest, RequirePin) { |
| 242 const char kPin[] = "123456"; | 242 const char kPin[] = "123456"; |
| 243 const bool kRequired = true; | 243 const bool kRequired = true; |
| 244 // Create response. | 244 // Create response. |
| 245 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); | 245 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); |
| 246 | 246 |
| 247 // Set expectations. | 247 // Set expectations. |
| 248 MockClosure mock_closure; | 248 MockClosure mock_closure; |
| 249 MockErrorCallback mock_error_callback; | 249 MockErrorCallback mock_error_callback; |
| 250 PrepareForMethodCall(flimflam::kRequirePinFunction, | 250 PrepareForMethodCall(flimflam::kRequirePinFunction, |
| 251 base::Bind(&ExpectStringAndBoolArguments, | 251 base::Bind(&ExpectStringAndBoolArguments, |
| 252 kPin, | 252 kPin, |
| 253 kRequired), | 253 kRequired), |
| 254 response.get()); | 254 response.get()); |
| 255 EXPECT_CALL(mock_closure, Run()).Times(1); | 255 EXPECT_CALL(mock_closure, Run()).Times(1); |
| 256 // Call method. | 256 // Call method. |
| 257 client_->RequirePin(dbus::ObjectPath(kExampleDevicePath), | 257 client_->RequirePin(dbus::ObjectPath(kExampleDevicePath), |
| 258 kPin, | 258 kPin, |
| 259 kRequired, | 259 kRequired, |
| 260 mock_closure.GetCallback(), | 260 mock_closure.GetCallback(), |
| 261 mock_error_callback.GetCallback()); | 261 mock_error_callback.GetCallback()); |
| 262 // Run the message loop. | 262 // Run the message loop. |
| 263 message_loop_.RunAllPending(); | 263 message_loop_.RunAllPending(); |
| 264 } | 264 } |
| 265 | 265 |
| 266 TEST_F(FlimflamDeviceClientTest, EnterPin) { | 266 TEST_F(ShillDeviceClientTest, EnterPin) { |
| 267 const char kPin[] = "123456"; | 267 const char kPin[] = "123456"; |
| 268 // Create response. | 268 // Create response. |
| 269 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); | 269 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); |
| 270 | 270 |
| 271 // Set expectations. | 271 // Set expectations. |
| 272 MockClosure mock_closure; | 272 MockClosure mock_closure; |
| 273 MockErrorCallback mock_error_callback; | 273 MockErrorCallback mock_error_callback; |
| 274 PrepareForMethodCall(flimflam::kEnterPinFunction, | 274 PrepareForMethodCall(flimflam::kEnterPinFunction, |
| 275 base::Bind(&ExpectStringArgument, | 275 base::Bind(&ExpectStringArgument, |
| 276 kPin), | 276 kPin), |
| 277 response.get()); | 277 response.get()); |
| 278 EXPECT_CALL(mock_closure, Run()).Times(1); | 278 EXPECT_CALL(mock_closure, Run()).Times(1); |
| 279 // Call method. | 279 // Call method. |
| 280 client_->EnterPin(dbus::ObjectPath(kExampleDevicePath), | 280 client_->EnterPin(dbus::ObjectPath(kExampleDevicePath), |
| 281 kPin, | 281 kPin, |
| 282 mock_closure.GetCallback(), | 282 mock_closure.GetCallback(), |
| 283 mock_error_callback.GetCallback()); | 283 mock_error_callback.GetCallback()); |
| 284 // Run the message loop. | 284 // Run the message loop. |
| 285 message_loop_.RunAllPending(); | 285 message_loop_.RunAllPending(); |
| 286 } | 286 } |
| 287 | 287 |
| 288 TEST_F(FlimflamDeviceClientTest, UnblockPin) { | 288 TEST_F(ShillDeviceClientTest, UnblockPin) { |
| 289 const char kPuk[] = "987654"; | 289 const char kPuk[] = "987654"; |
| 290 const char kPin[] = "123456"; | 290 const char kPin[] = "123456"; |
| 291 // Create response. | 291 // Create response. |
| 292 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); | 292 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); |
| 293 | 293 |
| 294 // Set expectations. | 294 // Set expectations. |
| 295 MockClosure mock_closure; | 295 MockClosure mock_closure; |
| 296 MockErrorCallback mock_error_callback; | 296 MockErrorCallback mock_error_callback; |
| 297 PrepareForMethodCall(flimflam::kUnblockPinFunction, | 297 PrepareForMethodCall(flimflam::kUnblockPinFunction, |
| 298 base::Bind(&ExpectTwoStringArguments, kPuk, kPin), | 298 base::Bind(&ExpectTwoStringArguments, kPuk, kPin), |
| 299 response.get()); | 299 response.get()); |
| 300 EXPECT_CALL(mock_closure, Run()).Times(1); | 300 EXPECT_CALL(mock_closure, Run()).Times(1); |
| 301 // Call method. | 301 // Call method. |
| 302 client_->UnblockPin(dbus::ObjectPath(kExampleDevicePath), | 302 client_->UnblockPin(dbus::ObjectPath(kExampleDevicePath), |
| 303 kPuk, | 303 kPuk, |
| 304 kPin, | 304 kPin, |
| 305 mock_closure.GetCallback(), | 305 mock_closure.GetCallback(), |
| 306 mock_error_callback.GetCallback()); | 306 mock_error_callback.GetCallback()); |
| 307 // Run the message loop. | 307 // Run the message loop. |
| 308 message_loop_.RunAllPending(); | 308 message_loop_.RunAllPending(); |
| 309 } | 309 } |
| 310 | 310 |
| 311 TEST_F(FlimflamDeviceClientTest, ChangePin) { | 311 TEST_F(ShillDeviceClientTest, ChangePin) { |
| 312 const char kOldPin[] = "123456"; | 312 const char kOldPin[] = "123456"; |
| 313 const char kNewPin[] = "234567"; | 313 const char kNewPin[] = "234567"; |
| 314 // Create response. | 314 // Create response. |
| 315 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); | 315 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); |
| 316 | 316 |
| 317 // Set expectations. | 317 // Set expectations. |
| 318 MockClosure mock_closure; | 318 MockClosure mock_closure; |
| 319 MockErrorCallback mock_error_callback; | 319 MockErrorCallback mock_error_callback; |
| 320 PrepareForMethodCall(flimflam::kChangePinFunction, | 320 PrepareForMethodCall(flimflam::kChangePinFunction, |
| 321 base::Bind(&ExpectTwoStringArguments, | 321 base::Bind(&ExpectTwoStringArguments, |
| 322 kOldPin, | 322 kOldPin, |
| 323 kNewPin), | 323 kNewPin), |
| 324 response.get()); | 324 response.get()); |
| 325 EXPECT_CALL(mock_closure, Run()).Times(1); | 325 EXPECT_CALL(mock_closure, Run()).Times(1); |
| 326 // Call method. | 326 // Call method. |
| 327 client_->ChangePin(dbus::ObjectPath(kExampleDevicePath), | 327 client_->ChangePin(dbus::ObjectPath(kExampleDevicePath), |
| 328 kOldPin, | 328 kOldPin, |
| 329 kNewPin, | 329 kNewPin, |
| 330 mock_closure.GetCallback(), | 330 mock_closure.GetCallback(), |
| 331 mock_error_callback.GetCallback()); | 331 mock_error_callback.GetCallback()); |
| 332 // Run the message loop. | 332 // Run the message loop. |
| 333 message_loop_.RunAllPending(); | 333 message_loop_.RunAllPending(); |
| 334 } | 334 } |
| 335 | 335 |
| 336 TEST_F(FlimflamDeviceClientTest, Register) { | 336 TEST_F(ShillDeviceClientTest, Register) { |
| 337 const char kNetworkId[] = "networkid"; | 337 const char kNetworkId[] = "networkid"; |
| 338 // Create response. | 338 // Create response. |
| 339 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); | 339 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); |
| 340 | 340 |
| 341 // Set expectations. | 341 // Set expectations. |
| 342 MockClosure mock_closure; | 342 MockClosure mock_closure; |
| 343 MockErrorCallback mock_error_callback; | 343 MockErrorCallback mock_error_callback; |
| 344 PrepareForMethodCall(flimflam::kRegisterFunction, | 344 PrepareForMethodCall(flimflam::kRegisterFunction, |
| 345 base::Bind(&ExpectStringArgument, kNetworkId), | 345 base::Bind(&ExpectStringArgument, kNetworkId), |
| 346 response.get()); | 346 response.get()); |
| 347 EXPECT_CALL(mock_closure, Run()).Times(1); | 347 EXPECT_CALL(mock_closure, Run()).Times(1); |
| 348 // Call method. | 348 // Call method. |
| 349 client_->Register(dbus::ObjectPath(kExampleDevicePath), | 349 client_->Register(dbus::ObjectPath(kExampleDevicePath), |
| 350 kNetworkId, | 350 kNetworkId, |
| 351 mock_closure.GetCallback(), | 351 mock_closure.GetCallback(), |
| 352 mock_error_callback.GetCallback()); | 352 mock_error_callback.GetCallback()); |
| 353 // Run the message loop. | 353 // Run the message loop. |
| 354 message_loop_.RunAllPending(); | 354 message_loop_.RunAllPending(); |
| 355 } | 355 } |
| 356 | 356 |
| 357 } // namespace chromeos | 357 } // namespace chromeos |
| OLD | NEW |