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> |
| 6 |
5 #include <limits> | 7 #include <limits> |
6 #include <string> | 8 #include <string> |
7 | 9 |
8 #include "base/basictypes.h" | |
9 #include "base/guid.h" | 10 #include "base/guid.h" |
10 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
11 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
12 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
13 #include "base/test/test_reg_util_win.h" | 14 #include "base/test/test_reg_util_win.h" |
14 #include "base/time/time.h" | 15 #include "base/time/time.h" |
15 #include "base/win/registry.h" | 16 #include "base/win/registry.h" |
16 #include "chrome/installer/gcapi/gcapi.h" | 17 #include "chrome/installer/gcapi/gcapi.h" |
17 #include "chrome/installer/util/google_update_constants.h" | 18 #include "chrome/installer/util/google_update_constants.h" |
18 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 23 matching lines...) Expand all Loading... |
42 std::wstring clients_path(google_update::kRegPathClients); | 43 std::wstring clients_path(google_update::kRegPathClients); |
43 clients_path += L"\\"; | 44 clients_path += L"\\"; |
44 clients_path += google_update::kChromeUpgradeCode; | 45 clients_path += google_update::kChromeUpgradeCode; |
45 RegKey client_key(HKEY_CURRENT_USER, | 46 RegKey client_key(HKEY_CURRENT_USER, |
46 clients_path.c_str(), | 47 clients_path.c_str(), |
47 KEY_CREATE_SUB_KEY | KEY_SET_VALUE | KEY_WOW64_32KEY); | 48 KEY_CREATE_SUB_KEY | KEY_SET_VALUE | KEY_WOW64_32KEY); |
48 ASSERT_TRUE(client_key.Valid()); | 49 ASSERT_TRUE(client_key.Valid()); |
49 client_key.WriteValue(L"pv", L"1.2.3.4"); | 50 client_key.WriteValue(L"pv", L"1.2.3.4"); |
50 } | 51 } |
51 | 52 |
52 bool SetLastRunTime(int64 last_run_time) { | 53 bool SetLastRunTime(int64_t last_run_time) { |
53 return SetLastRunTimeString(base::Int64ToString16(last_run_time)); | 54 return SetLastRunTimeString(base::Int64ToString16(last_run_time)); |
54 } | 55 } |
55 | 56 |
56 bool SetLastRunTimeString(const base::string16& last_run_time_string) { | 57 bool SetLastRunTimeString(const base::string16& last_run_time_string) { |
57 const wchar_t* base_path = google_update::kRegPathClientState; | 58 const wchar_t* base_path = google_update::kRegPathClientState; |
58 std::wstring path(base_path); | 59 std::wstring path(base_path); |
59 path += L"\\"; | 60 path += L"\\"; |
60 path += google_update::kChromeUpgradeCode; | 61 path += google_update::kChromeUpgradeCode; |
61 | 62 |
62 RegKey client_state( | 63 RegKey client_state( |
(...skipping 27 matching lines...) Expand all 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 |