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

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

Issue 7669061: Tommi: I need an owner review for the chrome frame changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Fixing license issue from presubmit check Created 9 years, 3 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 | 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/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 #include "base/test/test_reg_util_win.h"
8 #include "base/version.h" 9 #include "base/version.h"
9 #include "base/win/registry.h" 10 #include "base/win/registry.h"
10 #include "chrome/installer/util/browser_distribution.h" 11 #include "chrome/installer/util/browser_distribution.h"
11 #include "chrome/installer/util/google_update_constants.h" 12 #include "chrome/installer/util/google_update_constants.h"
12 #include "chrome/installer/util/installation_state.h" 13 #include "chrome/installer/util/installation_state.h"
13 #include "chrome/installer/util/product_unittest.h" 14 #include "chrome/installer/util/product_unittest.h"
14 #include "chrome/installer/util/util_constants.h" 15 #include "chrome/installer/util/util_constants.h"
15 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
16 17
17 using base::win::RegKey; 18 using base::win::RegKey;
18 using installer::ProductState; 19 using installer::ProductState;
20 using registry_util::RegistryOverrideManager;
19 21
20 class ProductStateTest : public testing::Test { 22 class ProductStateTest : public testing::Test {
21 protected: 23 protected:
22 static void SetUpTestCase(); 24 static void SetUpTestCase();
23 static void TearDownTestCase(); 25 static void TearDownTestCase();
24 26
25 virtual void SetUp(); 27 virtual void SetUp();
26 virtual void TearDown(); 28 virtual void TearDown();
27 29
28 void ApplyUninstallCommand(const wchar_t* exe_path, const wchar_t* args); 30 void ApplyUninstallCommand(const wchar_t* exe_path, const wchar_t* args);
(...skipping 12 matching lines...) Expand all
41 43
42 // static 44 // static
43 void ProductStateTest::SetUpTestCase() { 45 void ProductStateTest::SetUpTestCase() {
44 testing::Test::SetUpTestCase(); 46 testing::Test::SetUpTestCase();
45 47
46 // We'll use Chrome as our test subject. 48 // We'll use Chrome as our test subject.
47 dist_ = BrowserDistribution::GetSpecificDistribution( 49 dist_ = BrowserDistribution::GetSpecificDistribution(
48 BrowserDistribution::CHROME_BROWSER); 50 BrowserDistribution::CHROME_BROWSER);
49 51
50 // And we'll play in HKCU here: 52 // And we'll play in HKCU here:
51 temp_key_path_.assign(TempRegKeyOverride::kTempTestKeyPath) 53 temp_key_path_.assign(RegistryOverrideManager::kTempTestKeyPath)
52 .append(1, L'\\') 54 .append(1, L'\\')
53 .append(L"ProductStateTest"); 55 .append(L"ProductStateTest");
54 } 56 }
55 57
56 // static 58 // static
57 void ProductStateTest::TearDownTestCase() { 59 void ProductStateTest::TearDownTestCase() {
58 temp_key_path_.clear(); 60 temp_key_path_.clear();
59 dist_ = NULL; 61 dist_ = NULL;
60 62
61 testing::Test::TearDownTestCase(); 63 testing::Test::TearDownTestCase();
62 } 64 }
63 65
64 void ProductStateTest::SetUp() { 66 void ProductStateTest::SetUp() {
65 testing::Test::SetUp(); 67 testing::Test::SetUp();
66 68
67 // Create/open the keys for the product we'll test. 69 // Create/open the keys for the product we'll test.
68 system_install_ = true; 70 system_install_ = true;
69 overridden_ = (system_install_ ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER); 71 overridden_ = (system_install_ ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER);
70 72
71 // Override for test purposes. We don't use TempRegKeyOverride 73 // Override for test purposes. We don't use ScopedRegistryKeyOverride
72 // directly because it doesn't suit itself to our use here. 74 // directly because it doesn't suit itself to our use here.
73 RegKey temp_key; 75 RegKey temp_key;
74 EXPECT_EQ(ERROR_SUCCESS, 76 EXPECT_EQ(ERROR_SUCCESS,
75 temp_key.Create(HKEY_CURRENT_USER, temp_key_path_.c_str(), 77 temp_key.Create(HKEY_CURRENT_USER, temp_key_path_.c_str(),
76 KEY_ALL_ACCESS)); 78 KEY_ALL_ACCESS));
77 EXPECT_EQ(ERROR_SUCCESS, 79 EXPECT_EQ(ERROR_SUCCESS,
78 ::RegOverridePredefKey(overridden_, temp_key.Handle())); 80 ::RegOverridePredefKey(overridden_, temp_key.Handle()));
79 81
80 EXPECT_EQ(ERROR_SUCCESS, 82 EXPECT_EQ(ERROR_SUCCESS,
81 clients_.Create(overridden_, dist_->GetVersionKey().c_str(), 83 clients_.Create(overridden_, dist_->GetVersionKey().c_str(),
82 KEY_ALL_ACCESS)); 84 KEY_ALL_ACCESS));
83 EXPECT_EQ(ERROR_SUCCESS, 85 EXPECT_EQ(ERROR_SUCCESS,
84 client_state_.Create(overridden_, dist_->GetStateKey().c_str(), 86 client_state_.Create(overridden_, dist_->GetStateKey().c_str(),
85 KEY_ALL_ACCESS)); 87 KEY_ALL_ACCESS));
86 } 88 }
87 89
88 void ProductStateTest::TearDown() { 90 void ProductStateTest::TearDown() {
89 // Done with the keys. 91 // Done with the keys.
90 client_state_.Close(); 92 client_state_.Close();
91 clients_.Close(); 93 clients_.Close();
92 EXPECT_EQ(ERROR_SUCCESS, ::RegOverridePredefKey(overridden_, NULL)); 94 EXPECT_EQ(ERROR_SUCCESS, ::RegOverridePredefKey(overridden_, NULL));
93 overridden_ = NULL; 95 overridden_ = NULL;
94 system_install_ = false; 96 system_install_ = false;
95 97
96 // Shotgun approach to clearing out data we may have written. 98 // Shotgun approach to clearing out data we may have written.
97 TempRegKeyOverride::DeleteAllTempKeys(); 99 RegistryOverrideManager::DeleteAllTempKeys();
98 100
99 testing::Test::TearDown(); 101 testing::Test::TearDown();
100 } 102 }
101 103
102 void ProductStateTest::MinimallyInstallProduct(const wchar_t* version) { 104 void ProductStateTest::MinimallyInstallProduct(const wchar_t* version) {
103 EXPECT_EQ(ERROR_SUCCESS, 105 EXPECT_EQ(ERROR_SUCCESS,
104 clients_.WriteValue(google_update::kRegVersionField, version)); 106 clients_.WriteValue(google_update::kRegVersionField, version));
105 } 107 }
106 108
107 void ProductStateTest::ApplyUninstallCommand(const wchar_t* exe_path, 109 void ProductStateTest::ApplyUninstallCommand(const wchar_t* exe_path,
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 419
418 // Uninstall command with --multi-install is multi install. 420 // Uninstall command with --multi-install is multi install.
419 { 421 {
420 ProductState state; 422 ProductState state;
421 ApplyUninstallCommand(L"setup.exe", 423 ApplyUninstallCommand(L"setup.exe",
422 L"--uninstall --chrome --multi-install"); 424 L"--uninstall --chrome --multi-install");
423 EXPECT_TRUE(state.Initialize(system_install_, dist_)); 425 EXPECT_TRUE(state.Initialize(system_install_, dist_));
424 EXPECT_TRUE(state.is_multi_install()); 426 EXPECT_TRUE(state.is_multi_install());
425 } 427 }
426 } 428 }
OLDNEW
« no previous file with comments | « chrome/installer/util/installer_state_unittest.cc ('k') | chrome/installer/util/product_unittest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698