forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfake_installation_state.h
45 lines (37 loc) · 1.54 KB
/
fake_installation_state.h
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
// Copyright 2011 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_INSTALLER_UTIL_FAKE_INSTALLATION_STATE_H_
#define CHROME_INSTALLER_UTIL_FAKE_INSTALLATION_STATE_H_
#include "base/files/file_path.h"
#include "base/version.h"
#include "chrome/installer/util/fake_product_state.h"
#include "chrome/installer/util/helper.h"
#include "chrome/installer/util/installation_state.h"
#include "chrome/installer/util/util_constants.h"
namespace installer {
// An InstallationState helper for use by unit tests.
class FakeInstallationState : public InstallationState {
public:
// Takes ownership of |version|.
void AddChrome(bool system_install, base::Version* version) {
FakeProductState chrome_state;
chrome_state.set_version(version);
base::FilePath setup_exe(GetDefaultChromeInstallPath(system_install));
setup_exe = setup_exe.AppendASCII(version->GetString())
.Append(kInstallerDir)
.Append(kSetupExe);
chrome_state.SetUninstallProgram(setup_exe);
chrome_state.AddUninstallSwitch(switches::kUninstall);
SetProductState(system_install, chrome_state);
}
void SetProductState(bool system_install, const ProductState& product_state) {
GetProduct(system_install)->CopyFrom(product_state);
}
protected:
ProductState* GetProduct(bool system_install) {
return system_install ? &system_chrome_ : &user_chrome_;
}
};
} // namespace installer
#endif // CHROME_INSTALLER_UTIL_FAKE_INSTALLATION_STATE_H_