| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/chromeos/cros/mock_login_library.h" | |
| 6 #include "chrome/browser/chromeos/cros/mock_network_library.h" | 5 #include "chrome/browser/chromeos/cros/mock_network_library.h" |
| 7 #include "chrome/browser/chromeos/cros/mock_update_library.h" | 6 #include "chrome/browser/chromeos/cros/mock_update_library.h" |
| 7 #include "chrome/browser/chromeos/dbus/dbus_thread_manager.h" |
| 8 #include "chrome/browser/chromeos/dbus/mock_session_manager_client.h" |
| 8 #include "chrome/browser/chromeos/login/mock_screen_observer.h" | 9 #include "chrome/browser/chromeos/login/mock_screen_observer.h" |
| 9 #include "chrome/browser/chromeos/login/update_screen.h" | 10 #include "chrome/browser/chromeos/login/update_screen.h" |
| 10 #include "chrome/browser/chromeos/login/wizard_controller.h" | 11 #include "chrome/browser/chromeos/login/wizard_controller.h" |
| 11 #include "chrome/browser/chromeos/login/wizard_in_process_browser_test.h" | 12 #include "chrome/browser/chromeos/login/wizard_in_process_browser_test.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 13 | 14 |
| 14 namespace chromeos { | 15 namespace chromeos { |
| 15 using ::testing::_; | 16 using ::testing::_; |
| 16 using ::testing::AnyNumber; | 17 using ::testing::AnyNumber; |
| 17 using ::testing::AtLeast; | 18 using ::testing::AtLeast; |
| 18 using ::testing::Return; | 19 using ::testing::Return; |
| 19 using ::testing::ReturnRef; | 20 using ::testing::ReturnRef; |
| 20 using ::testing::Invoke; | 21 using ::testing::Invoke; |
| 21 | 22 |
| 22 static void RequestUpdateCheckSuccess(UpdateCallback callback, void* userdata) { | 23 static void RequestUpdateCheckSuccess(UpdateCallback callback, void* userdata) { |
| 23 callback(userdata, chromeos::UPDATE_RESULT_SUCCESS, NULL); | 24 callback(userdata, chromeos::UPDATE_RESULT_SUCCESS, NULL); |
| 24 } | 25 } |
| 25 | 26 |
| 26 class UpdateScreenTest : public WizardInProcessBrowserTest { | 27 class UpdateScreenTest : public WizardInProcessBrowserTest { |
| 27 public: | 28 public: |
| 28 UpdateScreenTest() : WizardInProcessBrowserTest("update"), | 29 UpdateScreenTest() : WizardInProcessBrowserTest("update"), |
| 29 mock_login_library_(NULL), | 30 mock_session_manager_client_(NULL), |
| 30 mock_update_library_(NULL), | 31 mock_update_library_(NULL), |
| 31 mock_network_library_(NULL) {} | 32 mock_network_library_(NULL) {} |
| 32 | 33 |
| 33 protected: | 34 protected: |
| 34 virtual void SetUpInProcessBrowserTestFixture() { | 35 virtual void SetUpInProcessBrowserTestFixture() { |
| 36 DBusThreadManager::Initialize(); |
| 35 WizardInProcessBrowserTest::SetUpInProcessBrowserTestFixture(); | 37 WizardInProcessBrowserTest::SetUpInProcessBrowserTestFixture(); |
| 36 cros_mock_->InitStatusAreaMocks(); | 38 cros_mock_->InitStatusAreaMocks(); |
| 37 cros_mock_->SetStatusAreaMocksExpectations(); | 39 cros_mock_->SetStatusAreaMocksExpectations(); |
| 38 ASSERT_TRUE(CrosLibrary::Get()->EnsureLoaded()); | 40 ASSERT_TRUE(CrosLibrary::Get()->EnsureLoaded()); |
| 39 | 41 |
| 40 mock_login_library_ = new MockLoginLibrary(); | 42 mock_session_manager_client_ = new MockSessionManagerClient(); |
| 41 cros_mock_->test_api()->SetLoginLibrary(mock_login_library_, true); | 43 DBusThreadManager::Get()->set_session_manager_client_for_testing( |
| 42 EXPECT_CALL(*mock_login_library_, EmitLoginPromptReady()) | 44 mock_session_manager_client_); |
| 45 EXPECT_CALL(*mock_session_manager_client_, EmitLoginPromptReady()) |
| 43 .Times(1); | 46 .Times(1); |
| 44 | 47 |
| 45 mock_update_library_ = new MockUpdateLibrary(); | 48 mock_update_library_ = new MockUpdateLibrary(); |
| 46 cros_mock_->test_api()->SetUpdateLibrary(mock_update_library_, true); | 49 cros_mock_->test_api()->SetUpdateLibrary(mock_update_library_, true); |
| 47 | 50 |
| 48 // UpdateScreen::StartUpdate() will be called by the WizardController | 51 // UpdateScreen::StartUpdate() will be called by the WizardController |
| 49 // just after creating the update screen, so the expectations for that | 52 // just after creating the update screen, so the expectations for that |
| 50 // should be set up here. | 53 // should be set up here. |
| 51 EXPECT_CALL(*mock_update_library_, AddObserver(_)) | 54 EXPECT_CALL(*mock_update_library_, AddObserver(_)) |
| 52 .Times(1); | 55 .Times(1); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 76 update_screen_ = controller()->GetUpdateScreen(); | 79 update_screen_ = controller()->GetUpdateScreen(); |
| 77 ASSERT_TRUE(update_screen_ != NULL); | 80 ASSERT_TRUE(update_screen_ != NULL); |
| 78 ASSERT_EQ(controller()->current_screen(), update_screen_); | 81 ASSERT_EQ(controller()->current_screen(), update_screen_); |
| 79 update_screen_->screen_observer_ = mock_screen_observer_.get(); | 82 update_screen_->screen_observer_ = mock_screen_observer_.get(); |
| 80 } | 83 } |
| 81 | 84 |
| 82 virtual void TearDownInProcessBrowserTestFixture() { | 85 virtual void TearDownInProcessBrowserTestFixture() { |
| 83 update_screen_->screen_observer_ = (controller()); | 86 update_screen_->screen_observer_ = (controller()); |
| 84 cros_mock_->test_api()->SetUpdateLibrary(NULL, true); | 87 cros_mock_->test_api()->SetUpdateLibrary(NULL, true); |
| 85 WizardInProcessBrowserTest::TearDownInProcessBrowserTestFixture(); | 88 WizardInProcessBrowserTest::TearDownInProcessBrowserTestFixture(); |
| 89 DBusThreadManager::Shutdown(); |
| 86 } | 90 } |
| 87 | 91 |
| 88 MockLoginLibrary* mock_login_library_; | 92 MockSessionManagerClient* mock_session_manager_client_; |
| 89 MockUpdateLibrary* mock_update_library_; | 93 MockUpdateLibrary* mock_update_library_; |
| 90 MockNetworkLibrary* mock_network_library_; | 94 MockNetworkLibrary* mock_network_library_; |
| 91 | 95 |
| 92 scoped_ptr<MockScreenObserver> mock_screen_observer_; | 96 scoped_ptr<MockScreenObserver> mock_screen_observer_; |
| 93 UpdateScreen* update_screen_; | 97 UpdateScreen* update_screen_; |
| 94 | 98 |
| 95 private: | 99 private: |
| 96 DISALLOW_COPY_AND_ASSIGN(UpdateScreenTest); | 100 DISALLOW_COPY_AND_ASSIGN(UpdateScreenTest); |
| 97 }; | 101 }; |
| 98 | 102 |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 EXPECT_CALL(*mock_update_library_, status()) | 228 EXPECT_CALL(*mock_update_library_, status()) |
| 225 .Times(AtLeast(1)) | 229 .Times(AtLeast(1)) |
| 226 .WillRepeatedly(ReturnRef(status)); | 230 .WillRepeatedly(ReturnRef(status)); |
| 227 EXPECT_CALL(*mock_screen_observer_, | 231 EXPECT_CALL(*mock_screen_observer_, |
| 228 OnExit(ScreenObserver::UPDATE_ERROR_UPDATING)) | 232 OnExit(ScreenObserver::UPDATE_ERROR_UPDATING)) |
| 229 .Times(1); | 233 .Times(1); |
| 230 update_screen_->UpdateStatusChanged(mock_update_library_); | 234 update_screen_->UpdateStatusChanged(mock_update_library_); |
| 231 } | 235 } |
| 232 | 236 |
| 233 } // namespace chromeos | 237 } // namespace chromeos |
| OLD | NEW |