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

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: review Created 7 years, 1 month 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_test_registry_overrider.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" 16 #include "testing/gtest/include/gtest/gtest.h"
20 17
21 using base::Time; 18 using base::Time;
22 using base::TimeDelta; 19 using base::TimeDelta;
23 using base::win::RegKey; 20 using base::win::RegKey;
24 21
25 class GCAPIReactivationTest : public ::testing::Test { 22 class GCAPIReactivationTest : public ::testing::Test {
26 protected: 23 protected:
27 void SetUp() { 24 GCAPIReactivationTest() {}
Alexei Svitkine (slow) 2013/11/05 23:05:23 Nit you can omit this, since this is entirely in t
gab 2013/11/06 16:39:10 I added this as not putting it results in this com
Alexei Svitkine (slow) 2013/11/06 22:45:06 Weird, okay.
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 25
37 bool SetChromeInstallMarker(HKEY hive) { 26 bool SetChromeInstallMarker(HKEY hive) {
38 // Create the client state keys in the right places. 27 // Create the client state keys in the right places.
39 std::wstring reg_path(google_update::kRegPathClients); 28 std::wstring reg_path(google_update::kRegPathClients);
40 reg_path += L"\\"; 29 reg_path += L"\\";
41 reg_path += google_update::kChromeUpgradeCode; 30 reg_path += google_update::kChromeUpgradeCode;
42 RegKey client_state(hive, 31 RegKey client_state(hive,
43 reg_path.c_str(), 32 reg_path.c_str(),
44 KEY_CREATE_SUB_KEY | KEY_SET_VALUE); 33 KEY_CREATE_SUB_KEY | KEY_SET_VALUE);
45 return (client_state.Valid() && 34 return (client_state.Valid() &&
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 std::wstring actual_brand; 82 std::wstring actual_brand;
94 if (client_state.ReadValue(google_update::kRegRLZReactivationBrandField, 83 if (client_state.ReadValue(google_update::kRegRLZReactivationBrandField,
95 &actual_brand) == ERROR_SUCCESS) { 84 &actual_brand) == ERROR_SUCCESS) {
96 return actual_brand; 85 return actual_brand;
97 } 86 }
98 } 87 }
99 88
100 return L"ERROR"; 89 return L"ERROR";
101 } 90 }
102 91
103 private: 92 const GCAPITestRegistryOverrider gcapi_test_registry_overrider_;
104 registry_util::RegistryOverrideManager override_manager_;
105 }; 93 };
106 94
107 TEST_F(GCAPIReactivationTest, CheckSetReactivationBrandCode) { 95 TEST_F(GCAPIReactivationTest, CheckSetReactivationBrandCode) {
108 EXPECT_TRUE(SetReactivationBrandCode(L"GAGA", GCAPI_INVOKED_STANDARD_SHELL)); 96 EXPECT_TRUE(SetReactivationBrandCode(L"GAGA", GCAPI_INVOKED_STANDARD_SHELL));
109 EXPECT_EQ(L"GAGA", GetReactivationString(HKEY_CURRENT_USER)); 97 EXPECT_EQ(L"GAGA", GetReactivationString(HKEY_CURRENT_USER));
110 98
111 EXPECT_TRUE(HasBeenReactivated()); 99 EXPECT_TRUE(HasBeenReactivated());
112
113 } 100 }
114 101
115 TEST_F(GCAPIReactivationTest, CanOfferReactivation_Basic) { 102 TEST_F(GCAPIReactivationTest, CanOfferReactivation_Basic) {
116 DWORD error; 103 DWORD error;
117 104
118 // We're not installed yet. Make sure CanOfferReactivation fails. 105 // We're not installed yet. Make sure CanOfferReactivation fails.
119 EXPECT_FALSE(CanOfferReactivation(L"GAGA", 106 EXPECT_FALSE(CanOfferReactivation(L"GAGA",
120 GCAPI_INVOKED_STANDARD_SHELL, 107 GCAPI_INVOKED_STANDARD_SHELL,
121 &error)); 108 &error));
122 EXPECT_EQ(REACTIVATE_ERROR_NOTINSTALLED, error); 109 EXPECT_EQ(REACTIVATE_ERROR_NOTINSTALLED, error);
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 EXPECT_TRUE(SetLastRunTime(HKEY_CURRENT_USER, 199 EXPECT_TRUE(SetLastRunTime(HKEY_CURRENT_USER,
213 hkcu_last_run.ToInternalValue())); 200 hkcu_last_run.ToInternalValue()));
214 201
215 EXPECT_TRUE(ReactivateChrome(L"GAGA", 202 EXPECT_TRUE(ReactivateChrome(L"GAGA",
216 GCAPI_INVOKED_STANDARD_SHELL, 203 GCAPI_INVOKED_STANDARD_SHELL,
217 &error)); 204 &error));
218 EXPECT_EQ(L"GAGA", GetReactivationString(HKEY_CURRENT_USER)); 205 EXPECT_EQ(L"GAGA", GetReactivationString(HKEY_CURRENT_USER));
219 206
220 EXPECT_TRUE(HasExperimentLabels(HKEY_CURRENT_USER)); 207 EXPECT_TRUE(HasExperimentLabels(HKEY_CURRENT_USER));
221 } 208 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698