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 @@
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/external_provider_impl.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/test/base/in_process_browser_test.h"
#include "chrome/test/base/testing_profile.h"
......@@ -98,6 +99,10 @@ class KioskLaunchControllerTest
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 SetOnline(bool online) {
......@@ -131,19 +136,27 @@ IN_PROC_BROWSER_TEST_P(KioskLaunchControllerTest, RegularFlow) {
launch_controls()->InitializeNetwork();
ExpectState(AppState::kInitNetwork, NetworkUIState::kNotShowing);
ExpectViewState(AppLaunchSplashScreenView::AppLaunchState::
APP_LAUNCH_STATE_PREPARING_NETWORK);
EXPECT_CALL(*launcher(), ContinueWithNetworkReady()).Times(1);
SetOnline(true);
launch_controls()->OnAppInstalling();
ExpectViewState(AppLaunchSplashScreenView::AppLaunchState::
APP_LAUNCH_STATE_INSTALLING_APPLICATION);
launch_controls()->OnAppPrepared();
ExpectState(AppState::kInstalled, NetworkUIState::kNotShowing);
ExpectViewState(AppLaunchSplashScreenView::AppLaunchState::
APP_LAUNCH_STATE_WAITING_APP_WINDOW);
EXPECT_CALL(*launcher(), LaunchApp()).Times(1);
FireSplashScreenTimer();
launch_controls()->OnAppLaunched();
ExpectState(AppState::kLaunched, NetworkUIState::kNotShowing);
ExpectViewState(AppLaunchSplashScreenView::AppLaunchState::
APP_LAUNCH_STATE_WAITING_APP_WINDOW);
EXPECT_TRUE(session_manager::SessionManager::Get()->IsSessionStarted());
}
......@@ -156,12 +169,16 @@ IN_PROC_BROWSER_TEST_P(KioskLaunchControllerTest, AlreadyInstalled) {
launch_controls()->OnAppPrepared();
ExpectState(AppState::kInstalled, NetworkUIState::kNotShowing);
ExpectViewState(AppLaunchSplashScreenView::AppLaunchState::
APP_LAUNCH_STATE_WAITING_APP_WINDOW);
EXPECT_CALL(*launcher(), LaunchApp()).Times(1);
FireSplashScreenTimer();
launch_controls()->OnAppLaunched();
ExpectState(AppState::kLaunched, NetworkUIState::kNotShowing);
ExpectViewState(AppLaunchSplashScreenView::AppLaunchState::
APP_LAUNCH_STATE_WAITING_APP_WINDOW);
EXPECT_TRUE(session_manager::SessionManager::Get()->IsSessionStarted());
}
......@@ -176,22 +193,32 @@ IN_PROC_BROWSER_TEST_P(KioskLaunchControllerTest,
EXPECT_CALL(*launcher(), Initialize()).Times(1);
profile_controls()->OnProfileLoaded(profile());
ExpectViewState(AppLaunchSplashScreenView::AppLaunchState::
APP_LAUNCH_STATE_SHOWING_NETWORK_CONFIGURE_UI);
// WebKioskAppLauncher::Initialize call is synchronous, we have to call the
// response now.
launch_controls()->InitializeNetwork();
ExpectState(AppState::kInitNetwork, NetworkUIState::kShowing);
ExpectViewState(AppLaunchSplashScreenView::AppLaunchState::
APP_LAUNCH_STATE_PREPARING_NETWORK);
EXPECT_CALL(*launcher(), RestartLauncher()).Times(1);
view_controls()->OnNetworkConfigFinished();
ExpectViewState(AppLaunchSplashScreenView::AppLaunchState::
APP_LAUNCH_STATE_PREPARING_PROFILE);
EXPECT_CALL(*launcher(), LaunchApp()).Times(1);
launch_controls()->OnAppPrepared();
ExpectViewState(AppLaunchSplashScreenView::AppLaunchState::
APP_LAUNCH_STATE_WAITING_APP_WINDOW);
// Skipping INSTALLED state since there splash screen timer is stopped when
// network configure ui was shown.
launch_controls()->OnAppLaunched();
ExpectState(AppState::kLaunched, NetworkUIState::kNotShowing);
ExpectViewState(AppLaunchSplashScreenView::AppLaunchState::
APP_LAUNCH_STATE_WAITING_APP_WINDOW);
EXPECT_TRUE(session_manager::SessionManager::Get()->IsSessionStarted());
}
......@@ -206,6 +233,8 @@ IN_PROC_BROWSER_TEST_P(KioskLaunchControllerTest,
launch_controls()->InitializeNetwork();
ExpectState(AppState::kInitNetwork, NetworkUIState::kNotShowing);
ExpectViewState(AppLaunchSplashScreenView::AppLaunchState::
APP_LAUNCH_STATE_PREPARING_NETWORK);
EXPECT_CALL(*launcher(), ContinueWithNetworkReady()).Times(1);
SetOnline(true);
......@@ -217,21 +246,31 @@ IN_PROC_BROWSER_TEST_P(KioskLaunchControllerTest,
// Launcher restart causes network to be requested again.
launch_controls()->InitializeNetwork();
ExpectState(AppState::kInitNetwork, NetworkUIState::kShowing);
ExpectViewState(AppLaunchSplashScreenView::AppLaunchState::
APP_LAUNCH_STATE_PREPARING_NETWORK);
EXPECT_CALL(*launcher(), RestartLauncher()).Times(1);
view_controls()->OnNetworkConfigFinished();
ExpectViewState(AppLaunchSplashScreenView::AppLaunchState::
APP_LAUNCH_STATE_PREPARING_PROFILE);
launch_controls()->OnAppInstalling();
ExpectState(AppState::kInstallingApp, NetworkUIState::kNotShowing);
ExpectViewState(AppLaunchSplashScreenView::AppLaunchState::
APP_LAUNCH_STATE_INSTALLING_APPLICATION);
launch_controls()->OnAppPrepared();
ExpectState(AppState::kInstalled, NetworkUIState::kNotShowing);
ExpectViewState(AppLaunchSplashScreenView::AppLaunchState::
APP_LAUNCH_STATE_WAITING_APP_WINDOW);
EXPECT_CALL(*launcher(), LaunchApp()).Times(1);
FireSplashScreenTimer();
launch_controls()->OnAppLaunched();
ExpectState(AppState::kLaunched, NetworkUIState::kNotShowing);
ExpectViewState(AppLaunchSplashScreenView::AppLaunchState::
APP_LAUNCH_STATE_WAITING_APP_WINDOW);
EXPECT_TRUE(session_manager::SessionManager::Get()->IsSessionStarted());
}
......@@ -245,30 +284,43 @@ IN_PROC_BROWSER_TEST_P(KioskLaunchControllerTest,
launch_controls()->InitializeNetwork();
ExpectState(AppState::kInitNetwork, NetworkUIState::kNotShowing);
ExpectViewState(AppLaunchSplashScreenView::AppLaunchState::
APP_LAUNCH_STATE_PREPARING_NETWORK);
EXPECT_CALL(*launcher(), ContinueWithNetworkReady()).Times(1);
SetOnline(true);
launch_controls()->OnAppInstalling();
ExpectState(AppState::kInstallingApp, NetworkUIState::kNotShowing);
ExpectViewState(AppLaunchSplashScreenView::AppLaunchState::
APP_LAUNCH_STATE_INSTALLING_APPLICATION);
SetOnline(false);
launch_controls()->InitializeNetwork();
ExpectState(AppState::kInitNetwork, NetworkUIState::kShowing);
// view state?
EXPECT_CALL(*launcher(), RestartLauncher()).Times(1);
view_controls()->OnNetworkConfigFinished();
ExpectViewState(AppLaunchSplashScreenView::AppLaunchState::
APP_LAUNCH_STATE_PREPARING_PROFILE);
launch_controls()->OnAppInstalling();
ExpectState(AppState::kInstallingApp, NetworkUIState::kNotShowing);
ExpectViewState(AppLaunchSplashScreenView::AppLaunchState::
APP_LAUNCH_STATE_INSTALLING_APPLICATION);
launch_controls()->OnAppPrepared();
ExpectState(AppState::kInstalled, NetworkUIState::kNotShowing);
ExpectViewState(AppLaunchSplashScreenView::AppLaunchState::
APP_LAUNCH_STATE_WAITING_APP_WINDOW);
EXPECT_CALL(*launcher(), LaunchApp()).Times(1);
FireSplashScreenTimer();
launch_controls()->OnAppLaunched();
ExpectState(AppState::kLaunched, NetworkUIState::kNotShowing);
ExpectViewState(AppLaunchSplashScreenView::AppLaunchState::
APP_LAUNCH_STATE_WAITING_APP_WINDOW);
EXPECT_TRUE(session_manager::SessionManager::Get()->IsSessionStarted());
}
......@@ -339,6 +391,8 @@ class KioskLaunchControllerWithExtensionTest
SetOnline(true);
launch_controls()->OnAppInstalling();
ExpectViewState(AppLaunchSplashScreenView::AppLaunchState::
APP_LAUNCH_STATE_INSTALLING_APPLICATION);
launch_controls()->OnAppPrepared();
}
......@@ -362,12 +416,16 @@ IN_PROC_BROWSER_TEST_P(KioskLaunchControllerWithExtensionTest,
SetExtensionLoaded();
RunUntilAppPrepared();
ExpectState(AppState::kInstalled, NetworkUIState::kNotShowing);
ExpectViewState(AppLaunchSplashScreenView::AppLaunchState::
APP_LAUNCH_STATE_WAITING_APP_WINDOW);
EXPECT_CALL(*launcher(), LaunchApp()).Times(1);
FireSplashScreenTimer();
launch_controls()->OnAppLaunched();
ExpectState(AppState::kLaunched, NetworkUIState::kNotShowing);
ExpectViewState(AppLaunchSplashScreenView::AppLaunchState::
APP_LAUNCH_STATE_WAITING_APP_WINDOW);
EXPECT_TRUE(session_manager::SessionManager::Get()->IsSessionStarted());
}
......@@ -375,6 +433,8 @@ IN_PROC_BROWSER_TEST_P(KioskLaunchControllerWithExtensionTest,
ExtensionLoadedAfterAppPrepared) {
RunUntilAppPrepared();
ExpectState(AppState::kInstallingExtensions, NetworkUIState::kNotShowing);
ExpectViewState(AppLaunchSplashScreenView::AppLaunchState::
APP_LAUNCH_STATE_INSTALLING_EXTENSION);
SetExtensionLoaded();
ExpectState(AppState::kInstalled, NetworkUIState::kNotShowing);
......@@ -384,6 +444,8 @@ IN_PROC_BROWSER_TEST_P(KioskLaunchControllerWithExtensionTest,
launch_controls()->OnAppLaunched();
ExpectState(AppState::kLaunched, NetworkUIState::kNotShowing);
ExpectViewState(AppLaunchSplashScreenView::AppLaunchState::
APP_LAUNCH_STATE_WAITING_APP_WINDOW);
EXPECT_TRUE(session_manager::SessionManager::Get()->IsSessionStarted());
}
......
......@@ -14,4 +14,14 @@ void FakeAppLaunchSplashScreenHandler::SetNetworkReady(bool ready) {
network_ready_ = ready;
}
void FakeAppLaunchSplashScreenHandler::UpdateAppLaunchState(
AppLaunchState state) {
state_ = state;
}
AppLaunchSplashScreenHandler::AppLaunchState
FakeAppLaunchSplashScreenHandler::GetAppLaunchState() {
return state_;
}
} // namespace chromeos
......@@ -15,15 +15,17 @@ class FakeAppLaunchSplashScreenHandler : public AppLaunchSplashScreenView {
void SetDelegate(Delegate*) override {}
void Show() override {}
void Hide() override {}
void UpdateAppLaunchState(AppLaunchState state) override {}
void UpdateAppLaunchState(AppLaunchState state) override;
void ToggleNetworkConfig(bool) override {}
void ShowNetworkConfigureUI() override {}
bool IsNetworkReady() override;
void SetNetworkReady(bool ready);
AppLaunchState GetAppLaunchState();
private:
bool network_ready_ = false;
AppLaunchState state_ = APP_LAUNCH_STATE_PREPARING_PROFILE;
};
} // 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