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

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

Issue 2692843002: Fail tests fast if overriding the Windows registry fails. (Closed)
Patch Set: sync to position 450085 Created 3 years, 10 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "chrome/installer/gcapi/gcapi_omaha_experiment.h" 5 #include "chrome/installer/gcapi/gcapi_omaha_experiment.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "base/test/test_reg_util_win.h"
10 #include "chrome/installer/gcapi/gcapi.h" 11 #include "chrome/installer/gcapi/gcapi.h"
11 #include "chrome/installer/gcapi/gcapi_test_registry_overrider.h"
12 #include "chrome/installer/util/google_update_constants.h" 12 #include "chrome/installer/util/google_update_constants.h"
13 #include "chrome/installer/util/google_update_settings.h" 13 #include "chrome/installer/util/google_update_settings.h"
14 #include "components/variations/variations_experiment_util.h" 14 #include "components/variations/variations_experiment_util.h"
15 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
16 16
17 using base::ASCIIToUTF16; 17 using base::ASCIIToUTF16;
18 18
19 namespace { 19 namespace {
20 20
21 const wchar_t kBrand[] = L"ABCD"; 21 const wchar_t kBrand[] = L"ABCD";
22 const uint16_t kUserLevel = GCAPI_INVOKED_STANDARD_SHELL; 22 const uint16_t kUserLevel = GCAPI_INVOKED_STANDARD_SHELL;
23 23
24 const wchar_t kSomeExperiments[] = L"myexp=1|Aug 2;yourexp=2|Sep 5"; 24 const wchar_t kSomeExperiments[] = L"myexp=1|Aug 2;yourexp=2|Sep 5";
25 const wchar_t kSomeOtherExperiments[] = L"anotherexp=joe|Jun 7 2008"; 25 const wchar_t kSomeOtherExperiments[] = L"anotherexp=joe|Jun 7 2008";
26 const wchar_t kSomeMoreExperiments[] = L"moreexp=foo|Jul 31 1999"; 26 const wchar_t kSomeMoreExperiments[] = L"moreexp=foo|Jul 31 1999";
27 27
28 class GCAPIOmahaExperimentTest : public ::testing::Test { 28 class GCAPIOmahaExperimentTest : public ::testing::Test {
29 protected: 29 protected:
30 GCAPIOmahaExperimentTest() 30 GCAPIOmahaExperimentTest()
31 : brand_(kBrand), 31 : brand_(kBrand),
32 reactivation_label_(gcapi_internals::GetGCAPIExperimentLabel( 32 reactivation_label_(gcapi_internals::GetGCAPIExperimentLabel(
33 kBrand, gcapi_internals::kReactivationLabel)), 33 kBrand, gcapi_internals::kReactivationLabel)),
34 relaunch_label_(gcapi_internals::GetGCAPIExperimentLabel( 34 relaunch_label_(gcapi_internals::GetGCAPIExperimentLabel(
35 kBrand, gcapi_internals::kRelaunchLabel)) { 35 kBrand, gcapi_internals::kRelaunchLabel)) {
36 } 36 }
37 37
38 void SetUp() override {
39 ASSERT_NO_FATAL_FAILURE(
40 override_manager_.OverrideRegistry(HKEY_CURRENT_USER));
41 ASSERT_NO_FATAL_FAILURE(
42 override_manager_.OverrideRegistry(HKEY_LOCAL_MACHINE));
43 }
44
38 void VerifyExperimentLabels(const base::string16& expected_labels) { 45 void VerifyExperimentLabels(const base::string16& expected_labels) {
39 base::string16 actual_labels; 46 base::string16 actual_labels;
40 EXPECT_TRUE(GoogleUpdateSettings::ReadExperimentLabels(false, 47 EXPECT_TRUE(GoogleUpdateSettings::ReadExperimentLabels(false,
41 &actual_labels)); 48 &actual_labels));
42 EXPECT_EQ(expected_labels, actual_labels); 49 EXPECT_EQ(expected_labels, actual_labels);
43 } 50 }
44 51
52 registry_util::RegistryOverrideManager override_manager_;
45 base::string16 brand_; 53 base::string16 brand_;
46 base::string16 reactivation_label_; 54 base::string16 reactivation_label_;
47 base::string16 relaunch_label_; 55 base::string16 relaunch_label_;
48
49 const GCAPITestRegistryOverrider gcapi_test_registry_overrider_;
50 }; 56 };
51 57
52 TEST_F(GCAPIOmahaExperimentTest, SetReactivationLabelFromEmptyExperiments) { 58 TEST_F(GCAPIOmahaExperimentTest, SetReactivationLabelFromEmptyExperiments) {
53 ASSERT_TRUE(SetReactivationExperimentLabels(kBrand, kUserLevel)); 59 ASSERT_TRUE(SetReactivationExperimentLabels(kBrand, kUserLevel));
54 VerifyExperimentLabels(reactivation_label_); 60 VerifyExperimentLabels(reactivation_label_);
55 } 61 }
56 62
57 // Test the relaunch label once; all other tests go more in depth, but since 63 // Test the relaunch label once; all other tests go more in depth, but since
58 // both labels use the same logic underneath there is no need to test both in 64 // both labels use the same logic underneath there is no need to test both in
59 // depth. 65 // depth.
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 base::string16 expected_labels(kSomeExperiments); 183 base::string16 expected_labels(kSomeExperiments);
178 expected_labels += variations::kExperimentLabelSeparator; 184 expected_labels += variations::kExperimentLabelSeparator;
179 expected_labels.append(gcapi_internals::kReactivationLabel); 185 expected_labels.append(gcapi_internals::kReactivationLabel);
180 expected_labels.append(kSomeOtherExperiments); 186 expected_labels.append(kSomeOtherExperiments);
181 expected_labels += variations::kExperimentLabelSeparator; 187 expected_labels += variations::kExperimentLabelSeparator;
182 expected_labels.append(reactivation_label_); 188 expected_labels.append(reactivation_label_);
183 VerifyExperimentLabels(expected_labels); 189 VerifyExperimentLabels(expected_labels);
184 } 190 }
185 191
186 } // namespace 192 } // namespace
OLDNEW
« no previous file with comments | « chrome/installer/gcapi/gcapi_last_run_test.cc ('k') | chrome/installer/gcapi/gcapi_reactivation_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698