Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(521)

Side by Side Diff: chrome/browser/chromeos/login/update_screen_browsertest.cc

Issue 6648009: Modify UpdateLibrary to use async RequestUpdateCheck call (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix nits Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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" 5 #include "chrome/browser/chromeos/cros/mock_login_library.h"
6 #include "chrome/browser/chromeos/cros/mock_network_library.h" 6 #include "chrome/browser/chromeos/cros/mock_network_library.h"
7 #include "chrome/browser/chromeos/cros/mock_update_library.h" 7 #include "chrome/browser/chromeos/cros/mock_update_library.h"
8 #include "chrome/browser/chromeos/login/mock_screen_observer.h" 8 #include "chrome/browser/chromeos/login/mock_screen_observer.h"
9 #include "chrome/browser/chromeos/login/update_screen.h" 9 #include "chrome/browser/chromeos/login/update_screen.h"
10 #include "chrome/browser/chromeos/login/wizard_controller.h" 10 #include "chrome/browser/chromeos/login/wizard_controller.h"
11 #include "chrome/browser/chromeos/login/wizard_in_process_browser_test.h" 11 #include "chrome/browser/chromeos/login/wizard_in_process_browser_test.h"
12 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
13 13
14 namespace chromeos { 14 namespace chromeos {
15 using ::testing::_; 15 using ::testing::_;
16 using ::testing::AtLeast; 16 using ::testing::AtLeast;
17 using ::testing::Return; 17 using ::testing::Return;
18 using ::testing::ReturnRef; 18 using ::testing::ReturnRef;
19 using ::testing::Invoke;
20
21 static void RequestUpdateCheckSuccess(UpdateCallback callback, void* userdata) {
22 callback(userdata, chromeos::UPDATE_RESULT_SUCCESS, NULL);
23 }
19 24
20 class UpdateScreenTest : public WizardInProcessBrowserTest { 25 class UpdateScreenTest : public WizardInProcessBrowserTest {
21 public: 26 public:
22 UpdateScreenTest() : WizardInProcessBrowserTest("update"), 27 UpdateScreenTest() : WizardInProcessBrowserTest("update"),
23 mock_login_library_(NULL), 28 mock_login_library_(NULL),
24 mock_update_library_(NULL), 29 mock_update_library_(NULL),
25 mock_network_library_(NULL) {} 30 mock_network_library_(NULL) {}
26 31
27 protected: 32 protected:
28 virtual void SetUpInProcessBrowserTestFixture() { 33 virtual void SetUpInProcessBrowserTestFixture() {
(...skipping 10 matching lines...) Expand all
39 mock_update_library_ = new MockUpdateLibrary(); 44 mock_update_library_ = new MockUpdateLibrary();
40 cros_mock_->test_api()->SetUpdateLibrary(mock_update_library_, true); 45 cros_mock_->test_api()->SetUpdateLibrary(mock_update_library_, true);
41 46
42 // UpdateScreen::StartUpdate() will be called by the WizardController 47 // UpdateScreen::StartUpdate() will be called by the WizardController
43 // just after creating the update screen, so the expectations for that 48 // just after creating the update screen, so the expectations for that
44 // should be set up here. 49 // should be set up here.
45 EXPECT_CALL(*mock_update_library_, AddObserver(_)) 50 EXPECT_CALL(*mock_update_library_, AddObserver(_))
46 .Times(1); 51 .Times(1);
47 EXPECT_CALL(*mock_update_library_, RemoveObserver(_)) 52 EXPECT_CALL(*mock_update_library_, RemoveObserver(_))
48 .Times(AtLeast(1)); 53 .Times(AtLeast(1));
49 EXPECT_CALL(*mock_update_library_, CheckForUpdate()) 54 EXPECT_CALL(*mock_update_library_, RequestUpdateCheck(_,_))
50 .Times(1) 55 .Times(1)
51 .WillOnce(Return(true)); 56 .WillOnce(Invoke(RequestUpdateCheckSuccess));
52 57
53 mock_network_library_ = cros_mock_->mock_network_library(); 58 mock_network_library_ = cros_mock_->mock_network_library();
54 EXPECT_CALL(*mock_network_library_, Connected()) 59 EXPECT_CALL(*mock_network_library_, Connected())
55 .Times(1) // also called by NetworkMenu::InitMenuItems() 60 .Times(1) // also called by NetworkMenu::InitMenuItems()
56 .WillRepeatedly((Return(false))) 61 .WillRepeatedly((Return(false)))
57 .RetiresOnSaturation(); 62 .RetiresOnSaturation();
58 EXPECT_CALL(*mock_network_library_, AddNetworkManagerObserver(_)) 63 EXPECT_CALL(*mock_network_library_, AddNetworkManagerObserver(_))
59 .Times(1) 64 .Times(1)
60 .RetiresOnSaturation(); 65 .RetiresOnSaturation();
61 } 66 }
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 EXPECT_CALL(*mock_update_library_, status()) 163 EXPECT_CALL(*mock_update_library_, status())
159 .Times(AtLeast(1)) 164 .Times(AtLeast(1))
160 .WillRepeatedly(ReturnRef(status)); 165 .WillRepeatedly(ReturnRef(status));
161 EXPECT_CALL(*mock_update_library_, RebootAfterUpdate()) 166 EXPECT_CALL(*mock_update_library_, RebootAfterUpdate())
162 .Times(1); 167 .Times(1);
163 update_screen->UpdateStatusChanged(mock_update_library_); 168 update_screen->UpdateStatusChanged(mock_update_library_);
164 169
165 controller()->set_observer(NULL); 170 controller()->set_observer(NULL);
166 } 171 }
167 172
173 static void RequestUpdateCheckFail(UpdateCallback callback, void* userdata) {
174 callback(userdata, chromeos::UPDATE_RESULT_FAILED, NULL);
175 }
176
168 IN_PROC_BROWSER_TEST_F(UpdateScreenTest, TestErrorIssuingUpdateCheck) { 177 IN_PROC_BROWSER_TEST_F(UpdateScreenTest, TestErrorIssuingUpdateCheck) {
169 ASSERT_TRUE(controller() != NULL); 178 ASSERT_TRUE(controller() != NULL);
170 scoped_ptr<MockScreenObserver> mock_screen_observer(new MockScreenObserver()); 179 scoped_ptr<MockScreenObserver> mock_screen_observer(new MockScreenObserver());
171 controller()->set_observer(mock_screen_observer.get()); 180 controller()->set_observer(mock_screen_observer.get());
172 UpdateScreen* update_screen = controller()->GetUpdateScreen(); 181 UpdateScreen* update_screen = controller()->GetUpdateScreen();
173 ASSERT_TRUE(update_screen != NULL); 182 ASSERT_TRUE(update_screen != NULL);
174 ASSERT_EQ(controller()->current_screen(), update_screen); 183 ASSERT_EQ(controller()->current_screen(), update_screen);
175 184
176 // First, cancel the update that is already in progress. 185 // First, cancel the update that is already in progress.
177 EXPECT_CALL(*mock_screen_observer, 186 EXPECT_CALL(*mock_screen_observer,
178 OnExit(ScreenObserver::UPDATE_NOUPDATE)) 187 OnExit(ScreenObserver::UPDATE_NOUPDATE))
179 .Times(1); 188 .Times(1);
180 update_screen->CancelUpdate(); 189 update_screen->CancelUpdate();
181 190
182 // Run UpdateScreen::StartUpdate() again, but CheckForUpdate() will fail 191 // Run UpdateScreen::StartUpdate() again, but CheckForUpdate() will fail
183 // issuing the update check this time. 192 // issuing the update check this time.
184 EXPECT_CALL(*mock_update_library_, AddObserver(_)) 193 EXPECT_CALL(*mock_update_library_, AddObserver(_))
185 .Times(1); 194 .Times(1);
186 EXPECT_CALL(*mock_update_library_, RemoveObserver(_)) 195 EXPECT_CALL(*mock_update_library_, RemoveObserver(_))
187 .Times(AtLeast(1)); 196 .Times(AtLeast(1));
188 EXPECT_CALL(*mock_update_library_, CheckForUpdate()) 197 EXPECT_CALL(*mock_update_library_, RequestUpdateCheck(_,_))
189 .Times(1) 198 .Times(1)
190 .WillOnce(Return(false)); 199 .WillOnce(Invoke(RequestUpdateCheckFail));
191 EXPECT_CALL(*mock_screen_observer, 200 EXPECT_CALL(*mock_screen_observer,
192 OnExit(ScreenObserver::UPDATE_ERROR_CHECKING_FOR_UPDATE)) 201 OnExit(ScreenObserver::UPDATE_ERROR_CHECKING_FOR_UPDATE))
193 .Times(1); 202 .Times(1);
194 update_screen->StartUpdate(); 203 update_screen->StartUpdate();
195 204
196 controller()->set_observer(NULL); 205 controller()->set_observer(NULL);
197 } 206 }
198 207
199 IN_PROC_BROWSER_TEST_F(UpdateScreenTest, TestErrorCheckingForUpdate) { 208 IN_PROC_BROWSER_TEST_F(UpdateScreenTest, TestErrorCheckingForUpdate) {
200 ASSERT_TRUE(controller() != NULL); 209 ASSERT_TRUE(controller() != NULL);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 .WillRepeatedly(ReturnRef(status)); 249 .WillRepeatedly(ReturnRef(status));
241 EXPECT_CALL(*mock_screen_observer, 250 EXPECT_CALL(*mock_screen_observer,
242 OnExit(ScreenObserver::UPDATE_ERROR_UPDATING)) 251 OnExit(ScreenObserver::UPDATE_ERROR_UPDATING))
243 .Times(1); 252 .Times(1);
244 update_screen->UpdateStatusChanged(mock_update_library_); 253 update_screen->UpdateStatusChanged(mock_update_library_);
245 254
246 controller()->set_observer(NULL); 255 controller()->set_observer(NULL);
247 } 256 }
248 257
249 } // namespace chromeos 258 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/update_screen.cc ('k') | chrome/browser/ui/webui/options/about_page_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698