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 <limits> | 5 #include <limits> |
6 #include <string> | 6 #include <string> |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/guid.h" | 9 #include "base/guid.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
11 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.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() { | 27 void SetUp() { |
28 // Override keys - this is undone during destruction. | 28 // Override keys - this is undone during destruction. |
29 std::wstring hkcu_override = base::StringPrintf( | 29 override_manager_.OverrideRegistry(HKEY_CURRENT_USER); |
30 L"hkcu_override\\%ls", base::ASCIIToWide(base::GenerateGUID()).c_str()); | |
31 override_manager_.OverrideRegistry(HKEY_CURRENT_USER, hkcu_override); | |
32 | 30 |
33 // Create the client state key in the right places. | 31 // Create the client state key in the right places. |
34 std::wstring reg_path(google_update::kRegPathClientState); | 32 std::wstring reg_path(google_update::kRegPathClientState); |
35 reg_path += L"\\"; | 33 reg_path += L"\\"; |
36 reg_path += google_update::kChromeUpgradeCode; | 34 reg_path += google_update::kChromeUpgradeCode; |
37 RegKey client_state(HKEY_CURRENT_USER, | 35 RegKey client_state(HKEY_CURRENT_USER, |
38 reg_path.c_str(), | 36 reg_path.c_str(), |
39 KEY_CREATE_SUB_KEY | KEY_WOW64_32KEY); | 37 KEY_CREATE_SUB_KEY | KEY_WOW64_32KEY); |
40 ASSERT_TRUE(client_state.Valid()); | 38 ASSERT_TRUE(client_state.Valid()); |
41 | 39 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 EXPECT_EQ(-1, days_since_last_run); | 90 EXPECT_EQ(-1, days_since_last_run); |
93 } | 91 } |
94 | 92 |
95 TEST_F(GCAPILastRunTest, OutOfRangeLastRun) { | 93 TEST_F(GCAPILastRunTest, OutOfRangeLastRun) { |
96 Time last_run = Time::NowFromSystemTime() - TimeDelta::FromDays(-42); | 94 Time last_run = Time::NowFromSystemTime() - TimeDelta::FromDays(-42); |
97 EXPECT_TRUE(SetLastRunTime(last_run.ToInternalValue())); | 95 EXPECT_TRUE(SetLastRunTime(last_run.ToInternalValue())); |
98 | 96 |
99 int days_since_last_run = GoogleChromeDaysSinceLastRun(); | 97 int days_since_last_run = GoogleChromeDaysSinceLastRun(); |
100 EXPECT_EQ(-1, days_since_last_run); | 98 EXPECT_EQ(-1, days_since_last_run); |
101 } | 99 } |
OLD | NEW |