| 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 "chromeos/dbus/shill_manager_client.h" | 5 #include "chromeos/dbus/shill_manager_client.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 std::string arg_string; | 45 std::string arg_string; |
| 46 ASSERT_TRUE(reader->PopString(&arg_string)); | 46 ASSERT_TRUE(reader->PopString(&arg_string)); |
| 47 EXPECT_EQ(*iter, arg_string); | 47 EXPECT_EQ(*iter, arg_string); |
| 48 } | 48 } |
| 49 dbus::ObjectPath path; | 49 dbus::ObjectPath path; |
| 50 ASSERT_TRUE(reader->PopObjectPath(&path)); | 50 ASSERT_TRUE(reader->PopObjectPath(&path)); |
| 51 EXPECT_EQ(object_path, path); | 51 EXPECT_EQ(object_path, path); |
| 52 EXPECT_FALSE(reader->HasMoreData()); | 52 EXPECT_FALSE(reader->HasMoreData()); |
| 53 } | 53 } |
| 54 | 54 |
| 55 void ExpectThrottlingArguments(bool throttling_enabled_expected, | |
| 56 uint32_t upload_rate_kbits_expected, | |
| 57 uint32_t download_rate_kbits_expected, | |
| 58 dbus::MessageReader* reader) { | |
| 59 bool throttling_enabled_actual; | |
| 60 uint32_t upload_rate_kbits_actual; | |
| 61 uint32_t download_rate_kbits_actual; | |
| 62 ASSERT_TRUE(reader->PopBool(&throttling_enabled_actual)); | |
| 63 EXPECT_EQ(throttling_enabled_actual, throttling_enabled_expected); | |
| 64 ASSERT_TRUE(reader->PopUint32(&upload_rate_kbits_actual)); | |
| 65 EXPECT_EQ(upload_rate_kbits_expected, upload_rate_kbits_actual); | |
| 66 ASSERT_TRUE(reader->PopUint32(&download_rate_kbits_actual)); | |
| 67 EXPECT_EQ(download_rate_kbits_expected, download_rate_kbits_actual); | |
| 68 EXPECT_FALSE(reader->HasMoreData()); | |
| 69 } | |
| 70 | 55 |
| 71 } // namespace | 56 } // namespace |
| 72 | 57 |
| 73 class ShillManagerClientTest : public ShillClientUnittestBase { | 58 class ShillManagerClientTest : public ShillClientUnittestBase { |
| 74 public: | 59 public: |
| 75 ShillManagerClientTest() | 60 ShillManagerClientTest() |
| 76 : ShillClientUnittestBase(shill::kFlimflamManagerInterface, | 61 : ShillClientUnittestBase(shill::kFlimflamManagerInterface, |
| 77 dbus::ObjectPath(shill::kFlimflamServicePath)) { | 62 dbus::ObjectPath(shill::kFlimflamServicePath)) { |
| 78 } | 63 } |
| 79 | 64 |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 client_->EnableTechnology(shill::kTypeWifi, | 242 client_->EnableTechnology(shill::kTypeWifi, |
| 258 mock_closure.GetCallback(), | 243 mock_closure.GetCallback(), |
| 259 mock_error_callback.GetCallback()); | 244 mock_error_callback.GetCallback()); |
| 260 EXPECT_CALL(mock_closure, Run()).Times(1); | 245 EXPECT_CALL(mock_closure, Run()).Times(1); |
| 261 EXPECT_CALL(mock_error_callback, Run(_, _)).Times(0); | 246 EXPECT_CALL(mock_error_callback, Run(_, _)).Times(0); |
| 262 | 247 |
| 263 // Run the message loop. | 248 // Run the message loop. |
| 264 base::RunLoop().RunUntilIdle(); | 249 base::RunLoop().RunUntilIdle(); |
| 265 } | 250 } |
| 266 | 251 |
| 267 TEST_F(ShillManagerClientTest, NetworkThrottling) { | |
| 268 // Create response. | |
| 269 std::unique_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); | |
| 270 // Set expectations. | |
| 271 const bool enabled = true; | |
| 272 const uint32_t upload_rate = 1200; | |
| 273 const uint32_t download_rate = 2000; | |
| 274 PrepareForMethodCall(shill::kSetNetworkThrottlingFunction, | |
| 275 base::Bind(&ExpectThrottlingArguments, enabled, | |
| 276 upload_rate, download_rate), | |
| 277 response.get()); | |
| 278 // Call method. | |
| 279 MockClosure mock_closure; | |
| 280 MockErrorCallback mock_error_callback; | |
| 281 client_->SetNetworkThrottlingStatus(enabled, upload_rate, download_rate, | |
| 282 mock_closure.GetCallback(), | |
| 283 mock_error_callback.GetCallback()); | |
| 284 EXPECT_CALL(mock_closure, Run()).Times(1); | |
| 285 EXPECT_CALL(mock_error_callback, Run(_, _)).Times(0); | |
| 286 | |
| 287 // Run the message loop. | |
| 288 base::RunLoop().RunUntilIdle(); | |
| 289 } | |
| 290 | |
| 291 TEST_F(ShillManagerClientTest, DisableTechnology) { | 252 TEST_F(ShillManagerClientTest, DisableTechnology) { |
| 292 // Create response. | 253 // Create response. |
| 293 std::unique_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); | 254 std::unique_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); |
| 294 // Set expectations. | 255 // Set expectations. |
| 295 PrepareForMethodCall(shill::kDisableTechnologyFunction, | 256 PrepareForMethodCall(shill::kDisableTechnologyFunction, |
| 296 base::Bind(&ExpectStringArgument, shill::kTypeWifi), | 257 base::Bind(&ExpectStringArgument, shill::kTypeWifi), |
| 297 response.get()); | 258 response.get()); |
| 298 // Call method. | 259 // Call method. |
| 299 MockClosure mock_closure; | 260 MockClosure mock_closure; |
| 300 MockErrorCallback mock_error_callback; | 261 MockErrorCallback mock_error_callback; |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 480 arguments[7], | 441 arguments[7], |
| 481 base::Bind(&ExpectStringResultWithoutStatus, expected), | 442 base::Bind(&ExpectStringResultWithoutStatus, expected), |
| 482 mock_error_callback.GetCallback()); | 443 mock_error_callback.GetCallback()); |
| 483 EXPECT_CALL(mock_error_callback, Run(_, _)).Times(0); | 444 EXPECT_CALL(mock_error_callback, Run(_, _)).Times(0); |
| 484 | 445 |
| 485 // Run the message loop. | 446 // Run the message loop. |
| 486 base::RunLoop().RunUntilIdle(); | 447 base::RunLoop().RunUntilIdle(); |
| 487 } | 448 } |
| 488 | 449 |
| 489 } // namespace chromeos | 450 } // namespace chromeos |
| OLD | NEW |