Commit b541a5ae authored by khorimoto's avatar khorimoto Committed by Commit bot

[CrOS Tether] Remove the ManagedTetherProperties dictionary.

All instances of ManagedTetherProperties are replaced by (non-managed) TetherProperties. This change is due to the fact that tether properties are not managed by policy.

This CL also adds API tests for the functions which can return Tether networks.

BUG=672263
CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:closure_compilation

Review-Url: https://codereview.chromium.org/2847453002
Cr-Commit-Position: refs/heads/master@{#467815}
parent 20d7dfb2
......@@ -300,6 +300,19 @@ class NetworkingPrivateChromeOSApiTest : public ExtensionApiTest {
content::RunAllPendingInMessageLoop();
}
void SetupTether() {
chromeos::NetworkStateHandler* network_state_handler =
chromeos::NetworkHandler::Get()->network_state_handler();
network_state_handler->SetTetherTechnologyState(
chromeos::NetworkStateHandler::TechnologyState::TECHNOLOGY_ENABLED);
network_state_handler->AddTetherNetworkState(
"tetherGuid1", "tetherName1", "tetherCarrier1",
50 /* battery_percentage */, 75 /* signal_strength */);
network_state_handler->AddTetherNetworkState(
"tetherGuid2", "tetherName2", "tetherCarrier2",
75 /* battery_percentage */, 100 /* signal_strength */);
}
void AddService(const std::string& service_path,
const std::string& name,
const std::string& type,
......@@ -851,6 +864,31 @@ IN_PROC_BROWSER_TEST_F(NetworkingPrivateChromeOSApiTest, GetGlobalPolicy) {
EXPECT_TRUE(RunNetworkingSubtest("getGlobalPolicy")) << message_;
}
IN_PROC_BROWSER_TEST_F(NetworkingPrivateChromeOSApiTest,
Tether_GetTetherNetworks) {
SetupTether();
EXPECT_TRUE(RunNetworkingSubtest("getTetherNetworks")) << message_;
}
IN_PROC_BROWSER_TEST_F(NetworkingPrivateChromeOSApiTest,
Tether_GetTetherNetworkProperties) {
SetupTether();
EXPECT_TRUE(RunNetworkingSubtest("getTetherNetworkProperties")) << message_;
}
IN_PROC_BROWSER_TEST_F(NetworkingPrivateChromeOSApiTest,
Tether_GetTetherNetworkManagedProperties) {
SetupTether();
EXPECT_TRUE(RunNetworkingSubtest("getTetherNetworkManagedProperties"))
<< message_;
}
IN_PROC_BROWSER_TEST_F(NetworkingPrivateChromeOSApiTest,
Tether_GetTetherNetworkState) {
SetupTether();
EXPECT_TRUE(RunNetworkingSubtest("getTetherNetworkState")) << message_;
}
// Tests subset of networking API for the networking API alias - to verify that
// using API methods and event does not cause access exceptions (due to
// missing permissions).
......
......@@ -81,6 +81,18 @@ var privateHelpers = {
};
chrome.networkingPrivate.onPortalDetectionCompleted.addListener(
self.onPortalDetectionCompleted);
},
verifyTetherNetwork: function(
properties, expectedGuid, expectedName, expectedBatteryPercentage,
expectedCarrier, expectedSignalStrength) {
//assertEq(NetworkType.Tether, properties.Type);
assertEq(expectedGuid, properties.GUID);
assertEq(expectedName,
properties.Name.hasOwnProperty('Active') ? properties.Name.Active
: properties.Name);
assertEq(expectedBatteryPercentage, properties.Tether.BatteryPercentage);
assertEq(expectedCarrier, properties.Tether.Carrier);
assertEq(expectedSignalStrength, properties.Tether.SignalStrength);
}
};
......@@ -923,6 +935,41 @@ var availableTests = [
}, result);
}));
},
function getTetherNetworks() {
chrome.networkingPrivate.getNetworks(
{networkType: 'Tether'},
callbackPass(function(tetherNetworks) {
assertEq(2, tetherNetworks.length);
privateHelpers.verifyTetherNetwork(tetherNetworks[0], 'tetherGuid1',
'tetherName1', 50, 'tetherCarrier1', 75);
privateHelpers.verifyTetherNetwork(tetherNetworks[1], 'tetherGuid2',
'tetherName2', 75, 'tetherCarrier2', 100);
}));
},
function getTetherNetworkProperties() {
chrome.networkingPrivate.getProperties(
'tetherGuid1',
callbackPass(function(tetherNetwork) {
privateHelpers.verifyTetherNetwork(tetherNetwork, 'tetherGuid1',
'tetherName1', 50, 'tetherCarrier1', 75);
}));
},
function getTetherNetworkManagedProperties() {
chrome.networkingPrivate.getManagedProperties(
'tetherGuid1',
callbackPass(function(tetherNetwork) {
privateHelpers.verifyTetherNetwork(tetherNetwork, 'tetherGuid1',
'tetherName1', 50, 'tetherCarrier1', 75);
}));
},
function getTetherNetworkState() {
chrome.networkingPrivate.getState(
'tetherGuid1',
callbackPass(function(tetherNetwork) {
privateHelpers.verifyTetherNetwork(tetherNetwork, 'tetherGuid1',
'tetherName1', 50, 'tetherCarrier1', 75);
}));
},
];
chrome.test.getConfig(function(config) {
......
......@@ -476,8 +476,11 @@ const NetworkState* NetworkStateHandler::GetNetworkStateFromServicePath(
bool configured_only) const {
ManagedState* managed =
GetModifiableManagedState(&network_list_, service_path);
if (!managed) {
managed = GetModifiableManagedState(&tether_network_list_, service_path);
if (!managed)
return nullptr;
}
const NetworkState* network = managed->AsNetworkState();
DCHECK(network);
if (!network->update_received() ||
......
......@@ -167,7 +167,9 @@ const OncFieldSignature ethernet_fields[] = {
{::onc::ethernet::kEAP, &kEAPSignature},
{NULL}};
const OncFieldSignature tether_fields[] = {
const OncFieldSignature tether_fields[] = {{NULL}};
const OncFieldSignature tether_with_state_fields[] = {
{::onc::tether::kBatteryPercentage, &kIntegerSignature},
{::onc::tether::kCarrier, &kStringSignature},
{::onc::tether::kSignalStrength, &kIntegerSignature},
......@@ -336,7 +338,7 @@ const OncFieldSignature network_with_state_fields[] = {
{::onc::network_config::kRestrictedConnectivity, &kBoolSignature},
{::onc::network_config::kSavedIPConfig, &kSavedIPConfigSignature},
{::onc::network_config::kSource, &kStringSignature},
{::onc::network_config::kTether, &kTetherSignature},
{::onc::network_config::kTether, &kTetherWithStateSignature},
{::onc::network_config::kWiFi, &kWiFiWithStateSignature},
{::onc::network_config::kWimax, &kWiMAXWithStateSignature},
{NULL}};
......@@ -401,8 +403,6 @@ const OncValueSignature kVPNSignature = {base::Value::Type::DICTIONARY,
vpn_fields, NULL};
const OncValueSignature kEthernetSignature = {base::Value::Type::DICTIONARY,
ethernet_fields, NULL};
const OncValueSignature kTetherSignature = {base::Value::Type::DICTIONARY,
tether_fields, NULL};
const OncValueSignature kIPConfigSignature = {base::Value::Type::DICTIONARY,
ipconfig_fields, NULL};
const OncValueSignature kSavedIPConfigSignature = {
......@@ -439,6 +439,11 @@ const OncValueSignature kNetworkWithStateSignature = {
const OncValueSignature kWiFiWithStateSignature = {
base::Value::Type::DICTIONARY, wifi_with_state_fields, NULL,
&kWiFiSignature};
const OncValueSignature kTetherSignature = {base::Value::Type::DICTIONARY,
tether_fields, NULL};
const OncValueSignature kTetherWithStateSignature = {
base::Value::Type::DICTIONARY, tether_with_state_fields, NULL,
&kTetherSignature};
const OncValueSignature kWiMAXWithStateSignature = {
base::Value::Type::DICTIONARY, wimax_with_state_fields, NULL,
&kWiMAXSignature};
......
......@@ -47,6 +47,7 @@ CHROMEOS_EXPORT extern const OncValueSignature kVerifyX509Signature;
CHROMEOS_EXPORT extern const OncValueSignature kVPNSignature;
CHROMEOS_EXPORT extern const OncValueSignature kEthernetSignature;
CHROMEOS_EXPORT extern const OncValueSignature kTetherSignature;
CHROMEOS_EXPORT extern const OncValueSignature kTetherWithStateSignature;
CHROMEOS_EXPORT extern const OncValueSignature kIPConfigSignature;
CHROMEOS_EXPORT extern const OncValueSignature kSavedIPConfigSignature;
CHROMEOS_EXPORT extern const OncValueSignature kStaticIPConfigSignature;
......
......@@ -248,6 +248,7 @@ const OncValueTranslationEntry onc_value_translation_table[] = {
{&kVerifyX509Signature, verify_x509_fields},
{&kVPNSignature, vpn_fields},
{&kTetherSignature, tether_fields},
{&kTetherWithStateSignature, tether_fields},
{&kWiFiSignature, wifi_fields},
{&kWiFiWithStateSignature, wifi_fields},
{&kWiMAXSignature, wimax_fields},
......
......@@ -129,7 +129,7 @@ std::unique_ptr<base::DictionaryValue> Validator::MapObject(
valid = ValidateEAP(repaired.get());
} else if (&signature == &kCertificateSignature) {
valid = ValidateCertificate(repaired.get());
} else if (&signature == &kTetherSignature) {
} else if (&signature == &kTetherWithStateSignature) {
valid = ValidateTether(repaired.get());
}
}
......
......@@ -586,12 +586,6 @@ namespace networkingPrivate {
long? SignalStrength;
};
dictionary ManagedTetherProperties {
ManagedLong? BatteryPercentage;
ManagedDOMString? Carrier;
ManagedLong? SignalStrength;
};
dictionary VPNProperties {
boolean? AutoConnect;
DOMString? Host;
......@@ -732,7 +726,7 @@ namespace networkingPrivate {
ManagedIPConfigProperties? StaticIPConfig;
IPConfigProperties? SavedIPConfig;
DOMString? Source;
ManagedTetherProperties? Tether;
TetherProperties? Tether;
NetworkType Type;
ManagedVPNProperties? VPN;
ManagedWiFiProperties? WiFi;
......
......@@ -773,16 +773,6 @@ chrome.networkingPrivate.EthernetStateProperties;
*/
chrome.networkingPrivate.TetherProperties;
/**
* @typedef {{
* BatteryPercentage: (!chrome.networkingPrivate.ManagedLong|undefined),
* Carrier: (!chrome.networkingPrivate.ManagedDOMString|undefined),
* SignalStrength: (!chrome.networkingPrivate.ManagedLong|undefined)
* }}
* @see https://developer.chrome.com/extensions/networkingPrivate#type-ManagedTetherProperties
*/
chrome.networkingPrivate.ManagedTetherProperties;
/**
* @typedef {{
* AutoConnect: (boolean|undefined),
......@@ -968,7 +958,7 @@ chrome.networkingPrivate.NetworkProperties;
* StaticIPConfig: (!chrome.networkingPrivate.ManagedIPConfigProperties|undefined),
* SavedIPConfig: (!chrome.networkingPrivate.IPConfigProperties|undefined),
* Source: (string|undefined),
* Tether: (!chrome.networkingPrivate.ManagedTetherProperties|undefined),
* Tether: (!chrome.networkingPrivate.TetherProperties|undefined),
* Type: !chrome.networkingPrivate.NetworkType,
* VPN: (!chrome.networkingPrivate.ManagedVPNProperties|undefined),
* WiFi: (!chrome.networkingPrivate.ManagedWiFiProperties|undefined),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment