Commit 453592c8 authored by Theo Johnson-kanu's avatar Theo Johnson-kanu Committed by Chromium LUCI CQ

[CrOS cellular] Hide eSIM section when not supported by device

Screenshot: https://screenshot.googleplex.com/788UBYwsmiFUoQV.png

Bug: 1163556
Change-Id: I5724e5af92c02edd024cd93c3b2dbde7219704e0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2611615
Commit-Queue: Nnamdi Theodore Johnson-kanu <tjohnsonkanu@google.com>
Reviewed-by: default avatarAzeem Arshad <azeemarshad@chromium.org>
Cr-Commit-Position: refs/heads/master@{#841343}
parent 2cfbefe0
...@@ -68,6 +68,7 @@ ...@@ -68,6 +68,7 @@
} }
</style> </style>
<template is="dom-if" if="[[!!euicc_]]" restamp>
<div class="cellular-network-list-header esim-list-header flex"> <div class="cellular-network-list-header esim-list-header flex">
<div class="esim-list-title">$i18n{cellularNetworkEsimLabel}</div> <div class="esim-list-title">$i18n{cellularNetworkEsimLabel}</div>
<div class="flex-column"> <div class="flex-column">
...@@ -106,6 +107,7 @@ ...@@ -106,6 +107,7 @@
</settings-localized-link> </settings-localized-link>
</div> </div>
</template> </template>
</template>
<div class="cellular-network-list-header"> <div class="cellular-network-list-header">
$i18n{cellularNetworkPsimLabel} $i18n{cellularNetworkPsimLabel}
</div> </div>
......
...@@ -104,6 +104,15 @@ Polymer({ ...@@ -104,6 +104,15 @@ Polymer({
shouldShowEidPopup_: { shouldShowEidPopup_: {
type: Boolean, type: Boolean,
value: false, value: false,
},
/**
* Euicc object representing the active euicc_ module on the device
* @private {?chromeos.cellularSetup.mojom.EuiccRemote}
*/
euicc_: {
type: Object,
value: null,
} }
}, },
...@@ -156,13 +165,12 @@ Polymer({ ...@@ -156,13 +165,12 @@ Polymer({
.getAvailableEuiccs() .getAvailableEuiccs()
.then(response => { .then(response => {
if (response.euiccs.length > 0) { if (response.euiccs.length > 0) {
return this.fetchESimPendingProfileListForEuicc_( // Use first available euicc as current. Only single Euicc modules are
response.euiccs[0]); // currently supported.
this.euicc_ = response.euiccs[0];
return this.fetchESimPendingProfileListForEuicc_(this.euicc_);
} }
throw new Error('No EUICCs available.'); this.euicc_ = null;
})
.catch(error => {
console.error(error);
}); });
}, },
......
...@@ -32,7 +32,9 @@ suite('CellularNetworkList', function() { ...@@ -32,7 +32,9 @@ suite('CellularNetworkList', function() {
eSimManagerRemote = new cellular_setup.FakeESimManagerRemote(); eSimManagerRemote = new cellular_setup.FakeESimManagerRemote();
cellular_setup.setESimManagerRemoteForTesting(eSimManagerRemote); cellular_setup.setESimManagerRemoteForTesting(eSimManagerRemote);
});
function init() {
cellularNetworkList = document.createElement('cellular-networks-list'); cellularNetworkList = document.createElement('cellular-networks-list');
// iron-list will not create list items if the container of the list is of // iron-list will not create list items if the container of the list is of
// size zero. // size zero.
...@@ -40,7 +42,7 @@ suite('CellularNetworkList', function() { ...@@ -40,7 +42,7 @@ suite('CellularNetworkList', function() {
cellularNetworkList.style.width = '100%'; cellularNetworkList.style.width = '100%';
document.body.appendChild(cellularNetworkList); document.body.appendChild(cellularNetworkList);
Polymer.dom.flush(); Polymer.dom.flush();
}); }
function setNetworksForTest(type, networks) { function setNetworksForTest(type, networks) {
mojoApi_.resetForTest(); mojoApi_.resetForTest();
...@@ -57,6 +59,8 @@ suite('CellularNetworkList', function() { ...@@ -57,6 +59,8 @@ suite('CellularNetworkList', function() {
} }
test('Tether, cellular and eSIM profiles', async () => { test('Tether, cellular and eSIM profiles', async () => {
init();
const eSimNetwork1 = OncMojo.getDefaultNetworkState( const eSimNetwork1 = OncMojo.getDefaultNetworkState(
mojom.NetworkType.kCellular, 'cellular_esim1'); mojom.NetworkType.kCellular, 'cellular_esim1');
const eSimNetwork2 = OncMojo.getDefaultNetworkState( const eSimNetwork2 = OncMojo.getDefaultNetworkState(
...@@ -102,10 +106,12 @@ suite('CellularNetworkList', function() { ...@@ -102,10 +106,12 @@ suite('CellularNetworkList', function() {
test( test(
'Fire show cellular setup event on eSim/psim no network link click', 'Fire show cellular setup event on eSim/psim no network link click',
async () => { async () => {
eSimManagerRemote.addEuiccForTest(0);
init();
setNetworksForTest(mojom.NetworkType.kCellular, [ setNetworksForTest(mojom.NetworkType.kCellular, [
OncMojo.getDefaultNetworkState(mojom.NetworkType.kTether, 'tether1'), OncMojo.getDefaultNetworkState(mojom.NetworkType.kTether, 'tether1'),
]); ]);
eSimManagerRemote.addEuiccForTest(0);
Polymer.dom.flush(); Polymer.dom.flush();
await flushAsync(); await flushAsync();
...@@ -139,8 +145,8 @@ suite('CellularNetworkList', function() { ...@@ -139,8 +145,8 @@ suite('CellularNetworkList', function() {
}); });
test('Show EID and QR code popup', async () => { test('Show EID and QR code popup', async () => {
eSimManagerRemote.addEuiccForTest(0); eSimManagerRemote.addEuiccForTest(1);
init();
let eidPopup = cellularNetworkList.$$('.eid-popup'); let eidPopup = cellularNetworkList.$$('.eid-popup');
assertFalse(!!eidPopup); assertFalse(!!eidPopup);
const eidPopupBtn = cellularNetworkList.$$('#eidPopupButton'); const eidPopupBtn = cellularNetworkList.$$('#eidPopupButton');
...@@ -155,6 +161,7 @@ suite('CellularNetworkList', function() { ...@@ -155,6 +161,7 @@ suite('CellularNetworkList', function() {
test('Install pending eSIM profile', async () => { test('Install pending eSIM profile', async () => {
eSimManagerRemote.addEuiccForTest(1); eSimManagerRemote.addEuiccForTest(1);
init();
await flushAsync(); await flushAsync();
let eSimNetworkList = cellularNetworkList.$$('#esimNetworkList'); let eSimNetworkList = cellularNetworkList.$$('#esimNetworkList');
...@@ -177,4 +184,16 @@ suite('CellularNetworkList', function() { ...@@ -177,4 +184,16 @@ suite('CellularNetworkList', function() {
.shadowRoot.querySelector('a'); .shadowRoot.querySelector('a');
assertTrue(!!esimNoNetworkAnchor); assertTrue(!!esimNoNetworkAnchor);
}); });
test('Hide esim section when no EUICC is found', async () => {
setNetworksForTest(mojom.NetworkType.kCellular, [
OncMojo.getDefaultNetworkState(mojom.NetworkType.kTether, 'tether1'),
]);
init();
Polymer.dom.flush();
await flushAsync();
const esimNetworkList = cellularNetworkList.$$('#esimNetworkList');
assertFalse(!!esimNetworkList);
});
}); });
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