Commit 59bfe6d5 authored by Nnamdi Theodore Johnson-Kanu's avatar Nnamdi Theodore Johnson-Kanu Committed by Commit Bot

[CrOS cellular] Fix carrier title in setup + tests

- Updates cellular setup mojom interface provider
- Adds fake cellular setup remote
- Updates psim test to use fake cellular setup remote
- Updates nameOfCarrierPendingSetup to use cellular metadata

Screenshot: https://screenshot.googleplex.com/6FvKzBoWQf4hGGQ.png

Bug: 1093185
Change-Id: Iabd1e0df3c02e192fbb1b109140d5d8d6c891284
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2443073
Commit-Queue: Nnamdi Theodore Johnson-kanu <tjohnsonkanu@google.com>
Reviewed-by: default avatarKyle Horimoto <khorimoto@chromium.org>
Reviewed-by: default avatarAzeem Arshad <azeemarshad@chromium.org>
Cr-Commit-Position: refs/heads/master@{#814956}
parent dc55cea9
...@@ -85,6 +85,7 @@ if (optimize_webui) { ...@@ -85,6 +85,7 @@ if (optimize_webui) {
"../../../../../ui/webui/resources:preprocess", "../../../../../ui/webui/resources:preprocess",
] ]
excludes = [ excludes = [
"chrome://resources/mojo/chromeos/services/cellular_setup/public/mojom/cellular_setup.mojom-lite.js",
"chrome://resources/mojo/chromeos/services/network_config/public/mojom/cros_network_config.mojom-lite.js", "chrome://resources/mojo/chromeos/services/network_config/public/mojom/cros_network_config.mojom-lite.js",
"chrome://resources/mojo/chromeos/services/network_config/public/mojom/network_types.mojom-lite.js", "chrome://resources/mojo/chromeos/services/network_config/public/mojom/network_types.mojom-lite.js",
"chrome://resources/mojo/mojo/public/mojom/base/unguessable_token.mojom-lite.js", "chrome://resources/mojo/mojo/public/mojom/base/unguessable_token.mojom-lite.js",
......
...@@ -252,6 +252,7 @@ if (include_js_tests) { ...@@ -252,6 +252,7 @@ if (include_js_tests) {
"$root_gen_dir/chrome/test/data/webui/cr_components/chromeos/cellular_setup/psim_flow_ui_test.m.js", "$root_gen_dir/chrome/test/data/webui/cr_components/chromeos/cellular_setup/psim_flow_ui_test.m.js",
"$root_gen_dir/chrome/test/data/webui/cr_components/chromeos/cellular_setup/setup_selection_flow_test.m.js", "$root_gen_dir/chrome/test/data/webui/cr_components/chromeos/cellular_setup/setup_selection_flow_test.m.js",
"$root_gen_dir/chrome/test/data/webui/cr_components/chromeos/cellular_setup/sim_detect_page_test.m.js", "$root_gen_dir/chrome/test/data/webui/cr_components/chromeos/cellular_setup/sim_detect_page_test.m.js",
"$root_gen_dir/chrome/test/data/webui/cr_components/chromeos/cellular_setup/fake_cellular_setup_remote.m.js",
"$root_gen_dir/chrome/test/data/webui/cr_components/chromeos/cellular_setup/fake_cellular_setup_delegate.m.js", "$root_gen_dir/chrome/test/data/webui/cr_components/chromeos/cellular_setup/fake_cellular_setup_delegate.m.js",
"$root_gen_dir/chrome/test/data/webui/cr_components/chromeos/network/cr_policy_network_behavior_mojo_tests.m.js", "$root_gen_dir/chrome/test/data/webui/cr_components/chromeos/network/cr_policy_network_behavior_mojo_tests.m.js",
"$root_gen_dir/chrome/test/data/webui/cr_components/chromeos/network/cr_policy_network_indicator_mojo_tests.m.js", "$root_gen_dir/chrome/test/data/webui/cr_components/chromeos/network/cr_policy_network_indicator_mojo_tests.m.js",
......
...@@ -17,8 +17,11 @@ js_modulizer("modulize") { ...@@ -17,8 +17,11 @@ js_modulizer("modulize") {
"setup_selection_flow_test.js", "setup_selection_flow_test.js",
"sim_detect_page_test.js", "sim_detect_page_test.js",
"fake_cellular_setup_delegate.js", "fake_cellular_setup_delegate.js",
"fake_cellular_setup_remote.js",
] ]
namespace_rewrites = namespace_rewrites = cr_components_chromeos_namespace_rewrites + [
cr_components_chromeos_namespace_rewrites + "cellular_setup.FakeCellularSetupDelegate|FakeCellularSetupDelegate",
[ "cellular_setup.FakeCellularSetupDelegate|FakeCellularSetupDelegate" ] "cellular_setup.FakeCarrierPortalHandlerRemote|FakeCarrierPortalHandlerRemote",
"cellular_setup.FakeCellularSetupRemote|FakeCellularSetupRemote",
]
} }
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
cr.define('cellular_setup', function() {
/**
* @implements {chromeos.cellularSetup.mojom.CarrierPortalHandlerInterface}
*/
/* #export */ class FakeCarrierPortalHandlerRemote {
constructor() {}
/** @override */
onCarrierPortalStatusChange(status) {
this.status_ = status;
}
}
/** @implements {chromeos.cellularSetup.mojom.CellularSetupInterface} */
/* #export */ class FakeCellularSetupRemote {
/**
* @param {!FakeCarrierPortalHandlerRemote} handler
*/
constructor(handler) {
this.carrierHandler_ = handler;
}
/** @override */
startActivation(delegate) {
this.delegate_ = delegate;
return new Promise((resolve, reject) => {
setTimeout(function() {
resolve({observer: this.carrierHandler_});
});
});
}
/**
* @returns {!chromeos.cellularSetup.mojom.ActivationDelegateRemote}
*/
getLastActivationDelegate() {
return this.delegate_;
}
}
// #cr_define_end
return {
FakeCellularSetupRemote: FakeCellularSetupRemote,
FakeCarrierPortalHandlerRemote: FakeCarrierPortalHandlerRemote,
};
});
\ No newline at end of file
...@@ -7,16 +7,43 @@ ...@@ -7,16 +7,43 @@
// #import 'chrome://resources/cr_components/chromeos/cellular_setup/psim_flow_ui.m.js'; // #import 'chrome://resources/cr_components/chromeos/cellular_setup/psim_flow_ui.m.js';
// #import {PSimUIState} from 'chrome://resources/cr_components/chromeos/cellular_setup/psim_flow_ui.m.js'; // #import {PSimUIState} from 'chrome://resources/cr_components/chromeos/cellular_setup/psim_flow_ui.m.js';
// #import {setCellularSetupRemoteForTesting} from 'chrome://resources/cr_components/chromeos/cellular_setup/mojo_interface_provider.m.js';
// #import {flush, Polymer} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; // #import {flush, Polymer} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js';
// #import {assertTrue} from '../../../chai_assert.js'; // #import {assertTrue} from '../../../chai_assert.js';
// #import {FakeCellularSetupDelegate} from './fake_cellular_setup_delegate.m.js'; // #import {FakeCellularSetupDelegate} from './fake_cellular_setup_delegate.m.js';
// #import {FakeCarrierPortalHandlerRemote, FakeCellularSetupRemote} from './fake_cellular_setup_remote.m.js';
// clang-format on // clang-format on
suite('CrComponentsPsimFlowUiTest', function() { suite('CrComponentsPsimFlowUiTest', function() {
let pSimPage; let pSimPage;
/** @type {?chromeos.cellularSetup.mojom.CellularSetupRemote} */
let cellularSetupRemote = null;
/** @type {?FakeCarrierPortalHandlerRemote} */
let cellularCarrierHandler = null;
/** @type {?chromeos.cellularSetup.mojom.ActivationDelegateReceiver} */
let cellularActivationDelegate = null;
function flushAsync() {
Polymer.dom.flush();
// Use setTimeout to wait for the next macrotask.
return new Promise(resolve => setTimeout(resolve));
}
suiteSetup(function() {
cellularCarrierHandler =
new cellular_setup.FakeCarrierPortalHandlerRemote();
cellularSetupRemote =
new cellular_setup.FakeCellularSetupRemote(cellularCarrierHandler);
cellular_setup.setCellularSetupRemoteForTesting(cellularSetupRemote);
});
setup(function() { setup(function() {
pSimPage = document.createElement('psim-flow-ui'); pSimPage = document.createElement('psim-flow-ui');
pSimPage.delegate = new cellular_setup.FakeCellularSetupDelegate(); pSimPage.delegate = new cellular_setup.FakeCellularSetupDelegate();
pSimPage.initSubflow();
document.body.appendChild(pSimPage); document.body.appendChild(pSimPage);
Polymer.dom.flush(); Polymer.dom.flush();
}); });
...@@ -34,4 +61,26 @@ suite('CrComponentsPsimFlowUiTest', function() { ...@@ -34,4 +61,26 @@ suite('CrComponentsPsimFlowUiTest', function() {
pSimPage.state_ === pSimPage.state_ ===
cellularSetup.PSimUIState.WAITING_FOR_ACTIVATION_TO_FINISH); cellularSetup.PSimUIState.WAITING_FOR_ACTIVATION_TO_FINISH);
}); });
test('Carrier title on provisioning page', async () => {
cellularActivationDelegate =
cellularSetupRemote.getLastActivationDelegate();
cellularActivationDelegate.onActivationStarted({
paymentUrl: {url: ''},
paymentPostData: 'verison_post_data',
carrier: 'Verizon wireless',
meid: '012345678912345',
imei: '012345678912345',
mdn: '0123456789'
});
cellularCarrierHandler.onCarrierPortalStatusChange(
chromeos.cellularSetup.mojom.CarrierPortalStatus
.kPortalLoadedWithoutPaidUser);
await flushAsync();
assertTrue(pSimPage.nameOfCarrierPendingSetup === 'Verizon wireless');
});
}); });
...@@ -70,6 +70,7 @@ GEN('#include "content/public/test/browser_test.h"'); ...@@ -70,6 +70,7 @@ GEN('#include "content/public/test/browser_test.h"');
]], ]],
['PsimFlowUi', 'cellular_setup/psim_flow_ui_test.js',[ ['PsimFlowUi', 'cellular_setup/psim_flow_ui_test.js',[
'./cellular_setup/fake_cellular_setup_delegate.js', './cellular_setup/fake_cellular_setup_delegate.js',
'./cellular_setup/fake_cellular_setup_remote.js',
]], ]],
['SetupSelectionFlow', 'cellular_setup/setup_selection_flow_test.js',[ ['SetupSelectionFlow', 'cellular_setup/setup_selection_flow_test.js',[
'./cellular_setup/fake_cellular_setup_delegate.js', './cellular_setup/fake_cellular_setup_delegate.js',
......
...@@ -2,37 +2,36 @@ ...@@ -2,37 +2,36 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// #import {addSingletonGetter} from 'chrome://resources/js/cr.m.js'; // clang-format off
// #import 'chrome://resources/mojo/mojo/public/js/mojo_bindings_lite.js';
// #import 'chrome://resources/mojo/url/mojom/url.mojom-lite.js';
// #import 'chrome://resources/mojo/chromeos/services/cellular_setup/public/mojom/cellular_setup.mojom-lite.js';
// clang-format on
cr.define('cellular_setup', function() { cr.define('cellular_setup', function() {
/** @interface */ let cellularRemote = null;
/* #export */ class MojoInterfaceProvider {
/** @return {!chromeos.cellularSetup.mojom.CellularSetupRemote} */ /**
getMojoServiceRemote() {} * @param {?chromeos.cellularSetup.mojom.CellularSetupRemote}
* testCellularRemote A test cellular remote
*/
/* #export */ function setCellularSetupRemoteForTesting(testCellularRemote) {
cellularRemote = testCellularRemote;
} }
/** @implements {cellular_setup.MojoInterfaceProvider} */ /**
/* #export */ class MojoInterfaceProviderImpl { * @returns {!chromeos.cellularSetup.mojom.CellularSetupRemote}
constructor() { */
/** @private {?chromeos.cellularSetup.mojom.CellularSetupRemote} */ /* #export */ function getCellularSetupRemote() {
this.remote_ = null; if (cellularRemote) {
return cellularRemote;
} }
/** @override */ cellularRemote = chromeos.cellularSetup.mojom.CellularSetup.getRemote();
getMojoServiceRemote() {
if (!this.remote_) {
this.remote_ = chromeos.cellularSetup.mojom.CellularSetup.getRemote();
}
return this.remote_; return cellularRemote;
}
} }
cr.addSingletonGetter(MojoInterfaceProviderImpl);
// #cr_define_end // #cr_define_end
return { return {setCellularSetupRemoteForTesting, getCellularSetupRemote};
MojoInterfaceProvider: MojoInterfaceProvider,
MojoInterfaceProviderImpl: MojoInterfaceProviderImpl,
};
}); });
...@@ -78,6 +78,8 @@ cr.define('cellularSetup', function() { ...@@ -78,6 +78,8 @@ cr.define('cellularSetup', function() {
nameOfCarrierPendingSetup: { nameOfCarrierPendingSetup: {
type: String, type: String,
notify: true, notify: true,
computed: 'getCarrierText(' +
'selectedPSimPageName_, cellularMetadata_.*)',
}, },
/** /**
...@@ -133,9 +135,9 @@ cr.define('cellularSetup', function() { ...@@ -133,9 +135,9 @@ cr.define('cellularSetup', function() {
/** /**
* Provides an interface to the CellularSetup Mojo service. * Provides an interface to the CellularSetup Mojo service.
* @private {?cellular_setup.MojoInterfaceProvider} * @private {?chromeos.cellularSetup.mojom.CellularSetupRemote}
*/ */
mojoInterfaceProvider_: null, cellularSetupRemote_: null,
/** /**
* Delegate responsible for routing activation started/finished events. * Delegate responsible for routing activation started/finished events.
...@@ -159,8 +161,7 @@ cr.define('cellularSetup', function() { ...@@ -159,8 +161,7 @@ cr.define('cellularSetup', function() {
/** @override */ /** @override */
created() { created() {
this.mojoInterfaceProvider_ = this.cellularSetupRemote_ = cellular_setup.getCellularSetupRemote();
cellular_setup.MojoInterfaceProviderImpl.getInstance();
}, },
/** /**
...@@ -264,6 +265,15 @@ cr.define('cellularSetup', function() { ...@@ -264,6 +265,15 @@ cr.define('cellularSetup', function() {
} }
}, },
/** @private */
getCarrierText() {
if (this.selectedPSimPageName_ === PSimPageName.PROVISIONING &&
this.cellularMetadata_) {
return this.cellularMetadata_.carrier;
}
return '';
},
/** @private */ /** @private */
updateShowError_() { updateShowError_() {
switch (this.state_) { switch (this.state_) {
...@@ -293,7 +303,6 @@ cr.define('cellularSetup', function() { ...@@ -293,7 +303,6 @@ cr.define('cellularSetup', function() {
case PSimUIState.WAITING_FOR_USER_PAYMENT: case PSimUIState.WAITING_FOR_USER_PAYMENT:
case PSimUIState.ACTIVATION_SUCCESS: case PSimUIState.ACTIVATION_SUCCESS:
this.selectedPSimPageName_ = PSimPageName.PROVISIONING; this.selectedPSimPageName_ = PSimPageName.PROVISIONING;
this.nameOfCarrierPendingSetup = 'TODO: network title';
return; return;
case PSimUIState.WAITING_FOR_ACTIVATION_TO_FINISH: case PSimUIState.WAITING_FOR_ACTIVATION_TO_FINISH:
case PSimUIState.TIMEOUT_FINISH_ACTIVATION: case PSimUIState.TIMEOUT_FINISH_ACTIVATION:
...@@ -356,7 +365,7 @@ cr.define('cellularSetup', function() { ...@@ -356,7 +365,7 @@ cr.define('cellularSetup', function() {
*/ */
(this)); (this));
this.mojoInterfaceProvider_.getMojoServiceRemote() this.cellularSetupRemote_
.startActivation( .startActivation(
this.activationDelegateReceiver_.$.bindNewPipeAndPassRemote()) this.activationDelegateReceiver_.$.bindNewPipeAndPassRemote())
.then( .then(
......
...@@ -14,7 +14,8 @@ cr_components_chromeos_namespace_rewrites = [ ...@@ -14,7 +14,8 @@ cr_components_chromeos_namespace_rewrites = [
"cellularSetup.PSimPageName|PSimPageName", "cellularSetup.PSimPageName|PSimPageName",
"cellularSetup.PSimUIState|PSimUIState", "cellularSetup.PSimUIState|PSimUIState",
"cellularSetup.getTimeoutMsForPSimUIState|getTimeoutMsForPSimUIState", "cellularSetup.getTimeoutMsForPSimUIState|getTimeoutMsForPSimUIState",
"cellular_setup.MojoInterfaceProvider|MojoInterfaceProvider", "cellular_setup.getCellularSetupRemote|getCellularSetupRemote",
"cellular_setup.setCellularSetupRemoteForTesting|setCellularSetupRemoteForTesting",
"cellular_setup.CellularSetupDelegate|CellularSetupDelegate", "cellular_setup.CellularSetupDelegate|CellularSetupDelegate",
"network_config.MojoInterfaceProvider|MojoInterfaceProvider", "network_config.MojoInterfaceProvider|MojoInterfaceProvider",
"network_config.MojoInterfaceProviderImpl|MojoInterfaceProviderImpl", "network_config.MojoInterfaceProviderImpl|MojoInterfaceProviderImpl",
...@@ -28,7 +29,7 @@ cr_components_chromeos_auto_imports = [ ...@@ -28,7 +29,7 @@ cr_components_chromeos_auto_imports = [
"ui/webui/resources/cr_components/chromeos/cellular_setup/cellular_types.html|ButtonState,Button,ButtonBarState,CellularSetupPageName", "ui/webui/resources/cr_components/chromeos/cellular_setup/cellular_types.html|ButtonState,Button,ButtonBarState,CellularSetupPageName",
"ui/webui/resources/cr_components/chromeos/cellular_setup/cellular_setup_delegate.html|CellularSetupDelegate", "ui/webui/resources/cr_components/chromeos/cellular_setup/cellular_setup_delegate.html|CellularSetupDelegate",
"ui/webui/resources/cr_components/chromeos/cellular_setup/subflow_behavior.html|SubflowBehavior", "ui/webui/resources/cr_components/chromeos/cellular_setup/subflow_behavior.html|SubflowBehavior",
"ui/webui/resources/cr_components/chromeos/cellular_setup/mojo_interface_provider.html|MojoInterfaceProviderImpl,MojoInterfaceProvider", "ui/webui/resources/cr_components/chromeos/cellular_setup/mojo_interface_provider.html|setCellularSetupRemoteForTesting,getCellularSetupRemote",
"ui/webui/resources/cr_components/chromeos/network/cr_policy_network_behavior_mojo.html|CrPolicyNetworkBehaviorMojo", "ui/webui/resources/cr_components/chromeos/network/cr_policy_network_behavior_mojo.html|CrPolicyNetworkBehaviorMojo",
"ui/webui/resources/cr_components/chromeos/network/onc_mojo.html|OncMojo", "ui/webui/resources/cr_components/chromeos/network/onc_mojo.html|OncMojo",
"ui/webui/resources/cr_components/chromeos/network/network_config_element_behavior.html|NetworkConfigElementBehavior", "ui/webui/resources/cr_components/chromeos/network/network_config_element_behavior.html|NetworkConfigElementBehavior",
......
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