15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved. 25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file. 45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef CHROME_TEST_MINI_INSTALLER_TEST_INSTALLER_TEST_UTIL_H_ 65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define CHROME_TEST_MINI_INSTALLER_TEST_INSTALLER_TEST_UTIL_H_ 75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include <vector> 95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/command_line.h" 112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "base/files/file_path.h" 125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/installer/util/installation_validator.h" 135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/test/mini_installer_test/switch_builder.h" 145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace installer_test { 165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)struct InstalledProduct { 185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) std::string version; 195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) installer::InstallationValidator::InstallationType type; 205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool system; 215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}; 225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Utility functions used to test Chrome installation. 245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Deletes the Chrome installation directory which is found at different 265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// locations depending on the |system_level| and |type|. 275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Returns true if successful, otherwise false. 285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)bool DeleteInstallDirectory( 295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool system_level, 305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) installer::InstallationValidator::InstallationType type); 315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Deletes the Chrome Windows registry entry. 335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Returns true if successful, otherwise false. 345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)bool DeleteRegistryKey( 355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool system_level, 365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) installer::InstallationValidator::InstallationType type); 375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Locates the Chrome installation directory based on the 395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// provided |system_level|. Returns true if successful, otherwise false. 405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Returns true if successful, otherwise false. 412a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)bool GetChromeInstallDirectory(bool system_level, base::FilePath* path); 425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Gets the installation directory of either Chrome or Chrome Frame 445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// as specified by the |system_level| and |type|. 455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Returns true if successful, otherwise false. 465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)bool GetInstallDirectory(bool system_level, 472a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) BrowserDistribution::Type type, base::FilePath* path); 485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Returns the version of the specified |product|. 505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)std::string GetVersion( 515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) installer::InstallationValidator::InstallationType product); 525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Gets a list of installed products. 545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Returns true if there are installed products. 555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)bool GetInstalledProducts(std::vector<InstalledProduct>* products); 565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 572a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)bool Install(const base::FilePath& installer); 582a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)bool Install(const base::FilePath& installer, const SwitchBuilder& switches); 595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)bool LaunchChrome(bool close_after_launch, bool system_level); 605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)bool LaunchIE(const std::string& url); 615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Uninstall all Chrome or Chrome Frame installations. 635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)bool UninstallAll(); 645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Uninstall the product specified by |system_level| and |type|. 665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)bool Uninstall( 675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool system_level, 685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) installer::InstallationValidator::InstallationType type); 695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Uninstall the product specified by |system_level| and |product|. 715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)bool Uninstall( 725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool system_level, 735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) BrowserDistribution::Type product); 745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)bool ValidateInstall( 765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool system_level, 775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) installer::InstallationValidator::InstallationType expected, 785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const std::string& version); 795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Run and wait for command to finish. 815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Returns true if successful, otherwise false. 825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)bool RunAndWaitForCommandToFinish(CommandLine command); 835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} // namespace 855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif // CHROME_TEST_MINI_INSTALLER_TEST_INSTALLER_TEST_UTIL_H_ 875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 88