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

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

Issue 23579003: GCAPI should append to the existing experiment_labels instead of clobbering them. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Move Windows only variations_util code to variations_util_win Created 7 years, 3 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
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 <string> 5 #include <string>
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/guid.h"
9 #include "base/strings/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
10 #include "base/strings/stringprintf.h"
11 #include "base/strings/utf_string_conversions.h"
12 #include "base/test/test_reg_util_win.h"
13 #include "base/time/time.h" 9 #include "base/time/time.h"
14 #include "base/win/registry.h" 10 #include "base/win/registry.h"
15 #include "chrome/installer/gcapi/gcapi.h" 11 #include "chrome/installer/gcapi/gcapi.h"
16 #include "chrome/installer/gcapi/gcapi_omaha_experiment.h" 12 #include "chrome/installer/gcapi/gcapi_omaha_experiment.h"
17 #include "chrome/installer/gcapi/gcapi_reactivation.h" 13 #include "chrome/installer/gcapi/gcapi_reactivation.h"
14 #include "chrome/installer/gcapi/gcapi_registry_overriding_test.h"
18 #include "chrome/installer/util/google_update_constants.h" 15 #include "chrome/installer/util/google_update_constants.h"
19 #include "testing/gtest/include/gtest/gtest.h"
20 16
21 using base::Time; 17 using base::Time;
22 using base::TimeDelta; 18 using base::TimeDelta;
23 using base::win::RegKey; 19 using base::win::RegKey;
24 20
25 class GCAPIReactivationTest : public ::testing::Test { 21 class GCAPIReactivationTest : public GCAPIRegistryOverridingTest {
26 protected: 22 protected:
27 void SetUp() {
28 // Override keys - this is undone during destruction.
29 std::wstring hkcu_override = base::StringPrintf(
30 L"hkcu_override\\%ls", ASCIIToWide(base::GenerateGUID()));
31 override_manager_.OverrideRegistry(HKEY_CURRENT_USER, hkcu_override);
32 std::wstring hklm_override = base::StringPrintf(
33 L"hklm_override\\%ls", ASCIIToWide(base::GenerateGUID()));
34 override_manager_.OverrideRegistry(HKEY_LOCAL_MACHINE, hklm_override);
35 }
36
37 bool SetChromeInstallMarker(HKEY hive) { 23 bool SetChromeInstallMarker(HKEY hive) {
38 // Create the client state keys in the right places. 24 // Create the client state keys in the right places.
39 std::wstring reg_path(google_update::kRegPathClients); 25 std::wstring reg_path(google_update::kRegPathClients);
40 reg_path += L"\\"; 26 reg_path += L"\\";
41 reg_path += google_update::kChromeUpgradeCode; 27 reg_path += google_update::kChromeUpgradeCode;
42 RegKey client_state(hive, 28 RegKey client_state(hive,
43 reg_path.c_str(), 29 reg_path.c_str(),
44 KEY_CREATE_SUB_KEY | KEY_SET_VALUE); 30 KEY_CREATE_SUB_KEY | KEY_SET_VALUE);
45 return (client_state.Valid() && 31 return (client_state.Valid() &&
46 client_state.WriteValue( 32 client_state.WriteValue(
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 if (client_state.Valid()) { 78 if (client_state.Valid()) {
93 std::wstring actual_brand; 79 std::wstring actual_brand;
94 if (client_state.ReadValue(google_update::kRegRLZReactivationBrandField, 80 if (client_state.ReadValue(google_update::kRegRLZReactivationBrandField,
95 &actual_brand) == ERROR_SUCCESS) { 81 &actual_brand) == ERROR_SUCCESS) {
96 return actual_brand; 82 return actual_brand;
97 } 83 }
98 } 84 }
99 85
100 return L"ERROR"; 86 return L"ERROR";
101 } 87 }
102
103 private:
104 registry_util::RegistryOverrideManager override_manager_;
105 }; 88 };
106 89
107 TEST_F(GCAPIReactivationTest, CheckSetReactivationBrandCode) { 90 TEST_F(GCAPIReactivationTest, CheckSetReactivationBrandCode) {
108 EXPECT_TRUE(SetReactivationBrandCode(L"GAGA", GCAPI_INVOKED_STANDARD_SHELL)); 91 EXPECT_TRUE(SetReactivationBrandCode(L"GAGA", GCAPI_INVOKED_STANDARD_SHELL));
109 EXPECT_EQ(L"GAGA", GetReactivationString(HKEY_CURRENT_USER)); 92 EXPECT_EQ(L"GAGA", GetReactivationString(HKEY_CURRENT_USER));
110 93
111 EXPECT_TRUE(HasBeenReactivated()); 94 EXPECT_TRUE(HasBeenReactivated());
112 95
113 } 96 }
114 97
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 EXPECT_TRUE(SetLastRunTime(HKEY_CURRENT_USER, 195 EXPECT_TRUE(SetLastRunTime(HKEY_CURRENT_USER,
213 hkcu_last_run.ToInternalValue())); 196 hkcu_last_run.ToInternalValue()));
214 197
215 EXPECT_TRUE(ReactivateChrome(L"GAGA", 198 EXPECT_TRUE(ReactivateChrome(L"GAGA",
216 GCAPI_INVOKED_STANDARD_SHELL, 199 GCAPI_INVOKED_STANDARD_SHELL,
217 &error)); 200 &error));
218 EXPECT_EQ(L"GAGA", GetReactivationString(HKEY_CURRENT_USER)); 201 EXPECT_EQ(L"GAGA", GetReactivationString(HKEY_CURRENT_USER));
219 202
220 EXPECT_TRUE(HasExperimentLabels(HKEY_CURRENT_USER)); 203 EXPECT_TRUE(HasExperimentLabels(HKEY_CURRENT_USER));
221 } 204 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698