OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <map> | 5 #include <map> |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 | 71 |
72 class FakeProductState : public ProductState { | 72 class FakeProductState : public ProductState { |
73 public: | 73 public: |
74 void SetChannel(const wchar_t* base, int channel_modifiers); | 74 void SetChannel(const wchar_t* base, int channel_modifiers); |
75 void SetVersion(const char* version); | 75 void SetVersion(const char* version); |
76 void SetUninstallCommand(BrowserDistribution::Type dist_type, | 76 void SetUninstallCommand(BrowserDistribution::Type dist_type, |
77 Level install_level, | 77 Level install_level, |
78 const char* version, | 78 const char* version, |
79 int channel_modifiers, | 79 int channel_modifiers, |
80 Vehicle vehicle); | 80 Vehicle vehicle); |
| 81 void AddQuickEnableApplicationHostCommand(BrowserDistribution::Type dist_type, |
| 82 Level install_level, |
| 83 const char* version, |
| 84 int channel_modifiers); |
81 void AddQuickEnableCfCommand(BrowserDistribution::Type dist_type, | 85 void AddQuickEnableCfCommand(BrowserDistribution::Type dist_type, |
82 Level install_level, | 86 Level install_level, |
83 const char* version, | 87 const char* version, |
84 int channel_modifiers); | 88 int channel_modifiers); |
85 void RemoveQuickEnableCfCommand(BrowserDistribution::Type dist_type); | |
86 void set_multi_install(bool is_multi_install) { | 89 void set_multi_install(bool is_multi_install) { |
87 multi_install_ = is_multi_install; | 90 multi_install_ = is_multi_install; |
88 } | 91 } |
89 installer::AppCommands& commands() { return commands_; } | 92 installer::AppCommands& commands() { return commands_; } |
90 | 93 |
91 protected: | 94 protected: |
92 struct ChannelMethodForModifier { | 95 struct ChannelMethodForModifier { |
93 ChannelModifier modifier; | 96 ChannelModifier modifier; |
94 bool (ChannelInfo::*method)(bool value); | 97 bool (ChannelInfo::*method)(bool value); |
95 }; | 98 }; |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 installer::switches::kChromeFrameReadyMode); | 190 installer::switches::kChromeFrameReadyMode); |
188 } | 191 } |
189 } | 192 } |
190 } else if (dist_type == BrowserDistribution::CHROME_FRAME) { | 193 } else if (dist_type == BrowserDistribution::CHROME_FRAME) { |
191 uninstall_command_.AppendSwitch(installer::switches::kChromeFrame); | 194 uninstall_command_.AppendSwitch(installer::switches::kChromeFrame); |
192 } | 195 } |
193 if (vehicle == MSI) | 196 if (vehicle == MSI) |
194 uninstall_command_.AppendSwitch(installer::switches::kMsi); | 197 uninstall_command_.AppendSwitch(installer::switches::kMsi); |
195 } | 198 } |
196 | 199 |
| 200 // Adds the "quick-enable-application-host" Google Update product command. |
| 201 void FakeProductState::AddQuickEnableApplicationHostCommand( |
| 202 BrowserDistribution::Type dist_type, |
| 203 Level install_level, |
| 204 const char* version, |
| 205 int channel_modifiers) { |
| 206 DCHECK_EQ(dist_type, BrowserDistribution::CHROME_BINARIES); |
| 207 DCHECK_NE(channel_modifiers & CM_MULTI, 0); |
| 208 |
| 209 CommandLine cmd_line(GetSetupExePath(dist_type, install_level, version, |
| 210 channel_modifiers)); |
| 211 cmd_line.AppendSwitch(installer::switches::kMultiInstall); |
| 212 cmd_line.AppendSwitch(installer::switches::kChromeAppHost); |
| 213 commands_.Set(installer::kCmdQuickEnableApplicationHost, |
| 214 AppCommand(cmd_line.GetCommandLineString(), true, true)); |
| 215 } |
| 216 |
197 // Adds the "quick-enable-cf" Google Update product command. | 217 // Adds the "quick-enable-cf" Google Update product command. |
198 void FakeProductState::AddQuickEnableCfCommand( | 218 void FakeProductState::AddQuickEnableCfCommand( |
199 BrowserDistribution::Type dist_type, | 219 BrowserDistribution::Type dist_type, |
200 Level install_level, | 220 Level install_level, |
201 const char* version, | 221 const char* version, |
202 int channel_modifiers) { | 222 int channel_modifiers) { |
203 DCHECK_EQ(dist_type, BrowserDistribution::CHROME_BINARIES); | 223 DCHECK_EQ(dist_type, BrowserDistribution::CHROME_BINARIES); |
204 DCHECK_NE(channel_modifiers & CM_MULTI, 0); | 224 DCHECK_NE(channel_modifiers & CM_MULTI, 0); |
205 | 225 |
206 CommandLine cmd_line(GetSetupExePath(dist_type, install_level, version, | 226 CommandLine cmd_line(GetSetupExePath(dist_type, install_level, version, |
207 channel_modifiers)); | 227 channel_modifiers)); |
208 cmd_line.AppendSwitch(installer::switches::kMultiInstall); | 228 cmd_line.AppendSwitch(installer::switches::kMultiInstall); |
209 if (install_level == SYSTEM_LEVEL) | 229 if (install_level == SYSTEM_LEVEL) |
210 cmd_line.AppendSwitch(installer::switches::kSystemLevel); | 230 cmd_line.AppendSwitch(installer::switches::kSystemLevel); |
211 cmd_line.AppendSwitch(installer::switches::kChromeFrameQuickEnable); | 231 cmd_line.AppendSwitch(installer::switches::kChromeFrameQuickEnable); |
212 commands_.Set(installer::kCmdQuickEnableCf, | 232 commands_.Set(installer::kCmdQuickEnableCf, |
213 AppCommand(cmd_line.GetCommandLineString(), true, true)); | 233 AppCommand(cmd_line.GetCommandLineString(), true, true)); |
214 } | 234 } |
215 | 235 |
216 // Removes the "quick-enable-cf" Google Update product command. | |
217 void FakeProductState::RemoveQuickEnableCfCommand( | |
218 BrowserDistribution::Type dist_type) { | |
219 DCHECK_EQ(dist_type, BrowserDistribution::CHROME_BINARIES); | |
220 | |
221 commands_.Remove(installer::kCmdQuickEnableCf); | |
222 } | |
223 | |
224 } // namespace | 236 } // namespace |
225 | 237 |
226 // Fixture for testing the InstallationValidator. Errors logged by the | 238 // Fixture for testing the InstallationValidator. Errors logged by the |
227 // validator are sent to an optional mock recipient (see | 239 // validator are sent to an optional mock recipient (see |
228 // set_validation_error_recipient) upon which expectations can be placed. | 240 // set_validation_error_recipient) upon which expectations can be placed. |
229 class InstallationValidatorTest | 241 class InstallationValidatorTest |
230 : public testing::TestWithParam<InstallationValidator::InstallationType> { | 242 : public testing::TestWithParam<InstallationValidator::InstallationType> { |
231 public: | 243 public: |
232 | 244 |
233 // These shouldn't need to be public, but there seems to be some interaction | 245 // These shouldn't need to be public, but there seems to be some interaction |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
405 state->SetUninstallCommand(prod_type, install_level, chrome::kChromeVersion, | 417 state->SetUninstallCommand(prod_type, install_level, chrome::kChromeVersion, |
406 channel_modifiers, vehicle); | 418 channel_modifiers, vehicle); |
407 state->set_multi_install(is_multi_install); | 419 state->set_multi_install(is_multi_install); |
408 if (prod_type == BrowserDistribution::CHROME_BINARIES && | 420 if (prod_type == BrowserDistribution::CHROME_BINARIES && |
409 (inst_type == InstallationValidator::CHROME_MULTI || | 421 (inst_type == InstallationValidator::CHROME_MULTI || |
410 inst_type == | 422 inst_type == |
411 InstallationValidator::CHROME_FRAME_READY_MODE_CHROME_MULTI)) { | 423 InstallationValidator::CHROME_FRAME_READY_MODE_CHROME_MULTI)) { |
412 state->AddQuickEnableCfCommand(prod_type, install_level, | 424 state->AddQuickEnableCfCommand(prod_type, install_level, |
413 chrome::kChromeVersion, channel_modifiers); | 425 chrome::kChromeVersion, channel_modifiers); |
414 } | 426 } |
| 427 if (prod_type == BrowserDistribution::CHROME_BINARIES) { |
| 428 state->AddQuickEnableApplicationHostCommand(prod_type, |
| 429 install_level, |
| 430 chrome::kChromeVersion, |
| 431 channel_modifiers); |
| 432 } |
415 } | 433 } |
416 | 434 |
417 // static | 435 // static |
418 // Populates |state| with the state of a valid installation of |inst_type|. | 436 // Populates |state| with the state of a valid installation of |inst_type|. |
419 void InstallationValidatorTest::MakeMachineState( | 437 void InstallationValidatorTest::MakeMachineState( |
420 InstallationValidator::InstallationType inst_type, | 438 InstallationValidator::InstallationType inst_type, |
421 Level install_level, | 439 Level install_level, |
422 Channel channel, | 440 Channel channel, |
423 Vehicle vehicle, | 441 Vehicle vehicle, |
424 FakeInstallationState* state) { | 442 FakeInstallationState* state) { |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
486 InstallationValidatorTest, | 504 InstallationValidatorTest, |
487 Values(InstallationValidator::NO_PRODUCTS, | 505 Values(InstallationValidator::NO_PRODUCTS, |
488 InstallationValidator::CHROME_SINGLE, | 506 InstallationValidator::CHROME_SINGLE, |
489 InstallationValidator::CHROME_MULTI, | 507 InstallationValidator::CHROME_MULTI, |
490 InstallationValidator::CHROME_FRAME_SINGLE, | 508 InstallationValidator::CHROME_FRAME_SINGLE, |
491 InstallationValidator::CHROME_FRAME_SINGLE_CHROME_SINGLE, | 509 InstallationValidator::CHROME_FRAME_SINGLE_CHROME_SINGLE, |
492 InstallationValidator::CHROME_FRAME_SINGLE_CHROME_MULTI, | 510 InstallationValidator::CHROME_FRAME_SINGLE_CHROME_MULTI, |
493 InstallationValidator::CHROME_FRAME_MULTI, | 511 InstallationValidator::CHROME_FRAME_MULTI, |
494 InstallationValidator::CHROME_FRAME_MULTI_CHROME_MULTI, | 512 InstallationValidator::CHROME_FRAME_MULTI_CHROME_MULTI, |
495 InstallationValidator::CHROME_FRAME_READY_MODE_CHROME_MULTI)); | 513 InstallationValidator::CHROME_FRAME_READY_MODE_CHROME_MULTI)); |
OLD | NEW |