OLD | NEW |
1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 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 """This script tests the installer with test cases specified in the config file. | 5 """This script tests the installer with test cases specified in the config file. |
6 | 6 |
7 For each test case, it checks that the machine states after the execution of | 7 For each test case, it checks that the machine states after the execution of |
8 each command match the expected machine states. For more details, take a look at | 8 each command match the expected machine states. For more details, take a look at |
9 the design documentation at http://goo.gl/Q0rGM6 | 9 the design documentation at http://goo.gl/Q0rGM6 |
10 """ | 10 """ |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 variable_expander: A VariableExpander object. | 161 variable_expander: A VariableExpander object. |
162 """ | 162 """ |
163 expanded_command = variable_expander.Expand(command) | 163 expanded_command = variable_expander.Expand(command) |
164 script_dir = os.path.dirname(os.path.abspath(__file__)) | 164 script_dir = os.path.dirname(os.path.abspath(__file__)) |
165 exit_status = subprocess.call(expanded_command, shell=True, cwd=script_dir) | 165 exit_status = subprocess.call(expanded_command, shell=True, cwd=script_dir) |
166 if exit_status != 0: | 166 if exit_status != 0: |
167 raise Exception('Command %s returned non-zero exit status %s' % ( | 167 raise Exception('Command %s returned non-zero exit status %s' % ( |
168 expanded_command, exit_status)) | 168 expanded_command, exit_status)) |
169 | 169 |
170 | 170 |
171 def DeleteGoogleUpdateRegistration(system_level, variable_expander): | 171 def DeleteGoogleUpdateRegistration(system_level, registry_subkey, |
| 172 variable_expander): |
172 """Deletes Chrome's registration with Google Update. | 173 """Deletes Chrome's registration with Google Update. |
173 | 174 |
174 Args: | 175 Args: |
175 system_level: True if system-level Chrome is to be deleted. | 176 system_level: True if system-level Chrome is to be deleted. |
| 177 registry_subkey: The pre-expansion registry subkey for the product. |
176 variable_expander: A VariableExpander object. | 178 variable_expander: A VariableExpander object. |
177 """ | 179 """ |
178 root = (_winreg.HKEY_LOCAL_MACHINE if system_level | 180 root = (_winreg.HKEY_LOCAL_MACHINE if system_level |
179 else _winreg.HKEY_CURRENT_USER) | 181 else _winreg.HKEY_CURRENT_USER) |
180 key_name = variable_expander.Expand('$CHROME_UPDATE_REGISTRY_SUBKEY') | 182 key_name = variable_expander.Expand(registry_subkey) |
181 try: | 183 try: |
182 key_handle = _winreg.OpenKey(root, key_name, 0, | 184 key_handle = _winreg.OpenKey(root, key_name, 0, |
183 _winreg.KEY_SET_VALUE | | 185 _winreg.KEY_SET_VALUE | |
184 _winreg.KEY_WOW64_32KEY) | 186 _winreg.KEY_WOW64_32KEY) |
185 _winreg.DeleteValue(key_handle, 'pv') | 187 _winreg.DeleteValue(key_handle, 'pv') |
186 except WindowsError: | 188 except WindowsError: |
187 # The key isn't present, so there is no value to delete. | 189 # The key isn't present, so there is no value to delete. |
188 pass | 190 pass |
189 | 191 |
190 | 192 |
191 def RunCleanCommand(force_clean, variable_expander): | 193 def RunCleanCommand(force_clean, variable_expander): |
192 """Puts the machine in the clean state (i.e. Chrome not installed). | 194 """Puts the machine in the clean state (i.e. Chrome not installed). |
193 | 195 |
194 Args: | 196 Args: |
195 force_clean: A boolean indicating whether to force cleaning existing | 197 force_clean: A boolean indicating whether to force cleaning existing |
196 installations. | 198 installations. |
197 variable_expander: A VariableExpander object. | 199 variable_expander: A VariableExpander object. |
198 """ | 200 """ |
199 # TODO(sukolsak): Handle Chrome SxS installs. | 201 # A list of (system_level, product_name, product_switch, registry_subkey) |
| 202 # tuples for the possible installed products. |
| 203 data = [ |
| 204 (False, '$CHROME_LONG_NAME', '', |
| 205 '$CHROME_UPDATE_REGISTRY_SUBKEY'), |
| 206 (True, '$CHROME_LONG_NAME', '--system-level', |
| 207 '$CHROME_UPDATE_REGISTRY_SUBKEY'), |
| 208 ] |
| 209 if variable_expander.Expand('$SUPPORTS_SXS') == 'True': |
| 210 data.append((False, '$CHROME_LONG_NAME_SXS', '', |
| 211 '$CHROME_UPDATE_REGISTRY_SUBKEY_SXS')) |
| 212 |
200 interactive_option = '--interactive' if not force_clean else '' | 213 interactive_option = '--interactive' if not force_clean else '' |
201 for system_level in (False, True): | 214 for system_level, product_name, product_switch, registry_subkey in data: |
202 level_option = '--system-level' if system_level else '' | |
203 command = ('python uninstall_chrome.py ' | 215 command = ('python uninstall_chrome.py ' |
204 '--chrome-long-name="$CHROME_LONG_NAME" ' | 216 '--chrome-long-name="%s" ' |
205 '--no-error-if-absent %s %s' % | 217 '--no-error-if-absent %s %s' % |
206 (level_option, interactive_option)) | 218 (product_name, product_switch, interactive_option)) |
207 RunCommand(command, variable_expander) | 219 RunCommand(command, variable_expander) |
208 if force_clean: | 220 if force_clean: |
209 DeleteGoogleUpdateRegistration(system_level, variable_expander) | 221 DeleteGoogleUpdateRegistration(system_level, registry_subkey, |
| 222 variable_expander) |
210 | 223 |
211 | 224 |
212 def MergePropertyDictionaries(current_property, new_property): | 225 def MergePropertyDictionaries(current_property, new_property): |
213 """Merges the new property dictionary into the current property dictionary. | 226 """Merges the new property dictionary into the current property dictionary. |
214 | 227 |
215 This is different from general dictionary merging in that, in case there are | 228 This is different from general dictionary merging in that, in case there are |
216 keys with the same name, we merge values together in the first level, and we | 229 keys with the same name, we merge values together in the first level, and we |
217 override earlier values in the second level. For more details, take a look at | 230 override earlier values in the second level. For more details, take a look at |
218 http://goo.gl/uE0RoR | 231 http://goo.gl/uE0RoR |
219 | 232 |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
420 trie[path] = value | 433 trie[path] = value |
421 return | 434 return |
422 directory, rest = path.split(TEST_SEPARATOR, 1) | 435 directory, rest = path.split(TEST_SEPARATOR, 1) |
423 if directory not in trie: | 436 if directory not in trie: |
424 trie[directory] = {} | 437 trie[directory] = {} |
425 _AddPathToTrie(trie[directory], rest, value) | 438 _AddPathToTrie(trie[directory], rest, value) |
426 | 439 |
427 | 440 |
428 if __name__ == '__main__': | 441 if __name__ == '__main__': |
429 sys.exit(main()) | 442 sys.exit(main()) |
OLD | NEW |