Commit 3ceda534 authored by jdufault's avatar jdufault Committed by Commit bot

cros: Use ScreenManager as a component instead of deriving WizardController from it

This makes it easier/cleaner to implement CoreOobeView::Delegate on ScreenManager in a follow-up CL.

BUG=672142

Review-Url: https://codereview.chromium.org/2739073002
Cr-Commit-Position: refs/heads/master@{#456228}
parent 2c657c64
...@@ -41,8 +41,8 @@ class EnrollmentScreenTest : public WizardInProcessBrowserTest { ...@@ -41,8 +41,8 @@ class EnrollmentScreenTest : public WizardInProcessBrowserTest {
IN_PROC_BROWSER_TEST_F(EnrollmentScreenTest, TestCancel) { IN_PROC_BROWSER_TEST_F(EnrollmentScreenTest, TestCancel) {
ASSERT_TRUE(WizardController::default_controller()); ASSERT_TRUE(WizardController::default_controller());
EnrollmentScreen* enrollment_screen = EnrollmentScreen* enrollment_screen = EnrollmentScreen::Get(
EnrollmentScreen::Get(WizardController::default_controller()); WizardController::default_controller()->screen_manager());
ASSERT_TRUE(enrollment_screen); ASSERT_TRUE(enrollment_screen);
base::RunLoop run_loop; base::RunLoop run_loop;
...@@ -69,8 +69,8 @@ IN_PROC_BROWSER_TEST_F(EnrollmentScreenTest, DISABLED_TestSuccess) { ...@@ -69,8 +69,8 @@ IN_PROC_BROWSER_TEST_F(EnrollmentScreenTest, DISABLED_TestSuccess) {
ASSERT_TRUE(WizardController::default_controller()); ASSERT_TRUE(WizardController::default_controller());
EXPECT_FALSE(StartupUtils::IsOobeCompleted()); EXPECT_FALSE(StartupUtils::IsOobeCompleted());
EnrollmentScreen* enrollment_screen = EnrollmentScreen* enrollment_screen = EnrollmentScreen::Get(
EnrollmentScreen::Get(WizardController::default_controller()); WizardController::default_controller()->screen_manager());
ASSERT_TRUE(enrollment_screen); ASSERT_TRUE(enrollment_screen);
base::RunLoop run_loop; base::RunLoop run_loop;
...@@ -105,8 +105,8 @@ class AttestationAuthEnrollmentScreenTest : public EnrollmentScreenTest { ...@@ -105,8 +105,8 @@ class AttestationAuthEnrollmentScreenTest : public EnrollmentScreenTest {
IN_PROC_BROWSER_TEST_F(AttestationAuthEnrollmentScreenTest, TestCancel) { IN_PROC_BROWSER_TEST_F(AttestationAuthEnrollmentScreenTest, TestCancel) {
ASSERT_TRUE(WizardController::default_controller()); ASSERT_TRUE(WizardController::default_controller());
EnrollmentScreen* enrollment_screen = EnrollmentScreen* enrollment_screen = EnrollmentScreen::Get(
EnrollmentScreen::Get(WizardController::default_controller()); WizardController::default_controller()->screen_manager());
ASSERT_TRUE(enrollment_screen); ASSERT_TRUE(enrollment_screen);
base::RunLoop run_loop; base::RunLoop run_loop;
...@@ -133,7 +133,8 @@ IN_PROC_BROWSER_TEST_F(EnrollmentScreenTest, EnrollmentSpinner) { ...@@ -133,7 +133,8 @@ IN_PROC_BROWSER_TEST_F(EnrollmentScreenTest, EnrollmentSpinner) {
WizardController* wcontroller = WizardController::default_controller(); WizardController* wcontroller = WizardController::default_controller();
ASSERT_TRUE(wcontroller); ASSERT_TRUE(wcontroller);
EnrollmentScreen* enrollment_screen = EnrollmentScreen::Get(wcontroller); EnrollmentScreen* enrollment_screen =
EnrollmentScreen::Get(wcontroller->screen_manager());
ASSERT_TRUE(enrollment_screen); ASSERT_TRUE(enrollment_screen);
EnrollmentScreenView* view = enrollment_screen->GetView(); EnrollmentScreenView* view = enrollment_screen->GetView();
...@@ -177,8 +178,8 @@ class ForcedAttestationAuthEnrollmentScreenTest : public EnrollmentScreenTest { ...@@ -177,8 +178,8 @@ class ForcedAttestationAuthEnrollmentScreenTest : public EnrollmentScreenTest {
IN_PROC_BROWSER_TEST_F(ForcedAttestationAuthEnrollmentScreenTest, TestCancel) { IN_PROC_BROWSER_TEST_F(ForcedAttestationAuthEnrollmentScreenTest, TestCancel) {
ASSERT_TRUE(WizardController::default_controller()); ASSERT_TRUE(WizardController::default_controller());
EnrollmentScreen* enrollment_screen = EnrollmentScreen* enrollment_screen = EnrollmentScreen::Get(
EnrollmentScreen::Get(WizardController::default_controller()); WizardController::default_controller()->screen_manager());
ASSERT_TRUE(enrollment_screen); ASSERT_TRUE(enrollment_screen);
base::RunLoop run_loop; base::RunLoop run_loop;
...@@ -224,8 +225,8 @@ class MultiAuthEnrollmentScreenTest : public EnrollmentScreenTest { ...@@ -224,8 +225,8 @@ class MultiAuthEnrollmentScreenTest : public EnrollmentScreenTest {
IN_PROC_BROWSER_TEST_F(MultiAuthEnrollmentScreenTest, TestCancel) { IN_PROC_BROWSER_TEST_F(MultiAuthEnrollmentScreenTest, TestCancel) {
ASSERT_TRUE(WizardController::default_controller()); ASSERT_TRUE(WizardController::default_controller());
EnrollmentScreen* enrollment_screen = EnrollmentScreen* enrollment_screen = EnrollmentScreen::Get(
EnrollmentScreen::Get(WizardController::default_controller()); WizardController::default_controller()->screen_manager());
ASSERT_TRUE(enrollment_screen); ASSERT_TRUE(enrollment_screen);
base::RunLoop run_loop; base::RunLoop run_loop;
...@@ -269,8 +270,8 @@ class ProvisionedEnrollmentScreenTest : public EnrollmentScreenTest { ...@@ -269,8 +270,8 @@ class ProvisionedEnrollmentScreenTest : public EnrollmentScreenTest {
IN_PROC_BROWSER_TEST_F(ProvisionedEnrollmentScreenTest, TestBackButton) { IN_PROC_BROWSER_TEST_F(ProvisionedEnrollmentScreenTest, TestBackButton) {
ASSERT_TRUE(WizardController::default_controller()); ASSERT_TRUE(WizardController::default_controller());
EnrollmentScreen* enrollment_screen = EnrollmentScreen* enrollment_screen = EnrollmentScreen::Get(
EnrollmentScreen::Get(WizardController::default_controller()); WizardController::default_controller()->screen_manager());
ASSERT_TRUE(enrollment_screen); ASSERT_TRUE(enrollment_screen);
base::RunLoop run_loop; base::RunLoop run_loop;
......
...@@ -201,7 +201,8 @@ class EnterpriseEnrollmentTest : public LoginManagerTest { ...@@ -201,7 +201,8 @@ class EnterpriseEnrollmentTest : public LoginManagerTest {
// Helper method to return the current EnrollmentScreen instance. // Helper method to return the current EnrollmentScreen instance.
EnrollmentScreen* enrollment_screen() { EnrollmentScreen* enrollment_screen() {
return EnrollmentScreen::Get(WizardController::default_controller()); return EnrollmentScreen::Get(
WizardController::default_controller()->screen_manager());
} }
private: private:
......
...@@ -94,8 +94,8 @@ class TimedRunLoop { ...@@ -94,8 +94,8 @@ class TimedRunLoop {
class LanguageListWaiter : public NetworkScreen::Observer { class LanguageListWaiter : public NetworkScreen::Observer {
public: public:
LanguageListWaiter() LanguageListWaiter()
: network_screen_( : network_screen_(NetworkScreen::Get(
NetworkScreen::Get(WizardController::default_controller())), WizardController::default_controller()->screen_manager())),
loop_(base::TimeDelta::FromSeconds(kTimeoutSeconds), "LanguageList") { loop_(base::TimeDelta::FromSeconds(kTimeoutSeconds), "LanguageList") {
network_screen_->AddObserver(this); network_screen_->AddObserver(this);
CheckLanguageList(); CheckLanguageList();
......
...@@ -4,22 +4,24 @@ ...@@ -4,22 +4,24 @@
#include "chrome/browser/chromeos/login/screen_manager.h" #include "chrome/browser/chromeos/login/screen_manager.h"
#include "base/memory/ptr_util.h"
#include "chrome/browser/chromeos/login/wizard_controller.h"
namespace chromeos { namespace chromeos {
ScreenManager::ScreenManager() { ScreenManager::ScreenManager(WizardController* wizard_controller)
} : wizard_controller_(wizard_controller) {}
ScreenManager::~ScreenManager() { ScreenManager::~ScreenManager() {}
}
BaseScreen* ScreenManager::GetScreen(OobeScreen screen) { BaseScreen* ScreenManager::GetScreen(OobeScreen screen) {
auto iter = screens_.find(screen); auto iter = screens_.find(screen);
if (iter != screens_.end()) if (iter != screens_.end())
return iter->second.get(); return iter->second.get();
BaseScreen* result = CreateScreen(screen); BaseScreen* result = wizard_controller_->CreateScreen(screen);
DCHECK(result) << "Can not create screen named " << GetOobeScreenName(screen); DCHECK(result) << "Can not create screen named " << GetOobeScreenName(screen);
screens_[screen] = make_linked_ptr(result); screens_[screen] = base::WrapUnique(result);
return result; return result;
} }
......
...@@ -6,26 +6,26 @@ ...@@ -6,26 +6,26 @@
#define CHROME_BROWSER_CHROMEOS_LOGIN_SCREEN_MANAGER_H_ #define CHROME_BROWSER_CHROMEOS_LOGIN_SCREEN_MANAGER_H_
#include <map> #include <map>
#include <memory>
#include <string> #include <string>
#include "base/gtest_prod_util.h" #include "base/gtest_prod_util.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/linked_ptr.h"
#include "chrome/browser/chromeos/login/screens/base_screen.h" #include "chrome/browser/chromeos/login/screens/base_screen.h"
namespace chromeos { namespace chromeos {
class WizardController;
// Class that manages creation and ownership of screens. // Class that manages creation and ownership of screens.
class ScreenManager { class ScreenManager {
public: public:
ScreenManager(); // |wizard_controller| is not owned by this class.
virtual ~ScreenManager(); explicit ScreenManager(WizardController* wizard_controller);
~ScreenManager();
// Getter for screen with lazy initialization. // Getter for screen with lazy initialization.
virtual BaseScreen* GetScreen(OobeScreen screen); BaseScreen* GetScreen(OobeScreen screen);
// Factory for screen instances.
virtual BaseScreen* CreateScreen(OobeScreen screen) = 0;
bool HasScreen(OobeScreen screen); bool HasScreen(OobeScreen screen);
...@@ -37,8 +37,11 @@ class ScreenManager { ...@@ -37,8 +37,11 @@ class ScreenManager {
friend class WizardInProcessBrowserTest; friend class WizardInProcessBrowserTest;
friend class WizardControllerBrokenLocalStateTest; friend class WizardControllerBrokenLocalStateTest;
// Screens. // Created screens.
std::map<OobeScreen, linked_ptr<BaseScreen>> screens_; std::map<OobeScreen, std::unique_ptr<BaseScreen>> screens_;
// Used to allocate BaseScreen instances. Unowned.
WizardController* wizard_controller_;
DISALLOW_COPY_AND_ASSIGN(ScreenManager); DISALLOW_COPY_AND_ASSIGN(ScreenManager);
}; };
......
...@@ -71,8 +71,8 @@ class NetworkScreenTest : public WizardInProcessBrowserTest { ...@@ -71,8 +71,8 @@ class NetworkScreenTest : public WizardInProcessBrowserTest {
WizardInProcessBrowserTest::SetUpOnMainThread(); WizardInProcessBrowserTest::SetUpOnMainThread();
mock_base_screen_delegate_.reset(new MockBaseScreenDelegate()); mock_base_screen_delegate_.reset(new MockBaseScreenDelegate());
ASSERT_TRUE(WizardController::default_controller() != nullptr); ASSERT_TRUE(WizardController::default_controller() != nullptr);
network_screen_ = network_screen_ = NetworkScreen::Get(
NetworkScreen::Get(WizardController::default_controller()); WizardController::default_controller()->screen_manager());
ASSERT_TRUE(network_screen_ != nullptr); ASSERT_TRUE(network_screen_ != nullptr);
ASSERT_EQ(WizardController::default_controller()->current_screen(), ASSERT_EQ(WizardController::default_controller()->current_screen(),
network_screen_); network_screen_);
......
...@@ -83,9 +83,10 @@ class UpdateScreenTest : public WizardInProcessBrowserTest { ...@@ -83,9 +83,10 @@ class UpdateScreenTest : public WizardInProcessBrowserTest {
WizardInProcessBrowserTest::SetUpOnMainThread(); WizardInProcessBrowserTest::SetUpOnMainThread();
ASSERT_TRUE(WizardController::default_controller() != NULL); ASSERT_TRUE(WizardController::default_controller() != nullptr);
update_screen_ = UpdateScreen::Get(WizardController::default_controller()); update_screen_ = UpdateScreen::Get(
ASSERT_TRUE(update_screen_ != NULL); WizardController::default_controller()->screen_manager());
ASSERT_TRUE(update_screen_ != nullptr);
ASSERT_EQ(WizardController::default_controller()->current_screen(), ASSERT_EQ(WizardController::default_controller()->current_screen(),
update_screen_); update_screen_);
update_screen_->base_screen_delegate_ = mock_base_screen_delegate_.get(); update_screen_->base_screen_delegate_ = mock_base_screen_delegate_.get();
......
...@@ -18,8 +18,8 @@ namespace { ...@@ -18,8 +18,8 @@ namespace {
SupervisedUserCreationScreen* GetScreen(LoginDisplayHost* host) { SupervisedUserCreationScreen* GetScreen(LoginDisplayHost* host) {
DCHECK(host); DCHECK(host);
DCHECK(host->GetWizardController()); DCHECK(host->GetWizardController());
SupervisedUserCreationScreen* result = SupervisedUserCreationScreen* result = SupervisedUserCreationScreen::Get(
SupervisedUserCreationScreen::Get(host->GetWizardController()); host->GetWizardController()->screen_manager());
DCHECK(result); DCHECK(result);
return result; return result;
} }
......
...@@ -189,7 +189,8 @@ bool UserImageSyncObserver::GetSyncedImageIndex(int* index) { ...@@ -189,7 +189,8 @@ bool UserImageSyncObserver::GetSyncedImageIndex(int* index) {
bool UserImageSyncObserver::CanUpdateLocalImageNow() { bool UserImageSyncObserver::CanUpdateLocalImageNow() {
if (WizardController* wizard_controller = if (WizardController* wizard_controller =
WizardController::default_controller()) { WizardController::default_controller()) {
UserImageScreen* screen = UserImageScreen::Get(wizard_controller); UserImageScreen* screen =
UserImageScreen::Get(wizard_controller->screen_manager());
if (wizard_controller->current_screen() == screen) { if (wizard_controller->current_screen() == screen) {
if (screen->user_selected_image()) if (screen->user_selected_image())
return false; return false;
......
...@@ -251,7 +251,10 @@ bool WizardController::zero_delay_enabled_ = false; ...@@ -251,7 +251,10 @@ bool WizardController::zero_delay_enabled_ = false;
PrefService* WizardController::local_state_for_testing_ = nullptr; PrefService* WizardController::local_state_for_testing_ = nullptr;
WizardController::WizardController(LoginDisplayHost* host, OobeUI* oobe_ui) WizardController::WizardController(LoginDisplayHost* host, OobeUI* oobe_ui)
: host_(host), oobe_ui_(oobe_ui), weak_factory_(this) { : screen_manager_(this),
host_(host),
oobe_ui_(oobe_ui),
weak_factory_(this) {
DCHECK(default_controller_ == nullptr); DCHECK(default_controller_ == nullptr);
default_controller_ = this; default_controller_ = this;
if (!ash_util::IsRunningInMash()) { if (!ash_util::IsRunningInMash()) {
...@@ -358,7 +361,7 @@ ErrorScreen* WizardController::GetErrorScreen() { ...@@ -358,7 +361,7 @@ ErrorScreen* WizardController::GetErrorScreen() {
BaseScreen* WizardController::GetScreen(OobeScreen screen) { BaseScreen* WizardController::GetScreen(OobeScreen screen) {
if (screen == OobeScreen::SCREEN_ERROR_MESSAGE) if (screen == OobeScreen::SCREEN_ERROR_MESSAGE)
return GetErrorScreen(); return GetErrorScreen();
return ScreenManager::GetScreen(screen); return screen_manager_.GetScreen(screen);
} }
BaseScreen* WizardController::CreateScreen(OobeScreen screen) { BaseScreen* WizardController::CreateScreen(OobeScreen screen) {
...@@ -430,7 +433,8 @@ void WizardController::ShowNetworkScreen() { ...@@ -430,7 +433,8 @@ void WizardController::ShowNetworkScreen() {
VLOG(1) << "Showing network screen."; VLOG(1) << "Showing network screen.";
// Hide the status area initially; it only appears after OOBE first animates // Hide the status area initially; it only appears after OOBE first animates
// in. Keep it visible if the user goes back to the existing network screen. // in. Keep it visible if the user goes back to the existing network screen.
SetStatusAreaVisible(HasScreen(OobeScreen::SCREEN_OOBE_NETWORK)); SetStatusAreaVisible(
screen_manager_.HasScreen(OobeScreen::SCREEN_OOBE_NETWORK));
SetCurrentScreen(GetScreen(OobeScreen::SCREEN_OOBE_NETWORK)); SetCurrentScreen(GetScreen(OobeScreen::SCREEN_OOBE_NETWORK));
// There are two possible screens where we listen to the incoming Bluetooth // There are two possible screens where we listen to the incoming Bluetooth
...@@ -582,7 +586,8 @@ void WizardController::ShowWrongHWIDScreen() { ...@@ -582,7 +586,8 @@ void WizardController::ShowWrongHWIDScreen() {
void WizardController::ShowAutoEnrollmentCheckScreen() { void WizardController::ShowAutoEnrollmentCheckScreen() {
VLOG(1) << "Showing Auto-enrollment check screen."; VLOG(1) << "Showing Auto-enrollment check screen.";
SetStatusAreaVisible(true); SetStatusAreaVisible(true);
AutoEnrollmentCheckScreen* screen = AutoEnrollmentCheckScreen::Get(this); AutoEnrollmentCheckScreen* screen =
AutoEnrollmentCheckScreen::Get(screen_manager());
if (retry_auto_enrollment_check_) if (retry_auto_enrollment_check_)
screen->ClearState(); screen->ClearState();
screen->set_auto_enrollment_controller(host_->GetAutoEnrollmentController()); screen->set_auto_enrollment_controller(host_->GetAutoEnrollmentController());
...@@ -893,7 +898,7 @@ void WizardController::InitiateOOBEUpdate() { ...@@ -893,7 +898,7 @@ void WizardController::InitiateOOBEUpdate() {
void WizardController::StartOOBEUpdate() { void WizardController::StartOOBEUpdate() {
VLOG(1) << "StartOOBEUpdate"; VLOG(1) << "StartOOBEUpdate";
SetCurrentScreenSmooth(GetScreen(OobeScreen::SCREEN_OOBE_UPDATE), true); SetCurrentScreenSmooth(GetScreen(OobeScreen::SCREEN_OOBE_UPDATE), true);
UpdateScreen::Get(this)->StartNetworkCheck(); UpdateScreen::Get(screen_manager())->StartNetworkCheck();
} }
void WizardController::StartTimezoneResolve() { void WizardController::StartTimezoneResolve() {
...@@ -1195,7 +1200,7 @@ bool WizardController::GetUsageStatisticsReporting() const { ...@@ -1195,7 +1200,7 @@ bool WizardController::GetUsageStatisticsReporting() const {
void WizardController::SetHostNetwork() { void WizardController::SetHostNetwork() {
if (!shark_controller_) if (!shark_controller_)
return; return;
NetworkScreen* network_screen = NetworkScreen::Get(this); NetworkScreen* network_screen = NetworkScreen::Get(screen_manager());
std::string onc_spec; std::string onc_spec;
network_screen->GetConnectedWifiNetwork(&onc_spec); network_screen->GetConnectedWifiNetwork(&onc_spec);
if (!onc_spec.empty()) if (!onc_spec.empty())
...@@ -1205,7 +1210,7 @@ void WizardController::SetHostNetwork() { ...@@ -1205,7 +1210,7 @@ void WizardController::SetHostNetwork() {
void WizardController::SetHostConfiguration() { void WizardController::SetHostConfiguration() {
if (!shark_controller_) if (!shark_controller_)
return; return;
NetworkScreen* network_screen = NetworkScreen::Get(this); NetworkScreen* network_screen = NetworkScreen::Get(screen_manager());
shark_controller_->SetHostConfiguration( shark_controller_->SetHostConfiguration(
true, // Eula must be accepted before we get this far. true, // Eula must be accepted before we get this far.
network_screen->GetApplicationLocale(), network_screen->GetTimezone(), network_screen->GetApplicationLocale(), network_screen->GetTimezone(),
...@@ -1224,7 +1229,7 @@ void WizardController::ConfigureHostRequested( ...@@ -1224,7 +1229,7 @@ void WizardController::ConfigureHostRequested(
StartupUtils::MarkEulaAccepted(); StartupUtils::MarkEulaAccepted();
SetUsageStatisticsReporting(send_reports); SetUsageStatisticsReporting(send_reports);
NetworkScreen* network_screen = NetworkScreen::Get(this); NetworkScreen* network_screen = NetworkScreen::Get(screen_manager());
network_screen->SetApplicationLocaleAndInputMethod(lang, keyboard_layout); network_screen->SetApplicationLocaleAndInputMethod(lang, keyboard_layout);
network_screen->SetTimezone(timezone); network_screen->SetTimezone(timezone);
...@@ -1241,7 +1246,7 @@ void WizardController::AddNetworkRequested(const std::string& onc_spec) { ...@@ -1241,7 +1246,7 @@ void WizardController::AddNetworkRequested(const std::string& onc_spec) {
remora_controller_->OnNetworkConnectivityChanged( remora_controller_->OnNetworkConnectivityChanged(
pairing_chromeos::HostPairingController::CONNECTIVITY_CONNECTING); pairing_chromeos::HostPairingController::CONNECTIVITY_CONNECTING);
NetworkScreen* network_screen = NetworkScreen::Get(this); NetworkScreen* network_screen = NetworkScreen::Get(screen_manager());
const chromeos::NetworkState* network_state = chromeos::NetworkHandler::Get() const chromeos::NetworkState* network_state = chromeos::NetworkHandler::Get()
->network_state_handler() ->network_state_handler()
->DefaultNetwork(); ->DefaultNetwork();
...@@ -1506,7 +1511,7 @@ void WizardController::StartEnrollmentScreen(bool force_interactive) { ...@@ -1506,7 +1511,7 @@ void WizardController::StartEnrollmentScreen(bool force_interactive) {
: policy::EnrollmentConfig::MODE_MANUAL_REENROLLMENT; : policy::EnrollmentConfig::MODE_MANUAL_REENROLLMENT;
} }
EnrollmentScreen* screen = EnrollmentScreen::Get(this); EnrollmentScreen* screen = EnrollmentScreen::Get(screen_manager());
screen->SetParameters(effective_config, shark_controller_.get()); screen->SetParameters(effective_config, shark_controller_.get());
SetStatusAreaVisible(true); SetStatusAreaVisible(true);
SetCurrentScreen(screen); SetCurrentScreen(screen);
......
...@@ -51,7 +51,6 @@ struct TimeZoneResponseData; ...@@ -51,7 +51,6 @@ struct TimeZoneResponseData;
// Class that manages control flow between wizard screens. Wizard controller // Class that manages control flow between wizard screens. Wizard controller
// interacts with screen controllers to move the user between screens. // interacts with screen controllers to move the user between screens.
class WizardController : public BaseScreenDelegate, class WizardController : public BaseScreenDelegate,
public ScreenManager,
public EulaScreen::Delegate, public EulaScreen::Delegate,
public ControllerPairingScreen::Delegate, public ControllerPairingScreen::Delegate,
public HostPairingScreen::Delegate, public HostPairingScreen::Delegate,
...@@ -113,13 +112,19 @@ class WizardController : public BaseScreenDelegate, ...@@ -113,13 +112,19 @@ class WizardController : public BaseScreenDelegate,
// Returns true if the current wizard instance has reached the login screen. // Returns true if the current wizard instance has reached the login screen.
bool login_screen_started() const { return login_screen_started_; } bool login_screen_started() const { return login_screen_started_; }
// ScreenManager implementation. // Returns a given screen. Creates it lazily.
BaseScreen* GetScreen(OobeScreen screen) override; BaseScreen* GetScreen(OobeScreen screen);
BaseScreen* CreateScreen(OobeScreen screen) override;
// Returns the current ScreenManager instance.
ScreenManager* screen_manager() { return &screen_manager_; }
// Volume percent at which spoken feedback is still audible. // Volume percent at which spoken feedback is still audible.
static const int kMinAudibleOutputVolumePercent; static const int kMinAudibleOutputVolumePercent;
// Allocate a given BaseScreen for the given |Screen|. Used by
// |screen_manager_|.
BaseScreen* CreateScreen(OobeScreen screen);
private: private:
// Show specific screen. // Show specific screen.
void ShowNetworkScreen(); void ShowNetworkScreen();
...@@ -300,6 +305,8 @@ class WizardController : public BaseScreenDelegate, ...@@ -300,6 +305,8 @@ class WizardController : public BaseScreenDelegate,
// attestation-based enrollment if appropriate. // attestation-based enrollment if appropriate.
void StartEnrollmentScreen(bool force_interactive); void StartEnrollmentScreen(bool force_interactive);
ScreenManager screen_manager_;
// Whether to skip any screens that may normally be shown after login // Whether to skip any screens that may normally be shown after login
// (registration, Terms of Service, user image selection). // (registration, Terms of Service, user image selection).
static bool skip_post_login_screens_; static bool skip_post_login_screens_;
......
...@@ -222,20 +222,22 @@ class MockOutShowHide : public T { ...@@ -222,20 +222,22 @@ class MockOutShowHide : public T {
std::unique_ptr<H> view_; std::unique_ptr<H> view_;
}; };
#define MOCK(mock_var, screen_name, mocked_class, view_class) \ #define MOCK(mock_var, screen_name, mocked_class, view_class) \
mock_var = new MockOutShowHide<mocked_class, view_class>( \ mock_var = new MockOutShowHide<mocked_class, view_class>( \
WizardController::default_controller(), new view_class); \ WizardController::default_controller(), new view_class); \
WizardController::default_controller()->screens_[screen_name] = \ WizardController::default_controller() \
make_linked_ptr(mock_var); \ ->screen_manager() \
EXPECT_CALL(*mock_var, Show()).Times(0); \ ->screens_[screen_name] = base::WrapUnique(mock_var); \
EXPECT_CALL(*mock_var, Show()).Times(0); \
EXPECT_CALL(*mock_var, Hide()).Times(0); EXPECT_CALL(*mock_var, Hide()).Times(0);
#define MOCK_WITH_DELEGATE(mock_var, screen_name, mocked_class, view_class) \ #define MOCK_WITH_DELEGATE(mock_var, screen_name, mocked_class, view_class) \
mock_var = new MockOutShowHide<mocked_class, view_class>( \ mock_var = new MockOutShowHide<mocked_class, view_class>( \
WizardController::default_controller(), \ WizardController::default_controller(), \
WizardController::default_controller(), new view_class); \ WizardController::default_controller(), new view_class); \
WizardController::default_controller()->screens_[screen_name] = \ WizardController::default_controller() \
make_linked_ptr(mock_var); \ ->screen_manager() \
->screens_[screen_name] = base::WrapUnique(mock_var); \
EXPECT_CALL(*mock_var, Show()).Times(0); \ EXPECT_CALL(*mock_var, Show()).Times(0); \
EXPECT_CALL(*mock_var, Hide()).Times(0); EXPECT_CALL(*mock_var, Hide()).Times(0);
...@@ -419,11 +421,13 @@ class WizardControllerFlowTest : public WizardControllerTest { ...@@ -419,11 +421,13 @@ class WizardControllerFlowTest : public WizardControllerTest {
NetworkHandler::Get()->network_state_handler()->SetCheckPortalList(""); NetworkHandler::Get()->network_state_handler()->SetCheckPortalList("");
// Set up the mocks for all screens. // Set up the mocks for all screens.
mock_network_screen_.reset(new MockNetworkScreen( mock_network_screen_ = new MockNetworkScreen(
WizardController::default_controller(), WizardController::default_controller(),
WizardController::default_controller(), GetOobeUI()->GetNetworkView())); WizardController::default_controller(), GetOobeUI()->GetNetworkView());
WizardController::default_controller() WizardController::default_controller()
->screens_[OobeScreen::SCREEN_OOBE_NETWORK] = mock_network_screen_; ->screen_manager()
->screens_[OobeScreen::SCREEN_OOBE_NETWORK]
.reset(mock_network_screen_);
EXPECT_CALL(*mock_network_screen_, Show()).Times(0); EXPECT_CALL(*mock_network_screen_, Show()).Times(0);
EXPECT_CALL(*mock_network_screen_, Hide()).Times(0); EXPECT_CALL(*mock_network_screen_, Hide()).Times(0);
...@@ -442,9 +446,10 @@ class WizardControllerFlowTest : public WizardControllerTest { ...@@ -442,9 +446,10 @@ class WizardControllerFlowTest : public WizardControllerTest {
OobeScreen::SCREEN_OOBE_ENABLE_DEBUGGING, MockEnableDebuggingScreen, OobeScreen::SCREEN_OOBE_ENABLE_DEBUGGING, MockEnableDebuggingScreen,
MockEnableDebuggingScreenView); MockEnableDebuggingScreenView);
device_disabled_screen_view_.reset(new MockDeviceDisabledScreenView); device_disabled_screen_view_.reset(new MockDeviceDisabledScreenView);
wizard_controller->screens_[OobeScreen::SCREEN_DEVICE_DISABLED] = wizard_controller->screen_manager()
make_linked_ptr(new DeviceDisabledScreen( ->screens_[OobeScreen::SCREEN_DEVICE_DISABLED] =
wizard_controller, device_disabled_screen_view_.get())); base::MakeUnique<DeviceDisabledScreen>(
wizard_controller, device_disabled_screen_view_.get());
EXPECT_CALL(*device_disabled_screen_view_, Show()).Times(0); EXPECT_CALL(*device_disabled_screen_view_, Show()).Times(0);
// Switch to the initial screen. // Switch to the initial screen.
...@@ -454,7 +459,7 @@ class WizardControllerFlowTest : public WizardControllerTest { ...@@ -454,7 +459,7 @@ class WizardControllerFlowTest : public WizardControllerTest {
} }
void TearDownOnMainThread() override { void TearDownOnMainThread() override {
mock_network_screen_.reset(); mock_network_screen_ = nullptr;
device_disabled_screen_view_.reset(); device_disabled_screen_view_.reset();
WizardControllerTest::TearDownOnMainThread(); WizardControllerTest::TearDownOnMainThread();
} }
...@@ -512,7 +517,7 @@ class WizardControllerFlowTest : public WizardControllerTest { ...@@ -512,7 +517,7 @@ class WizardControllerFlowTest : public WizardControllerTest {
} }
void ResetAutoEnrollmentCheckScreen() { void ResetAutoEnrollmentCheckScreen() {
WizardController::default_controller()->screens_.erase( WizardController::default_controller()->screen_manager()->screens_.erase(
OobeScreen::SCREEN_AUTO_ENROLLMENT_CHECK); OobeScreen::SCREEN_AUTO_ENROLLMENT_CHECK);
} }
...@@ -567,7 +572,7 @@ class WizardControllerFlowTest : public WizardControllerTest { ...@@ -567,7 +572,7 @@ class WizardControllerFlowTest : public WizardControllerTest {
->GetCurrentTimezoneID())); ->GetCurrentTimezoneID()));
} }
linked_ptr<MockNetworkScreen> mock_network_screen_; MockNetworkScreen* mock_network_screen_; // Unowned ptr.
MockOutShowHide<MockUpdateScreen, MockUpdateView>* mock_update_screen_; MockOutShowHide<MockUpdateScreen, MockUpdateView>* mock_update_screen_;
MockOutShowHide<MockEulaScreen, MockEulaView>* mock_eula_screen_; MockOutShowHide<MockEulaScreen, MockEulaView>* mock_eula_screen_;
MockOutShowHide<MockEnrollmentScreen, MockEnrollmentScreenView>* MockOutShowHide<MockEnrollmentScreen, MockEnrollmentScreenView>*
......
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