| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <stdint.h> | 5 #include <stdint.h> |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/guid.h" | 10 #include "base/guid.h" |
| 11 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
| 12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
| 13 #include "base/test/test_reg_util_win.h" | 13 #include "base/test/test_reg_util_win.h" |
| 14 #include "base/time/time.h" | 14 #include "base/time/time.h" |
| 15 #include "base/win/registry.h" | 15 #include "base/win/registry.h" |
| 16 #include "chrome/installer/gcapi/gcapi.h" | 16 #include "chrome/installer/gcapi/gcapi.h" |
| 17 #include "chrome/installer/util/google_update_constants.h" | 17 #include "chrome/installer/util/google_update_constants.h" |
| 18 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
| 19 | 19 |
| 20 using base::Time; | 20 using base::Time; |
| 21 using base::TimeDelta; | 21 using base::TimeDelta; |
| 22 using base::win::RegKey; | 22 using base::win::RegKey; |
| 23 | 23 |
| 24 | 24 |
| 25 class GCAPILastRunTest : public ::testing::Test { | 25 class GCAPILastRunTest : public ::testing::Test { |
| 26 protected: | 26 protected: |
| 27 void SetUp() override { | 27 void SetUp() override { |
| 28 // Override keys - this is undone during destruction. | 28 // Override keys - this is undone during destruction. |
| 29 override_manager_.OverrideRegistry(HKEY_CURRENT_USER); | 29 ASSERT_NO_FATAL_FAILURE( |
| 30 override_manager_.OverrideRegistry(HKEY_CURRENT_USER)); |
| 30 | 31 |
| 31 // Create the client state key in the right places. | 32 // Create the client state key in the right places. |
| 32 std::wstring reg_path(google_update::kRegPathClientState); | 33 std::wstring reg_path(google_update::kRegPathClientState); |
| 33 reg_path += L"\\"; | 34 reg_path += L"\\"; |
| 34 reg_path += google_update::kChromeUpgradeCode; | 35 reg_path += google_update::kChromeUpgradeCode; |
| 35 RegKey client_state(HKEY_CURRENT_USER, | 36 RegKey client_state(HKEY_CURRENT_USER, |
| 36 reg_path.c_str(), | 37 reg_path.c_str(), |
| 37 KEY_CREATE_SUB_KEY | KEY_WOW64_32KEY); | 38 KEY_CREATE_SUB_KEY | KEY_WOW64_32KEY); |
| 38 ASSERT_TRUE(client_state.Valid()); | 39 ASSERT_TRUE(client_state.Valid()); |
| 39 | 40 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 EXPECT_EQ(-1, days_since_last_run); | 91 EXPECT_EQ(-1, days_since_last_run); |
| 91 } | 92 } |
| 92 | 93 |
| 93 TEST_F(GCAPILastRunTest, OutOfRangeLastRun) { | 94 TEST_F(GCAPILastRunTest, OutOfRangeLastRun) { |
| 94 Time last_run = Time::NowFromSystemTime() - TimeDelta::FromDays(-42); | 95 Time last_run = Time::NowFromSystemTime() - TimeDelta::FromDays(-42); |
| 95 EXPECT_TRUE(SetLastRunTime(last_run.ToInternalValue())); | 96 EXPECT_TRUE(SetLastRunTime(last_run.ToInternalValue())); |
| 96 | 97 |
| 97 int days_since_last_run = GoogleChromeDaysSinceLastRun(); | 98 int days_since_last_run = GoogleChromeDaysSinceLastRun(); |
| 98 EXPECT_EQ(-1, days_since_last_run); | 99 EXPECT_EQ(-1, days_since_last_run); |
| 99 } | 100 } |
| OLD | NEW |