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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/guid.h" |
8 #include "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
9 #include "base/stringprintf.h" | 10 #include "base/stringprintf.h" |
10 #include "base/test/test_reg_util_win.h" | 11 #include "base/test/test_reg_util_win.h" |
11 #include "base/time.h" | 12 #include "base/time.h" |
12 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
13 #include "base/win/registry.h" | 14 #include "base/win/registry.h" |
14 #include "chrome/common/guid.h" | |
15 #include "chrome/installer/gcapi/gcapi.h" | 15 #include "chrome/installer/gcapi/gcapi.h" |
16 #include "chrome/installer/gcapi/gcapi_omaha_experiment.h" | 16 #include "chrome/installer/gcapi/gcapi_omaha_experiment.h" |
17 #include "chrome/installer/gcapi/gcapi_reactivation.h" | 17 #include "chrome/installer/gcapi/gcapi_reactivation.h" |
18 #include "chrome/installer/util/google_update_constants.h" | 18 #include "chrome/installer/util/google_update_constants.h" |
19 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
20 | 20 |
21 using base::Time; | 21 using base::Time; |
22 using base::TimeDelta; | 22 using base::TimeDelta; |
23 using base::win::RegKey; | 23 using base::win::RegKey; |
24 | 24 |
25 namespace { | 25 namespace { |
26 | 26 |
27 const wchar_t kExperimentLabels[] = L"experiment_labels"; | 27 const wchar_t kExperimentLabels[] = L"experiment_labels"; |
28 | 28 |
29 const wchar_t* kExperimentAppGuids[] = { | 29 const wchar_t* kExperimentAppGuids[] = { |
30 L"{4DC8B4CA-1BDA-483e-B5FA-D3C12E15B62D}", | 30 L"{4DC8B4CA-1BDA-483e-B5FA-D3C12E15B62D}", |
31 L"{8A69D345-D564-463C-AFF1-A69D9E530F96}", | 31 L"{8A69D345-D564-463C-AFF1-A69D9E530F96}", |
32 }; | 32 }; |
33 | 33 |
34 } | 34 } |
35 | 35 |
36 class GCAPIReactivationTest : public ::testing::Test { | 36 class GCAPIReactivationTest : public ::testing::Test { |
37 protected: | 37 protected: |
38 void SetUp() { | 38 void SetUp() { |
39 // Override keys - this is undone during destruction. | 39 // Override keys - this is undone during destruction. |
40 std::wstring hkcu_override = base::StringPrintf( | 40 std::wstring hkcu_override = base::StringPrintf( |
41 L"hkcu_override\\%ls", ASCIIToWide(guid::GenerateGUID())); | 41 L"hkcu_override\\%ls", ASCIIToWide(base::GenerateGUID())); |
42 override_manager_.OverrideRegistry(HKEY_CURRENT_USER, hkcu_override); | 42 override_manager_.OverrideRegistry(HKEY_CURRENT_USER, hkcu_override); |
43 std::wstring hklm_override = base::StringPrintf( | 43 std::wstring hklm_override = base::StringPrintf( |
44 L"hklm_override\\%ls", ASCIIToWide(guid::GenerateGUID())); | 44 L"hklm_override\\%ls", ASCIIToWide(base::GenerateGUID())); |
45 override_manager_.OverrideRegistry(HKEY_LOCAL_MACHINE, hklm_override); | 45 override_manager_.OverrideRegistry(HKEY_LOCAL_MACHINE, hklm_override); |
46 } | 46 } |
47 | 47 |
48 bool SetChromeInstallMarker(HKEY hive) { | 48 bool SetChromeInstallMarker(HKEY hive) { |
49 // Create the client state keys in the right places. | 49 // Create the client state keys in the right places. |
50 std::wstring reg_path(google_update::kRegPathClients); | 50 std::wstring reg_path(google_update::kRegPathClients); |
51 reg_path += L"\\"; | 51 reg_path += L"\\"; |
52 reg_path += google_update::kChromeUpgradeCode; | 52 reg_path += google_update::kChromeUpgradeCode; |
53 RegKey client_state(hive, | 53 RegKey client_state(hive, |
54 reg_path.c_str(), | 54 reg_path.c_str(), |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 EXPECT_TRUE(SetLastRunTime(HKEY_CURRENT_USER, | 229 EXPECT_TRUE(SetLastRunTime(HKEY_CURRENT_USER, |
230 hkcu_last_run.ToInternalValue())); | 230 hkcu_last_run.ToInternalValue())); |
231 | 231 |
232 EXPECT_TRUE(ReactivateChrome(L"GAGA", | 232 EXPECT_TRUE(ReactivateChrome(L"GAGA", |
233 GCAPI_INVOKED_STANDARD_SHELL, | 233 GCAPI_INVOKED_STANDARD_SHELL, |
234 &error)); | 234 &error)); |
235 EXPECT_EQ(L"GAGA", GetReactivationString(HKEY_CURRENT_USER)); | 235 EXPECT_EQ(L"GAGA", GetReactivationString(HKEY_CURRENT_USER)); |
236 | 236 |
237 EXPECT_TRUE(HasExperimentLabels(HKEY_CURRENT_USER)); | 237 EXPECT_TRUE(HasExperimentLabels(HKEY_CURRENT_USER)); |
238 } | 238 } |
OLD | NEW |