Commit 80c575a9 authored by Jacob Dufault's avatar Jacob Dufault Committed by Commit Bot

cros: Simplify BaseScreen configuration code

Bug: 928555
Change-Id: I6ae62f29040216ea349c3d78f102716e86044d1b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1562715
Commit-Queue: Jacob Dufault <jdufault@chromium.org>
Reviewed-by: default avatarAlexander Alekseev <alemate@chromium.org>
Cr-Commit-Position: refs/heads/master@{#652253}
parent dc86bdf4
......@@ -12,16 +12,12 @@ BaseScreen::BaseScreen(OobeScreen screen_id) : screen_id_(screen_id) {}
BaseScreen::~BaseScreen() {}
void BaseScreen::OnConfigurationChanged() {}
void BaseScreen::OnUserAction(const std::string& action_id) {
LOG(WARNING) << "Unhandled user action: action_id=" << action_id;
}
void BaseScreen::SetConfiguration(base::Value* configuration, bool notify) {
void BaseScreen::SetConfiguration(base::Value* configuration) {
configuration_ = configuration;
if (notify)
OnConfigurationChanged();
}
} // namespace chromeos
......@@ -38,7 +38,8 @@ class BaseScreen {
// counterpart.
virtual void OnUserAction(const std::string& action_id);
virtual void SetConfiguration(base::Value* configuration, bool notify);
// Change the configuration for the screen. |configuration| is unowned.
virtual void SetConfiguration(base::Value* configuration);
protected:
// Global configuration for OOBE screens, that can be used to automate some
......@@ -51,9 +52,6 @@ class BaseScreen {
// triggering while the screen is not displayed.
base::Value* GetConfiguration() { return configuration_; }
// This is called when configuration is changed while screen is displayed.
virtual void OnConfigurationChanged();
private:
// Configuration itself is owned by WizardController and is accessible
// to screen only between OnShow / OnHide calls.
......
......@@ -22,7 +22,7 @@ class MockWelcomeScreen : public WelcomeScreen {
MOCK_METHOD0(Show, void());
MOCK_METHOD0(Hide, void());
MOCK_METHOD2(SetConfiguration, void(base::Value* configuration, bool notify));
MOCK_METHOD1(SetConfiguration, void(base::Value* configuration));
void ExitScreen();
......
......@@ -286,9 +286,7 @@ PrefService* WizardController::local_state_for_testing_ = nullptr;
WizardController::WizardController()
: screen_manager_(std::make_unique<ScreenManager>()),
network_state_helper_(std::make_unique<login::NetworkStateHelper>()),
oobe_configuration_(base::Value(base::Value::Type::DICTIONARY)),
weak_factory_(this) {
network_state_helper_(std::make_unique<login::NetworkStateHelper>()) {
// In session OOBE was initiated from voice interaction keyboard shortcuts.
is_in_session_oobe_ =
session_manager::SessionManager::Get()->IsSessionStarted();
......@@ -1279,7 +1277,7 @@ void WizardController::ShowCurrentScreen() {
smooth_show_timer_.Stop();
UpdateStatusAreaVisibilityForScreen(current_screen_->screen_id());
current_screen_->SetConfiguration(&oobe_configuration_, false /*notify */);
current_screen_->SetConfiguration(&oobe_configuration_);
current_screen_->Show();
}
......@@ -1296,7 +1294,7 @@ void WizardController::SetCurrentScreenSmooth(BaseScreen* new_current,
if (current_screen_) {
current_screen_->Hide();
current_screen_->SetConfiguration(nullptr, false /*notify */);
current_screen_->SetConfiguration(nullptr);
}
const OobeScreen screen = new_current->screen_id();
......
......@@ -416,11 +416,11 @@ class WizardController : public BaseScreenDelegate {
base::Closure on_timezone_resolved_for_testing_;
// Configuration (dictionary) for automating OOBE screens.
base::Value oobe_configuration_;
base::Value oobe_configuration_{base::Value::Type::DICTIONARY};
BaseScreen* hid_screen_ = nullptr;
base::WeakPtrFactory<WizardController> weak_factory_;
base::WeakPtrFactory<WizardController> weak_factory_{this};
DISALLOW_COPY_AND_ASSIGN(WizardController);
};
......
......@@ -688,7 +688,7 @@ class WizardControllerFlowTest : public WizardControllerTest {
// Switch to the initial screen.
EXPECT_EQ(NULL, wizard_controller->current_screen());
EXPECT_CALL(*mock_welcome_screen_, SetConfiguration(NotNull(), _)).Times(1);
EXPECT_CALL(*mock_welcome_screen_, SetConfiguration(NotNull())).Times(1);
EXPECT_CALL(*mock_welcome_screen_, Show()).Times(1);
wizard_controller->AdvanceToScreen(OobeScreen::SCREEN_OOBE_WELCOME);
}
......@@ -767,7 +767,7 @@ class WizardControllerFlowTest : public WizardControllerTest {
ASSERT_TRUE(shelf_helper.IsLoginShelfShown());
EXPECT_CALL(*mock_welcome_screen_, Hide()).Times(1);
EXPECT_CALL(*mock_welcome_screen_, SetConfiguration(IsNull(), _)).Times(1);
EXPECT_CALL(*mock_welcome_screen_, SetConfiguration(IsNull())).Times(1);
EXPECT_CALL(*mock_eula_screen_, Show()).Times(1);
EXPECT_CALL(*mock_network_screen_, Show()).Times(1);
mock_welcome_screen_->ExitScreen();
......@@ -876,7 +876,7 @@ IN_PROC_BROWSER_TEST_F(WizardControllerFlowTest,
EXPECT_CALL(*mock_update_screen_, Show()).Times(0);
EXPECT_CALL(*mock_network_screen_, Show()).Times(1);
EXPECT_CALL(*mock_welcome_screen_, Hide()).Times(1);
EXPECT_CALL(*mock_welcome_screen_, SetConfiguration(IsNull(), _)).Times(1);
EXPECT_CALL(*mock_welcome_screen_, SetConfiguration(IsNull())).Times(1);
mock_welcome_screen_->ExitScreen();
CheckCurrentScreen(OobeScreen::SCREEN_OOBE_NETWORK);
......@@ -917,7 +917,7 @@ IN_PROC_BROWSER_TEST_F(WizardControllerFlowTest,
EXPECT_CALL(*mock_update_screen_, Show()).Times(0);
EXPECT_CALL(*mock_network_screen_, Show()).Times(1);
EXPECT_CALL(*mock_welcome_screen_, Hide()).Times(1);
EXPECT_CALL(*mock_welcome_screen_, SetConfiguration(IsNull(), _)).Times(1);
EXPECT_CALL(*mock_welcome_screen_, SetConfiguration(IsNull())).Times(1);
mock_welcome_screen_->ExitScreen();
CheckCurrentScreen(OobeScreen::SCREEN_OOBE_NETWORK);
......@@ -951,7 +951,7 @@ IN_PROC_BROWSER_TEST_F(WizardControllerFlowTest, ControlFlowSkipUpdateEnroll) {
EXPECT_CALL(*mock_update_screen_, Show()).Times(0);
EXPECT_CALL(*mock_network_screen_, Show()).Times(1);
EXPECT_CALL(*mock_welcome_screen_, Hide()).Times(1);
EXPECT_CALL(*mock_welcome_screen_, SetConfiguration(IsNull(), _)).Times(1);
EXPECT_CALL(*mock_welcome_screen_, SetConfiguration(IsNull())).Times(1);
mock_welcome_screen_->ExitScreen();
CheckCurrentScreen(OobeScreen::SCREEN_OOBE_NETWORK);
......@@ -991,7 +991,7 @@ IN_PROC_BROWSER_TEST_F(WizardControllerFlowTest, ControlFlowEulaDeclined) {
CheckCurrentScreen(OobeScreen::SCREEN_OOBE_WELCOME);
EXPECT_CALL(*mock_network_screen_, Show()).Times(1);
EXPECT_CALL(*mock_welcome_screen_, Hide()).Times(1);
EXPECT_CALL(*mock_welcome_screen_, SetConfiguration(IsNull(), _)).Times(1);
EXPECT_CALL(*mock_welcome_screen_, SetConfiguration(IsNull())).Times(1);
mock_welcome_screen_->ExitScreen();
CheckCurrentScreen(OobeScreen::SCREEN_OOBE_NETWORK);
......@@ -1019,7 +1019,7 @@ IN_PROC_BROWSER_TEST_F(WizardControllerFlowTest,
.Times(1);
EXPECT_CALL(*mock_enrollment_screen_, Show()).Times(1);
EXPECT_CALL(*mock_welcome_screen_, Hide()).Times(1);
EXPECT_CALL(*mock_welcome_screen_, SetConfiguration(IsNull(), _)).Times(1);
EXPECT_CALL(*mock_welcome_screen_, SetConfiguration(IsNull())).Times(1);
WizardController::default_controller()->AdvanceToScreen(
OobeScreen::SCREEN_OOBE_ENROLLMENT);
......@@ -1072,7 +1072,7 @@ IN_PROC_BROWSER_TEST_P(WizardControllerUpdateAfterCompletedOobeTest,
EXPECT_CALL(*mock_update_screen_, Show()).Times(0);
EXPECT_CALL(*mock_network_screen_, Show()).Times(1);
EXPECT_CALL(*mock_welcome_screen_, Hide()).Times(1);
EXPECT_CALL(*mock_welcome_screen_, SetConfiguration(IsNull(), _)).Times(1);
EXPECT_CALL(*mock_welcome_screen_, SetConfiguration(IsNull())).Times(1);
mock_welcome_screen_->ExitScreen();
CheckCurrentScreen(OobeScreen::SCREEN_OOBE_NETWORK);
......@@ -1193,7 +1193,7 @@ IN_PROC_BROWSER_TEST_F(WizardControllerDeviceStateTest,
CheckCurrentScreen(OobeScreen::SCREEN_OOBE_WELCOME);
EXPECT_CALL(*mock_welcome_screen_, Hide()).Times(1);
EXPECT_CALL(*mock_welcome_screen_, SetConfiguration(IsNull(), _)).Times(1);
EXPECT_CALL(*mock_welcome_screen_, SetConfiguration(IsNull())).Times(1);
EXPECT_CALL(*mock_network_screen_, Show()).Times(1);
mock_welcome_screen_->ExitScreen();
......@@ -1239,7 +1239,7 @@ IN_PROC_BROWSER_TEST_F(WizardControllerDeviceStateTest,
MAYBE_ControlFlowDeviceDisabled) {
CheckCurrentScreen(OobeScreen::SCREEN_OOBE_WELCOME);
EXPECT_CALL(*mock_welcome_screen_, Hide()).Times(1);
EXPECT_CALL(*mock_welcome_screen_, SetConfiguration(IsNull(), _)).Times(1);
EXPECT_CALL(*mock_welcome_screen_, SetConfiguration(IsNull())).Times(1);
EXPECT_CALL(*mock_network_screen_, Show()).Times(1);
mock_welcome_screen_->ExitScreen();
......@@ -1339,7 +1339,7 @@ IN_PROC_BROWSER_TEST_P(WizardControllerDeviceStateExplicitRequirementTest,
DISABLED_ControlFlowForcedReEnrollment) {
CheckCurrentScreen(OobeScreen::SCREEN_OOBE_WELCOME);
EXPECT_CALL(*mock_welcome_screen_, Hide()).Times(1);
EXPECT_CALL(*mock_welcome_screen_, SetConfiguration(IsNull(), _)).Times(1);
EXPECT_CALL(*mock_welcome_screen_, SetConfiguration(IsNull())).Times(1);
EXPECT_CALL(*mock_network_screen_, Show()).Times(1);
mock_welcome_screen_->ExitScreen();
......@@ -1439,7 +1439,7 @@ IN_PROC_BROWSER_TEST_P(WizardControllerDeviceStateExplicitRequirementTest,
CheckCurrentScreen(OobeScreen::SCREEN_OOBE_WELCOME);
EXPECT_CALL(*mock_welcome_screen_, Hide()).Times(1);
EXPECT_CALL(*mock_welcome_screen_, SetConfiguration(IsNull(), _)).Times(1);
EXPECT_CALL(*mock_welcome_screen_, SetConfiguration(IsNull())).Times(1);
EXPECT_CALL(*mock_network_screen_, Show()).Times(1);
mock_welcome_screen_->ExitScreen();
......@@ -1585,7 +1585,7 @@ IN_PROC_BROWSER_TEST_F(WizardControllerDeviceStateWithInitialEnrollmentTest,
GenerateEmbargoEndDate(-15 /* days_offset */));
CheckCurrentScreen(OobeScreen::SCREEN_OOBE_WELCOME);
EXPECT_CALL(*mock_welcome_screen_, Hide()).Times(1);
EXPECT_CALL(*mock_welcome_screen_, SetConfiguration(IsNull(), _)).Times(1);
EXPECT_CALL(*mock_welcome_screen_, SetConfiguration(IsNull())).Times(1);
EXPECT_CALL(*mock_network_screen_, Show()).Times(1);
mock_welcome_screen_->ExitScreen();
......@@ -1660,7 +1660,7 @@ IN_PROC_BROWSER_TEST_F(WizardControllerDeviceStateWithInitialEnrollmentTest,
GenerateEmbargoEndDate(-15 /* days_offset */));
CheckCurrentScreen(OobeScreen::SCREEN_OOBE_WELCOME);
EXPECT_CALL(*mock_welcome_screen_, Hide()).Times(1);
EXPECT_CALL(*mock_welcome_screen_, SetConfiguration(IsNull(), _)).Times(1);
EXPECT_CALL(*mock_welcome_screen_, SetConfiguration(IsNull())).Times(1);
EXPECT_CALL(*mock_network_screen_, Show()).Times(1);
mock_welcome_screen_->ExitScreen();
......@@ -1756,7 +1756,7 @@ IN_PROC_BROWSER_TEST_F(WizardControllerDeviceStateWithInitialEnrollmentTest,
CheckCurrentScreen(OobeScreen::SCREEN_OOBE_WELCOME);
EXPECT_CALL(*mock_welcome_screen_, Hide()).Times(1);
EXPECT_CALL(*mock_welcome_screen_, SetConfiguration(IsNull(), _)).Times(1);
EXPECT_CALL(*mock_welcome_screen_, SetConfiguration(IsNull())).Times(1);
EXPECT_CALL(*mock_network_screen_, Show()).Times(1);
mock_welcome_screen_->ExitScreen();
......@@ -1801,7 +1801,7 @@ IN_PROC_BROWSER_TEST_F(WizardControllerDeviceStateWithInitialEnrollmentTest,
CheckCurrentScreen(OobeScreen::SCREEN_OOBE_WELCOME);
EXPECT_CALL(*mock_welcome_screen_, Hide()).Times(1);
EXPECT_CALL(*mock_welcome_screen_, SetConfiguration(IsNull(), _)).Times(1);
EXPECT_CALL(*mock_welcome_screen_, SetConfiguration(IsNull())).Times(1);
EXPECT_CALL(*mock_network_screen_, Show()).Times(1);
mock_welcome_screen_->ExitScreen();
......@@ -1858,7 +1858,7 @@ IN_PROC_BROWSER_TEST_F(WizardControllerDeviceStateWithInitialEnrollmentTest,
CheckCurrentScreen(OobeScreen::SCREEN_OOBE_WELCOME);
EXPECT_CALL(*mock_welcome_screen_, Hide()).Times(1);
EXPECT_CALL(*mock_welcome_screen_, SetConfiguration(IsNull(), _)).Times(1);
EXPECT_CALL(*mock_welcome_screen_, SetConfiguration(IsNull())).Times(1);
EXPECT_CALL(*mock_network_screen_, Show()).Times(1);
mock_welcome_screen_->ExitScreen();
......@@ -1915,7 +1915,7 @@ IN_PROC_BROWSER_TEST_F(WizardControllerDeviceStateWithInitialEnrollmentTest,
CheckCurrentScreen(OobeScreen::SCREEN_OOBE_WELCOME);
EXPECT_CALL(*mock_welcome_screen_, Hide()).Times(1);
EXPECT_CALL(*mock_welcome_screen_, SetConfiguration(IsNull(), _)).Times(1);
EXPECT_CALL(*mock_welcome_screen_, SetConfiguration(IsNull())).Times(1);
EXPECT_CALL(*mock_network_screen_, Show()).Times(1);
mock_welcome_screen_->ExitScreen();
......@@ -1998,7 +1998,7 @@ IN_PROC_BROWSER_TEST_F(WizardControllerDeviceStateWithInitialEnrollmentTest,
CheckCurrentScreen(OobeScreen::SCREEN_OOBE_WELCOME);
EXPECT_CALL(*mock_welcome_screen_, Hide()).Times(1);
EXPECT_CALL(*mock_welcome_screen_, SetConfiguration(IsNull(), _)).Times(1);
EXPECT_CALL(*mock_welcome_screen_, SetConfiguration(IsNull())).Times(1);
EXPECT_CALL(*mock_network_screen_, Show()).Times(1);
mock_welcome_screen_->ExitScreen();
......@@ -2149,7 +2149,7 @@ IN_PROC_BROWSER_TEST_F(WizardControllerKioskFlowTest,
.Times(1);
CheckCurrentScreen(OobeScreen::SCREEN_OOBE_WELCOME);
EXPECT_CALL(*mock_welcome_screen_, Hide()).Times(1);
EXPECT_CALL(*mock_welcome_screen_, SetConfiguration(IsNull(), _)).Times(1);
EXPECT_CALL(*mock_welcome_screen_, SetConfiguration(IsNull())).Times(1);
EXPECT_CALL(*mock_network_screen_, Show()).Times(1);
mock_welcome_screen_->ExitScreen();
......@@ -2198,7 +2198,7 @@ IN_PROC_BROWSER_TEST_F(WizardControllerKioskFlowTest,
CheckCurrentScreen(OobeScreen::SCREEN_OOBE_WELCOME);
EXPECT_CALL(*mock_welcome_screen_, Hide()).Times(1);
EXPECT_CALL(*mock_welcome_screen_, SetConfiguration(IsNull(), _)).Times(1);
EXPECT_CALL(*mock_welcome_screen_, SetConfiguration(IsNull())).Times(1);
EXPECT_CALL(*mock_network_screen_, Show()).Times(1);
mock_welcome_screen_->ExitScreen();
......@@ -2259,7 +2259,7 @@ IN_PROC_BROWSER_TEST_F(WizardControllerEnableDebuggingTest,
WaitUntilJSIsReady();
EXPECT_CALL(*mock_welcome_screen_, Hide()).Times(1);
EXPECT_CALL(*mock_welcome_screen_, SetConfiguration(IsNull(), _)).Times(1);
EXPECT_CALL(*mock_welcome_screen_, SetConfiguration(IsNull())).Times(1);
EXPECT_CALL(*mock_enable_debugging_screen_, Show()).Times(1);
// Find the enable debugging link element (in the appropriate shadow root),
......@@ -2276,7 +2276,7 @@ IN_PROC_BROWSER_TEST_F(WizardControllerEnableDebuggingTest,
CheckCurrentScreen(OobeScreen::SCREEN_OOBE_ENABLE_DEBUGGING);
EXPECT_CALL(*mock_enable_debugging_screen_, Hide()).Times(1);
EXPECT_CALL(*mock_welcome_screen_, SetConfiguration(NotNull(), _)).Times(1);
EXPECT_CALL(*mock_welcome_screen_, SetConfiguration(NotNull())).Times(1);
EXPECT_CALL(*mock_welcome_screen_, Show()).Times(1);
mock_enable_debugging_screen_->ExitScreen();
......@@ -2317,7 +2317,7 @@ IN_PROC_BROWSER_TEST_F(WizardControllerDemoSetupTest,
WaitUntilJSIsReady();
EXPECT_CALL(*mock_welcome_screen_, Hide()).Times(1);
EXPECT_CALL(*mock_welcome_screen_, SetConfiguration(IsNull(), _)).Times(1);
EXPECT_CALL(*mock_welcome_screen_, SetConfiguration(IsNull())).Times(1);
EXPECT_CALL(*mock_demo_preferences_screen_, Show()).Times(1);
WizardController::default_controller()->StartDemoModeSetup();
......@@ -2392,7 +2392,7 @@ IN_PROC_BROWSER_TEST_F(WizardControllerDemoSetupTest,
WaitUntilJSIsReady();
EXPECT_CALL(*mock_welcome_screen_, Hide()).Times(1);
EXPECT_CALL(*mock_welcome_screen_, SetConfiguration(IsNull(), _)).Times(1);
EXPECT_CALL(*mock_welcome_screen_, SetConfiguration(IsNull())).Times(1);
EXPECT_CALL(*mock_demo_preferences_screen_, Show()).Times(1);
WizardController::default_controller()->StartDemoModeSetup();
......@@ -2450,7 +2450,7 @@ IN_PROC_BROWSER_TEST_F(WizardControllerDemoSetupTest, DemoSetupCanceled) {
WaitUntilJSIsReady();
EXPECT_CALL(*mock_welcome_screen_, Hide()).Times(1);
EXPECT_CALL(*mock_welcome_screen_, SetConfiguration(IsNull(), _)).Times(1);
EXPECT_CALL(*mock_welcome_screen_, SetConfiguration(IsNull())).Times(1);
EXPECT_CALL(*mock_demo_preferences_screen_, Show()).Times(1);
WizardController::default_controller()->StartDemoModeSetup();
......@@ -2513,7 +2513,7 @@ IN_PROC_BROWSER_TEST_F(WizardControllerDemoSetupTest, DemoSetupCanceled) {
EXPECT_CALL(*mock_demo_setup_screen_, Hide()).Times(1);
EXPECT_CALL(*mock_welcome_screen_, Show()).Times(1);
EXPECT_CALL(*mock_welcome_screen_, SetConfiguration(NotNull(), _)).Times(1);
EXPECT_CALL(*mock_welcome_screen_, SetConfiguration(NotNull())).Times(1);
mock_demo_setup_screen_->ExitScreen(DemoSetupScreen::Result::CANCELED);
......@@ -2625,7 +2625,7 @@ IN_PROC_BROWSER_TEST_F(WizardControllerDemoSetupDeviceDisabledTest,
WaitUntilJSIsReady();
EXPECT_CALL(*mock_welcome_screen_, Hide()).Times(1);
EXPECT_CALL(*mock_welcome_screen_, SetConfiguration(IsNull(), _)).Times(1);
EXPECT_CALL(*mock_welcome_screen_, SetConfiguration(IsNull())).Times(1);
EXPECT_CALL(*mock_demo_preferences_screen_, Show()).Times(1);
WizardController::default_controller()->StartDemoModeSetup();
......@@ -2757,7 +2757,7 @@ class WizardControllerOobeResumeTest : public WizardControllerTest {
IN_PROC_BROWSER_TEST_F(WizardControllerOobeResumeTest,
PRE_ControlFlowResumeInterruptedOobe) {
// Switch to the initial screen.
EXPECT_CALL(*mock_welcome_screen_, SetConfiguration(NotNull(), _)).Times(1);
EXPECT_CALL(*mock_welcome_screen_, SetConfiguration(NotNull())).Times(1);
EXPECT_CALL(*mock_welcome_screen_, Show()).Times(1);
WizardController::default_controller()->AdvanceToScreen(
OobeScreen::SCREEN_OOBE_WELCOME);
......@@ -2769,7 +2769,7 @@ IN_PROC_BROWSER_TEST_F(WizardControllerOobeResumeTest,
.Times(1);
EXPECT_CALL(*mock_enrollment_screen_, Show()).Times(1);
EXPECT_CALL(*mock_welcome_screen_, Hide()).Times(1);
EXPECT_CALL(*mock_welcome_screen_, SetConfiguration(IsNull(), _)).Times(1);
EXPECT_CALL(*mock_welcome_screen_, SetConfiguration(IsNull())).Times(1);
WizardController::default_controller()->AdvanceToScreen(
OobeScreen::SCREEN_OOBE_ENROLLMENT);
......@@ -2854,8 +2854,7 @@ IN_PROC_BROWSER_TEST_F(WizardControllerOobeConfigurationTest,
DISABLED_ConfigurationIsLoaded) {
WaitForConfigurationLoaded();
EXPECT_CALL(*mock_welcome_screen_, Show()).Times(1);
EXPECT_CALL(*mock_welcome_screen_,
SetConfiguration(NonEmptyConfiguration(), _))
EXPECT_CALL(*mock_welcome_screen_, SetConfiguration(NonEmptyConfiguration()))
.Times(1);
WizardController::default_controller()->AdvanceToScreen(
OobeScreen::SCREEN_OOBE_WELCOME);
......
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