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

Side by Side Diff: chrome/installer/gcapi/gcapi_last_run_test.cc

Issue 297233010: Revert 273108 "Omaha configuration parameters now use Wow6432Nod..." (Closed) Base URL: svn://svn.chromium.org/chrome/branches/2017/src/
Patch Set: Created 6 years, 6 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
« no previous file with comments | « chrome/installer/gcapi/gcapi.cc ('k') | chrome/installer/gcapi/gcapi_reactivation.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
(...skipping 18 matching lines...) Expand all
29 std::wstring hkcu_override = base::StringPrintf( 29 std::wstring hkcu_override = base::StringPrintf(
30 L"hkcu_override\\%ls", base::ASCIIToWide(base::GenerateGUID())); 30 L"hkcu_override\\%ls", base::ASCIIToWide(base::GenerateGUID()));
31 override_manager_.OverrideRegistry(HKEY_CURRENT_USER, hkcu_override); 31 override_manager_.OverrideRegistry(HKEY_CURRENT_USER, hkcu_override);
32 32
33 // Create the client state key in the right places. 33 // Create the client state key in the right places.
34 std::wstring reg_path(google_update::kRegPathClientState); 34 std::wstring reg_path(google_update::kRegPathClientState);
35 reg_path += L"\\"; 35 reg_path += L"\\";
36 reg_path += google_update::kChromeUpgradeCode; 36 reg_path += google_update::kChromeUpgradeCode;
37 RegKey client_state(HKEY_CURRENT_USER, 37 RegKey client_state(HKEY_CURRENT_USER,
38 reg_path.c_str(), 38 reg_path.c_str(),
39 KEY_CREATE_SUB_KEY | KEY_WOW64_32KEY); 39 KEY_CREATE_SUB_KEY);
40 ASSERT_TRUE(client_state.Valid()); 40 ASSERT_TRUE(client_state.Valid());
41 41
42 // Place a bogus "pv" value in the right places to make the last run 42 // Place a bogus "pv" value in the right places to make the last run
43 // checker believe Chrome is installed. 43 // checker believe Chrome is installed.
44 std::wstring clients_path(google_update::kRegPathClients); 44 std::wstring clients_path(google_update::kRegPathClients);
45 clients_path += L"\\"; 45 clients_path += L"\\";
46 clients_path += google_update::kChromeUpgradeCode; 46 clients_path += google_update::kChromeUpgradeCode;
47 RegKey client_key(HKEY_CURRENT_USER, 47 RegKey client_key(HKEY_CURRENT_USER,
48 clients_path.c_str(), 48 clients_path.c_str(),
49 KEY_CREATE_SUB_KEY | KEY_SET_VALUE | KEY_WOW64_32KEY); 49 KEY_CREATE_SUB_KEY | KEY_SET_VALUE);
50 ASSERT_TRUE(client_key.Valid()); 50 ASSERT_TRUE(client_key.Valid());
51 client_key.WriteValue(L"pv", L"1.2.3.4"); 51 client_key.WriteValue(L"pv", L"1.2.3.4");
52 } 52 }
53 53
54 bool SetLastRunTime(int64 last_run_time) { 54 bool SetLastRunTime(int64 last_run_time) {
55 return SetLastRunTimeString(base::Int64ToString16(last_run_time)); 55 return SetLastRunTimeString(base::Int64ToString16(last_run_time));
56 } 56 }
57 57
58 bool SetLastRunTimeString(const base::string16& last_run_time_string) { 58 bool SetLastRunTimeString(const base::string16& last_run_time_string) {
59 const wchar_t* base_path = google_update::kRegPathClientState; 59 const wchar_t* base_path = google_update::kRegPathClientState;
60 std::wstring path(base_path); 60 std::wstring path(base_path);
61 path += L"\\"; 61 path += L"\\";
62 path += google_update::kChromeUpgradeCode; 62 path += google_update::kChromeUpgradeCode;
63 63
64 RegKey client_state( 64 RegKey client_state(HKEY_CURRENT_USER, path.c_str(), KEY_SET_VALUE);
65 HKEY_CURRENT_USER, path.c_str(), KEY_SET_VALUE | KEY_WOW64_32KEY);
66 return (client_state.Valid() && 65 return (client_state.Valid() &&
67 client_state.WriteValue( 66 client_state.WriteValue(
68 google_update::kRegLastRunTimeField, 67 google_update::kRegLastRunTimeField,
69 last_run_time_string.c_str()) == ERROR_SUCCESS); 68 last_run_time_string.c_str()) == ERROR_SUCCESS);
70 } 69 }
71 70
72 private: 71 private:
73 registry_util::RegistryOverrideManager override_manager_; 72 registry_util::RegistryOverrideManager override_manager_;
74 }; 73 };
75 74
(...skipping 16 matching lines...) Expand all
92 EXPECT_EQ(-1, days_since_last_run); 91 EXPECT_EQ(-1, days_since_last_run);
93 } 92 }
94 93
95 TEST_F(GCAPILastRunTest, OutOfRangeLastRun) { 94 TEST_F(GCAPILastRunTest, OutOfRangeLastRun) {
96 Time last_run = Time::NowFromSystemTime() - TimeDelta::FromDays(-42); 95 Time last_run = Time::NowFromSystemTime() - TimeDelta::FromDays(-42);
97 EXPECT_TRUE(SetLastRunTime(last_run.ToInternalValue())); 96 EXPECT_TRUE(SetLastRunTime(last_run.ToInternalValue()));
98 97
99 int days_since_last_run = GoogleChromeDaysSinceLastRun(); 98 int days_since_last_run = GoogleChromeDaysSinceLastRun();
100 EXPECT_EQ(-1, days_since_last_run); 99 EXPECT_EQ(-1, days_since_last_run);
101 } 100 }
OLDNEW
« no previous file with comments | « chrome/installer/gcapi/gcapi.cc ('k') | chrome/installer/gcapi/gcapi_reactivation.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698