OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/win/registry.h" | 8 #include "base/win/registry.h" |
9 #include "chrome/installer/util/browser_distribution.h" | 9 #include "chrome/installer/util/browser_distribution.h" |
10 #include "chrome/installer/util/installation_state.h" | 10 #include "chrome/installer/util/installation_state.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 bool multi_install = false; | 27 bool multi_install = false; |
28 HKEY root = system_level ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; | 28 HKEY root = system_level ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; |
29 | 29 |
30 RegKey key; | 30 RegKey key; |
31 std::wstring launch_cmd = L"hey diddle diddle"; | 31 std::wstring launch_cmd = L"hey diddle diddle"; |
32 std::wstring value; | 32 std::wstring value; |
33 | 33 |
34 // check results for a fresh install of single Chrome | 34 // check results for a fresh install of single Chrome |
35 { | 35 { |
36 TempRegKeyOverride override(root, L"root_inst_res"); | 36 TempRegKeyOverride override(root, L"root_inst_res"); |
37 const MasterPreferences prefs( | 37 CommandLine cmd_line = CommandLine::FromString(L"setup.exe --system-level"); |
38 CommandLine::FromString(L"setup.exe --system-level")); | 38 const MasterPreferences prefs(cmd_line); |
39 InstallationState machine_state; | 39 InstallationState machine_state; |
40 machine_state.Initialize(prefs); | 40 machine_state.Initialize(); |
41 InstallerState state; | 41 InstallerState state; |
42 state.Initialize(prefs, machine_state); | 42 state.Initialize(cmd_line, prefs, machine_state); |
43 InstallUtil::WriteInstallerResult(system_level, state.state_key(), | 43 InstallUtil::WriteInstallerResult(system_level, state.state_key(), |
44 installer::FIRST_INSTALL_SUCCESS, 0, &launch_cmd); | 44 installer::FIRST_INSTALL_SUCCESS, 0, &launch_cmd); |
45 BrowserDistribution* distribution = | 45 BrowserDistribution* distribution = |
46 BrowserDistribution::GetSpecificDistribution( | 46 BrowserDistribution::GetSpecificDistribution( |
47 BrowserDistribution::CHROME_BROWSER, prefs); | 47 BrowserDistribution::CHROME_BROWSER); |
48 EXPECT_EQ(ERROR_SUCCESS, | 48 EXPECT_EQ(ERROR_SUCCESS, |
49 key.Open(root, distribution->GetStateKey().c_str(), KEY_READ)); | 49 key.Open(root, distribution->GetStateKey().c_str(), KEY_READ)); |
50 EXPECT_EQ(ERROR_SUCCESS, | 50 EXPECT_EQ(ERROR_SUCCESS, |
51 key.ReadValue(installer::kInstallerSuccessLaunchCmdLine, &value)); | 51 key.ReadValue(installer::kInstallerSuccessLaunchCmdLine, &value)); |
52 EXPECT_EQ(launch_cmd, value); | 52 EXPECT_EQ(launch_cmd, value); |
53 } | 53 } |
54 TempRegKeyOverride::DeleteAllTempKeys(); | 54 TempRegKeyOverride::DeleteAllTempKeys(); |
55 | 55 |
56 // check results for a fresh install of multi Chrome | 56 // check results for a fresh install of multi Chrome |
57 { | 57 { |
58 TempRegKeyOverride override(root, L"root_inst_res"); | 58 TempRegKeyOverride override(root, L"root_inst_res"); |
59 const MasterPreferences prefs( | 59 CommandLine cmd_line = CommandLine::FromString( |
60 CommandLine::FromString( | 60 L"setup.exe --system-level --multi-install --chrome"); |
61 L"setup.exe --system-level --multi-install --chrome")); | 61 const MasterPreferences prefs(cmd_line); |
62 InstallationState machine_state; | 62 InstallationState machine_state; |
63 machine_state.Initialize(prefs); | 63 machine_state.Initialize(); |
64 InstallerState state; | 64 InstallerState state; |
65 state.Initialize(prefs, machine_state); | 65 state.Initialize(cmd_line, prefs, machine_state); |
66 InstallUtil::WriteInstallerResult(system_level, state.state_key(), | 66 InstallUtil::WriteInstallerResult(system_level, state.state_key(), |
67 installer::FIRST_INSTALL_SUCCESS, 0, &launch_cmd); | 67 installer::FIRST_INSTALL_SUCCESS, 0, &launch_cmd); |
68 BrowserDistribution* distribution = | 68 BrowserDistribution* distribution = |
69 BrowserDistribution::GetSpecificDistribution( | 69 BrowserDistribution::GetSpecificDistribution( |
70 BrowserDistribution::CHROME_BROWSER, prefs); | 70 BrowserDistribution::CHROME_BROWSER); |
71 EXPECT_EQ(ERROR_SUCCESS, | 71 EXPECT_EQ(ERROR_SUCCESS, |
72 key.Open(root, distribution->GetStateKey().c_str(), KEY_READ)); | 72 key.Open(root, distribution->GetStateKey().c_str(), KEY_READ)); |
73 EXPECT_EQ(ERROR_SUCCESS, | 73 EXPECT_EQ(ERROR_SUCCESS, |
74 key.ReadValue(installer::kInstallerSuccessLaunchCmdLine, &value)); | 74 key.ReadValue(installer::kInstallerSuccessLaunchCmdLine, &value)); |
75 EXPECT_EQ(launch_cmd, value); | 75 EXPECT_EQ(launch_cmd, value); |
76 key.Close(); | 76 key.Close(); |
77 } | 77 } |
78 TempRegKeyOverride::DeleteAllTempKeys(); | 78 TempRegKeyOverride::DeleteAllTempKeys(); |
79 } | 79 } |
OLD | NEW |