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)); | |
robertshield
2011/03/03 19:32:26
don't you also need to add a --uninstall switch he
grt (UTC plus 2)
2011/03/03 19:38:44
Nice catch! Done.
| |
173 if (system_level) | |
174 product_state.AddUninstallSwitch(installer::switches::kSystemLevel); | |
175 if (multi_install) { | |
176 product_state.AddUninstallSwitch(installer::switches::kMultiInstall); | |
177 product_state.AddUninstallSwitch(installer::switches::kChrome); | |
178 if (with_chrome_frame_ready_mode) { | |
179 product_state.AddUninstallSwitch(installer::switches::kChromeFrame); | |
180 product_state.AddUninstallSwitch( | |
181 installer::switches::kChromeFrameReadyMode); | |
182 } | |
183 } | |
184 | |
185 installation_state->SetProductState(system_level, | |
186 BrowserDistribution::CHROME_BROWSER, | |
187 product_state); | |
188 } | |
189 | |
190 void AddChromeFrameToInstallationState( | |
191 bool system_level, | |
192 bool multi_install, | |
193 bool ready_mode, | |
194 MockInstallationState* installation_state) { | |
195 MockProductState product_state; | |
196 product_state.set_version(current_version_->Clone()); | |
197 product_state.set_multi_install(multi_install); | |
198 BrowserDistribution* dist = | |
199 BrowserDistribution::GetSpecificDistribution( | |
200 multi_install ? BrowserDistribution::CHROME_BINARIES : | |
201 BrowserDistribution::CHROME_FRAME); | |
202 FilePath install_path = | |
203 installer::GetChromeInstallPath(system_level, dist); | |
204 product_state.SetUninstallProgram( | |
205 install_path.Append(installer::kSetupExe)); | |
robertshield
2011/03/03 19:32:26
ditto
grt (UTC plus 2)
2011/03/03 19:38:44
Done.
| |
206 product_state.AddUninstallSwitch(installer::switches::kChromeFrame); | |
207 if (system_level) | |
208 product_state.AddUninstallSwitch(installer::switches::kSystemLevel); | |
209 if (multi_install) { | |
210 product_state.AddUninstallSwitch(installer::switches::kMultiInstall); | |
211 if (ready_mode) { | |
212 product_state.AddUninstallSwitch( | |
213 installer::switches::kChromeFrameReadyMode); | |
214 } | |
215 } | |
216 | |
217 installation_state->SetProductState(system_level, | |
218 BrowserDistribution::CHROME_FRAME, | |
219 product_state); | |
220 } | |
221 | |
145 MockInstallationState* BuildChromeInstallationState(bool system_level, | 222 MockInstallationState* BuildChromeInstallationState(bool system_level, |
146 bool multi_install) { | 223 bool multi_install) { |
147 scoped_ptr<MockInstallationState> installation_state( | 224 scoped_ptr<MockInstallationState> installation_state( |
148 new MockInstallationState()); | 225 new MockInstallationState()); |
149 | 226 AddChromeToInstallationState(system_level, multi_install, false, |
150 MockProductState product_state; | 227 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(); | 228 return installation_state.release(); |
162 } | 229 } |
163 | 230 |
164 MockInstallerState* BuildChromeInstallerState(bool system_install, | 231 static MockInstallerState* BuildBasicInstallerState( |
232 bool system_install, | |
165 bool multi_install, | 233 bool multi_install, |
166 const InstallationState& machine_state, | 234 const InstallationState& machine_state, |
167 InstallerState::Operation operation) { | 235 InstallerState::Operation operation) { |
168 scoped_ptr<MockInstallerState> installer_state(new MockInstallerState()); | 236 scoped_ptr<MockInstallerState> installer_state(new MockInstallerState()); |
169 | 237 |
170 InstallerState::Level level = system_install ? | 238 InstallerState::Level level = system_install ? |
171 InstallerState::SYSTEM_LEVEL : InstallerState::USER_LEVEL; | 239 InstallerState::SYSTEM_LEVEL : InstallerState::USER_LEVEL; |
172 installer_state->set_level(level); | 240 installer_state->set_level(level); |
173 installer_state->set_operation(operation); | 241 installer_state->set_operation(operation); |
174 // Hope this next one isn't checked for now. | 242 // Hope this next one isn't checked for now. |
175 installer_state->set_state_key(L"PROBABLY_INVALID_REG_PATH"); | 243 installer_state->set_state_key(L"PROBABLY_INVALID_REG_PATH"); |
176 if (multi_install) { | 244 installer_state->set_package_type(multi_install ? |
177 installer_state->set_package_type(InstallerState::MULTI_PACKAGE); | 245 InstallerState::MULTI_PACKAGE : |
246 InstallerState::SINGLE_PACKAGE); | |
247 return installer_state.release(); | |
248 } | |
249 | |
250 static void AddChromeToInstallerState( | |
251 const InstallationState& machine_state, | |
252 MockInstallerState* installer_state) { | |
253 // Fresh install or upgrade? | |
254 const ProductState* chrome = | |
255 machine_state.GetProductState(installer_state->system_install(), | |
256 BrowserDistribution::CHROME_BROWSER); | |
257 if (chrome != NULL) { | |
258 installer_state->AddProductFromState(BrowserDistribution::CHROME_BROWSER, | |
259 *chrome); | |
260 } else { | |
261 BrowserDistribution* dist = | |
262 BrowserDistribution::GetSpecificDistribution( | |
263 BrowserDistribution::CHROME_BROWSER); | |
264 scoped_ptr<Product> product(new Product(dist)); | |
265 if (installer_state->is_multi_install()) | |
266 product->SetOption(installer::kOptionMultiInstall, true); | |
267 installer_state->AddProduct(&product); | |
178 } | 268 } |
179 const ProductState* chrome = | 269 } |
180 machine_state.GetProductState(system_install, | 270 |
181 BrowserDistribution::CHROME_BROWSER); | 271 static void AddChromeFrameToInstallerState( |
182 installer_state->AddProductFromState(BrowserDistribution::CHROME_BROWSER, | 272 const InstallationState& machine_state, |
183 *chrome); | 273 bool ready_mode, |
274 MockInstallerState* installer_state) { | |
275 // Fresh install or upgrade? | |
276 const ProductState* cf = | |
277 machine_state.GetProductState(installer_state->system_install(), | |
278 BrowserDistribution::CHROME_FRAME); | |
279 if (cf != NULL) { | |
280 installer_state->AddProductFromState(BrowserDistribution::CHROME_FRAME, | |
281 *cf); | |
282 } else { | |
283 BrowserDistribution* dist = | |
284 BrowserDistribution::GetSpecificDistribution( | |
285 BrowserDistribution::CHROME_FRAME); | |
286 scoped_ptr<Product> product(new Product(dist)); | |
287 if (installer_state->is_multi_install()) { | |
288 product->SetOption(installer::kOptionMultiInstall, true); | |
289 if (ready_mode) | |
290 product->SetOption(installer::kOptionReadyMode, true); | |
291 } | |
292 installer_state->AddProduct(&product); | |
293 } | |
294 } | |
295 | |
296 static MockInstallerState* BuildChromeInstallerState( | |
297 bool system_install, | |
298 bool multi_install, | |
299 const InstallationState& machine_state, | |
300 InstallerState::Operation operation) { | |
301 scoped_ptr<MockInstallerState> installer_state( | |
302 BuildBasicInstallerState(system_install, multi_install, machine_state, | |
303 operation)); | |
304 AddChromeToInstallerState(machine_state, installer_state.get()); | |
305 return installer_state.release(); | |
306 } | |
307 | |
308 static MockInstallerState* BuildChromeFrameInstallerState( | |
309 bool system_install, | |
310 bool multi_install, | |
311 bool ready_mode, | |
312 const InstallationState& machine_state, | |
313 InstallerState::Operation operation) { | |
314 scoped_ptr<MockInstallerState> installer_state( | |
315 BuildBasicInstallerState(system_install, multi_install, machine_state, | |
316 operation)); | |
317 AddChromeFrameToInstallerState(machine_state, ready_mode, | |
318 installer_state.get()); | |
184 return installer_state.release(); | 319 return installer_state.release(); |
185 } | 320 } |
186 | 321 |
187 protected: | 322 protected: |
188 scoped_ptr<Version> current_version_; | 323 scoped_ptr<Version> current_version_; |
189 scoped_ptr<Version> new_version_; | 324 scoped_ptr<Version> new_version_; |
190 FilePath archive_path_; | 325 FilePath archive_path_; |
191 FilePath installation_path_; | 326 FilePath installation_path_; |
192 FilePath setup_path_; | 327 FilePath setup_path_; |
193 FilePath src_path_; | 328 FilePath src_path_; |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
361 EXPECT_CALL(work_item_list, AddSetRegDwordValueWorkItem(_, _, _, _, _)) | 496 EXPECT_CALL(work_item_list, AddSetRegDwordValueWorkItem(_, _, _, _, _)) |
362 .Times(0); | 497 .Times(0); |
363 EXPECT_CALL(work_item_list, AddSetRegStringValueWorkItem(_, _, _, _, _)) | 498 EXPECT_CALL(work_item_list, AddSetRegStringValueWorkItem(_, _, _, _, _)) |
364 .Times(0); | 499 .Times(0); |
365 | 500 |
366 AddElevationPolicyWorkItems(*installation_state.get(), | 501 AddElevationPolicyWorkItems(*installation_state.get(), |
367 *installer_state.get(), | 502 *installer_state.get(), |
368 *new_version_.get(), | 503 *new_version_.get(), |
369 &work_item_list); | 504 &work_item_list); |
370 } | 505 } |
506 | |
507 // Test scenarios under which the quick-enable-cf command should not exist after | |
508 // the run. We're permissive in that we allow the DeleteRegKeyWorkItem even if | |
509 // it isn't strictly needed. | |
510 class QuickEnableAbsentTest : public InstallWorkerTest { | |
511 public: | |
512 virtual void SetUp() { | |
513 InstallWorkerTest::SetUp(); | |
514 root_key_ = system_level_ ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; | |
515 delete_reg_key_item_.reset( | |
516 WorkItem::CreateDeleteRegKeyWorkItem(root_key_, kRegKeyPath)); | |
517 machine_state_.reset(new MockInstallationState()); | |
518 EXPECT_CALL(work_item_list_, | |
519 AddDeleteRegKeyWorkItem(Eq(root_key_), StrCaseEq(kRegKeyPath))) | |
520 .Times(AtMost(1)) | |
521 .WillRepeatedly(Return(delete_reg_key_item_.get())); | |
522 } | |
523 virtual void TearDown() { | |
524 machine_state_.reset(); | |
525 delete_reg_key_item_.reset(); | |
526 root_key_ = NULL; | |
527 InstallWorkerTest::TearDown(); | |
528 } | |
529 protected: | |
530 static const bool system_level_ = false; | |
531 static const wchar_t kRegKeyPath[]; | |
532 HKEY root_key_; | |
533 scoped_ptr<DeleteRegKeyWorkItem> delete_reg_key_item_; | |
534 scoped_ptr<MockInstallationState> machine_state_; | |
535 StrictMock<MockWorkItemList> work_item_list_; | |
536 }; | |
537 | |
538 const wchar_t QuickEnableAbsentTest::kRegKeyPath[] = | |
539 L"Software\\Google\\Update\\Clients\\" | |
540 L"{4DC8B4CA-1BDA-483e-B5FA-D3C12E15B62D}\\Commands\\quick-enable-cf"; | |
541 | |
542 TEST_F(QuickEnableAbsentTest, CleanInstallSingleChrome) { | |
543 // Install single Chrome on a clean system. | |
544 scoped_ptr<MockInstallerState> installer_state( | |
545 BuildChromeInstallerState(system_level_, false, *machine_state_, | |
546 InstallerState::SINGLE_INSTALL_OR_UPDATE)); | |
547 AddQuickEnableWorkItems(*installer_state, *machine_state_, &setup_path_, | |
548 new_version_.get(), &work_item_list_); | |
549 } | |
550 | |
551 TEST_F(QuickEnableAbsentTest, CleanInstallSingleChromeFrame) { | |
552 // Install single Chrome Frame on a clean system. | |
553 scoped_ptr<MockInstallerState> installer_state( | |
554 BuildChromeFrameInstallerState(system_level_, false, false, | |
555 *machine_state_, | |
556 InstallerState::SINGLE_INSTALL_OR_UPDATE)); | |
557 AddQuickEnableWorkItems(*installer_state, *machine_state_, &setup_path_, | |
558 new_version_.get(), &work_item_list_); | |
559 } | |
560 | |
561 TEST_F(QuickEnableAbsentTest, CleanInstallMultiChromeFrame) { | |
562 // Install multi Chrome Frame on a clean system. | |
563 scoped_ptr<MockInstallerState> installer_state( | |
564 BuildChromeFrameInstallerState(system_level_, true, false, | |
565 *machine_state_, | |
566 InstallerState::MULTI_INSTALL)); | |
567 AddQuickEnableWorkItems(*installer_state, *machine_state_, &setup_path_, | |
568 new_version_.get(), &work_item_list_); | |
569 } | |
570 | |
571 TEST_F(QuickEnableAbsentTest, CleanInstallMultiChromeChromeFrame) { | |
572 // Install multi Chrome and Chrome Frame on a clean system. | |
573 scoped_ptr<MockInstallerState> installer_state( | |
574 BuildBasicInstallerState(system_level_, true, *machine_state_, | |
575 InstallerState::MULTI_INSTALL)); | |
576 AddChromeToInstallerState(*machine_state_, installer_state.get()); | |
577 AddChromeFrameToInstallerState(*machine_state_, false, | |
578 installer_state.get()); | |
579 AddQuickEnableWorkItems(*installer_state, *machine_state_, &setup_path_, | |
580 new_version_.get(), &work_item_list_); | |
581 } | |
582 | |
583 TEST_F(QuickEnableAbsentTest, UninstallMultiChromeLeaveMultiChromeFrame) { | |
584 // Uninstall multi Chrome on a machine with multi Chrome Frame. | |
585 AddChromeToInstallationState(system_level_, true, false, | |
586 machine_state_.get()); | |
587 AddChromeFrameToInstallationState(system_level_, true, false, | |
588 machine_state_.get()); | |
589 scoped_ptr<MockInstallerState> installer_state( | |
590 BuildBasicInstallerState(system_level_, true, *machine_state_, | |
591 InstallerState::UNINSTALL)); | |
592 AddChromeToInstallerState(*machine_state_, installer_state.get()); | |
593 AddQuickEnableWorkItems(*installer_state, *machine_state_, &setup_path_, | |
594 new_version_.get(), &work_item_list_); | |
595 } | |
596 | |
597 TEST_F(QuickEnableAbsentTest, UninstallMultiChromeLeaveSingleChromeFrame) { | |
598 // Uninstall multi Chrome on a machine with single Chrome Frame. | |
599 AddChromeToInstallationState(system_level_, true, false, | |
600 machine_state_.get()); | |
601 AddChromeFrameToInstallationState(system_level_, false, false, | |
602 machine_state_.get()); | |
603 scoped_ptr<MockInstallerState> installer_state( | |
604 BuildBasicInstallerState(system_level_, true, *machine_state_, | |
605 InstallerState::UNINSTALL)); | |
606 AddChromeToInstallerState(*machine_state_, installer_state.get()); | |
607 AddQuickEnableWorkItems(*installer_state, *machine_state_, &setup_path_, | |
608 new_version_.get(), &work_item_list_); | |
609 } | |
610 | |
611 TEST_F(QuickEnableAbsentTest, AcceptReadyMode) { | |
612 // Accept ready-mode. | |
613 AddChromeToInstallationState(system_level_, true, true, | |
614 machine_state_.get()); | |
615 AddChromeFrameToInstallationState(system_level_, true, true, | |
616 machine_state_.get()); | |
617 scoped_ptr<MockInstallerState> installer_state( | |
618 BuildBasicInstallerState(system_level_, true, *machine_state_, | |
619 InstallerState::UNINSTALL)); | |
620 AddChromeToInstallerState(*machine_state_, installer_state.get()); | |
621 AddChromeFrameToInstallerState(*machine_state_, false, installer_state.get()); | |
622 AddQuickEnableWorkItems(*installer_state, *machine_state_, &setup_path_, | |
623 new_version_.get(), &work_item_list_); | |
624 } | |
625 | |
626 // Test scenarios under which the quick-enable-cf command should exist after the | |
627 // run. | |
628 class QuickEnablePresentTest : public InstallWorkerTest { | |
629 public: | |
630 virtual void SetUp() { | |
631 InstallWorkerTest::SetUp(); | |
632 root_key_ = system_level_ ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; | |
633 create_reg_key_work_item_.reset( | |
634 WorkItem::CreateCreateRegKeyWorkItem(root_key_, kRegKeyPath)); | |
635 set_reg_value_work_item_.reset( | |
636 WorkItem::CreateSetRegValueWorkItem(root_key_, kRegKeyPath, L"", L"", | |
637 false)); | |
638 machine_state_.reset(new MockInstallationState()); | |
639 EXPECT_CALL(work_item_list_, | |
640 AddCreateRegKeyWorkItem(Eq(root_key_), StrCaseEq(kRegKeyPath))) | |
641 .Times(1) | |
642 .WillOnce(Return(create_reg_key_work_item_.get())); | |
643 EXPECT_CALL(work_item_list_, | |
644 AddSetRegStringValueWorkItem(Eq(root_key_), | |
645 StrCaseEq(kRegKeyPath), | |
646 StrEq(L"CommandLine"), _, | |
647 Eq(true))) | |
648 .Times(1) | |
649 .WillOnce(Return(set_reg_value_work_item_.get())); | |
650 EXPECT_CALL(work_item_list_, | |
651 AddSetRegDwordValueWorkItem(Eq(root_key_), | |
652 StrCaseEq(kRegKeyPath), _, | |
653 Eq(static_cast<DWORD>(1)), | |
654 Eq(true))) | |
655 .Times(2) | |
656 .WillRepeatedly(Return(set_reg_value_work_item_.get())); | |
657 } | |
658 virtual void TearDown() { | |
659 machine_state_.reset(); | |
660 set_reg_value_work_item_.reset(); | |
661 create_reg_key_work_item_.reset(); | |
662 root_key_ = NULL; | |
663 InstallWorkerTest::TearDown(); | |
664 } | |
665 protected: | |
666 static const bool system_level_ = false; | |
667 static const wchar_t kRegKeyPath[]; | |
668 HKEY root_key_; | |
669 scoped_ptr<CreateRegKeyWorkItem> create_reg_key_work_item_; | |
670 scoped_ptr<SetRegValueWorkItem> set_reg_value_work_item_; | |
671 scoped_ptr<MockInstallationState> machine_state_; | |
672 StrictMock<MockWorkItemList> work_item_list_; | |
673 }; | |
674 | |
675 const wchar_t QuickEnablePresentTest::kRegKeyPath[] = | |
676 L"Software\\Google\\Update\\Clients\\" | |
677 L"{4DC8B4CA-1BDA-483e-B5FA-D3C12E15B62D}\\Commands\\quick-enable-cf"; | |
678 | |
679 TEST_F(QuickEnablePresentTest, CleanInstallMultiChrome) { | |
680 // Install multi Chrome on a clean system. | |
681 scoped_ptr<MockInstallerState> installer_state( | |
682 BuildChromeInstallerState(system_level_, true, *machine_state_, | |
683 InstallerState::MULTI_INSTALL)); | |
684 AddQuickEnableWorkItems(*installer_state, *machine_state_, &setup_path_, | |
685 new_version_.get(), &work_item_list_); | |
686 } | |
687 | |
688 TEST_F(QuickEnablePresentTest, CleanInstallMultiChromeReadyMode) { | |
689 // Install multi Chrome with Chrome Frame ready-mode on a clean system. | |
690 scoped_ptr<MockInstallerState> installer_state( | |
691 BuildBasicInstallerState(system_level_, true, *machine_state_, | |
692 InstallerState::MULTI_INSTALL)); | |
693 AddChromeToInstallerState(*machine_state_, installer_state.get()); | |
694 AddChromeFrameToInstallerState(*machine_state_, true, | |
695 installer_state.get()); | |
696 AddQuickEnableWorkItems(*installer_state, *machine_state_, &setup_path_, | |
697 new_version_.get(), &work_item_list_); | |
698 } | |
699 | |
700 TEST_F(QuickEnablePresentTest, UninstallSingleChromeFrame) { | |
701 // Uninstall single Chrome Frame on a machine with multi Chrome. | |
702 AddChromeToInstallationState(system_level_, true, false, | |
703 machine_state_.get()); | |
704 AddChromeFrameToInstallationState(system_level_, false, false, | |
705 machine_state_.get()); | |
706 scoped_ptr<MockInstallerState> installer_state( | |
707 BuildBasicInstallerState(system_level_, false, *machine_state_, | |
708 InstallerState::UNINSTALL)); | |
709 AddChromeFrameToInstallerState(*machine_state_, false, installer_state.get()); | |
710 AddQuickEnableWorkItems(*installer_state, *machine_state_, &setup_path_, | |
711 new_version_.get(), &work_item_list_); | |
712 } | |
713 | |
714 TEST_F(QuickEnablePresentTest, UninstallMultiChromeFrame) { | |
715 // Uninstall multi Chrome Frame on a machine with multi Chrome. | |
716 AddChromeToInstallationState(system_level_, true, false, | |
717 machine_state_.get()); | |
718 AddChromeFrameToInstallationState(system_level_, true, false, | |
719 machine_state_.get()); | |
720 scoped_ptr<MockInstallerState> installer_state( | |
721 BuildBasicInstallerState(system_level_, true, *machine_state_, | |
722 InstallerState::UNINSTALL)); | |
723 AddChromeFrameToInstallerState(*machine_state_, false, installer_state.get()); | |
724 AddQuickEnableWorkItems(*installer_state, *machine_state_, &setup_path_, | |
725 new_version_.get(), &work_item_list_); | |
726 } | |
OLD | NEW |