summaryrefslogtreecommitdiffstats
path: root/chrome/test/mini_installer_test/chrome_mini_installer.h
blob: df93b521674408ccc38ee822a00dae6b18663af6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_TEST_MINI_INSTALLER_TEST_CHROME_MINI_INSTALLER_H__
#define CHROME_TEST_MINI_INSTALLER_TEST_CHROME_MINI_INSTALLER_H__

#include <windows.h>
#include <process.h>
#include <psapi.h>
#include <tlhelp32.h>
#include <tchar.h>
#include <errno.h>
#include <string>
#include <vector>

#include "base/basictypes.h"

// This structure holds the name and creation time
// details of all the chrome nightly builds.
class file_info {
 public:
  file_info() {}
  file_info(const std::wstring& in_name, int in_creation_time) {
    name_.assign(in_name);
    creation_time_ = in_creation_time;
  }
  // This is a predicate to sort file information.
  bool IsNewer(const file_info& creation_time_begin,
               const file_info& creation_time_end);

  std::wstring name_;
  int creation_time_;
};
typedef std::vector<file_info> file_info_list;

// This class has methods to install and uninstall Chrome mini installer.
class ChromeMiniInstaller {
 public:
  explicit ChromeMiniInstaller(std::wstring type) {
    install_type_ = type;
  }

  ~ChromeMiniInstaller() {}

  // Closes specified process.
  void CloseProcesses(const std::wstring& executable_name);

  // This method will first install the full installer and
  // then over installs with diff installer.
  void InstallDifferentialInstaller();

  // Installs chrome.
  void Install();

  // Installs the latest full installer.
  void InstallFullInstaller();

  // Installs Google Chrome through meta installer.
  void InstallMetaInstaller();

  // Installs Chrome Mini Installer.
  void InstallMiniInstaller(bool over_install = false,
                            const std::wstring& path = L"");

  // This will test the standalone installer.
  void InstallStandaloneIntaller();

  // Uninstalls Chrome.
  void UnInstall();

  // This method takes care of all overinstall cases.
  void OverInstall();

 private:
  // This variable holds the install type.
  // Install type can be either system or user level.
  std::wstring install_type_;

  bool standalone_installer;

  // Closes First Run UI dialog.
  void CloseFirstRunUIDialog(bool over_install);

  // Close Window whose name is 'window_name', by sending Windows message
  // 'message' to it.
  bool CloseWindow(const wchar_t* window_name, UINT message);

  // Closes Chrome uninstall confirm dialog window.
  bool CloseUninstallWindow();

  // Closes Chrome browser.
  void CloseChromeBrowser(const wchar_t* window_name);

  // Checks for registry key.
  bool CheckRegistryKey(const std::wstring& key_path);

  // Checks for registry key on uninstall.
  bool CheckRegistryKeyOnUninstall(const std::wstring& key_path);

  // Deletes App folder after uninstall.
  void DeleteAppFolder();

  // This method verifies Chrome shortcut.
  void FindChromeShortcut();

  // This method returns path to either program files
  // or documents and setting based on the install type.
  std::wstring GetChromeInstallDirectoryLocation();

  // This method will create a command line to run apply tag.
  bool GetCommandForTagging(std::wstring *return_command);

  // This method will get the latest installer based
  // on the pattern argument passed.
  bool GetInstaller(const wchar_t* pattern, std::wstring *name);

  // Get path for mini_installer.exe.
  std::wstring GetInstallerExePath(const wchar_t* installer_name);

  // This method will get the latest installer filename,
  // based on the passed pattern argument.
  bool GetLatestFile(const wchar_t* path,
                     const wchar_t* pattern,
                     file_info_list *file_name);

  // This method will get the previous full installer based on
  // the diff installer file name argument.
  bool GetPreviousFullInstaller(const std::wstring& diff_file,
                                std::wstring *previous);

  // Get HKEY based on install type.
  HKEY GetRootRegistryKey();

  // Returns Chrome pv registry key value
  bool GetChromeVersionFromRegistry(std::wstring *return_reg_key_value);

  // This method gets the shortcut path from start menu based on install type.
  std::wstring GetStartMenuShortcutPath();

  // This method will return standalone installer file name.
  bool GetStandaloneInstallerFileName(file_info_list *file_name);

  // This method will get the version number from the filename.
  bool GetStandaloneVersion(std::wstring* version);

  // Get path for uninstall.
  std::wstring GetUninstallPath();

  // Checks for the build type
  bool IsChromiumBuild();

  // Launches the chrome installer and waits for it to end.
  void LaunchInstaller(const std::wstring& install_path,
                       const wchar_t* process_name);

  // Verifies if Chrome launches after install.
  void VerifyChromeLaunch();

  // Compares the registry key values after overinstall.
  bool VerifyOverInstall(const std::wstring& reg_key_value_before_overinstall,
                         const std::wstring& reg_key_value_after_overinstall);

  // Checks if the differential install is correct.
  bool VerifyDifferentialInstall(const std::wstring& full_installer_value,
                                 const std::wstring& diff_installer_value,
                                 const std::wstring& diff_installer_name);

  // This method will verify if the installed build is correct.
  bool VerifyStandaloneInstall();

  // Waits until the given process starts running
  void WaitUntilProcessStartsRunning(const wchar_t* process_name);

  // Waits until the given process stops running
  void WaitUntilProcessStopsRunning(const wchar_t* process_name);

  DISALLOW_COPY_AND_ASSIGN(ChromeMiniInstaller);
};

#endif  // CHROME_TEST_MINI_INSTALLER_TEST_CHROME_MINI_INSTALLER_H__