Commit 83c0a8eb authored by Anatoliy Potapchuk's avatar Anatoliy Potapchuk Committed by Commit Bot

[Kiosk] Fix flaky KioskTest.LaunchAppNetworkPortal

We did properly handle the case of losing network connection during
installation. We should close the network configure ui as soon as the
network appears to cover cases without an operator.

Bug: 1104169
Change-Id: Iee4cc7f342f417d51c152fd6d7ffa86e97affdf0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2302618Reviewed-by: default avatarAnqing Zhao <anqing@chromium.org>
Reviewed-by: default avatarDenis Kuznetsov [CET] <antrim@chromium.org>
Reviewed-by: default avatarRoman Sorokin [CET] <rsorokin@chromium.org>
Commit-Queue: Anatoliy Potapchuk <apotapchuk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#790900}
parent af550f78
...@@ -1012,8 +1012,7 @@ IN_PROC_BROWSER_TEST_F(KioskTest, LaunchAppNetworkDownConfigureNotAllowed) { ...@@ -1012,8 +1012,7 @@ IN_PROC_BROWSER_TEST_F(KioskTest, LaunchAppNetworkDownConfigureNotAllowed) {
WaitForAppLaunchSuccess(); WaitForAppLaunchSuccess();
} }
// TODO(crbug.com/1104169): Fix flaky failures and enable this test. IN_PROC_BROWSER_TEST_F(KioskTest, LaunchAppNetworkPortal) {
IN_PROC_BROWSER_TEST_F(KioskTest, DISABLED_LaunchAppNetworkPortal) {
// Mock network could be configured without the owner password. // Mock network could be configured without the owner password.
ScopedCanConfigureNetwork can_configure_network(true, false); ScopedCanConfigureNetwork can_configure_network(true, false);
......
...@@ -233,6 +233,10 @@ KioskAppManagerBase::App KioskLaunchController::GetAppData() { ...@@ -233,6 +233,10 @@ KioskAppManagerBase::App KioskLaunchController::GetAppData() {
} }
} }
bool KioskLaunchController::IsNetworkRequired() {
return network_required_;
}
void KioskLaunchController::CleanUp() { void KioskLaunchController::CleanUp() {
network_wait_timer_.Stop(); network_wait_timer_.Stop();
splash_wait_timer_.Stop(); splash_wait_timer_.Stop();
...@@ -300,6 +304,10 @@ void KioskLaunchController::InitializeNetwork() { ...@@ -300,6 +304,10 @@ void KioskLaunchController::InitializeNetwork() {
network_wait_timer_.Start(FROM_HERE, g_network_wait_time, this, network_wait_timer_.Start(FROM_HERE, g_network_wait_time, this,
&KioskLaunchController::OnNetworkWaitTimedOut); &KioskLaunchController::OnNetworkWaitTimedOut);
// When we are asked to initialize network, we should remember that this app
// requires network.
network_required_ = true;
splash_screen_view_->UpdateAppLaunchState( splash_screen_view_->UpdateAppLaunchState(
AppLaunchSplashScreenView::APP_LAUNCH_STATE_PREPARING_NETWORK); AppLaunchSplashScreenView::APP_LAUNCH_STATE_PREPARING_NETWORK);
...@@ -310,9 +318,6 @@ void KioskLaunchController::InitializeNetwork() { ...@@ -310,9 +318,6 @@ void KioskLaunchController::InitializeNetwork() {
} }
void KioskLaunchController::OnNetworkWaitTimedOut() { void KioskLaunchController::OnNetworkWaitTimedOut() {
DCHECK_EQ(
app_state_,
AppState::INIT_NETWORK); // Otherwise we should be installing the app.
DCHECK_EQ(network_ui_state_, NetworkUIState::NOT_SHOWING); DCHECK_EQ(network_ui_state_, NetworkUIState::NOT_SHOWING);
auto connection_type = network::mojom::ConnectionType::CONNECTION_UNKNOWN; auto connection_type = network::mojom::ConnectionType::CONNECTION_UNKNOWN;
...@@ -500,7 +505,7 @@ void KioskLaunchController::ShowNetworkConfigureUI() { ...@@ -500,7 +505,7 @@ void KioskLaunchController::ShowNetworkConfigureUI() {
splash_screen_view_->ShowNetworkConfigureUI(); splash_screen_view_->ShowNetworkConfigureUI();
} }
void KioskLaunchController::CloseNetworkConfigureScreenIfTimedout() { void KioskLaunchController::CloseNetworkConfigureScreenIfOnline() {
if (network_ui_state_ == NetworkUIState::SHOWING && network_wait_timedout_) { if (network_ui_state_ == NetworkUIState::SHOWING && network_wait_timedout_) {
SYSLOG(INFO) << "We are back online, closing network configure screen."; SYSLOG(INFO) << "We are back online, closing network configure screen.";
splash_screen_view_->ToggleNetworkConfig(false); splash_screen_view_->ToggleNetworkConfig(false);
...@@ -519,10 +524,9 @@ void KioskLaunchController::OnNetworkConfigRequested() { ...@@ -519,10 +524,9 @@ void KioskLaunchController::OnNetworkConfigRequested() {
case AppState::INSTALLING: case AppState::INSTALLING:
// When requesting to show network configure UI, we should cancel current // When requesting to show network configure UI, we should cancel current
// installation and restart it as soon as the network is configured. // installation and restart it as soon as the network is configured.
// This is identical to what happens when we lose network connection app_state_ = AppState::INIT_NETWORK;
// during installation app_launcher_->RestartLauncher();
network_ui_state_ = NetworkUIState::NEED_TO_SHOW; MaybeShowNetworkConfigureUI();
OnNetworkStateChanged(/*online*/ false);
break; break;
case AppState::LAUNCHED: case AppState::LAUNCHED:
// We do nothing since the splash screen is soon to be destroyed. // We do nothing since the splash screen is soon to be destroyed.
...@@ -545,17 +549,15 @@ void KioskLaunchController::OnNetworkStateChanged(bool online) { ...@@ -545,17 +549,15 @@ void KioskLaunchController::OnNetworkStateChanged(bool online) {
if (network_ui_state_ == NetworkUIState::NOT_SHOWING || if (network_ui_state_ == NetworkUIState::NOT_SHOWING ||
network_wait_timedout_) { network_wait_timedout_) {
network_wait_timer_.Stop(); network_wait_timer_.Stop();
CloseNetworkConfigureScreenIfTimedout(); CloseNetworkConfigureScreenIfOnline();
app_launcher_->ContinueWithNetworkReady(); app_launcher_->ContinueWithNetworkReady();
} }
} }
if (app_state_ == AppState::INSTALLING && !online) { if (app_state_ == AppState::INSTALLING && network_required_ && !online) {
SYSLOG(WARNING) SYSLOG(WARNING)
<< "Connection lost during installation, restarting launcher."; << "Connection lost during installation, restarting launcher.";
app_state_ = AppState::INIT_NETWORK; OnNetworkWaitTimedOut();
app_launcher_->RestartLauncher();
MaybeShowNetworkConfigureUI();
} }
} }
......
...@@ -119,6 +119,7 @@ class KioskLaunchController : public KioskProfileLoader::Delegate, ...@@ -119,6 +119,7 @@ class KioskLaunchController : public KioskProfileLoader::Delegate,
void OnNetworkConfigFinished() override; void OnNetworkConfigFinished() override;
void OnNetworkStateChanged(bool online) override; void OnNetworkStateChanged(bool online) override;
KioskAppManagerBase::App GetAppData() override; KioskAppManagerBase::App GetAppData() override;
bool IsNetworkRequired() override;
// KioskAppLauncher::Delegate: // KioskAppLauncher::Delegate:
void InitializeNetwork() override; void InitializeNetwork() override;
...@@ -149,7 +150,7 @@ class KioskLaunchController : public KioskProfileLoader::Delegate, ...@@ -149,7 +150,7 @@ class KioskLaunchController : public KioskProfileLoader::Delegate,
void MaybeShowNetworkConfigureUI(); void MaybeShowNetworkConfigureUI();
// Shows the network configuration dialog. // Shows the network configuration dialog.
void ShowNetworkConfigureUI(); void ShowNetworkConfigureUI();
void CloseNetworkConfigureScreenIfTimedout(); void CloseNetworkConfigureScreenIfOnline();
void HandleWebAppInstallFailed(); void HandleWebAppInstallFailed();
...@@ -173,6 +174,8 @@ class KioskLaunchController : public KioskProfileLoader::Delegate, ...@@ -173,6 +174,8 @@ class KioskLaunchController : public KioskProfileLoader::Delegate,
// Whether app should be launched as soon as it is ready. // Whether app should be launched as soon as it is ready.
bool launch_on_install_ = false; bool launch_on_install_ = false;
bool network_wait_timedout_ = false; bool network_wait_timedout_ = false;
// Whether the network is required for the installation.
bool network_required_ = false;
// Used to login into kiosk user profile. // Used to login into kiosk user profile.
std::unique_ptr<KioskProfileLoader> kiosk_profile_loader_; std::unique_ptr<KioskProfileLoader> kiosk_profile_loader_;
......
...@@ -242,7 +242,6 @@ IN_PROC_BROWSER_TEST_F(KioskLaunchControllerTest, ...@@ -242,7 +242,6 @@ IN_PROC_BROWSER_TEST_F(KioskLaunchControllerTest,
launch_controls()->OnAppInstalling(); launch_controls()->OnAppInstalling();
ExpectState(AppState::INSTALLING, NetworkUIState::NOT_SHOWING); ExpectState(AppState::INSTALLING, NetworkUIState::NOT_SHOWING);
EXPECT_CALL(*launcher(), RestartLauncher()).Times(1);
SetOnline(false); SetOnline(false);
launch_controls()->InitializeNetwork(); launch_controls()->InitializeNetwork();
ExpectState(AppState::INIT_NETWORK, NetworkUIState::SHOWING); ExpectState(AppState::INIT_NETWORK, NetworkUIState::SHOWING);
......
...@@ -125,12 +125,6 @@ void AppLaunchSplashScreenHandler::UpdateAppLaunchState(AppLaunchState state) { ...@@ -125,12 +125,6 @@ void AppLaunchSplashScreenHandler::UpdateAppLaunchState(AppLaunchState state) {
l10n_util::GetStringUTF8(GetProgressMessageFromState(state_))); l10n_util::GetStringUTF8(GetProgressMessageFromState(state_)));
} }
// When we are asked to initialize network, we should remember that this app
// requires network.
if (state_ == AppLaunchState::APP_LAUNCH_STATE_PREPARING_NETWORK) {
network_required_ = true;
}
UpdateState(NetworkError::ERROR_REASON_UPDATE); UpdateState(NetworkError::ERROR_REASON_UPDATE);
} }
...@@ -145,7 +139,7 @@ void AppLaunchSplashScreenHandler::ShowNetworkConfigureUI() { ...@@ -145,7 +139,7 @@ void AppLaunchSplashScreenHandler::ShowNetworkConfigureUI() {
// We should not block users when the network was not required by the // We should not block users when the network was not required by the
// controller. // controller.
if (!network_required_) { if (!delegate_->IsNetworkRequired()) {
state = NetworkStateInformer::ONLINE; state = NetworkStateInformer::ONLINE;
} }
......
...@@ -42,6 +42,9 @@ class AppLaunchSplashScreenView { ...@@ -42,6 +42,9 @@ class AppLaunchSplashScreenView {
// Returns the data needed to be displayed on the splash screen. // Returns the data needed to be displayed on the splash screen.
virtual KioskAppManagerBase::App GetAppData() = 0; virtual KioskAppManagerBase::App GetAppData() = 0;
// Tells whether the network connection is required for app launch.
virtual bool IsNetworkRequired() = 0;
}; };
enum AppLaunchState { enum AppLaunchState {
...@@ -133,8 +136,6 @@ class AppLaunchSplashScreenHandler ...@@ -133,8 +136,6 @@ class AppLaunchSplashScreenHandler
// Whether network configure UI is being shown. // Whether network configure UI is being shown.
bool network_config_shown_ = false; bool network_config_shown_ = false;
// Whether the network is required in order to proceed with app launch.
bool network_required_ = false;
DISALLOW_COPY_AND_ASSIGN(AppLaunchSplashScreenHandler); DISALLOW_COPY_AND_ASSIGN(AppLaunchSplashScreenHandler);
}; };
......
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