blob: b6ef1826e1b5aaefd1659eb4345ca6804a43b1d2 [file] [log] [blame]
[email protected]e3e696d32013-06-21 20:41:361// Copyright 2013 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
sorinb120440b2015-04-27 16:34:155#ifndef COMPONENTS_UPDATE_CLIENT_TEST_INSTALLER_H_
6#define COMPONENTS_UPDATE_CLIENT_TEST_INSTALLER_H_
[email protected]e3e696d32013-06-21 20:41:367
[email protected]28ea9ac2014-05-03 22:07:188#include <string>
9
[email protected]e3e696d32013-06-21 20:41:3610#include "base/files/file_path.h"
sorin52ac0882015-01-24 01:15:0011#include "components/update_client/update_client.h"
[email protected]e3e696d32013-06-21 20:41:3612
13namespace base {
14class DictionaryValue;
15}
16
sorin52ac0882015-01-24 01:15:0017namespace update_client {
[email protected]055981f2014-01-17 20:22:3218
sorin9797aba2015-04-17 17:15:0319// TODO(sorin): consider reducing the number of the installer mocks.
[email protected]e3e696d32013-06-21 20:41:3620// A TestInstaller is an installer that does nothing for installation except
21// increment a counter.
sorin9797aba2015-04-17 17:15:0322class TestInstaller : public CrxInstaller {
[email protected]e3e696d32013-06-21 20:41:3623 public:
[email protected]de0fdca22014-08-19 05:26:0924 TestInstaller();
[email protected]e3e696d32013-06-21 20:41:3625
dcheng00ea022b2014-10-21 11:24:5626 void OnUpdateError(int error) override;
[email protected]e3e696d32013-06-21 20:41:3627
dcheng00ea022b2014-10-21 11:24:5628 bool Install(const base::DictionaryValue& manifest,
29 const base::FilePath& unpack_path) override;
[email protected]e3e696d32013-06-21 20:41:3630
dcheng00ea022b2014-10-21 11:24:5631 bool GetInstalledFile(const std::string& file,
32 base::FilePath* installed_file) override;
[email protected]e3e696d32013-06-21 20:41:3633
bauerb1f6657e72015-02-09 00:00:2734 bool Uninstall() override;
35
sorinb120440b2015-04-27 16:34:1536 int error() const { return error_; }
[email protected]e3e696d32013-06-21 20:41:3637
sorinb120440b2015-04-27 16:34:1538 int install_count() const { return install_count_; }
[email protected]e3e696d32013-06-21 20:41:3639
40 protected:
bauerb810e60f42015-02-05 01:09:1041 ~TestInstaller() override;
42
[email protected]e3e696d32013-06-21 20:41:3643 int error_;
44 int install_count_;
45};
46
47// A ReadOnlyTestInstaller is an installer that knows about files in an existing
48// directory. It will not write to the directory.
49class ReadOnlyTestInstaller : public TestInstaller {
50 public:
51 explicit ReadOnlyTestInstaller(const base::FilePath& installed_path);
52
dcheng00ea022b2014-10-21 11:24:5653 bool GetInstalledFile(const std::string& file,
54 base::FilePath* installed_file) override;
[email protected]e3e696d32013-06-21 20:41:3655
56 private:
bauerb810e60f42015-02-05 01:09:1057 ~ReadOnlyTestInstaller() override;
58
[email protected]e3e696d32013-06-21 20:41:3659 base::FilePath install_directory_;
60};
61
62// A VersionedTestInstaller is an installer that installs files into versioned
63// directories (e.g. somedir/25.23.89.141/<files>).
64class VersionedTestInstaller : public TestInstaller {
[email protected]d0c8b8b42014-05-06 05:11:4565 public:
[email protected]de0fdca22014-08-19 05:26:0966 VersionedTestInstaller();
[email protected]e3e696d32013-06-21 20:41:3667
dcheng00ea022b2014-10-21 11:24:5668 bool Install(const base::DictionaryValue& manifest,
69 const base::FilePath& unpack_path) override;
[email protected]e3e696d32013-06-21 20:41:3670
dcheng00ea022b2014-10-21 11:24:5671 bool GetInstalledFile(const std::string& file,
72 base::FilePath* installed_file) override;
[email protected]e3e696d32013-06-21 20:41:3673
74 private:
bauerb810e60f42015-02-05 01:09:1075 ~VersionedTestInstaller() override;
76
[email protected]e3e696d32013-06-21 20:41:3677 base::FilePath install_directory_;
thakis37be69c2015-08-19 03:26:5778 Version current_version_;
[email protected]e3e696d32013-06-21 20:41:3679};
80
sorin52ac0882015-01-24 01:15:0081} // namespace update_client
[email protected]055981f2014-01-17 20:22:3282
sorinb120440b2015-04-27 16:34:1583#endif // COMPONENTS_UPDATE_CLIENT_TEST_INSTALLER_H_