OLD | NEW |
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 "chrome/installer/setup/install_worker.h" | 5 #include "chrome/installer/setup/install_worker.h" |
6 | 6 |
7 #include "base/win/registry.h" | 7 #include "base/win/registry.h" |
8 #include "base/version.h" | 8 #include "base/version.h" |
9 #include "chrome/common/chrome_constants.h" | 9 #include "chrome/common/chrome_constants.h" |
| 10 #include "chrome/installer/util/delete_reg_key_work_item.h" |
| 11 #include "chrome/installer/util/create_reg_key_work_item.h" |
| 12 #include "chrome/installer/util/helper.h" |
10 #include "chrome/installer/util/installation_state.h" | 13 #include "chrome/installer/util/installation_state.h" |
11 #include "chrome/installer/util/installer_state.h" | 14 #include "chrome/installer/util/installer_state.h" |
| 15 #include "chrome/installer/util/set_reg_value_work_item.h" |
12 #include "chrome/installer/util/util_constants.h" | 16 #include "chrome/installer/util/util_constants.h" |
13 #include "chrome/installer/util/work_item_list.h" | 17 #include "chrome/installer/util/work_item_list.h" |
14 | 18 |
15 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
16 #include "testing/gmock/include/gmock/gmock.h" | 20 #include "testing/gmock/include/gmock/gmock.h" |
17 | 21 |
18 using installer::InstallationState; | 22 using installer::InstallationState; |
19 using installer::InstallerState; | 23 using installer::InstallerState; |
| 24 using installer::Product; |
20 using installer::ProductState; | 25 using installer::ProductState; |
21 | 26 |
22 using ::testing::_; | 27 using ::testing::_; |
23 using ::testing::AtLeast; | 28 using ::testing::AtLeast; |
| 29 using ::testing::AtMost; |
| 30 using ::testing::Eq; |
| 31 using ::testing::Return; |
| 32 using ::testing::StrCaseEq; |
24 using ::testing::StrEq; | 33 using ::testing::StrEq; |
| 34 using ::testing::StrictMock; |
25 | 35 |
26 // Mock classes to help with testing | 36 // Mock classes to help with testing |
27 //------------------------------------------------------------------------------ | 37 //------------------------------------------------------------------------------ |
28 | 38 |
29 class MockWorkItemList : public WorkItemList { | 39 class MockWorkItemList : public WorkItemList { |
30 public: | 40 public: |
31 MockWorkItemList() {} | 41 MockWorkItemList() {} |
32 | 42 |
33 MOCK_METHOD5(AddCopyTreeWorkItem, WorkItem*(const std::wstring&, | 43 MOCK_METHOD5(AddCopyTreeWorkItem, WorkItem*(const std::wstring&, |
34 const std::wstring&, | 44 const std::wstring&, |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 MOCK_METHOD3(AddSelfRegWorkItem, WorkItem* (const std::wstring&, | 84 MOCK_METHOD3(AddSelfRegWorkItem, WorkItem* (const std::wstring&, |
75 bool, | 85 bool, |
76 bool)); | 86 bool)); |
77 }; | 87 }; |
78 | 88 |
79 class MockProductState : public ProductState { | 89 class MockProductState : public ProductState { |
80 public: | 90 public: |
81 // Takes ownership of |version|. | 91 // Takes ownership of |version|. |
82 void set_version(Version* version) { version_.reset(version); } | 92 void set_version(Version* version) { version_.reset(version); } |
83 void set_multi_install(bool multi) { multi_install_ = multi; } | 93 void set_multi_install(bool multi) { multi_install_ = multi; } |
| 94 void SetUninstallProgram(const FilePath& setup_exe) { |
| 95 uninstall_command_ = CommandLine(setup_exe); |
| 96 } |
84 void AddUninstallSwitch(const std::string& option) { | 97 void AddUninstallSwitch(const std::string& option) { |
85 uninstall_command_.AppendSwitch(option); | 98 uninstall_command_.AppendSwitch(option); |
86 } | 99 } |
87 }; | 100 }; |
88 | 101 |
89 // Okay, so this isn't really a mock as such, but it does add setter methods | 102 // Okay, so this isn't really a mock as such, but it does add setter methods |
90 // to make it easier to build custom InstallationStates. | 103 // to make it easier to build custom InstallationStates. |
91 class MockInstallationState : public InstallationState { | 104 class MockInstallationState : public InstallationState { |
92 public: | 105 public: |
93 // Included for testing. | 106 // Included for testing. |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 installation_path_ = FilePath(L"C:\\Program Files\\Google\\Chrome\\"); | 148 installation_path_ = FilePath(L"C:\\Program Files\\Google\\Chrome\\"); |
136 src_path_ = | 149 src_path_ = |
137 FilePath(L"C:\\UnlikelyPath\\Temp\\chrome_123\\source\\Chrome-bin"); | 150 FilePath(L"C:\\UnlikelyPath\\Temp\\chrome_123\\source\\Chrome-bin"); |
138 setup_path_ = FilePath(L"C:\\UnlikelyPath\\Temp\\CR_123.tmp\\setup.exe"); | 151 setup_path_ = FilePath(L"C:\\UnlikelyPath\\Temp\\CR_123.tmp\\setup.exe"); |
139 temp_dir_ = FilePath(L"C:\\UnlikelyPath\\Temp\\chrome_123"); | 152 temp_dir_ = FilePath(L"C:\\UnlikelyPath\\Temp\\chrome_123"); |
140 } | 153 } |
141 | 154 |
142 virtual void TearDown() { | 155 virtual void TearDown() { |
143 } | 156 } |
144 | 157 |
| 158 void AddChromeToInstallationState( |
| 159 bool system_level, |
| 160 bool multi_install, |
| 161 bool with_chrome_frame_ready_mode, |
| 162 MockInstallationState* installation_state) { |
| 163 MockProductState product_state; |
| 164 product_state.set_version(current_version_->Clone()); |
| 165 product_state.set_multi_install(multi_install); |
| 166 BrowserDistribution* dist = |
| 167 BrowserDistribution::GetSpecificDistribution( |
| 168 BrowserDistribution::CHROME_BROWSER); |
| 169 FilePath install_path = |
| 170 installer::GetChromeInstallPath(system_level, dist); |
| 171 product_state.SetUninstallProgram( |
| 172 install_path.Append(installer::kSetupExe)); |
| 173 product_state.AddUninstallSwitch(installer::switches::kUninstall); |
| 174 if (system_level) |
| 175 product_state.AddUninstallSwitch(installer::switches::kSystemLevel); |
| 176 if (multi_install) { |
| 177 product_state.AddUninstallSwitch(installer::switches::kMultiInstall); |
| 178 product_state.AddUninstallSwitch(installer::switches::kChrome); |
| 179 if (with_chrome_frame_ready_mode) { |
| 180 product_state.AddUninstallSwitch(installer::switches::kChromeFrame); |
| 181 product_state.AddUninstallSwitch( |
| 182 installer::switches::kChromeFrameReadyMode); |
| 183 } |
| 184 } |
| 185 |
| 186 installation_state->SetProductState(system_level, |
| 187 BrowserDistribution::CHROME_BROWSER, |
| 188 product_state); |
| 189 } |
| 190 |
| 191 void AddChromeFrameToInstallationState( |
| 192 bool system_level, |
| 193 bool multi_install, |
| 194 bool ready_mode, |
| 195 MockInstallationState* installation_state) { |
| 196 MockProductState product_state; |
| 197 product_state.set_version(current_version_->Clone()); |
| 198 product_state.set_multi_install(multi_install); |
| 199 BrowserDistribution* dist = |
| 200 BrowserDistribution::GetSpecificDistribution( |
| 201 multi_install ? BrowserDistribution::CHROME_BINARIES : |
| 202 BrowserDistribution::CHROME_FRAME); |
| 203 FilePath install_path = |
| 204 installer::GetChromeInstallPath(system_level, dist); |
| 205 product_state.SetUninstallProgram( |
| 206 install_path.Append(installer::kSetupExe)); |
| 207 product_state.AddUninstallSwitch(installer::switches::kUninstall); |
| 208 product_state.AddUninstallSwitch(installer::switches::kChromeFrame); |
| 209 if (system_level) |
| 210 product_state.AddUninstallSwitch(installer::switches::kSystemLevel); |
| 211 if (multi_install) { |
| 212 product_state.AddUninstallSwitch(installer::switches::kMultiInstall); |
| 213 if (ready_mode) { |
| 214 product_state.AddUninstallSwitch( |
| 215 installer::switches::kChromeFrameReadyMode); |
| 216 } |
| 217 } |
| 218 |
| 219 installation_state->SetProductState(system_level, |
| 220 BrowserDistribution::CHROME_FRAME, |
| 221 product_state); |
| 222 } |
| 223 |
145 MockInstallationState* BuildChromeInstallationState(bool system_level, | 224 MockInstallationState* BuildChromeInstallationState(bool system_level, |
146 bool multi_install) { | 225 bool multi_install) { |
147 scoped_ptr<MockInstallationState> installation_state( | 226 scoped_ptr<MockInstallationState> installation_state( |
148 new MockInstallationState()); | 227 new MockInstallationState()); |
149 | 228 AddChromeToInstallationState(system_level, multi_install, false, |
150 MockProductState product_state; | 229 installation_state.get()); |
151 product_state.set_version(current_version_->Clone()); | |
152 product_state.set_multi_install(multi_install); | |
153 if (multi_install) { | |
154 product_state.AddUninstallSwitch(installer::switches::kMultiInstall); | |
155 } | |
156 | |
157 installation_state->SetProductState(system_level, | |
158 BrowserDistribution::CHROME_BROWSER, | |
159 product_state); | |
160 | |
161 return installation_state.release(); | 230 return installation_state.release(); |
162 } | 231 } |
163 | 232 |
164 MockInstallerState* BuildChromeInstallerState(bool system_install, | 233 static MockInstallerState* BuildBasicInstallerState( |
| 234 bool system_install, |
165 bool multi_install, | 235 bool multi_install, |
166 const InstallationState& machine_state, | 236 const InstallationState& machine_state, |
167 InstallerState::Operation operation) { | 237 InstallerState::Operation operation) { |
168 scoped_ptr<MockInstallerState> installer_state(new MockInstallerState()); | 238 scoped_ptr<MockInstallerState> installer_state(new MockInstallerState()); |
169 | 239 |
170 InstallerState::Level level = system_install ? | 240 InstallerState::Level level = system_install ? |
171 InstallerState::SYSTEM_LEVEL : InstallerState::USER_LEVEL; | 241 InstallerState::SYSTEM_LEVEL : InstallerState::USER_LEVEL; |
172 installer_state->set_level(level); | 242 installer_state->set_level(level); |
173 installer_state->set_operation(operation); | 243 installer_state->set_operation(operation); |
174 // Hope this next one isn't checked for now. | 244 // Hope this next one isn't checked for now. |
175 installer_state->set_state_key(L"PROBABLY_INVALID_REG_PATH"); | 245 installer_state->set_state_key(L"PROBABLY_INVALID_REG_PATH"); |
176 if (multi_install) { | 246 installer_state->set_package_type(multi_install ? |
177 installer_state->set_package_type(InstallerState::MULTI_PACKAGE); | 247 InstallerState::MULTI_PACKAGE : |
| 248 InstallerState::SINGLE_PACKAGE); |
| 249 return installer_state.release(); |
| 250 } |
| 251 |
| 252 static void AddChromeToInstallerState( |
| 253 const InstallationState& machine_state, |
| 254 MockInstallerState* installer_state) { |
| 255 // Fresh install or upgrade? |
| 256 const ProductState* chrome = |
| 257 machine_state.GetProductState(installer_state->system_install(), |
| 258 BrowserDistribution::CHROME_BROWSER); |
| 259 if (chrome != NULL) { |
| 260 installer_state->AddProductFromState(BrowserDistribution::CHROME_BROWSER, |
| 261 *chrome); |
| 262 } else { |
| 263 BrowserDistribution* dist = |
| 264 BrowserDistribution::GetSpecificDistribution( |
| 265 BrowserDistribution::CHROME_BROWSER); |
| 266 scoped_ptr<Product> product(new Product(dist)); |
| 267 if (installer_state->is_multi_install()) |
| 268 product->SetOption(installer::kOptionMultiInstall, true); |
| 269 installer_state->AddProduct(&product); |
178 } | 270 } |
179 const ProductState* chrome = | 271 } |
180 machine_state.GetProductState(system_install, | 272 |
181 BrowserDistribution::CHROME_BROWSER); | 273 static void AddChromeFrameToInstallerState( |
182 installer_state->AddProductFromState(BrowserDistribution::CHROME_BROWSER, | 274 const InstallationState& machine_state, |
183 *chrome); | 275 bool ready_mode, |
| 276 MockInstallerState* installer_state) { |
| 277 // Fresh install or upgrade? |
| 278 const ProductState* cf = |
| 279 machine_state.GetProductState(installer_state->system_install(), |
| 280 BrowserDistribution::CHROME_FRAME); |
| 281 if (cf != NULL) { |
| 282 installer_state->AddProductFromState(BrowserDistribution::CHROME_FRAME, |
| 283 *cf); |
| 284 } else { |
| 285 BrowserDistribution* dist = |
| 286 BrowserDistribution::GetSpecificDistribution( |
| 287 BrowserDistribution::CHROME_FRAME); |
| 288 scoped_ptr<Product> product(new Product(dist)); |
| 289 if (installer_state->is_multi_install()) { |
| 290 product->SetOption(installer::kOptionMultiInstall, true); |
| 291 if (ready_mode) |
| 292 product->SetOption(installer::kOptionReadyMode, true); |
| 293 } |
| 294 installer_state->AddProduct(&product); |
| 295 } |
| 296 } |
| 297 |
| 298 static MockInstallerState* BuildChromeInstallerState( |
| 299 bool system_install, |
| 300 bool multi_install, |
| 301 const InstallationState& machine_state, |
| 302 InstallerState::Operation operation) { |
| 303 scoped_ptr<MockInstallerState> installer_state( |
| 304 BuildBasicInstallerState(system_install, multi_install, machine_state, |
| 305 operation)); |
| 306 AddChromeToInstallerState(machine_state, installer_state.get()); |
| 307 return installer_state.release(); |
| 308 } |
| 309 |
| 310 static MockInstallerState* BuildChromeFrameInstallerState( |
| 311 bool system_install, |
| 312 bool multi_install, |
| 313 bool ready_mode, |
| 314 const InstallationState& machine_state, |
| 315 InstallerState::Operation operation) { |
| 316 scoped_ptr<MockInstallerState> installer_state( |
| 317 BuildBasicInstallerState(system_install, multi_install, machine_state, |
| 318 operation)); |
| 319 AddChromeFrameToInstallerState(machine_state, ready_mode, |
| 320 installer_state.get()); |
184 return installer_state.release(); | 321 return installer_state.release(); |
185 } | 322 } |
186 | 323 |
187 protected: | 324 protected: |
188 scoped_ptr<Version> current_version_; | 325 scoped_ptr<Version> current_version_; |
189 scoped_ptr<Version> new_version_; | 326 scoped_ptr<Version> new_version_; |
190 FilePath archive_path_; | 327 FilePath archive_path_; |
191 FilePath installation_path_; | 328 FilePath installation_path_; |
192 FilePath setup_path_; | 329 FilePath setup_path_; |
193 FilePath src_path_; | 330 FilePath src_path_; |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 EXPECT_CALL(work_item_list, AddSetRegDwordValueWorkItem(_, _, _, _, _)) | 498 EXPECT_CALL(work_item_list, AddSetRegDwordValueWorkItem(_, _, _, _, _)) |
362 .Times(0); | 499 .Times(0); |
363 EXPECT_CALL(work_item_list, AddSetRegStringValueWorkItem(_, _, _, _, _)) | 500 EXPECT_CALL(work_item_list, AddSetRegStringValueWorkItem(_, _, _, _, _)) |
364 .Times(0); | 501 .Times(0); |
365 | 502 |
366 AddElevationPolicyWorkItems(*installation_state.get(), | 503 AddElevationPolicyWorkItems(*installation_state.get(), |
367 *installer_state.get(), | 504 *installer_state.get(), |
368 *new_version_.get(), | 505 *new_version_.get(), |
369 &work_item_list); | 506 &work_item_list); |
370 } | 507 } |
| 508 |
| 509 // Test scenarios under which the quick-enable-cf command should not exist after |
| 510 // the run. We're permissive in that we allow the DeleteRegKeyWorkItem even if |
| 511 // it isn't strictly needed. |
| 512 class QuickEnableAbsentTest : public InstallWorkerTest { |
| 513 public: |
| 514 virtual void SetUp() { |
| 515 InstallWorkerTest::SetUp(); |
| 516 root_key_ = system_level_ ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; |
| 517 delete_reg_key_item_.reset( |
| 518 WorkItem::CreateDeleteRegKeyWorkItem(root_key_, kRegKeyPath)); |
| 519 machine_state_.reset(new MockInstallationState()); |
| 520 EXPECT_CALL(work_item_list_, |
| 521 AddDeleteRegKeyWorkItem(Eq(root_key_), StrCaseEq(kRegKeyPath))) |
| 522 .Times(AtMost(1)) |
| 523 .WillRepeatedly(Return(delete_reg_key_item_.get())); |
| 524 } |
| 525 virtual void TearDown() { |
| 526 machine_state_.reset(); |
| 527 delete_reg_key_item_.reset(); |
| 528 root_key_ = NULL; |
| 529 InstallWorkerTest::TearDown(); |
| 530 } |
| 531 protected: |
| 532 static const bool system_level_ = false; |
| 533 static const wchar_t kRegKeyPath[]; |
| 534 HKEY root_key_; |
| 535 scoped_ptr<DeleteRegKeyWorkItem> delete_reg_key_item_; |
| 536 scoped_ptr<MockInstallationState> machine_state_; |
| 537 StrictMock<MockWorkItemList> work_item_list_; |
| 538 }; |
| 539 |
| 540 const wchar_t QuickEnableAbsentTest::kRegKeyPath[] = |
| 541 L"Software\\Google\\Update\\Clients\\" |
| 542 L"{4DC8B4CA-1BDA-483e-B5FA-D3C12E15B62D}\\Commands\\quick-enable-cf"; |
| 543 |
| 544 TEST_F(QuickEnableAbsentTest, CleanInstallSingleChrome) { |
| 545 // Install single Chrome on a clean system. |
| 546 scoped_ptr<MockInstallerState> installer_state( |
| 547 BuildChromeInstallerState(system_level_, false, *machine_state_, |
| 548 InstallerState::SINGLE_INSTALL_OR_UPDATE)); |
| 549 AddQuickEnableWorkItems(*installer_state, *machine_state_, &setup_path_, |
| 550 new_version_.get(), &work_item_list_); |
| 551 } |
| 552 |
| 553 TEST_F(QuickEnableAbsentTest, CleanInstallSingleChromeFrame) { |
| 554 // Install single Chrome Frame on a clean system. |
| 555 scoped_ptr<MockInstallerState> installer_state( |
| 556 BuildChromeFrameInstallerState(system_level_, false, false, |
| 557 *machine_state_, |
| 558 InstallerState::SINGLE_INSTALL_OR_UPDATE)); |
| 559 AddQuickEnableWorkItems(*installer_state, *machine_state_, &setup_path_, |
| 560 new_version_.get(), &work_item_list_); |
| 561 } |
| 562 |
| 563 TEST_F(QuickEnableAbsentTest, CleanInstallMultiChromeFrame) { |
| 564 // Install multi Chrome Frame on a clean system. |
| 565 scoped_ptr<MockInstallerState> installer_state( |
| 566 BuildChromeFrameInstallerState(system_level_, true, false, |
| 567 *machine_state_, |
| 568 InstallerState::MULTI_INSTALL)); |
| 569 AddQuickEnableWorkItems(*installer_state, *machine_state_, &setup_path_, |
| 570 new_version_.get(), &work_item_list_); |
| 571 } |
| 572 |
| 573 TEST_F(QuickEnableAbsentTest, CleanInstallMultiChromeChromeFrame) { |
| 574 // Install multi Chrome and Chrome Frame on a clean system. |
| 575 scoped_ptr<MockInstallerState> installer_state( |
| 576 BuildBasicInstallerState(system_level_, true, *machine_state_, |
| 577 InstallerState::MULTI_INSTALL)); |
| 578 AddChromeToInstallerState(*machine_state_, installer_state.get()); |
| 579 AddChromeFrameToInstallerState(*machine_state_, false, |
| 580 installer_state.get()); |
| 581 AddQuickEnableWorkItems(*installer_state, *machine_state_, &setup_path_, |
| 582 new_version_.get(), &work_item_list_); |
| 583 } |
| 584 |
| 585 TEST_F(QuickEnableAbsentTest, UninstallMultiChromeLeaveMultiChromeFrame) { |
| 586 // Uninstall multi Chrome on a machine with multi Chrome Frame. |
| 587 AddChromeToInstallationState(system_level_, true, false, |
| 588 machine_state_.get()); |
| 589 AddChromeFrameToInstallationState(system_level_, true, false, |
| 590 machine_state_.get()); |
| 591 scoped_ptr<MockInstallerState> installer_state( |
| 592 BuildBasicInstallerState(system_level_, true, *machine_state_, |
| 593 InstallerState::UNINSTALL)); |
| 594 AddChromeToInstallerState(*machine_state_, installer_state.get()); |
| 595 AddQuickEnableWorkItems(*installer_state, *machine_state_, &setup_path_, |
| 596 new_version_.get(), &work_item_list_); |
| 597 } |
| 598 |
| 599 TEST_F(QuickEnableAbsentTest, UninstallMultiChromeLeaveSingleChromeFrame) { |
| 600 // Uninstall multi Chrome on a machine with single Chrome Frame. |
| 601 AddChromeToInstallationState(system_level_, true, false, |
| 602 machine_state_.get()); |
| 603 AddChromeFrameToInstallationState(system_level_, false, false, |
| 604 machine_state_.get()); |
| 605 scoped_ptr<MockInstallerState> installer_state( |
| 606 BuildBasicInstallerState(system_level_, true, *machine_state_, |
| 607 InstallerState::UNINSTALL)); |
| 608 AddChromeToInstallerState(*machine_state_, installer_state.get()); |
| 609 AddQuickEnableWorkItems(*installer_state, *machine_state_, &setup_path_, |
| 610 new_version_.get(), &work_item_list_); |
| 611 } |
| 612 |
| 613 TEST_F(QuickEnableAbsentTest, AcceptReadyMode) { |
| 614 // Accept ready-mode. |
| 615 AddChromeToInstallationState(system_level_, true, true, |
| 616 machine_state_.get()); |
| 617 AddChromeFrameToInstallationState(system_level_, true, true, |
| 618 machine_state_.get()); |
| 619 scoped_ptr<MockInstallerState> installer_state( |
| 620 BuildBasicInstallerState(system_level_, true, *machine_state_, |
| 621 InstallerState::UNINSTALL)); |
| 622 AddChromeToInstallerState(*machine_state_, installer_state.get()); |
| 623 AddChromeFrameToInstallerState(*machine_state_, false, installer_state.get()); |
| 624 AddQuickEnableWorkItems(*installer_state, *machine_state_, &setup_path_, |
| 625 new_version_.get(), &work_item_list_); |
| 626 } |
| 627 |
| 628 // Test scenarios under which the quick-enable-cf command should exist after the |
| 629 // run. |
| 630 class QuickEnablePresentTest : public InstallWorkerTest { |
| 631 public: |
| 632 virtual void SetUp() { |
| 633 InstallWorkerTest::SetUp(); |
| 634 root_key_ = system_level_ ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; |
| 635 create_reg_key_work_item_.reset( |
| 636 WorkItem::CreateCreateRegKeyWorkItem(root_key_, kRegKeyPath)); |
| 637 set_reg_value_work_item_.reset( |
| 638 WorkItem::CreateSetRegValueWorkItem(root_key_, kRegKeyPath, L"", L"", |
| 639 false)); |
| 640 machine_state_.reset(new MockInstallationState()); |
| 641 EXPECT_CALL(work_item_list_, |
| 642 AddCreateRegKeyWorkItem(Eq(root_key_), StrCaseEq(kRegKeyPath))) |
| 643 .Times(1) |
| 644 .WillOnce(Return(create_reg_key_work_item_.get())); |
| 645 EXPECT_CALL(work_item_list_, |
| 646 AddSetRegStringValueWorkItem(Eq(root_key_), |
| 647 StrCaseEq(kRegKeyPath), |
| 648 StrEq(L"CommandLine"), _, |
| 649 Eq(true))) |
| 650 .Times(1) |
| 651 .WillOnce(Return(set_reg_value_work_item_.get())); |
| 652 EXPECT_CALL(work_item_list_, |
| 653 AddSetRegDwordValueWorkItem(Eq(root_key_), |
| 654 StrCaseEq(kRegKeyPath), _, |
| 655 Eq(static_cast<DWORD>(1)), |
| 656 Eq(true))) |
| 657 .Times(2) |
| 658 .WillRepeatedly(Return(set_reg_value_work_item_.get())); |
| 659 } |
| 660 virtual void TearDown() { |
| 661 machine_state_.reset(); |
| 662 set_reg_value_work_item_.reset(); |
| 663 create_reg_key_work_item_.reset(); |
| 664 root_key_ = NULL; |
| 665 InstallWorkerTest::TearDown(); |
| 666 } |
| 667 protected: |
| 668 static const bool system_level_ = false; |
| 669 static const wchar_t kRegKeyPath[]; |
| 670 HKEY root_key_; |
| 671 scoped_ptr<CreateRegKeyWorkItem> create_reg_key_work_item_; |
| 672 scoped_ptr<SetRegValueWorkItem> set_reg_value_work_item_; |
| 673 scoped_ptr<MockInstallationState> machine_state_; |
| 674 StrictMock<MockWorkItemList> work_item_list_; |
| 675 }; |
| 676 |
| 677 const wchar_t QuickEnablePresentTest::kRegKeyPath[] = |
| 678 L"Software\\Google\\Update\\Clients\\" |
| 679 L"{4DC8B4CA-1BDA-483e-B5FA-D3C12E15B62D}\\Commands\\quick-enable-cf"; |
| 680 |
| 681 TEST_F(QuickEnablePresentTest, CleanInstallMultiChrome) { |
| 682 // Install multi Chrome on a clean system. |
| 683 scoped_ptr<MockInstallerState> installer_state( |
| 684 BuildChromeInstallerState(system_level_, true, *machine_state_, |
| 685 InstallerState::MULTI_INSTALL)); |
| 686 AddQuickEnableWorkItems(*installer_state, *machine_state_, &setup_path_, |
| 687 new_version_.get(), &work_item_list_); |
| 688 } |
| 689 |
| 690 TEST_F(QuickEnablePresentTest, CleanInstallMultiChromeReadyMode) { |
| 691 // Install multi Chrome with Chrome Frame ready-mode on a clean system. |
| 692 scoped_ptr<MockInstallerState> installer_state( |
| 693 BuildBasicInstallerState(system_level_, true, *machine_state_, |
| 694 InstallerState::MULTI_INSTALL)); |
| 695 AddChromeToInstallerState(*machine_state_, installer_state.get()); |
| 696 AddChromeFrameToInstallerState(*machine_state_, true, |
| 697 installer_state.get()); |
| 698 AddQuickEnableWorkItems(*installer_state, *machine_state_, &setup_path_, |
| 699 new_version_.get(), &work_item_list_); |
| 700 } |
| 701 |
| 702 TEST_F(QuickEnablePresentTest, UninstallSingleChromeFrame) { |
| 703 // Uninstall single Chrome Frame on a machine with multi Chrome. |
| 704 AddChromeToInstallationState(system_level_, true, false, |
| 705 machine_state_.get()); |
| 706 AddChromeFrameToInstallationState(system_level_, false, false, |
| 707 machine_state_.get()); |
| 708 scoped_ptr<MockInstallerState> installer_state( |
| 709 BuildBasicInstallerState(system_level_, false, *machine_state_, |
| 710 InstallerState::UNINSTALL)); |
| 711 AddChromeFrameToInstallerState(*machine_state_, false, installer_state.get()); |
| 712 AddQuickEnableWorkItems(*installer_state, *machine_state_, &setup_path_, |
| 713 new_version_.get(), &work_item_list_); |
| 714 } |
| 715 |
| 716 TEST_F(QuickEnablePresentTest, UninstallMultiChromeFrame) { |
| 717 // Uninstall multi Chrome Frame on a machine with multi Chrome. |
| 718 AddChromeToInstallationState(system_level_, true, false, |
| 719 machine_state_.get()); |
| 720 AddChromeFrameToInstallationState(system_level_, true, false, |
| 721 machine_state_.get()); |
| 722 scoped_ptr<MockInstallerState> installer_state( |
| 723 BuildBasicInstallerState(system_level_, true, *machine_state_, |
| 724 InstallerState::UNINSTALL)); |
| 725 AddChromeFrameToInstallerState(*machine_state_, false, installer_state.get()); |
| 726 AddQuickEnableWorkItems(*installer_state, *machine_state_, &setup_path_, |
| 727 new_version_.get(), &work_item_list_); |
| 728 } |
OLD | NEW |