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

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

Issue 8725034: network_library: Add a few policy-configured test networks. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix unit tests. Created 9 years 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 | « no previous file | chrome/browser/chromeos/cros/network_library_unittest.cc » ('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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/browser/chromeos/cros/network_library.h" 5 #include "chrome/browser/chromeos/cros/network_library.h"
6 6
7 #include <dbus/dbus-glib.h> 7 #include <dbus/dbus-glib.h>
8 #include <dbus/dbus-gtype-specialized.h> 8 #include <dbus/dbus-gtype-specialized.h>
9 #include <glib-object.h> 9 #include <glib-object.h>
10 10
(...skipping 10 matching lines...) Expand all
21 #include "base/json/json_writer.h" // for debug output only. 21 #include "base/json/json_writer.h" // for debug output only.
22 #include "base/metrics/histogram.h" 22 #include "base/metrics/histogram.h"
23 #include "base/stl_util.h" 23 #include "base/stl_util.h"
24 #include "base/string_number_conversions.h" 24 #include "base/string_number_conversions.h"
25 #include "base/string_tokenizer.h" 25 #include "base/string_tokenizer.h"
26 #include "base/string_util.h" 26 #include "base/string_util.h"
27 #include "base/stringprintf.h" 27 #include "base/stringprintf.h"
28 #include "base/utf_string_conversion_utils.h" 28 #include "base/utf_string_conversion_utils.h"
29 #include "base/utf_string_conversions.h" 29 #include "base/utf_string_conversions.h"
30 #include "base/values.h" 30 #include "base/values.h"
31 #include "chrome/browser/chromeos/cros_settings.h"
32 #include "chrome/browser/chromeos/cros/cros_library.h" 31 #include "chrome/browser/chromeos/cros/cros_library.h"
33 #include "chrome/browser/chromeos/cros/native_network_constants.h" 32 #include "chrome/browser/chromeos/cros/native_network_constants.h"
34 #include "chrome/browser/chromeos/cros/native_network_parser.h" 33 #include "chrome/browser/chromeos/cros/native_network_parser.h"
34 #include "chrome/browser/chromeos/cros/network_ui_data.h"
35 #include "chrome/browser/chromeos/cros/onc_network_parser.h" 35 #include "chrome/browser/chromeos/cros/onc_network_parser.h"
36 #include "chrome/browser/chromeos/cros_settings.h"
36 #include "chrome/browser/chromeos/network_login_observer.h" 37 #include "chrome/browser/chromeos/network_login_observer.h"
37 #include "chrome/common/time_format.h" 38 #include "chrome/common/time_format.h"
38 #include "content/public/browser/browser_thread.h" 39 #include "content/public/browser/browser_thread.h"
39 #include "crypto/nss_util.h" // crypto::GetTPMTokenInfo() for 802.1X and VPN. 40 #include "crypto/nss_util.h" // crypto::GetTPMTokenInfo() for 802.1X and VPN.
40 #include "grit/generated_resources.h" 41 #include "grit/generated_resources.h"
41 #include "third_party/cros_system_api/dbus/service_constants.h" 42 #include "third_party/cros_system_api/dbus/service_constants.h"
42 #include "ui/base/l10n/l10n_util.h" 43 #include "ui/base/l10n/l10n_util.h"
43 #include "ui/base/text/bytes_formatting.h" 44 #include "ui/base/text/bytes_formatting.h"
44 45
45 using content::BrowserThread; 46 using content::BrowserThread;
(...skipping 4819 matching lines...) Expand 10 before | Expand all | Expand 10 after
4865 (1 << TYPE_ETHERNET) | (1 << TYPE_WIFI) | (1 << TYPE_CELLULAR); 4866 (1 << TYPE_ETHERNET) | (1 << TYPE_WIFI) | (1 << TYPE_CELLULAR);
4866 available_devices_ = devices; 4867 available_devices_ = devices;
4867 enabled_devices_ = devices; 4868 enabled_devices_ = devices;
4868 connected_devices_ = devices; 4869 connected_devices_ = devices;
4869 4870
4870 NetworkDevice* cellular = new NetworkDevice("cellular"); 4871 NetworkDevice* cellular = new NetworkDevice("cellular");
4871 cellular->type_ = TYPE_CELLULAR; 4872 cellular->type_ = TYPE_CELLULAR;
4872 cellular->imsi_ = "123456789012345"; 4873 cellular->imsi_ = "123456789012345";
4873 device_map_["cellular"] = cellular; 4874 device_map_["cellular"] = cellular;
4874 4875
4876 CellularApn apn;
4877 apn.apn = "apn";
4878 apn.network_id = "network_id";
4879 apn.username = "username";
4880 apn.password = "password";
4881 apn.name = "name";
4882 apn.localized_name = "localized_name";
4883 apn.language = "language";
4884
4885 CellularApnList apn_list;
4886 apn_list.push_back(apn);
4887
4888 NetworkDevice* cellular_gsm = new NetworkDevice("cellular_gsm");
4889 cellular_gsm->type_ = TYPE_CELLULAR;
4890 cellular_gsm->set_technology_family(TECHNOLOGY_FAMILY_GSM);
4891 cellular_gsm->imsi_ = "123456789012345";
4892 cellular_gsm->set_sim_pin_required(SIM_PIN_REQUIRED);
4893 cellular_gsm->set_provider_apn_list(apn_list);
4894 device_map_["cellular_gsm"] = cellular_gsm;
4895
4875 // Profiles 4896 // Profiles
4876 AddProfile("default", PROFILE_SHARED); 4897 AddProfile("default", PROFILE_SHARED);
4877 AddProfile("user", PROFILE_USER); 4898 AddProfile("user", PROFILE_USER);
4878 4899
4879 // Networks 4900 // Networks
4880 // If these change, the expectations in network_library_unittest and 4901 // If these change, the expectations in network_library_unittest and
4881 // network_menu_icon_unittest need to be changed also. 4902 // network_menu_icon_unittest need to be changed also.
4882 4903
4883 // Networks are added in priority order. 4904 // Networks are added in priority order.
4884 network_priority_order_ = 0; 4905 network_priority_order_ = 0;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
4924 wifi5->SetSsid("Fake WiFi5 UTF-8 SSID \u3042\u3044\u3046"); 4945 wifi5->SetSsid("Fake WiFi5 UTF-8 SSID \u3042\u3044\u3046");
4925 wifi5->set_strength(25); 4946 wifi5->set_strength(25);
4926 AddStubNetwork(wifi5, PROFILE_NONE); 4947 AddStubNetwork(wifi5, PROFILE_NONE);
4927 4948
4928 WifiNetwork* wifi6 = new WifiNetwork("wifi6"); 4949 WifiNetwork* wifi6 = new WifiNetwork("wifi6");
4929 wifi6->set_name("Fake WiFi6 latin-1 SSID "); 4950 wifi6->set_name("Fake WiFi6 latin-1 SSID ");
4930 wifi6->SetSsid("Fake WiFi6 latin-1 SSID \xc0\xcb\xcc\xd6\xfb"); 4951 wifi6->SetSsid("Fake WiFi6 latin-1 SSID \xc0\xcb\xcc\xd6\xfb");
4931 wifi6->set_strength(20); 4952 wifi6->set_strength(20);
4932 AddStubNetwork(wifi6, PROFILE_NONE); 4953 AddStubNetwork(wifi6, PROFILE_NONE);
4933 4954
4955 WifiNetwork* wifi7 = new WifiNetwork("wifi7");
4956 wifi7->set_name("Fake Wifi7 (policy-managed)");
4957 wifi7->set_strength(100);
4958 wifi7->set_connectable(false);
4959 wifi7->set_passphrase_required(true);
4960 wifi7->set_encryption(SECURITY_8021X);
4961 wifi7->SetEAPMethod(EAP_METHOD_PEAP);
4962 wifi7->SetEAPIdentity("enterprise@example.com");
4963 wifi7->SetEAPPassphrase("password");
4964 NetworkUIData wifi7_ui_data;
4965 wifi7_ui_data.set_onc_source(NetworkUIData::ONC_SOURCE_DEVICE_POLICY);
4966 wifi7_ui_data.FillDictionary(wifi7->ui_data());
4967 AddStubNetwork(wifi7, PROFILE_USER);
4968
4934 CellularNetwork* cellular1 = new CellularNetwork("cellular1"); 4969 CellularNetwork* cellular1 = new CellularNetwork("cellular1");
4935 cellular1->set_name("Fake Cellular1"); 4970 cellular1->set_name("Fake Cellular 1");
4936 cellular1->set_strength(100); 4971 cellular1->set_strength(100);
4937 cellular1->set_connected(true); 4972 cellular1->set_connected(true);
4938 cellular1->set_activation_state(ACTIVATION_STATE_ACTIVATED); 4973 cellular1->set_activation_state(ACTIVATION_STATE_ACTIVATED);
4939 cellular1->set_payment_url(std::string("http://www.google.com")); 4974 cellular1->set_payment_url(std::string("http://www.google.com"));
4940 cellular1->set_usage_url(std::string("http://www.google.com")); 4975 cellular1->set_usage_url(std::string("http://www.google.com"));
4941 cellular1->set_network_technology(NETWORK_TECHNOLOGY_EVDO); 4976 cellular1->set_network_technology(NETWORK_TECHNOLOGY_EVDO);
4942 AddStubNetwork(cellular1, PROFILE_NONE); 4977 AddStubNetwork(cellular1, PROFILE_NONE);
4943 4978
4944 CellularNetwork* cellular2 = new CellularNetwork("cellular2"); 4979 CellularNetwork* cellular2 = new CellularNetwork("cellular2");
4945 cellular2->set_name("Fake Cellular2"); 4980 cellular2->set_name("Fake Cellular 2");
4946 cellular2->set_strength(50); 4981 cellular2->set_strength(50);
4947 cellular2->set_activation_state(ACTIVATION_STATE_NOT_ACTIVATED); 4982 cellular2->set_activation_state(ACTIVATION_STATE_NOT_ACTIVATED);
4948 cellular2->set_network_technology(NETWORK_TECHNOLOGY_UMTS); 4983 cellular2->set_network_technology(NETWORK_TECHNOLOGY_UMTS);
4949 cellular2->set_roaming_state(ROAMING_STATE_ROAMING); 4984 cellular2->set_roaming_state(ROAMING_STATE_ROAMING);
4950 AddStubNetwork(cellular2, PROFILE_NONE); 4985 AddStubNetwork(cellular2, PROFILE_NONE);
4951 4986
4987 CellularNetwork* cellular3 = new CellularNetwork("cellular3");
4988 cellular3->set_name("Fake Cellular 3 (policy-managed)");
4989 cellular3->set_device_path(cellular->device_path());
4990 cellular3->set_activation_state(ACTIVATION_STATE_ACTIVATED);
4991 cellular3->set_network_technology(NETWORK_TECHNOLOGY_EVDO);
4992 NetworkUIData cellular3_ui_data;
4993 cellular3_ui_data.set_onc_source(NetworkUIData::ONC_SOURCE_USER_POLICY);
4994 cellular3_ui_data.FillDictionary(cellular3->ui_data());
4995 AddStubNetwork(cellular3, PROFILE_NONE);
4996
4997 CellularNetwork* cellular4 = new CellularNetwork("cellular4");
4998 cellular4->set_name("Fake Cellular 4 (policy-managed)");
4999 cellular4->set_device_path(cellular_gsm->device_path());
5000 cellular4->set_activation_state(ACTIVATION_STATE_ACTIVATED);
5001 cellular4->set_network_technology(NETWORK_TECHNOLOGY_GSM);
5002 NetworkUIData cellular4_ui_data;
5003 cellular4_ui_data.set_onc_source(NetworkUIData::ONC_SOURCE_USER_POLICY);
5004 cellular4_ui_data.FillDictionary(cellular4->ui_data());
5005 AddStubNetwork(cellular4, PROFILE_NONE);
5006
4952 CellularDataPlan* base_plan = new CellularDataPlan(); 5007 CellularDataPlan* base_plan = new CellularDataPlan();
4953 base_plan->plan_name = "Base plan"; 5008 base_plan->plan_name = "Base plan";
4954 base_plan->plan_type = CELLULAR_DATA_PLAN_METERED_BASE; 5009 base_plan->plan_type = CELLULAR_DATA_PLAN_METERED_BASE;
4955 base_plan->plan_data_bytes = 100ll * 1024 * 1024; 5010 base_plan->plan_data_bytes = 100ll * 1024 * 1024;
4956 base_plan->data_bytes_used = base_plan->plan_data_bytes / 4; 5011 base_plan->data_bytes_used = base_plan->plan_data_bytes / 4;
4957 5012
4958 CellularDataPlan* paid_plan = new CellularDataPlan(); 5013 CellularDataPlan* paid_plan = new CellularDataPlan();
4959 paid_plan->plan_name = "Paid plan"; 5014 paid_plan->plan_name = "Paid plan";
4960 paid_plan->plan_type = CELLULAR_DATA_PLAN_METERED_PAID; 5015 paid_plan->plan_type = CELLULAR_DATA_PLAN_METERED_PAID;
4961 paid_plan->plan_data_bytes = 5ll * 1024 * 1024 * 1024; 5016 paid_plan->plan_data_bytes = 5ll * 1024 * 1024 * 1024;
(...skipping 17 matching lines...) Expand all
4979 vpn2->set_provider_type(PROVIDER_TYPE_L2TP_IPSEC_USER_CERT); 5034 vpn2->set_provider_type(PROVIDER_TYPE_L2TP_IPSEC_USER_CERT);
4980 vpn2->set_username("VPN User 2"); 5035 vpn2->set_username("VPN User 2");
4981 AddStubNetwork(vpn2, PROFILE_USER); 5036 AddStubNetwork(vpn2, PROFILE_USER);
4982 5037
4983 VirtualNetwork* vpn3 = new VirtualNetwork("vpn3"); 5038 VirtualNetwork* vpn3 = new VirtualNetwork("vpn3");
4984 vpn3->set_name("Fake VPN3"); 5039 vpn3->set_name("Fake VPN3");
4985 vpn3->set_server_hostname("vpn3server.fake.com"); 5040 vpn3->set_server_hostname("vpn3server.fake.com");
4986 vpn3->set_provider_type(PROVIDER_TYPE_OPEN_VPN); 5041 vpn3->set_provider_type(PROVIDER_TYPE_OPEN_VPN);
4987 AddStubNetwork(vpn3, PROFILE_USER); 5042 AddStubNetwork(vpn3, PROFILE_USER);
4988 5043
5044 VirtualNetwork* vpn4 = new VirtualNetwork("vpn4");
5045 vpn4->set_name("Fake VPN4 (policy-managed)");
5046 vpn4->set_server_hostname("vpn4server.fake.com");
5047 vpn4->set_provider_type(PROVIDER_TYPE_OPEN_VPN);
5048 NetworkUIData vpn4_ui_data;
5049 vpn4_ui_data.set_onc_source(NetworkUIData::ONC_SOURCE_DEVICE_POLICY);
5050 vpn4_ui_data.FillDictionary(vpn4->ui_data());
5051 AddStubNetwork(vpn4, PROFILE_USER);
5052
4989 wifi_scanning_ = false; 5053 wifi_scanning_ = false;
4990 offline_mode_ = false; 5054 offline_mode_ = false;
4991 5055
4992 // Ensure our active network is connected and vice versa, otherwise our 5056 // Ensure our active network is connected and vice versa, otherwise our
4993 // autotest browser_tests sometimes conclude the device is offline. 5057 // autotest browser_tests sometimes conclude the device is offline.
4994 CHECK(active_network()->connected()); 5058 CHECK(active_network()->connected());
4995 CHECK(connected_network()->is_active()); 5059 CHECK(connected_network()->is_active());
4996 5060
4997 std::string test_blob( 5061 std::string test_blob(
4998 "{" 5062 "{"
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
5249 return impl; 5313 return impl;
5250 } 5314 }
5251 5315
5252 ///////////////////////////////////////////////////////////////////////////// 5316 /////////////////////////////////////////////////////////////////////////////
5253 5317
5254 } // namespace chromeos 5318 } // namespace chromeos
5255 5319
5256 // Allows InvokeLater without adding refcounting. This class is a Singleton and 5320 // Allows InvokeLater without adding refcounting. This class is a Singleton and
5257 // won't be deleted until its last InvokeLater is run. 5321 // won't be deleted until its last InvokeLater is run.
5258 DISABLE_RUNNABLE_METHOD_REFCOUNT(chromeos::NetworkLibraryImplBase); 5322 DISABLE_RUNNABLE_METHOD_REFCOUNT(chromeos::NetworkLibraryImplBase);
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/cros/network_library_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698