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

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: Rebase 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
« no previous file with comments | « chrome/browser/chromeos/cros/cros_network_functions.cc ('k') | no next file » | 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/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 1042 matching lines...) Expand 10 before | Expand all | Expand 10 after
1053 CrosNetworkWatcher* watcher = CrosMonitorNetworkDeviceProperties( 1053 CrosNetworkWatcher* watcher = CrosMonitorNetworkDeviceProperties(
1054 callback, path.value()); 1054 callback, path.value());
1055 // Call callback. 1055 // Call callback.
1056 handler.Run(key, value); 1056 handler.Run(key, value);
1057 // Stop monitoring. 1057 // Stop monitoring.
1058 EXPECT_CALL(*mock_device_client_, 1058 EXPECT_CALL(*mock_device_client_,
1059 ResetPropertyChangedHandler(path)).Times(1); 1059 ResetPropertyChangedHandler(path)).Times(1);
1060 delete watcher; 1060 delete watcher;
1061 } 1061 }
1062 1062
1063 TEST_F(CrosNetworkFunctionsTest, CrosMonitorCellularDataPlan) {
1064 const std::string modem_service_path = "/modem/path";
1065 const int64 kUpdateTime = 123456;
1066 const int64 kPlanStartTime = 234567;
1067 const int64 kPlanEndTime = 345678;
1068
1069 CellularDataPlan* data_plan = new CellularDataPlan;
1070 CellularDataPlanVector data_plans;
1071 data_plan->plan_name = "plan name";
1072 data_plan->plan_type = CELLULAR_DATA_PLAN_METERED_PAID;
1073 data_plan->update_time = base::Time::FromInternalValue(kUpdateTime);
1074 data_plan->plan_start_time = base::Time::FromInternalValue(kPlanStartTime);
1075 data_plan->plan_end_time = base::Time::FromInternalValue(kPlanEndTime);
1076 data_plan->plan_data_bytes = 1024*1024;
1077 data_plan->data_bytes_used = 12345;
1078 data_plans.push_back(data_plan);
1079
1080 base::DictionaryValue* data_plan_dictionary = new base::DictionaryValue;
1081 data_plan_dictionary->SetWithoutPathExpansion(
1082 cashew::kCellularPlanNameProperty,
1083 base::Value::CreateStringValue(data_plan->plan_name));
1084 data_plan_dictionary->SetWithoutPathExpansion(
1085 cashew::kCellularPlanTypeProperty,
1086 base::Value::CreateStringValue(cashew::kCellularDataPlanMeteredPaid));
1087 data_plan_dictionary->SetWithoutPathExpansion(
1088 cashew::kCellularPlanUpdateTimeProperty,
1089 base::Value::CreateDoubleValue(kUpdateTime));
1090 data_plan_dictionary->SetWithoutPathExpansion(
1091 cashew::kCellularPlanStartProperty,
1092 base::Value::CreateDoubleValue(kPlanStartTime));
1093 data_plan_dictionary->SetWithoutPathExpansion(
1094 cashew::kCellularPlanEndProperty,
1095 base::Value::CreateDoubleValue(kPlanEndTime));
1096 data_plan_dictionary->SetWithoutPathExpansion(
1097 cashew::kCellularPlanDataBytesProperty,
1098 base::Value::CreateDoubleValue(data_plan->plan_data_bytes));
1099 data_plan_dictionary->SetWithoutPathExpansion(
1100 cashew::kCellularDataBytesUsedProperty,
1101 base::Value::CreateDoubleValue(data_plan->data_bytes_used));
1102
1103 base::ListValue data_plans_list;
1104 data_plans_list.Append(data_plan_dictionary);
1105
1106 // Set expectations.
1107 DataPlanUpdateWatcherCallback callback =
1108 MockDataPlanUpdateWatcherCallback::CreateCallback(modem_service_path,
1109 data_plans);
1110 CashewClient::DataPlansUpdateHandler arg_callback;
1111 EXPECT_CALL(*mock_cashew_client_, SetDataPlansUpdateHandler(_))
1112 .WillOnce(SaveArg<0>(&arg_callback));
1113
1114 // Start monitoring.
1115 CrosNetworkWatcher* watcher = CrosMonitorCellularDataPlan(callback);
1116
1117 // Run callback.
1118 arg_callback.Run(modem_service_path, data_plans_list);
1119
1120 // Stop monitoring.
1121 EXPECT_CALL(*mock_cashew_client_, ResetDataPlansUpdateHandler()).Times(1);
1122 delete watcher;
1123 }
1124
1063 TEST_F(CrosNetworkFunctionsTest, CrosRequestNetworkManagerProperties) { 1125 TEST_F(CrosNetworkFunctionsTest, CrosRequestNetworkManagerProperties) {
1064 const std::string key1 = "key1"; 1126 const std::string key1 = "key1";
1065 const std::string value1 = "value1"; 1127 const std::string value1 = "value1";
1066 const std::string key2 = "key.2."; 1128 const std::string key2 = "key.2.";
1067 const std::string value2 = "value2"; 1129 const std::string value2 = "value2";
1068 // Create result value. 1130 // Create result value.
1069 base::DictionaryValue result; 1131 base::DictionaryValue result;
1070 result.SetWithoutPathExpansion(key1, base::Value::CreateStringValue(value1)); 1132 result.SetWithoutPathExpansion(key1, base::Value::CreateStringValue(value1));
1071 result.SetWithoutPathExpansion(key2, base::Value::CreateStringValue(value2)); 1133 result.SetWithoutPathExpansion(key2, base::Value::CreateStringValue(value2));
1072 // Set expectations. 1134 // Set expectations.
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after
1488 const std::string string2 = "string2"; 1550 const std::string string2 = "string2";
1489 base::DictionaryValue value; 1551 base::DictionaryValue value;
1490 value.SetString(key1, string1); 1552 value.SetString(key1, string1);
1491 value.SetString(key2, string2); 1553 value.SetString(key2, string2);
1492 EXPECT_CALL(*mock_manager_client_, ConfigureService(IsEqualTo(&value), _)) 1554 EXPECT_CALL(*mock_manager_client_, ConfigureService(IsEqualTo(&value), _))
1493 .Times(1); 1555 .Times(1);
1494 CrosConfigureService(value); 1556 CrosConfigureService(value);
1495 } 1557 }
1496 1558
1497 } // namespace chromeos 1559 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/cros/cros_network_functions.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698