Commit 9d387cd5 authored by Sanja Perisic's avatar Sanja Perisic Committed by Chromium LUCI CQ

Added tests for AppLaunchState in browsertest for Kiosk

Updated AppLaunchSplashScreenView and FakeAppLaunchSplashScreenHandler, so that they now support tests for app launch state.

Added verification for app launch state in Kiosk browser test.

Bug: 1156788
Change-Id: If2ebead7e75c80bdbcfe1dbf62c2dd415fcee024
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2588933Reviewed-by: default avatarRoman Sorokin [CET] <rsorokin@chromium.org>
Reviewed-by: default avatarAnatoliy Potapchuk <apotapchuk@chromium.org>
Reviewed-by: default avatarAnqing Zhao <anqing@chromium.org>
Reviewed-by: default avatarAya Elsayed <ayaelattar@chromium.org>
Commit-Queue: Sanja Perisic <sanjaperisic@chromium.org>
Cr-Commit-Position: refs/heads/master@{#837567}
parent dbb1f6a0
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/external_provider_impl.h" #include "chrome/browser/extensions/external_provider_impl.h"
#include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/webui/chromeos/login/app_launch_splash_screen_handler.h"
#include "chrome/browser/ui/webui/chromeos/login/fake_app_launch_splash_screen_handler.h" #include "chrome/browser/ui/webui/chromeos/login/fake_app_launch_splash_screen_handler.h"
#include "chrome/test/base/in_process_browser_test.h" #include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/testing_profile.h" #include "chrome/test/base/testing_profile.h"
...@@ -98,6 +99,10 @@ class KioskLaunchControllerTest ...@@ -98,6 +99,10 @@ class KioskLaunchControllerTest
EXPECT_EQ(network_state, controller_->network_ui_state_); EXPECT_EQ(network_state, controller_->network_ui_state_);
} }
void ExpectViewState(AppLaunchSplashScreenView::AppLaunchState launch_state) {
EXPECT_EQ(launch_state, view_->GetAppLaunchState());
}
void FireSplashScreenTimer() { controller_->OnTimerFire(); } void FireSplashScreenTimer() { controller_->OnTimerFire(); }
void SetOnline(bool online) { void SetOnline(bool online) {
...@@ -131,19 +136,27 @@ IN_PROC_BROWSER_TEST_P(KioskLaunchControllerTest, RegularFlow) { ...@@ -131,19 +136,27 @@ IN_PROC_BROWSER_TEST_P(KioskLaunchControllerTest, RegularFlow) {
launch_controls()->InitializeNetwork(); launch_controls()->InitializeNetwork();
ExpectState(AppState::kInitNetwork, NetworkUIState::kNotShowing); ExpectState(AppState::kInitNetwork, NetworkUIState::kNotShowing);
ExpectViewState(AppLaunchSplashScreenView::AppLaunchState::
APP_LAUNCH_STATE_PREPARING_NETWORK);
EXPECT_CALL(*launcher(), ContinueWithNetworkReady()).Times(1); EXPECT_CALL(*launcher(), ContinueWithNetworkReady()).Times(1);
SetOnline(true); SetOnline(true);
launch_controls()->OnAppInstalling(); launch_controls()->OnAppInstalling();
ExpectViewState(AppLaunchSplashScreenView::AppLaunchState::
APP_LAUNCH_STATE_INSTALLING_APPLICATION);
launch_controls()->OnAppPrepared(); launch_controls()->OnAppPrepared();
ExpectState(AppState::kInstalled, NetworkUIState::kNotShowing); ExpectState(AppState::kInstalled, NetworkUIState::kNotShowing);
ExpectViewState(AppLaunchSplashScreenView::AppLaunchState::
APP_LAUNCH_STATE_WAITING_APP_WINDOW);
EXPECT_CALL(*launcher(), LaunchApp()).Times(1); EXPECT_CALL(*launcher(), LaunchApp()).Times(1);
FireSplashScreenTimer(); FireSplashScreenTimer();
launch_controls()->OnAppLaunched(); launch_controls()->OnAppLaunched();
ExpectState(AppState::kLaunched, NetworkUIState::kNotShowing); ExpectState(AppState::kLaunched, NetworkUIState::kNotShowing);
ExpectViewState(AppLaunchSplashScreenView::AppLaunchState::
APP_LAUNCH_STATE_WAITING_APP_WINDOW);
EXPECT_TRUE(session_manager::SessionManager::Get()->IsSessionStarted()); EXPECT_TRUE(session_manager::SessionManager::Get()->IsSessionStarted());
} }
...@@ -156,12 +169,16 @@ IN_PROC_BROWSER_TEST_P(KioskLaunchControllerTest, AlreadyInstalled) { ...@@ -156,12 +169,16 @@ IN_PROC_BROWSER_TEST_P(KioskLaunchControllerTest, AlreadyInstalled) {
launch_controls()->OnAppPrepared(); launch_controls()->OnAppPrepared();
ExpectState(AppState::kInstalled, NetworkUIState::kNotShowing); ExpectState(AppState::kInstalled, NetworkUIState::kNotShowing);
ExpectViewState(AppLaunchSplashScreenView::AppLaunchState::
APP_LAUNCH_STATE_WAITING_APP_WINDOW);
EXPECT_CALL(*launcher(), LaunchApp()).Times(1); EXPECT_CALL(*launcher(), LaunchApp()).Times(1);
FireSplashScreenTimer(); FireSplashScreenTimer();
launch_controls()->OnAppLaunched(); launch_controls()->OnAppLaunched();
ExpectState(AppState::kLaunched, NetworkUIState::kNotShowing); ExpectState(AppState::kLaunched, NetworkUIState::kNotShowing);
ExpectViewState(AppLaunchSplashScreenView::AppLaunchState::
APP_LAUNCH_STATE_WAITING_APP_WINDOW);
EXPECT_TRUE(session_manager::SessionManager::Get()->IsSessionStarted()); EXPECT_TRUE(session_manager::SessionManager::Get()->IsSessionStarted());
} }
...@@ -176,22 +193,32 @@ IN_PROC_BROWSER_TEST_P(KioskLaunchControllerTest, ...@@ -176,22 +193,32 @@ IN_PROC_BROWSER_TEST_P(KioskLaunchControllerTest,
EXPECT_CALL(*launcher(), Initialize()).Times(1); EXPECT_CALL(*launcher(), Initialize()).Times(1);
profile_controls()->OnProfileLoaded(profile()); profile_controls()->OnProfileLoaded(profile());
ExpectViewState(AppLaunchSplashScreenView::AppLaunchState::
APP_LAUNCH_STATE_SHOWING_NETWORK_CONFIGURE_UI);
// WebKioskAppLauncher::Initialize call is synchronous, we have to call the // WebKioskAppLauncher::Initialize call is synchronous, we have to call the
// response now. // response now.
launch_controls()->InitializeNetwork(); launch_controls()->InitializeNetwork();
ExpectState(AppState::kInitNetwork, NetworkUIState::kShowing); ExpectState(AppState::kInitNetwork, NetworkUIState::kShowing);
ExpectViewState(AppLaunchSplashScreenView::AppLaunchState::
APP_LAUNCH_STATE_PREPARING_NETWORK);
EXPECT_CALL(*launcher(), RestartLauncher()).Times(1); EXPECT_CALL(*launcher(), RestartLauncher()).Times(1);
view_controls()->OnNetworkConfigFinished(); view_controls()->OnNetworkConfigFinished();
ExpectViewState(AppLaunchSplashScreenView::AppLaunchState::
APP_LAUNCH_STATE_PREPARING_PROFILE);
EXPECT_CALL(*launcher(), LaunchApp()).Times(1); EXPECT_CALL(*launcher(), LaunchApp()).Times(1);
launch_controls()->OnAppPrepared(); launch_controls()->OnAppPrepared();
ExpectViewState(AppLaunchSplashScreenView::AppLaunchState::
APP_LAUNCH_STATE_WAITING_APP_WINDOW);
// Skipping INSTALLED state since there splash screen timer is stopped when // Skipping INSTALLED state since there splash screen timer is stopped when
// network configure ui was shown. // network configure ui was shown.
launch_controls()->OnAppLaunched(); launch_controls()->OnAppLaunched();
ExpectState(AppState::kLaunched, NetworkUIState::kNotShowing); ExpectState(AppState::kLaunched, NetworkUIState::kNotShowing);
ExpectViewState(AppLaunchSplashScreenView::AppLaunchState::
APP_LAUNCH_STATE_WAITING_APP_WINDOW);
EXPECT_TRUE(session_manager::SessionManager::Get()->IsSessionStarted()); EXPECT_TRUE(session_manager::SessionManager::Get()->IsSessionStarted());
} }
...@@ -206,6 +233,8 @@ IN_PROC_BROWSER_TEST_P(KioskLaunchControllerTest, ...@@ -206,6 +233,8 @@ IN_PROC_BROWSER_TEST_P(KioskLaunchControllerTest,
launch_controls()->InitializeNetwork(); launch_controls()->InitializeNetwork();
ExpectState(AppState::kInitNetwork, NetworkUIState::kNotShowing); ExpectState(AppState::kInitNetwork, NetworkUIState::kNotShowing);
ExpectViewState(AppLaunchSplashScreenView::AppLaunchState::
APP_LAUNCH_STATE_PREPARING_NETWORK);
EXPECT_CALL(*launcher(), ContinueWithNetworkReady()).Times(1); EXPECT_CALL(*launcher(), ContinueWithNetworkReady()).Times(1);
SetOnline(true); SetOnline(true);
...@@ -217,21 +246,31 @@ IN_PROC_BROWSER_TEST_P(KioskLaunchControllerTest, ...@@ -217,21 +246,31 @@ IN_PROC_BROWSER_TEST_P(KioskLaunchControllerTest,
// Launcher restart causes network to be requested again. // Launcher restart causes network to be requested again.
launch_controls()->InitializeNetwork(); launch_controls()->InitializeNetwork();
ExpectState(AppState::kInitNetwork, NetworkUIState::kShowing); ExpectState(AppState::kInitNetwork, NetworkUIState::kShowing);
ExpectViewState(AppLaunchSplashScreenView::AppLaunchState::
APP_LAUNCH_STATE_PREPARING_NETWORK);
EXPECT_CALL(*launcher(), RestartLauncher()).Times(1); EXPECT_CALL(*launcher(), RestartLauncher()).Times(1);
view_controls()->OnNetworkConfigFinished(); view_controls()->OnNetworkConfigFinished();
ExpectViewState(AppLaunchSplashScreenView::AppLaunchState::
APP_LAUNCH_STATE_PREPARING_PROFILE);
launch_controls()->OnAppInstalling(); launch_controls()->OnAppInstalling();
ExpectState(AppState::kInstallingApp, NetworkUIState::kNotShowing); ExpectState(AppState::kInstallingApp, NetworkUIState::kNotShowing);
ExpectViewState(AppLaunchSplashScreenView::AppLaunchState::
APP_LAUNCH_STATE_INSTALLING_APPLICATION);
launch_controls()->OnAppPrepared(); launch_controls()->OnAppPrepared();
ExpectState(AppState::kInstalled, NetworkUIState::kNotShowing); ExpectState(AppState::kInstalled, NetworkUIState::kNotShowing);
ExpectViewState(AppLaunchSplashScreenView::AppLaunchState::
APP_LAUNCH_STATE_WAITING_APP_WINDOW);
EXPECT_CALL(*launcher(), LaunchApp()).Times(1); EXPECT_CALL(*launcher(), LaunchApp()).Times(1);
FireSplashScreenTimer(); FireSplashScreenTimer();
launch_controls()->OnAppLaunched(); launch_controls()->OnAppLaunched();
ExpectState(AppState::kLaunched, NetworkUIState::kNotShowing); ExpectState(AppState::kLaunched, NetworkUIState::kNotShowing);
ExpectViewState(AppLaunchSplashScreenView::AppLaunchState::
APP_LAUNCH_STATE_WAITING_APP_WINDOW);
EXPECT_TRUE(session_manager::SessionManager::Get()->IsSessionStarted()); EXPECT_TRUE(session_manager::SessionManager::Get()->IsSessionStarted());
} }
...@@ -245,30 +284,43 @@ IN_PROC_BROWSER_TEST_P(KioskLaunchControllerTest, ...@@ -245,30 +284,43 @@ IN_PROC_BROWSER_TEST_P(KioskLaunchControllerTest,
launch_controls()->InitializeNetwork(); launch_controls()->InitializeNetwork();
ExpectState(AppState::kInitNetwork, NetworkUIState::kNotShowing); ExpectState(AppState::kInitNetwork, NetworkUIState::kNotShowing);
ExpectViewState(AppLaunchSplashScreenView::AppLaunchState::
APP_LAUNCH_STATE_PREPARING_NETWORK);
EXPECT_CALL(*launcher(), ContinueWithNetworkReady()).Times(1); EXPECT_CALL(*launcher(), ContinueWithNetworkReady()).Times(1);
SetOnline(true); SetOnline(true);
launch_controls()->OnAppInstalling(); launch_controls()->OnAppInstalling();
ExpectState(AppState::kInstallingApp, NetworkUIState::kNotShowing); ExpectState(AppState::kInstallingApp, NetworkUIState::kNotShowing);
ExpectViewState(AppLaunchSplashScreenView::AppLaunchState::
APP_LAUNCH_STATE_INSTALLING_APPLICATION);
SetOnline(false); SetOnline(false);
launch_controls()->InitializeNetwork(); launch_controls()->InitializeNetwork();
ExpectState(AppState::kInitNetwork, NetworkUIState::kShowing); ExpectState(AppState::kInitNetwork, NetworkUIState::kShowing);
// view state?
EXPECT_CALL(*launcher(), RestartLauncher()).Times(1); EXPECT_CALL(*launcher(), RestartLauncher()).Times(1);
view_controls()->OnNetworkConfigFinished(); view_controls()->OnNetworkConfigFinished();
ExpectViewState(AppLaunchSplashScreenView::AppLaunchState::
APP_LAUNCH_STATE_PREPARING_PROFILE);
launch_controls()->OnAppInstalling(); launch_controls()->OnAppInstalling();
ExpectState(AppState::kInstallingApp, NetworkUIState::kNotShowing); ExpectState(AppState::kInstallingApp, NetworkUIState::kNotShowing);
ExpectViewState(AppLaunchSplashScreenView::AppLaunchState::
APP_LAUNCH_STATE_INSTALLING_APPLICATION);
launch_controls()->OnAppPrepared(); launch_controls()->OnAppPrepared();
ExpectState(AppState::kInstalled, NetworkUIState::kNotShowing); ExpectState(AppState::kInstalled, NetworkUIState::kNotShowing);
ExpectViewState(AppLaunchSplashScreenView::AppLaunchState::
APP_LAUNCH_STATE_WAITING_APP_WINDOW);
EXPECT_CALL(*launcher(), LaunchApp()).Times(1); EXPECT_CALL(*launcher(), LaunchApp()).Times(1);
FireSplashScreenTimer(); FireSplashScreenTimer();
launch_controls()->OnAppLaunched(); launch_controls()->OnAppLaunched();
ExpectState(AppState::kLaunched, NetworkUIState::kNotShowing); ExpectState(AppState::kLaunched, NetworkUIState::kNotShowing);
ExpectViewState(AppLaunchSplashScreenView::AppLaunchState::
APP_LAUNCH_STATE_WAITING_APP_WINDOW);
EXPECT_TRUE(session_manager::SessionManager::Get()->IsSessionStarted()); EXPECT_TRUE(session_manager::SessionManager::Get()->IsSessionStarted());
} }
...@@ -339,6 +391,8 @@ class KioskLaunchControllerWithExtensionTest ...@@ -339,6 +391,8 @@ class KioskLaunchControllerWithExtensionTest
SetOnline(true); SetOnline(true);
launch_controls()->OnAppInstalling(); launch_controls()->OnAppInstalling();
ExpectViewState(AppLaunchSplashScreenView::AppLaunchState::
APP_LAUNCH_STATE_INSTALLING_APPLICATION);
launch_controls()->OnAppPrepared(); launch_controls()->OnAppPrepared();
} }
...@@ -362,12 +416,16 @@ IN_PROC_BROWSER_TEST_P(KioskLaunchControllerWithExtensionTest, ...@@ -362,12 +416,16 @@ IN_PROC_BROWSER_TEST_P(KioskLaunchControllerWithExtensionTest,
SetExtensionLoaded(); SetExtensionLoaded();
RunUntilAppPrepared(); RunUntilAppPrepared();
ExpectState(AppState::kInstalled, NetworkUIState::kNotShowing); ExpectState(AppState::kInstalled, NetworkUIState::kNotShowing);
ExpectViewState(AppLaunchSplashScreenView::AppLaunchState::
APP_LAUNCH_STATE_WAITING_APP_WINDOW);
EXPECT_CALL(*launcher(), LaunchApp()).Times(1); EXPECT_CALL(*launcher(), LaunchApp()).Times(1);
FireSplashScreenTimer(); FireSplashScreenTimer();
launch_controls()->OnAppLaunched(); launch_controls()->OnAppLaunched();
ExpectState(AppState::kLaunched, NetworkUIState::kNotShowing); ExpectState(AppState::kLaunched, NetworkUIState::kNotShowing);
ExpectViewState(AppLaunchSplashScreenView::AppLaunchState::
APP_LAUNCH_STATE_WAITING_APP_WINDOW);
EXPECT_TRUE(session_manager::SessionManager::Get()->IsSessionStarted()); EXPECT_TRUE(session_manager::SessionManager::Get()->IsSessionStarted());
} }
...@@ -375,6 +433,8 @@ IN_PROC_BROWSER_TEST_P(KioskLaunchControllerWithExtensionTest, ...@@ -375,6 +433,8 @@ IN_PROC_BROWSER_TEST_P(KioskLaunchControllerWithExtensionTest,
ExtensionLoadedAfterAppPrepared) { ExtensionLoadedAfterAppPrepared) {
RunUntilAppPrepared(); RunUntilAppPrepared();
ExpectState(AppState::kInstallingExtensions, NetworkUIState::kNotShowing); ExpectState(AppState::kInstallingExtensions, NetworkUIState::kNotShowing);
ExpectViewState(AppLaunchSplashScreenView::AppLaunchState::
APP_LAUNCH_STATE_INSTALLING_EXTENSION);
SetExtensionLoaded(); SetExtensionLoaded();
ExpectState(AppState::kInstalled, NetworkUIState::kNotShowing); ExpectState(AppState::kInstalled, NetworkUIState::kNotShowing);
...@@ -384,6 +444,8 @@ IN_PROC_BROWSER_TEST_P(KioskLaunchControllerWithExtensionTest, ...@@ -384,6 +444,8 @@ IN_PROC_BROWSER_TEST_P(KioskLaunchControllerWithExtensionTest,
launch_controls()->OnAppLaunched(); launch_controls()->OnAppLaunched();
ExpectState(AppState::kLaunched, NetworkUIState::kNotShowing); ExpectState(AppState::kLaunched, NetworkUIState::kNotShowing);
ExpectViewState(AppLaunchSplashScreenView::AppLaunchState::
APP_LAUNCH_STATE_WAITING_APP_WINDOW);
EXPECT_TRUE(session_manager::SessionManager::Get()->IsSessionStarted()); EXPECT_TRUE(session_manager::SessionManager::Get()->IsSessionStarted());
} }
......
...@@ -14,4 +14,14 @@ void FakeAppLaunchSplashScreenHandler::SetNetworkReady(bool ready) { ...@@ -14,4 +14,14 @@ void FakeAppLaunchSplashScreenHandler::SetNetworkReady(bool ready) {
network_ready_ = ready; network_ready_ = ready;
} }
void FakeAppLaunchSplashScreenHandler::UpdateAppLaunchState(
AppLaunchState state) {
state_ = state;
}
AppLaunchSplashScreenHandler::AppLaunchState
FakeAppLaunchSplashScreenHandler::GetAppLaunchState() {
return state_;
}
} // namespace chromeos } // namespace chromeos
...@@ -15,15 +15,17 @@ class FakeAppLaunchSplashScreenHandler : public AppLaunchSplashScreenView { ...@@ -15,15 +15,17 @@ class FakeAppLaunchSplashScreenHandler : public AppLaunchSplashScreenView {
void SetDelegate(Delegate*) override {} void SetDelegate(Delegate*) override {}
void Show() override {} void Show() override {}
void Hide() override {} void Hide() override {}
void UpdateAppLaunchState(AppLaunchState state) override {} void UpdateAppLaunchState(AppLaunchState state) override;
void ToggleNetworkConfig(bool) override {} void ToggleNetworkConfig(bool) override {}
void ShowNetworkConfigureUI() override {} void ShowNetworkConfigureUI() override {}
bool IsNetworkReady() override; bool IsNetworkReady() override;
void SetNetworkReady(bool ready); void SetNetworkReady(bool ready);
AppLaunchState GetAppLaunchState();
private: private:
bool network_ready_ = false; bool network_ready_ = false;
AppLaunchState state_ = APP_LAUNCH_STATE_PREPARING_PROFILE;
}; };
} // namespace chromeos } // namespace chromeos
......
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