Commit 6cc15bfd authored by Azeem Arshad's avatar Azeem Arshad Committed by Chromium LUCI CQ

[CrOS Cellular] Fix ESim network list in mobile data subpage.

This fixes issue with eSIM networks incorrectly appearing
in pSIM group. This was caused because the eid property was
not being checked properly.

Bug: 1093185
Change-Id: I9c3f2f72810e186dd35f47dedff61bf7efd2c06b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2575149Reviewed-by: default avatarKyle Horimoto <khorimoto@chromium.org>
Commit-Queue: Azeem Arshad <azeemarshad@chromium.org>
Cr-Commit-Position: refs/heads/master@{#834354}
parent bdcac45f
...@@ -213,6 +213,7 @@ js_library("cellular_networks_list") { ...@@ -213,6 +213,7 @@ js_library("cellular_networks_list") {
deps = [ deps = [
":cellular_eid_popup", ":cellular_eid_popup",
"//ui/webui/resources/cr_components/chromeos/cellular_setup:cellular_types", "//ui/webui/resources/cr_components/chromeos/cellular_setup:cellular_types",
"//ui/webui/resources/cr_components/chromeos/network:mojo_interface_provider",
"//ui/webui/resources/cr_components/chromeos/network:onc_mojo", "//ui/webui/resources/cr_components/chromeos/network:onc_mojo",
"//ui/webui/resources/cr_elements/cr_icon_button:cr_icon_button", "//ui/webui/resources/cr_elements/cr_icon_button:cr_icon_button",
"//ui/webui/resources/js:i18n_behavior", "//ui/webui/resources/js:i18n_behavior",
......
<link rel="import" href="chrome://resources/html/polymer.html"> <link rel="import" href="chrome://resources/html/polymer.html">
<link rel="import" href="chrome://resources/cr_components/chromeos/network/onc_mojo.html"> <link rel="import" href="chrome://resources/cr_components/chromeos/network/onc_mojo.html">
<link rel="import" href="chrome://resources/cr_components/chromeos/network/mojo_interface_provider.html">
<link rel="import" href="chrome://resources/cr_elements/cr_icon_button/cr_icon_button.html"> <link rel="import" href="chrome://resources/cr_elements/cr_icon_button/cr_icon_button.html">
<link rel="import" href="chrome://resources/cr_elements/cr_icons_css.html"> <link rel="import" href="chrome://resources/cr_elements/cr_icons_css.html">
<link rel="import" href="chrome://resources/cr_components/chromeos/cellular_setup/cellular_types.html"> <link rel="import" href="chrome://resources/cr_components/chromeos/cellular_setup/cellular_types.html">
......
...@@ -24,7 +24,7 @@ Polymer({ ...@@ -24,7 +24,7 @@ Polymer({
value() { value() {
return []; return [];
}, },
observer: 'networksListChange_', observer: 'onNetworksListChanged_',
}, },
/** /**
...@@ -85,34 +85,51 @@ Polymer({ ...@@ -85,34 +85,51 @@ Polymer({
'close-eid-popup': 'toggleEidPopup_', 'close-eid-popup': 'toggleEidPopup_',
}, },
/** @private {?chromeos.networkConfig.mojom.CrosNetworkConfigRemote} */
networkConfig_: null,
/** @override */
created() {
this.networkConfig_ = network_config.MojoInterfaceProviderImpl.getInstance()
.getMojoServiceRemote();
},
/** /**
* @private * @private
*/ */
networksListChange_() { async onNetworksListChanged_() {
const mojom = chromeos.networkConfig.mojom; const mojom = chromeos.networkConfig.mojom;
const pSimNetworks = []; const pSimNetworks = [];
const eSimNetworks = []; const eSimNetworks = [];
const tetherNetworks = []; const tetherNetworks = [];
for (const network of this.networks) { for (const network of this.networks) {
if (network.eid) {
eSimNetworks.push(network);
continue;
}
if (network.type === mojom.NetworkType.kTether) { if (network.type === mojom.NetworkType.kTether) {
tetherNetworks.push(network); tetherNetworks.push(network);
continue; continue;
} }
pSimNetworks.push(network);
const managedPropertiesResponse =
await this.networkConfig_.getManagedProperties(network.guid);
if (!managedPropertiesResponse || !managedPropertiesResponse.result) {
console.error(
'Unable to get managed properties for network. guid=',
network.guid);
continue;
}
if (managedPropertiesResponse.result.typeProperties.cellular.eid) {
eSimNetworks.push(network);
} else {
pSimNetworks.push(network);
}
} }
this.eSimNetworks_ = eSimNetworks; this.eSimNetworks_ = eSimNetworks;
this.pSimNetworks_ = pSimNetworks; this.pSimNetworks_ = pSimNetworks;
this.tetherNetworks_ = tetherNetworks; this.tetherNetworks_ = tetherNetworks;
}, },
/** /**
* @param {!Array<!OncMojo.NetworkStateProperties>} list * @param {!Array<!OncMojo.NetworkStateProperties>} list
* @returns {boolean} * @returns {boolean}
......
...@@ -50,18 +50,34 @@ suite('CellularNetworkList', function() { ...@@ -50,18 +50,34 @@ suite('CellularNetworkList', function() {
} }
test('Tether plus cellular', async () => { test('Tether plus cellular', async () => {
const eSimNetwork1 = OncMojo.getDefaultNetworkState(
mojom.NetworkType.kCellular, 'cellular_esim1');
const eSimNetwork2 = OncMojo.getDefaultNetworkState(
mojom.NetworkType.kCellular, 'cellular_esim2');
setNetworksForTest(mojom.NetworkType.kCellular, [ setNetworksForTest(mojom.NetworkType.kCellular, [
OncMojo.getDefaultNetworkState(mojom.NetworkType.kCellular, 'cellular1'), OncMojo.getDefaultNetworkState(mojom.NetworkType.kCellular, 'cellular1'),
OncMojo.getDefaultNetworkState(mojom.NetworkType.kCellular, 'cellular2'), OncMojo.getDefaultNetworkState(mojom.NetworkType.kCellular, 'cellular2'),
eSimNetwork1,
eSimNetwork2,
OncMojo.getDefaultNetworkState(mojom.NetworkType.kTether, 'tether1'), OncMojo.getDefaultNetworkState(mojom.NetworkType.kTether, 'tether1'),
OncMojo.getDefaultNetworkState(mojom.NetworkType.kTether, 'tether2'), OncMojo.getDefaultNetworkState(mojom.NetworkType.kTether, 'tether2'),
]); ]);
Polymer.dom.flush();
const eSimManagedProperties1 = OncMojo.getDefaultManagedProperties(
mojom.NetworkType.kCellular, eSimNetwork1.guid, eSimNetwork1.name);
const eSimManagedProperties2 = OncMojo.getDefaultManagedProperties(
mojom.NetworkType.kCellular, eSimNetwork2.guid, eSimNetwork2.name);
eSimManagedProperties1.typeProperties.cellular.eid =
'11111111111111111111111111111111';
eSimManagedProperties2.typeProperties.cellular.eid =
'22222222222222222222222222222222';
mojoApi_.setManagedPropertiesForTest(eSimManagedProperties1);
mojoApi_.setManagedPropertiesForTest(eSimManagedProperties2);
await flushAsync(); await flushAsync();
assertEquals(2, cellularNetworkList.pSimNetworks_.length); const eSimNetworkList = cellularNetworkList.$$('#esimNetworkList');
assertEquals(2, cellularNetworkList.tetherNetworks_.length); assertTrue(!!eSimNetworkList);
const pSimNetworkList = cellularNetworkList.$$('#psimNetworkList'); const pSimNetworkList = cellularNetworkList.$$('#psimNetworkList');
assertTrue(!!pSimNetworkList); assertTrue(!!pSimNetworkList);
...@@ -69,6 +85,7 @@ suite('CellularNetworkList', function() { ...@@ -69,6 +85,7 @@ suite('CellularNetworkList', function() {
const tetherNetworkList = cellularNetworkList.$$('#tetherNetworkList'); const tetherNetworkList = cellularNetworkList.$$('#tetherNetworkList');
assertTrue(!!tetherNetworkList); assertTrue(!!tetherNetworkList);
assertEquals(2, eSimNetworkList.networks.length);
assertEquals(2, pSimNetworkList.networks.length); assertEquals(2, pSimNetworkList.networks.length);
assertEquals(2, tetherNetworkList.networks.length); assertEquals(2, tetherNetworkList.networks.length);
}); });
...@@ -109,6 +126,7 @@ suite('CellularNetworkList', function() { ...@@ -109,6 +126,7 @@ suite('CellularNetworkList', function() {
pSimCellularEvent.detail.pageName, pSimCellularEvent.detail.pageName,
cellularSetup.CellularSetupPageName.PSIM_FLOW_UI); cellularSetup.CellularSetupPageName.PSIM_FLOW_UI);
}); });
test('Show EID and QR code popup', async () => { test('Show EID and QR code popup', async () => {
let eidPopup = cellularNetworkList.$$('.eid-popup'); let eidPopup = cellularNetworkList.$$('.eid-popup');
assertFalse(!!eidPopup); assertFalse(!!eidPopup);
......
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