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

Side by Side Diff: chrome/installer/util/product_state_unittest.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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <windows.h> 5 #include <windows.h>
6 6
7 #include "base/test/test_reg_util_win.h" 7 #include "base/test/test_reg_util_win.h"
8 #include "base/version.h" 8 #include "base/version.h"
9 #include "base/win/registry.h" 9 #include "base/win/registry.h"
10 #include "chrome/installer/util/browser_distribution.h" 10 #include "chrome/installer/util/browser_distribution.h"
11 #include "chrome/installer/util/google_update_constants.h" 11 #include "chrome/installer/util/google_update_constants.h"
12 #include "chrome/installer/util/installation_state.h" 12 #include "chrome/installer/util/installation_state.h"
13 #include "chrome/installer/util/util_constants.h" 13 #include "chrome/installer/util/util_constants.h"
14 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
15 15
16 namespace installer { 16 namespace installer {
17 17
18 class ProductStateTest : public testing::TestWithParam<bool> { 18 class ProductStateTest : public testing::TestWithParam<bool> {
19 protected: 19 protected:
20 ProductStateTest(); 20 ProductStateTest();
21 21
22 void SetUp() override;
23
22 void ApplyUninstallCommand(const wchar_t* exe_path, const wchar_t* args); 24 void ApplyUninstallCommand(const wchar_t* exe_path, const wchar_t* args);
23 void MinimallyInstallProduct(const wchar_t* version); 25 void MinimallyInstallProduct(const wchar_t* version);
24 26
25 const bool system_install_; 27 const bool system_install_;
26 const HKEY overridden_; 28 const HKEY overridden_;
27 registry_util::RegistryOverrideManager registry_override_manager_; 29 registry_util::RegistryOverrideManager registry_override_manager_;
28 base::win::RegKey clients_; 30 base::win::RegKey clients_;
29 base::win::RegKey client_state_; 31 base::win::RegKey client_state_;
30 }; 32 };
31 33
32 ProductStateTest::ProductStateTest() 34 ProductStateTest::ProductStateTest()
33 : system_install_(GetParam()), 35 : system_install_(GetParam()),
34 overridden_(system_install_ ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER) { 36 overridden_(system_install_ ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER) {}
35 registry_override_manager_.OverrideRegistry(overridden_); 37
38 void ProductStateTest::SetUp() {
39 ASSERT_NO_FATAL_FAILURE(
40 registry_override_manager_.OverrideRegistry(overridden_));
36 41
37 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); 42 BrowserDistribution* dist = BrowserDistribution::GetDistribution();
38 EXPECT_EQ(ERROR_SUCCESS, 43 ASSERT_EQ(ERROR_SUCCESS,
39 clients_.Create(overridden_, dist->GetVersionKey().c_str(), 44 clients_.Create(overridden_, dist->GetVersionKey().c_str(),
40 KEY_ALL_ACCESS | KEY_WOW64_32KEY)); 45 KEY_ALL_ACCESS | KEY_WOW64_32KEY));
41 EXPECT_EQ(ERROR_SUCCESS, 46 ASSERT_EQ(ERROR_SUCCESS,
42 client_state_.Create(overridden_, dist->GetStateKey().c_str(), 47 client_state_.Create(overridden_, dist->GetStateKey().c_str(),
43 KEY_ALL_ACCESS | KEY_WOW64_32KEY)); 48 KEY_ALL_ACCESS | KEY_WOW64_32KEY));
44 } 49 }
45 50
46 void ProductStateTest::MinimallyInstallProduct(const wchar_t* version) { 51 void ProductStateTest::MinimallyInstallProduct(const wchar_t* version) {
47 EXPECT_EQ(ERROR_SUCCESS, 52 EXPECT_EQ(ERROR_SUCCESS,
48 clients_.WriteValue(google_update::kRegVersionField, version)); 53 clients_.WriteValue(google_update::kRegVersionField, version));
49 } 54 }
50 55
51 void ProductStateTest::ApplyUninstallCommand(const wchar_t* exe_path, 56 void ProductStateTest::ApplyUninstallCommand(const wchar_t* exe_path,
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 L"--uninstall --chrome --multi-install"); 368 L"--uninstall --chrome --multi-install");
364 EXPECT_TRUE(state.Initialize(system_install_)); 369 EXPECT_TRUE(state.Initialize(system_install_));
365 EXPECT_TRUE(state.is_multi_install()); 370 EXPECT_TRUE(state.is_multi_install());
366 } 371 }
367 } 372 }
368 373
369 INSTANTIATE_TEST_CASE_P(UserLevel, ProductStateTest, ::testing::Values(false)); 374 INSTANTIATE_TEST_CASE_P(UserLevel, ProductStateTest, ::testing::Values(false));
370 INSTANTIATE_TEST_CASE_P(SystemLevel, ProductStateTest, ::testing::Values(true)); 375 INSTANTIATE_TEST_CASE_P(SystemLevel, ProductStateTest, ::testing::Values(true));
371 376
372 } // namespace installer 377 } // namespace installer
OLDNEW
« no previous file with comments | « chrome/installer/util/install_util_unittest.cc ('k') | chrome/installer/util/product_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698