OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/test/mini_installer_test/chrome_mini_installer.h" | 5 #include "chrome/test/mini_installer_test/chrome_mini_installer.h" |
6 | 6 |
7 #include "base/path_service.h" | 7 #include "base/path_service.h" |
8 #include "base/process_util.h" | 8 #include "base/process_util.h" |
9 #include "base/registry.h" | 9 #include "base/registry.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 return; | 106 return; |
107 } | 107 } |
108 | 108 |
109 printf("\nClosing Chrome processes, if any...\n"); | 109 printf("\nClosing Chrome processes, if any...\n"); |
110 CloseProcesses(installer_util::kChromeExe); | 110 CloseProcesses(installer_util::kChromeExe); |
111 | 111 |
112 std::wstring uninstall_path = GetUninstallPath(); | 112 std::wstring uninstall_path = GetUninstallPath(); |
113 ASSERT_TRUE(file_util::PathExists(uninstall_path)); | 113 ASSERT_TRUE(file_util::PathExists(uninstall_path)); |
114 | 114 |
115 printf("\nUninstalling Chrome...\n"); | 115 printf("\nUninstalling Chrome...\n"); |
116 process_util::LaunchApp(L"\"" + uninstall_path + L"\"" + L" -uninstall", | 116 base::LaunchApp(L"\"" + uninstall_path + L"\"" + L" -uninstall", |
117 false, false, NULL); | 117 false, false, NULL); |
118 printf("\nLaunched setup.exe -uninstall....\n"); | 118 printf("\nLaunched setup.exe -uninstall....\n"); |
119 ASSERT_TRUE(CloseWindow(mini_installer_constants::kChromeBuildType, | 119 ASSERT_TRUE(CloseWindow(mini_installer_constants::kChromeBuildType, |
120 WM_COMMAND)); | 120 WM_COMMAND)); |
121 WaitUntilProcessStopsRunning( | 121 WaitUntilProcessStopsRunning( |
122 mini_installer_constants::kChromeSetupExecutable); | 122 mini_installer_constants::kChromeSetupExecutable); |
123 ASSERT_FALSE(CheckRegistryKey(dist->GetVersionKey())); | 123 ASSERT_FALSE(CheckRegistryKey(dist->GetVersionKey())); |
124 DeleteAppFolder(); | 124 DeleteAppFolder(); |
125 FindChromeShortcut(); | 125 FindChromeShortcut(); |
126 CloseProcesses(mini_installer_constants::kIEExecutable); | 126 CloseProcesses(mini_installer_constants::kIEExecutable); |
127 ASSERT_EQ(0, process_util::GetProcessCount( | 127 ASSERT_EQ(0, |
128 mini_installer_constants::kIEExecutable, NULL)); | 128 base::GetProcessCount(mini_installer_constants::kIEExecutable, NULL)); |
129 } | 129 } |
130 | 130 |
131 // Takes care of Chrome uninstall dialog. | 131 // Takes care of Chrome uninstall dialog. |
132 bool ChromeMiniInstaller::CloseWindow(LPCWSTR window_name, UINT message) { | 132 bool ChromeMiniInstaller::CloseWindow(LPCWSTR window_name, UINT message) { |
133 int timer = 0; | 133 int timer = 0; |
134 bool return_val = false; | 134 bool return_val = false; |
135 HWND hndl = FindWindow(NULL, window_name); | 135 HWND hndl = FindWindow(NULL, window_name); |
136 while (hndl== NULL && (timer < 60000)) { | 136 while (hndl== NULL && (timer < 60000)) { |
137 hndl = FindWindow(NULL, window_name); | 137 hndl = FindWindow(NULL, window_name); |
138 Sleep(200); | 138 Sleep(200); |
139 timer = timer + 200; | 139 timer = timer + 200; |
140 } | 140 } |
141 if (hndl != NULL) { | 141 if (hndl != NULL) { |
142 LRESULT _result = SendMessage(hndl, message, 1, 0); | 142 LRESULT _result = SendMessage(hndl, message, 1, 0); |
143 return_val = true; | 143 return_val = true; |
144 } | 144 } |
145 return return_val; | 145 return return_val; |
146 } | 146 } |
147 | 147 |
148 // Closes Chrome browser. | 148 // Closes Chrome browser. |
149 void ChromeMiniInstaller::CloseChromeBrowser(LPCWSTR window_name) { | 149 void ChromeMiniInstaller::CloseChromeBrowser(LPCWSTR window_name) { |
150 WaitUntilProcessStartsRunning(installer_util::kChromeExe); | 150 WaitUntilProcessStartsRunning(installer_util::kChromeExe); |
151 ASSERT_TRUE(CloseWindow(window_name, WM_CLOSE)); | 151 ASSERT_TRUE(CloseWindow(window_name, WM_CLOSE)); |
152 } | 152 } |
153 | 153 |
154 // Checks for all requested running processes and kills them. | 154 // Checks for all requested running processes and kills them. |
155 void ChromeMiniInstaller::CloseProcesses(const std::wstring& executable_name) { | 155 void ChromeMiniInstaller::CloseProcesses(const std::wstring& executable_name) { |
156 int timer = 0; | 156 int timer = 0; |
157 while ((process_util::GetProcessCount(executable_name, NULL) > 0) && | 157 while ((base::GetProcessCount(executable_name, NULL) > 0) && |
158 (timer < 20000)) { | 158 (timer < 20000)) { |
159 process_util::KillProcesses(executable_name, 1, NULL); | 159 process_util::KillProcesses(executable_name, 1, NULL); |
160 Sleep(200); | 160 Sleep(200); |
161 timer = timer + 200; | 161 timer = timer + 200; |
162 } | 162 } |
163 ASSERT_EQ(0, process_util::GetProcessCount(executable_name, NULL)); | 163 ASSERT_EQ(0, process_util::GetProcessCount(executable_name, NULL)); |
164 } | 164 } |
165 | 165 |
166 // Checks for Chrome registry keys. | 166 // Checks for Chrome registry keys. |
167 bool ChromeMiniInstaller::CheckRegistryKey(std::wstring key_path) { | 167 bool ChromeMiniInstaller::CheckRegistryKey(std::wstring key_path) { |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 int timer = 0; | 311 int timer = 0; |
312 printf("\nWaiting for this process to end... %ls\n", process_name); | 312 printf("\nWaiting for this process to end... %ls\n", process_name); |
313 while ((process_util::GetProcessCount(process_name, NULL) > 0) && | 313 while ((process_util::GetProcessCount(process_name, NULL) > 0) && |
314 (timer < 60000)) { | 314 (timer < 60000)) { |
315 Sleep(200); | 315 Sleep(200); |
316 timer = timer + 200; | 316 timer = timer + 200; |
317 } | 317 } |
318 ASSERT_EQ(0, process_util::GetProcessCount(process_name, NULL)); | 318 ASSERT_EQ(0, process_util::GetProcessCount(process_name, NULL)); |
319 } | 319 } |
320 | 320 |
OLD | NEW |