OLD | NEW |
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 <atlbase.h> | 5 #include <atlbase.h> |
6 #include <atlapp.h> | 6 #include <atlapp.h> |
7 #include <atlmisc.h> | 7 #include <atlmisc.h> |
8 #include <atlwin.h> | 8 #include <atlwin.h> |
9 | 9 |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 | 323 |
324 ReadyModeRegistryTest() | 324 ReadyModeRegistryTest() |
325 : is_product_registered_(true), | 325 : is_product_registered_(true), |
326 is_product_installed_(false), | 326 is_product_installed_(false), |
327 observer_(NULL), | 327 observer_(NULL), |
328 installation_state_(NULL) { | 328 installation_state_(NULL) { |
329 } | 329 } |
330 | 330 |
331 virtual void SetUp() { | 331 virtual void SetUp() { |
332 base::win::RegKey key; | 332 base::win::RegKey key; |
333 ASSERT_TRUE(key.Create(HKEY_CURRENT_USER, kRootKey, KEY_ALL_ACCESS)); | 333 ASSERT_EQ(ERROR_SUCCESS, key.Create(HKEY_CURRENT_USER, kRootKey, |
| 334 KEY_ALL_ACCESS)); |
334 observer_ = new MockRegistryReadyModeStateObserver(); | 335 observer_ = new MockRegistryReadyModeStateObserver(); |
335 installation_state_ = new MockInstallationState(); | 336 installation_state_ = new MockInstallationState(); |
336 | 337 |
337 EXPECT_CALL(*installation_state_, IsProductRegistered()) | 338 EXPECT_CALL(*installation_state_, IsProductRegistered()) |
338 .Times(testing::AnyNumber()) | 339 .Times(testing::AnyNumber()) |
339 .WillRepeatedly(ReturnPointee(&is_product_registered_)); | 340 .WillRepeatedly(ReturnPointee(&is_product_registered_)); |
340 EXPECT_CALL(*installation_state_, IsProductInstalled()) | 341 EXPECT_CALL(*installation_state_, IsProductInstalled()) |
341 .Times(testing::AnyNumber()) | 342 .Times(testing::AnyNumber()) |
342 .WillRepeatedly(ReturnPointee(&is_product_installed_)); | 343 .WillRepeatedly(ReturnPointee(&is_product_installed_)); |
343 | 344 |
344 ready_mode_state_.reset(new TimeControlledRegistryReadyModeState( | 345 ready_mode_state_.reset(new TimeControlledRegistryReadyModeState( |
345 kRootKey, | 346 kRootKey, |
346 base::TimeDelta::FromSeconds(kTemporaryDeclineDurationInSeconds), | 347 base::TimeDelta::FromSeconds(kTemporaryDeclineDurationInSeconds), |
347 installation_state_, | 348 installation_state_, |
348 observer_)); | 349 observer_)); |
349 } | 350 } |
350 | 351 |
351 virtual void TearDown() { | 352 virtual void TearDown() { |
352 base::win::RegKey key; | 353 base::win::RegKey key; |
353 EXPECT_TRUE(key.Open(HKEY_CURRENT_USER, L"", KEY_ALL_ACCESS)); | 354 EXPECT_EQ(ERROR_SUCCESS, key.Open(HKEY_CURRENT_USER, L"", KEY_ALL_ACCESS)); |
354 EXPECT_TRUE(key.DeleteKey(kRootKey)); | 355 EXPECT_EQ(ERROR_SUCCESS, key.DeleteKey(kRootKey)); |
355 } | 356 } |
356 | 357 |
357 protected: | 358 protected: |
358 void AdjustClockBySeconds(int seconds) { | 359 void AdjustClockBySeconds(int seconds) { |
359 ready_mode_state_->now_ += base::TimeDelta::FromSeconds(seconds); | 360 ready_mode_state_->now_ += base::TimeDelta::FromSeconds(seconds); |
360 } | 361 } |
361 | 362 |
362 void ExpectUnregisterProductAndReturn(bool success) { | 363 void ExpectUnregisterProductAndReturn(bool success) { |
363 EXPECT_CALL(*installation_state_, UnregisterProduct()) | 364 EXPECT_CALL(*installation_state_, UnregisterProduct()) |
364 .WillOnce(testing::DoAll( | 365 .WillOnce(testing::DoAll( |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
464 // Which component is responsible for messaging the user? The installer? The | 465 // Which component is responsible for messaging the user? The installer? The |
465 // InstallationState implementation? The ReadyModeState implementation? | 466 // InstallationState implementation? The ReadyModeState implementation? |
466 TEST_F(ReadyModeRegistryTest, AcceptChromeFrameInstallFails) { | 467 TEST_F(ReadyModeRegistryTest, AcceptChromeFrameInstallFails) { |
467 ASSERT_EQ(READY_MODE_ACTIVE, ready_mode_state_->GetStatus()); | 468 ASSERT_EQ(READY_MODE_ACTIVE, ready_mode_state_->GetStatus()); |
468 | 469 |
469 ExpectInstallProductAndReturn(false); | 470 ExpectInstallProductAndReturn(false); |
470 ready_mode_state_->AcceptChromeFrame(); | 471 ready_mode_state_->AcceptChromeFrame(); |
471 | 472 |
472 ASSERT_EQ(READY_MODE_ACTIVE, ready_mode_state_->GetStatus()); | 473 ASSERT_EQ(READY_MODE_ACTIVE, ready_mode_state_->GetStatus()); |
473 } | 474 } |
OLD | NEW |