summaryrefslogtreecommitdiffstats
path: root/chrome/browser/chromeos
diff options
context:
space:
mode:
authordenisromanov@chromium.org <denisromanov@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-23 14:51:37 +0000
committerdenisromanov@chromium.org <denisromanov@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-23 14:51:37 +0000
commit25ce958f845d21b541dcc43f30316d19ba87ca88 (patch)
tree6750bcd017081634690a00b47ad4a9aa910a841d /chrome/browser/chromeos
parentb6f31f8de7f49c75238e8e0422f80f35eb5267e2 (diff)
downloadchromium_src-25ce958f845d21b541dcc43f30316d19ba87ca88.zip
chromium_src-25ce958f845d21b541dcc43f30316d19ba87ca88.tar.gz
chromium_src-25ce958f845d21b541dcc43f30316d19ba87ca88.tar.bz2
Added browser test for the OOBE update screen.
BUG=chromium-os:2265 TEST=Make and run out/Debug/browser_tests Review URL: http://codereview.chromium.org/3130044 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@57053 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/chromeos')
-rw-r--r--chrome/browser/chromeos/login/update_screen.cc38
-rw-r--r--chrome/browser/chromeos/login/update_screen.h17
-rw-r--r--chrome/browser/chromeos/login/update_screen_browsertest.cc248
-rw-r--r--chrome/browser/chromeos/login/update_view.cc1
-rw-r--r--chrome/browser/chromeos/login/wizard_controller.cc12
-rw-r--r--chrome/browser/chromeos/login/wizard_screen.h1
6 files changed, 301 insertions, 16 deletions
diff --git a/chrome/browser/chromeos/login/update_screen.cc b/chrome/browser/chromeos/login/update_screen.cc
index 7f801f1..4260241 100644
--- a/chrome/browser/chromeos/login/update_screen.cc
+++ b/chrome/browser/chromeos/login/update_screen.cc
@@ -11,13 +11,6 @@
namespace {
-// Update window should appear for at least kMinimalUpdateTime seconds.
-const int kMinimalUpdateTimeSec = 3;
-
-// Time in seconds that we wait for the device to reboot.
-// If reboot didn't happen, ask user to reboot device manually.
-const int kWaitForRebootTimeSec = 3;
-
// Progress bar stages. Each represents progress bar value
// at the beginning of each stage.
// TODO(nkostylev): Base stage progress values on approximate time.
@@ -38,7 +31,9 @@ namespace chromeos {
UpdateScreen::UpdateScreen(WizardScreenDelegate* delegate)
: DefaultViewScreen<chromeos::UpdateView>(delegate),
proceed_with_oobe_(false),
- checking_for_update_(true) {
+ checking_for_update_(true),
+ minimal_update_time_(0),
+ reboot_check_delay_(0) {
}
UpdateScreen::~UpdateScreen() {
@@ -50,7 +45,6 @@ UpdateScreen::~UpdateScreen() {
void UpdateScreen::UpdateStatusChanged(UpdateLibrary* library) {
UpdateStatusOperation status = library->status().status;
- LOG(INFO) << "Update status: " << status;
if (checking_for_update_ && status > UPDATE_STATUS_CHECKING_FOR_UPDATE) {
checking_for_update_ = false;
}
@@ -81,7 +75,7 @@ void UpdateScreen::UpdateStatusChanged(UpdateLibrary* library) {
view()->SetProgress(kProgressComplete);
CrosLibrary::Get()->GetUpdateLibrary()->RebootAfterUpdate();
LOG(INFO) << "Reboot API was called. Waiting for reboot.";
- reboot_timer_.Start(base::TimeDelta::FromSeconds(kWaitForRebootTimeSec),
+ reboot_timer_.Start(base::TimeDelta::FromSeconds(reboot_check_delay_),
this,
&UpdateScreen::OnWaitForRebootTimeElapsed);
break;
@@ -105,10 +99,12 @@ void UpdateScreen::StartUpdate() {
view()->set_controller(this);
// Start the minimal update time timer.
- minimal_update_time_timer_.Start(
- base::TimeDelta::FromSeconds(kMinimalUpdateTimeSec),
- this,
- &UpdateScreen::OnMinimalUpdateTimeElapsed);
+ if (minimal_update_time_ > 0) {
+ minimal_update_time_timer_.Start(
+ base::TimeDelta::FromSeconds(minimal_update_time_),
+ this,
+ &UpdateScreen::OnMinimalUpdateTimeElapsed);
+ }
view()->SetProgress(kBeforeUpdateCheckProgress);
@@ -168,4 +164,18 @@ void UpdateScreen::OnWaitForRebootTimeElapsed() {
view()->ShowManualRebootInfo();
}
+void UpdateScreen::SetMinimalUpdateTime(int seconds) {
+ if (seconds <= 0)
+ minimal_update_time_timer_.Stop();
+ DCHECK(!minimal_update_time_timer_.IsRunning());
+ minimal_update_time_ = seconds;
+}
+
+void UpdateScreen::SetRebootCheckDelay(int seconds) {
+ if (seconds <= 0)
+ reboot_timer_.Stop();
+ DCHECK(!reboot_timer_.IsRunning());
+ reboot_check_delay_ = seconds;
+}
+
} // namespace chromeos
diff --git a/chrome/browser/chromeos/login/update_screen.h b/chrome/browser/chromeos/login/update_screen.h
index deefbaf..ce5dd8a 100644
--- a/chrome/browser/chromeos/login/update_screen.h
+++ b/chrome/browser/chromeos/login/update_screen.h
@@ -41,6 +41,14 @@ class UpdateScreen: public DefaultViewScreen<chromeos::UpdateView>,
// Returns true if minimal update time has elapsed.
virtual bool MinimalUpdateTimeElapsed();
+ // Minimal update time get/set, in seconds.
+ int minimal_update_time() const { return minimal_update_time_; }
+ void SetMinimalUpdateTime(int seconds);
+
+ // Reboot check delay get/set, in seconds.
+ int reboot_check_delay() const { return reboot_check_delay_; }
+ void SetRebootCheckDelay(int seconds);
+
private:
// Timer notification handlers.
void OnMinimalUpdateTimeElapsed();
@@ -59,6 +67,15 @@ class UpdateScreen: public DefaultViewScreen<chromeos::UpdateView>,
// True if in the process of checking for update.
bool checking_for_update_;
+ // Minimal update delay in seconds, for a user to notice
+ // check for update is taking place.
+ int minimal_update_time_;
+
+ // Time in seconds after which we decide that the device has not rebooted
+ // automatically. If reboot didn't happen durin this interval, ask user to
+ // reboot device manually.
+ int reboot_check_delay_;
+
DISALLOW_COPY_AND_ASSIGN(UpdateScreen);
};
diff --git a/chrome/browser/chromeos/login/update_screen_browsertest.cc b/chrome/browser/chromeos/login/update_screen_browsertest.cc
new file mode 100644
index 0000000..dd33ee8
--- /dev/null
+++ b/chrome/browser/chromeos/login/update_screen_browsertest.cc
@@ -0,0 +1,248 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/chromeos/cros/mock_login_library.h"
+#include "chrome/browser/chromeos/cros/mock_update_library.h"
+#include "chrome/browser/chromeos/login/mock_screen_observer.h"
+#include "chrome/browser/chromeos/login/update_screen.h"
+#include "chrome/browser/chromeos/login/wizard_controller.h"
+#include "chrome/browser/chromeos/login/wizard_in_process_browser_test.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace chromeos {
+using ::testing::_;
+using ::testing::AtLeast;
+using ::testing::Return;
+using ::testing::ReturnRef;
+
+class UpdateScreenTest : public WizardInProcessBrowserTest {
+ public:
+ UpdateScreenTest() : WizardInProcessBrowserTest("update"),
+ mock_login_library_(NULL),
+ mock_update_library_(NULL) {}
+
+ protected:
+ virtual void SetUpInProcessBrowserTestFixture() {
+ WizardInProcessBrowserTest::SetUpInProcessBrowserTestFixture();
+ cros_mock_->InitStatusAreaMocks();
+ cros_mock_->SetStatusAreaMocksExpectations();
+ ASSERT_TRUE(CrosLibrary::Get()->EnsureLoaded());
+
+ mock_login_library_ = new MockLoginLibrary();
+ cros_mock_->test_api()->SetLoginLibrary(mock_login_library_, true);
+ EXPECT_CALL(*mock_login_library_, EmitLoginPromptReady())
+ .Times(1);
+
+ mock_update_library_ = new MockUpdateLibrary();
+ cros_mock_->test_api()->SetUpdateLibrary(mock_update_library_, true);
+
+ // UpdateScreen::StartUpdate() will be called by the WizardController
+ // just after creating the update screen, so the expectations for that
+ // should be set up here.
+ EXPECT_CALL(*mock_update_library_, AddObserver(_))
+ .Times(1);
+ EXPECT_CALL(*mock_update_library_, RemoveObserver(_))
+ .Times(AtLeast(1));
+ EXPECT_CALL(*mock_update_library_, CheckForUpdate())
+ .Times(1)
+ .WillOnce(Return(true));
+ }
+
+ virtual void TearDownInProcessBrowserTestFixture() {
+ cros_mock_->test_api()->SetUpdateLibrary(NULL, true);
+ WizardInProcessBrowserTest::TearDownInProcessBrowserTestFixture();
+ }
+
+ MockLoginLibrary* mock_login_library_;
+ MockUpdateLibrary* mock_update_library_;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(UpdateScreenTest);
+};
+
+IN_PROC_BROWSER_TEST_F(UpdateScreenTest, TestBasic) {
+ ASSERT_TRUE(controller() != NULL);
+ scoped_ptr<MockScreenObserver> mock_screen_observer(new MockScreenObserver());
+ controller()->set_observer(mock_screen_observer.get());
+ UpdateScreen* update_screen = controller()->GetUpdateScreen();
+ ASSERT_TRUE(update_screen != NULL);
+ ASSERT_EQ(controller()->current_screen(), update_screen);
+ UpdateView* update_view = update_screen->view();
+ ASSERT_TRUE(update_view != NULL);
+ controller()->set_observer(NULL);
+}
+
+IN_PROC_BROWSER_TEST_F(UpdateScreenTest, TestNoUpdate) {
+ ASSERT_TRUE(controller() != NULL);
+ scoped_ptr<MockScreenObserver> mock_screen_observer(new MockScreenObserver());
+ controller()->set_observer(mock_screen_observer.get());
+ UpdateScreen* update_screen = controller()->GetUpdateScreen();
+ ASSERT_TRUE(update_screen != NULL);
+ ASSERT_EQ(controller()->current_screen(), update_screen);
+ update_screen->SetMinimalUpdateTime(0);
+
+ UpdateLibrary::Status status;
+ status.status = UPDATE_STATUS_IDLE;
+ EXPECT_CALL(*mock_update_library_, status())
+ .Times(AtLeast(1))
+ .WillRepeatedly(ReturnRef(status));
+ EXPECT_CALL(*mock_screen_observer, OnExit(ScreenObserver::UPDATE_NOUPDATE))
+ .Times(1);
+ update_screen->UpdateStatusChanged(mock_update_library_);
+
+ controller()->set_observer(NULL);
+}
+
+IN_PROC_BROWSER_TEST_F(UpdateScreenTest, TestUpdateAvailable) {
+ ASSERT_TRUE(controller() != NULL);
+ scoped_ptr<MockScreenObserver> mock_screen_observer(new MockScreenObserver());
+ controller()->set_observer(mock_screen_observer.get());
+ UpdateScreen* update_screen = controller()->GetUpdateScreen();
+ ASSERT_TRUE(update_screen != NULL);
+ ASSERT_EQ(controller()->current_screen(), update_screen);
+ update_screen->SetMinimalUpdateTime(0);
+
+ UpdateLibrary::Status status;
+
+ status.status = UPDATE_STATUS_UPDATE_AVAILABLE;
+ status.new_version = "latest and greatest";
+ EXPECT_CALL(*mock_update_library_, status())
+ .Times(AtLeast(1))
+ .WillRepeatedly(ReturnRef(status));
+ update_screen->UpdateStatusChanged(mock_update_library_);
+
+ status.status = UPDATE_STATUS_DOWNLOADING;
+ status.download_progress = 0.0;
+ EXPECT_CALL(*mock_update_library_, status())
+ .Times(AtLeast(1))
+ .WillRepeatedly(ReturnRef(status));
+ update_screen->UpdateStatusChanged(mock_update_library_);
+
+ status.download_progress = 0.5;
+ EXPECT_CALL(*mock_update_library_, status())
+ .Times(AtLeast(1))
+ .WillRepeatedly(ReturnRef(status));
+ update_screen->UpdateStatusChanged(mock_update_library_);
+
+ status.download_progress = 1.0;
+ EXPECT_CALL(*mock_update_library_, status())
+ .Times(AtLeast(1))
+ .WillRepeatedly(ReturnRef(status));
+ update_screen->UpdateStatusChanged(mock_update_library_);
+
+ status.status = UPDATE_STATUS_VERIFYING;
+ EXPECT_CALL(*mock_update_library_, status())
+ .Times(AtLeast(1))
+ .WillRepeatedly(ReturnRef(status));
+ update_screen->UpdateStatusChanged(mock_update_library_);
+
+ status.status = UPDATE_STATUS_FINALIZING;
+ EXPECT_CALL(*mock_update_library_, status())
+ .Times(AtLeast(1))
+ .WillRepeatedly(ReturnRef(status));
+ update_screen->UpdateStatusChanged(mock_update_library_);
+
+ status.status = UPDATE_STATUS_UPDATED_NEED_REBOOT;
+ EXPECT_CALL(*mock_update_library_, status())
+ .Times(AtLeast(1))
+ .WillRepeatedly(ReturnRef(status));
+ EXPECT_CALL(*mock_update_library_, RebootAfterUpdate())
+ .Times(1);
+ update_screen->UpdateStatusChanged(mock_update_library_);
+
+ controller()->set_observer(NULL);
+}
+
+IN_PROC_BROWSER_TEST_F(UpdateScreenTest, TestErrorIssuingUpdateCheck) {
+ ASSERT_TRUE(controller() != NULL);
+ scoped_ptr<MockScreenObserver> mock_screen_observer(new MockScreenObserver());
+ controller()->set_observer(mock_screen_observer.get());
+ UpdateScreen* update_screen = controller()->GetUpdateScreen();
+ ASSERT_TRUE(update_screen != NULL);
+ ASSERT_EQ(controller()->current_screen(), update_screen);
+ update_screen->SetMinimalUpdateTime(0);
+
+ UpdateLibrary::Status status;
+
+ // First, cancel the update that is already in progress.
+ EXPECT_CALL(*mock_update_library_, status())
+ .Times(AtLeast(1))
+ .WillRepeatedly(ReturnRef(status));
+ update_screen->CancelUpdate();
+
+ // Run UpdateScreen::StartUpdate() again, but CheckForUpdate() will fail
+ // issuing the update check this time.
+ EXPECT_CALL(*mock_update_library_, AddObserver(_))
+ .Times(1);
+ EXPECT_CALL(*mock_update_library_, RemoveObserver(_))
+ .Times(AtLeast(1));
+ EXPECT_CALL(*mock_update_library_, CheckForUpdate())
+ .Times(1)
+ .WillOnce(Return(false));
+
+ status.status = UPDATE_STATUS_ERROR;
+ EXPECT_CALL(*mock_update_library_, status())
+ .Times(AtLeast(1))
+ .WillRepeatedly(ReturnRef(status));
+ EXPECT_CALL(*mock_screen_observer,
+ OnExit(ScreenObserver::UPDATE_ERROR_CHECKING_FOR_UPDATE))
+ .Times(1);
+ update_screen->StartUpdate();
+
+ controller()->set_observer(NULL);
+}
+
+IN_PROC_BROWSER_TEST_F(UpdateScreenTest, TestErrorCheckingForUpdate) {
+ ASSERT_TRUE(controller() != NULL);
+ scoped_ptr<MockScreenObserver> mock_screen_observer(new MockScreenObserver());
+ controller()->set_observer(mock_screen_observer.get());
+ UpdateScreen* update_screen = controller()->GetUpdateScreen();
+ ASSERT_TRUE(update_screen != NULL);
+ ASSERT_EQ(controller()->current_screen(), update_screen);
+ update_screen->SetMinimalUpdateTime(0);
+
+ UpdateLibrary::Status status;
+ status.status = UPDATE_STATUS_ERROR;
+ EXPECT_CALL(*mock_update_library_, status())
+ .Times(AtLeast(1))
+ .WillRepeatedly(ReturnRef(status));
+ EXPECT_CALL(*mock_screen_observer,
+ OnExit(ScreenObserver::UPDATE_ERROR_CHECKING_FOR_UPDATE))
+ .Times(1);
+ update_screen->UpdateStatusChanged(mock_update_library_);
+
+ controller()->set_observer(NULL);
+}
+
+IN_PROC_BROWSER_TEST_F(UpdateScreenTest, TestErrorUpdating) {
+ ASSERT_TRUE(controller() != NULL);
+ scoped_ptr<MockScreenObserver> mock_screen_observer(new MockScreenObserver());
+ controller()->set_observer(mock_screen_observer.get());
+ UpdateScreen* update_screen = controller()->GetUpdateScreen();
+ ASSERT_TRUE(update_screen != NULL);
+ ASSERT_EQ(controller()->current_screen(), update_screen);
+ update_screen->SetMinimalUpdateTime(0);
+
+ UpdateLibrary::Status status;
+
+ status.status = UPDATE_STATUS_UPDATE_AVAILABLE;
+ status.new_version = "latest and greatest";
+ EXPECT_CALL(*mock_update_library_, status())
+ .Times(AtLeast(1))
+ .WillRepeatedly(ReturnRef(status));
+ update_screen->UpdateStatusChanged(mock_update_library_);
+
+ status.status = UPDATE_STATUS_ERROR;
+ EXPECT_CALL(*mock_update_library_, status())
+ .Times(AtLeast(1))
+ .WillRepeatedly(ReturnRef(status));
+ EXPECT_CALL(*mock_screen_observer,
+ OnExit(ScreenObserver::UPDATE_ERROR_UPDATING))
+ .Times(1);
+ update_screen->UpdateStatusChanged(mock_update_library_);
+
+ controller()->set_observer(NULL);
+}
+
+} // namespace chromeos
diff --git a/chrome/browser/chromeos/login/update_view.cc b/chrome/browser/chromeos/login/update_view.cc
index 53943a8..1037a9f 100644
--- a/chrome/browser/chromeos/login/update_view.cc
+++ b/chrome/browser/chromeos/login/update_view.cc
@@ -99,6 +99,7 @@ void UpdateView::Init() {
void UpdateView::Reset() {
progress_bar_->SetProgress(0);
#if !defined(OFFICIAL_BUILD)
+ ResetAccelerators();
AddAccelerator(escape_accelerator_);
#endif
}
diff --git a/chrome/browser/chromeos/login/wizard_controller.cc b/chrome/browser/chromeos/login/wizard_controller.cc
index 5f1672c..b5b4dce 100644
--- a/chrome/browser/chromeos/login/wizard_controller.cc
+++ b/chrome/browser/chromeos/login/wizard_controller.cc
@@ -69,6 +69,13 @@ const char kOobeCompleteFlagFilePath[] =
const int kWizardScreenWidth = 700;
const int kWizardScreenHeight = 416;
+// Update window should appear for at least kMinimalUpdateTimeSec seconds.
+const int kMinimalUpdateTimeSec = 3;
+
+// Time in seconds that we wait for the device to reboot.
+// If reboot didn't happen, ask user to reboot device manually.
+const int kWaitForRebootTimeSec = 3;
+
// RootView of the Widget WizardController creates. Contains the contents of the
// WizardController.
class ContentView : public views::View {
@@ -344,8 +351,11 @@ chromeos::AccountScreen* WizardController::GetAccountScreen() {
}
chromeos::UpdateScreen* WizardController::GetUpdateScreen() {
- if (!update_screen_.get())
+ if (!update_screen_.get()) {
update_screen_.reset(new chromeos::UpdateScreen(this));
+ update_screen_->SetMinimalUpdateTime(kMinimalUpdateTimeSec);
+ update_screen_->SetRebootCheckDelay(kWaitForRebootTimeSec);
+ }
return update_screen_.get();
}
diff --git a/chrome/browser/chromeos/login/wizard_screen.h b/chrome/browser/chromeos/login/wizard_screen.h
index 1f213165..7cc3089 100644
--- a/chrome/browser/chromeos/login/wizard_screen.h
+++ b/chrome/browser/chromeos/login/wizard_screen.h
@@ -52,4 +52,3 @@ class WizardScreen {
};
#endif // CHROME_BROWSER_CHROMEOS_LOGIN_WIZARD_SCREEN_H_
-