blob: a12baf9bb7cd63072037b02795bdc2d5f2c7bc1d [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
Sorin Jianu990ee142017-06-02 22:34:088#include <memory>
[email protected]28ea9ac2014-05-03 22:07:189#include <string>
Sorin Jianua8ef73d2017-11-02 16:55:1710#include <utility>
[email protected]28ea9ac2014-05-03 22:07:1811
[email protected]e3e696d32013-06-21 20:41:3612#include "base/files/file_path.h"
sorin52ac0882015-01-24 01:15:0013#include "components/update_client/update_client.h"
[email protected]e3e696d32013-06-21 20:41:3614
sorin52ac0882015-01-24 01:15:0015namespace update_client {
[email protected]055981f2014-01-17 20:22:3216
sorin9797aba2015-04-17 17:15:0317// TODO(sorin): consider reducing the number of the installer mocks.
[email protected]e3e696d32013-06-21 20:41:3618// A TestInstaller is an installer that does nothing for installation except
19// increment a counter.
sorin9797aba2015-04-17 17:15:0320class TestInstaller : public CrxInstaller {
[email protected]e3e696d32013-06-21 20:41:3621 public:
[email protected]de0fdca22014-08-19 05:26:0922 TestInstaller();
[email protected]e3e696d32013-06-21 20:41:3623
dcheng00ea022b2014-10-21 11:24:5624 void OnUpdateError(int error) override;
[email protected]e3e696d32013-06-21 20:41:3625
Sorin Jianu7aa6d1f2017-10-13 20:29:2926 void Install(const base::FilePath& unpack_path,
Sorin Jianuea5534e92017-10-27 01:40:2827 const std::string& public_key,
Sorin Jianua8ef73d2017-11-02 16:55:1728 Callback callback) override;
[email protected]e3e696d32013-06-21 20:41:3629
dcheng00ea022b2014-10-21 11:24:5630 bool GetInstalledFile(const std::string& file,
31 base::FilePath* installed_file) override;
[email protected]e3e696d32013-06-21 20:41:3632
bauerb1f6657e72015-02-09 00:00:2733 bool Uninstall() override;
34
sorinb120440b2015-04-27 16:34:1535 int error() const { return error_; }
[email protected]e3e696d32013-06-21 20:41:3636
sorinb120440b2015-04-27 16:34:1537 int install_count() const { return install_count_; }
[email protected]e3e696d32013-06-21 20:41:3638
39 protected:
bauerb810e60f42015-02-05 01:09:1040 ~TestInstaller() override;
41
Sorin Jianua8ef73d2017-11-02 16:55:1742 void InstallComplete(Callback callback, const Result& result) const;
Sorin Jianuf40ab4b32017-10-06 22:53:4143
[email protected]e3e696d32013-06-21 20:41:3644 int error_;
45 int install_count_;
Sorin Jianu23f70f752017-05-30 16:21:5846
47 private:
48 // Contains the |unpack_path| argument of the Install call.
49 base::FilePath unpack_path_;
[email protected]e3e696d32013-06-21 20:41:3650};
51
52// A ReadOnlyTestInstaller is an installer that knows about files in an existing
53// directory. It will not write to the directory.
54class ReadOnlyTestInstaller : public TestInstaller {
55 public:
56 explicit ReadOnlyTestInstaller(const base::FilePath& installed_path);
57
dcheng00ea022b2014-10-21 11:24:5658 bool GetInstalledFile(const std::string& file,
59 base::FilePath* installed_file) override;
[email protected]e3e696d32013-06-21 20:41:3660
61 private:
bauerb810e60f42015-02-05 01:09:1062 ~ReadOnlyTestInstaller() override;
63
[email protected]e3e696d32013-06-21 20:41:3664 base::FilePath install_directory_;
65};
66
67// A VersionedTestInstaller is an installer that installs files into versioned
68// directories (e.g. somedir/25.23.89.141/<files>).
69class VersionedTestInstaller : public TestInstaller {
[email protected]d0c8b8b42014-05-06 05:11:4570 public:
[email protected]de0fdca22014-08-19 05:26:0971 VersionedTestInstaller();
[email protected]e3e696d32013-06-21 20:41:3672
Sorin Jianu7aa6d1f2017-10-13 20:29:2973 void Install(const base::FilePath& unpack_path,
Sorin Jianuea5534e92017-10-27 01:40:2874 const std::string& public_key,
Sorin Jianua8ef73d2017-11-02 16:55:1775 Callback callback) override;
[email protected]e3e696d32013-06-21 20:41:3676
dcheng00ea022b2014-10-21 11:24:5677 bool GetInstalledFile(const std::string& file,
78 base::FilePath* installed_file) override;
[email protected]e3e696d32013-06-21 20:41:3679
80 private:
bauerb810e60f42015-02-05 01:09:1081 ~VersionedTestInstaller() override;
82
[email protected]e3e696d32013-06-21 20:41:3683 base::FilePath install_directory_;
pwnalldb0b72412016-08-19 21:39:1284 base::Version current_version_;
[email protected]e3e696d32013-06-21 20:41:3685};
86
sorin52ac0882015-01-24 01:15:0087} // namespace update_client
[email protected]055981f2014-01-17 20:22:3288
sorinb120440b2015-04-27 16:34:1589#endif // COMPONENTS_UPDATE_CLIENT_TEST_INSTALLER_H_