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

Side by Side Diff: chrome/browser/chromeos/cros/cros_network_functions_unittest.cc

Issue 10140016: Reimplement MonitorCellularDataPlan without Libcros (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: _ Created 8 years, 8 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 | Annotate | Revision Log
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/memory/scoped_ptr.h" 6 #include "base/memory/scoped_ptr.h"
7 #include "base/values.h" 7 #include "base/values.h"
8 #include "chrome/browser/chromeos/cros/cros_network_functions.h" 8 #include "chrome/browser/chromeos/cros/cros_network_functions.h"
9 #include "chrome/browser/chromeos/cros/gvalue_util.h" 9 #include "chrome/browser/chromeos/cros/gvalue_util.h"
10 #include "chrome/browser/chromeos/cros/mock_chromeos_network.h" 10 #include "chrome/browser/chromeos/cros/mock_chromeos_network.h"
(...skipping 951 matching lines...) Expand 10 before | Expand all | Expand 10 after
962 CrosNetworkWatcher* watcher = CrosMonitorNetworkDeviceProperties( 962 CrosNetworkWatcher* watcher = CrosMonitorNetworkDeviceProperties(
963 callback, path.value()); 963 callback, path.value());
964 // Call callback. 964 // Call callback.
965 handler.Run(key, value); 965 handler.Run(key, value);
966 // Stop monitoring. 966 // Stop monitoring.
967 EXPECT_CALL(*mock_device_client_, 967 EXPECT_CALL(*mock_device_client_,
968 ResetPropertyChangedHandler(path)).Times(1); 968 ResetPropertyChangedHandler(path)).Times(1);
969 delete watcher; 969 delete watcher;
970 } 970 }
971 971
972 TEST_F(CrosNetworkFunctionsTest, CrosMonitorCellularDataPlan) {
973 const std::string modem_service_path = "/modem/path";
974 const int64 kUpdateTime = 123456;
975 const int64 kPlanStartTime = 234567;
976 const int64 kPlanEndTime = 345678;
977
978 CellularDataPlan* data_plan = new CellularDataPlan;
979 CellularDataPlanVector data_plans;
980 data_plan->plan_name = "plan name";
981 data_plan->plan_type = CELLULAR_DATA_PLAN_METERED_PAID;
982 data_plan->update_time = base::Time::FromInternalValue(kUpdateTime);
983 data_plan->plan_start_time = base::Time::FromInternalValue(kPlanStartTime);
984 data_plan->plan_end_time = base::Time::FromInternalValue(kPlanEndTime);
985 data_plan->plan_data_bytes = 1024*1024;
986 data_plan->data_bytes_used = 12345;
987 data_plans.push_back(data_plan);
988
989 base::DictionaryValue* data_plan_dictionary = new base::DictionaryValue;
990 data_plan_dictionary->SetWithoutPathExpansion(
991 cashew::kCellularPlanNameProperty,
992 base::Value::CreateStringValue(data_plan->plan_name));
993 data_plan_dictionary->SetWithoutPathExpansion(
994 cashew::kCellularPlanTypeProperty,
995 base::Value::CreateStringValue(cashew::kCellularDataPlanMeteredPaid));
996 data_plan_dictionary->SetWithoutPathExpansion(
997 cashew::kCellularPlanUpdateTimeProperty,
998 base::Value::CreateDoubleValue(kUpdateTime));
999 data_plan_dictionary->SetWithoutPathExpansion(
1000 cashew::kCellularPlanStartProperty,
1001 base::Value::CreateDoubleValue(kPlanStartTime));
1002 data_plan_dictionary->SetWithoutPathExpansion(
1003 cashew::kCellularPlanEndProperty,
1004 base::Value::CreateDoubleValue(kPlanEndTime));
1005 data_plan_dictionary->SetWithoutPathExpansion(
1006 cashew::kCellularPlanDataBytesProperty,
1007 base::Value::CreateDoubleValue(data_plan->plan_data_bytes));
1008 data_plan_dictionary->SetWithoutPathExpansion(
1009 cashew::kCellularDataBytesUsedProperty,
1010 base::Value::CreateDoubleValue(data_plan->data_bytes_used));
1011
1012 base::ListValue data_plans_list;
1013 data_plans_list.Append(data_plan_dictionary);
1014
1015 // Set expectations.
1016 DataPlanUpdateWatcherCallback callback =
1017 MockDataPlanUpdateWatcherCallback::CreateCallback(modem_service_path,
1018 data_plans);
1019 CashewClient::DataPlansUpdateHandler arg_callback;
1020 EXPECT_CALL(*mock_cashew_client_, SetDataPlansUpdateHandler(_))
1021 .WillOnce(SaveArg<0>(&arg_callback));
1022
1023 // Start monitoring.
1024 CrosNetworkWatcher* watcher = CrosMonitorCellularDataPlan(callback);
1025
1026 // Run callback.
1027 arg_callback.Run(modem_service_path, data_plans_list);
1028
1029 // Stop monitoring.
1030 EXPECT_CALL(*mock_cashew_client_, ResetDataPlansUpdateHandler()).Times(1);
1031 delete watcher;
1032 }
1033
972 TEST_F(CrosNetworkFunctionsTest, CrosRequestNetworkManagerProperties) { 1034 TEST_F(CrosNetworkFunctionsTest, CrosRequestNetworkManagerProperties) {
973 const std::string key1 = "key1"; 1035 const std::string key1 = "key1";
974 const std::string value1 = "value1"; 1036 const std::string value1 = "value1";
975 const std::string key2 = "key.2."; 1037 const std::string key2 = "key.2.";
976 const std::string value2 = "value2"; 1038 const std::string value2 = "value2";
977 // Create result value. 1039 // Create result value.
978 base::DictionaryValue result; 1040 base::DictionaryValue result;
979 result.SetWithoutPathExpansion(key1, base::Value::CreateStringValue(value1)); 1041 result.SetWithoutPathExpansion(key1, base::Value::CreateStringValue(value1));
980 result.SetWithoutPathExpansion(key2, base::Value::CreateStringValue(value2)); 1042 result.SetWithoutPathExpansion(key2, base::Value::CreateStringValue(value2));
981 // Set expectations. 1043 // Set expectations.
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
1232 const std::string string2 = "string2"; 1294 const std::string string2 = "string2";
1233 base::DictionaryValue value; 1295 base::DictionaryValue value;
1234 value.SetString(key1, string1); 1296 value.SetString(key1, string1);
1235 value.SetString(key2, string2); 1297 value.SetString(key2, string2);
1236 EXPECT_CALL(*mock_manager_client_, ConfigureService(IsEqualTo(&value), _)) 1298 EXPECT_CALL(*mock_manager_client_, ConfigureService(IsEqualTo(&value), _))
1237 .Times(1); 1299 .Times(1);
1238 CrosConfigureService(value); 1300 CrosConfigureService(value);
1239 } 1301 }
1240 1302
1241 } // namespace chromeos 1303 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698