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

Side by Side Diff: chrome/installer/util/product_state_unittest.cc

Issue 57423008: Base: Make RegistryOverrideManager support sharded/parallel tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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) 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/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "base/test/test_reg_util_win.h" 8 #include "base/test/test_reg_util_win.h"
9 #include "base/version.h" 9 #include "base/version.h"
10 #include "base/win/registry.h" 10 #include "base/win/registry.h"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 testing::Test::TearDownTestCase(); 63 testing::Test::TearDownTestCase();
64 } 64 }
65 65
66 void ProductStateTest::SetUp() { 66 void ProductStateTest::SetUp() {
67 testing::Test::SetUp(); 67 testing::Test::SetUp();
68 68
69 // Create/open the keys for the product we'll test. 69 // Create/open the keys for the product we'll test.
70 system_install_ = true; 70 system_install_ = true;
71 overridden_ = (system_install_ ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER); 71 overridden_ = (system_install_ ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER);
72 72
73 // Override for test purposes. We don't use ScopedRegistryKeyOverride 73 // Override for test purposes. We don't use ScopedRegistryKeyOverride
grt (UTC plus 2) 2013/11/07 02:39:33 Can RegistryOverrideManager replace this? As it is
tommycli 2013/11/07 18:02:07 Done.
74 // directly because it doesn't suit itself to our use here. 74 // directly because it doesn't suit itself to our use here.
75 RegKey temp_key; 75 RegKey temp_key;
76 EXPECT_EQ(ERROR_SUCCESS, 76 EXPECT_EQ(ERROR_SUCCESS,
77 temp_key.Create(HKEY_CURRENT_USER, temp_key_path_.c_str(), 77 temp_key.Create(HKEY_CURRENT_USER, temp_key_path_.c_str(),
78 KEY_ALL_ACCESS)); 78 KEY_ALL_ACCESS));
79 EXPECT_EQ(ERROR_SUCCESS, 79 EXPECT_EQ(ERROR_SUCCESS,
80 ::RegOverridePredefKey(overridden_, temp_key.Handle())); 80 ::RegOverridePredefKey(overridden_, temp_key.Handle()));
81 81
82 EXPECT_EQ(ERROR_SUCCESS, 82 EXPECT_EQ(ERROR_SUCCESS,
83 clients_.Create(overridden_, dist_->GetVersionKey().c_str(), 83 clients_.Create(overridden_, dist_->GetVersionKey().c_str(),
84 KEY_ALL_ACCESS)); 84 KEY_ALL_ACCESS));
85 EXPECT_EQ(ERROR_SUCCESS, 85 EXPECT_EQ(ERROR_SUCCESS,
86 client_state_.Create(overridden_, dist_->GetStateKey().c_str(), 86 client_state_.Create(overridden_, dist_->GetStateKey().c_str(),
87 KEY_ALL_ACCESS)); 87 KEY_ALL_ACCESS));
88 } 88 }
89 89
90 void ProductStateTest::TearDown() { 90 void ProductStateTest::TearDown() {
91 // Done with the keys. 91 // Done with the keys.
92 client_state_.Close(); 92 client_state_.Close();
93 clients_.Close(); 93 clients_.Close();
94 EXPECT_EQ(ERROR_SUCCESS, ::RegOverridePredefKey(overridden_, NULL)); 94 EXPECT_EQ(ERROR_SUCCESS, ::RegOverridePredefKey(overridden_, NULL));
95 overridden_ = NULL; 95 overridden_ = NULL;
96 system_install_ = false; 96 system_install_ = false;
97 97
98 // Shotgun approach to clearing out data we may have written.
99 RegistryOverrideManager::DeleteAllTempKeys();
100
101 testing::Test::TearDown(); 98 testing::Test::TearDown();
102 } 99 }
103 100
104 void ProductStateTest::MinimallyInstallProduct(const wchar_t* version) { 101 void ProductStateTest::MinimallyInstallProduct(const wchar_t* version) {
105 EXPECT_EQ(ERROR_SUCCESS, 102 EXPECT_EQ(ERROR_SUCCESS,
106 clients_.WriteValue(google_update::kRegVersionField, version)); 103 clients_.WriteValue(google_update::kRegVersionField, version));
107 } 104 }
108 105
109 void ProductStateTest::ApplyUninstallCommand(const wchar_t* exe_path, 106 void ProductStateTest::ApplyUninstallCommand(const wchar_t* exe_path,
110 const wchar_t* args) { 107 const wchar_t* args) {
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 416
420 // Uninstall command with --multi-install is multi install. 417 // Uninstall command with --multi-install is multi install.
421 { 418 {
422 ProductState state; 419 ProductState state;
423 ApplyUninstallCommand(L"setup.exe", 420 ApplyUninstallCommand(L"setup.exe",
424 L"--uninstall --chrome --multi-install"); 421 L"--uninstall --chrome --multi-install");
425 EXPECT_TRUE(state.Initialize(system_install_, dist_)); 422 EXPECT_TRUE(state.Initialize(system_install_, dist_));
426 EXPECT_TRUE(state.is_multi_install()); 423 EXPECT_TRUE(state.is_multi_install());
427 } 424 }
428 } 425 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698