[email protected] | e3e696d3 | 2013-06-21 20:41:36 | [diff] [blame] | 1 | // 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 | |||||
sorin | b120440b | 2015-04-27 16:34:15 | [diff] [blame] | 5 | #ifndef COMPONENTS_UPDATE_CLIENT_TEST_INSTALLER_H_ |
6 | #define COMPONENTS_UPDATE_CLIENT_TEST_INSTALLER_H_ | ||||
[email protected] | e3e696d3 | 2013-06-21 20:41:36 | [diff] [blame] | 7 | |
[email protected] | 28ea9ac | 2014-05-03 22:07:18 | [diff] [blame] | 8 | #include <string> |
9 | |||||
[email protected] | e3e696d3 | 2013-06-21 20:41:36 | [diff] [blame] | 10 | #include "base/files/file_path.h" |
sorin | 52ac088 | 2015-01-24 01:15:00 | [diff] [blame] | 11 | #include "components/update_client/update_client.h" |
[email protected] | e3e696d3 | 2013-06-21 20:41:36 | [diff] [blame] | 12 | |
13 | namespace base { | ||||
14 | class DictionaryValue; | ||||
15 | } | ||||
16 | |||||
sorin | 52ac088 | 2015-01-24 01:15:00 | [diff] [blame] | 17 | namespace update_client { |
[email protected] | 055981f | 2014-01-17 20:22:32 | [diff] [blame] | 18 | |
sorin | 9797aba | 2015-04-17 17:15:03 | [diff] [blame] | 19 | // TODO(sorin): consider reducing the number of the installer mocks. |
[email protected] | e3e696d3 | 2013-06-21 20:41:36 | [diff] [blame] | 20 | // A TestInstaller is an installer that does nothing for installation except |
21 | // increment a counter. | ||||
sorin | 9797aba | 2015-04-17 17:15:03 | [diff] [blame] | 22 | class TestInstaller : public CrxInstaller { |
[email protected] | e3e696d3 | 2013-06-21 20:41:36 | [diff] [blame] | 23 | public: |
[email protected] | de0fdca2 | 2014-08-19 05:26:09 | [diff] [blame] | 24 | TestInstaller(); |
[email protected] | e3e696d3 | 2013-06-21 20:41:36 | [diff] [blame] | 25 | |
dcheng | 00ea022b | 2014-10-21 11:24:56 | [diff] [blame] | 26 | void OnUpdateError(int error) override; |
[email protected] | e3e696d3 | 2013-06-21 20:41:36 | [diff] [blame] | 27 | |
dcheng | 00ea022b | 2014-10-21 11:24:56 | [diff] [blame] | 28 | bool Install(const base::DictionaryValue& manifest, |
29 | const base::FilePath& unpack_path) override; | ||||
[email protected] | e3e696d3 | 2013-06-21 20:41:36 | [diff] [blame] | 30 | |
dcheng | 00ea022b | 2014-10-21 11:24:56 | [diff] [blame] | 31 | bool GetInstalledFile(const std::string& file, |
32 | base::FilePath* installed_file) override; | ||||
[email protected] | e3e696d3 | 2013-06-21 20:41:36 | [diff] [blame] | 33 | |
bauerb | 1f6657e7 | 2015-02-09 00:00:27 | [diff] [blame] | 34 | bool Uninstall() override; |
35 | |||||
sorin | b120440b | 2015-04-27 16:34:15 | [diff] [blame] | 36 | int error() const { return error_; } |
[email protected] | e3e696d3 | 2013-06-21 20:41:36 | [diff] [blame] | 37 | |
sorin | b120440b | 2015-04-27 16:34:15 | [diff] [blame] | 38 | int install_count() const { return install_count_; } |
[email protected] | e3e696d3 | 2013-06-21 20:41:36 | [diff] [blame] | 39 | |
40 | protected: | ||||
bauerb | 810e60f4 | 2015-02-05 01:09:10 | [diff] [blame] | 41 | ~TestInstaller() override; |
42 | |||||
[email protected] | e3e696d3 | 2013-06-21 20:41:36 | [diff] [blame] | 43 | 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. | ||||
49 | class ReadOnlyTestInstaller : public TestInstaller { | ||||
50 | public: | ||||
51 | explicit ReadOnlyTestInstaller(const base::FilePath& installed_path); | ||||
52 | |||||
dcheng | 00ea022b | 2014-10-21 11:24:56 | [diff] [blame] | 53 | bool GetInstalledFile(const std::string& file, |
54 | base::FilePath* installed_file) override; | ||||
[email protected] | e3e696d3 | 2013-06-21 20:41:36 | [diff] [blame] | 55 | |
56 | private: | ||||
bauerb | 810e60f4 | 2015-02-05 01:09:10 | [diff] [blame] | 57 | ~ReadOnlyTestInstaller() override; |
58 | |||||
[email protected] | e3e696d3 | 2013-06-21 20:41:36 | [diff] [blame] | 59 | 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>). | ||||
64 | class VersionedTestInstaller : public TestInstaller { | ||||
[email protected] | d0c8b8b4 | 2014-05-06 05:11:45 | [diff] [blame] | 65 | public: |
[email protected] | de0fdca2 | 2014-08-19 05:26:09 | [diff] [blame] | 66 | VersionedTestInstaller(); |
[email protected] | e3e696d3 | 2013-06-21 20:41:36 | [diff] [blame] | 67 | |
dcheng | 00ea022b | 2014-10-21 11:24:56 | [diff] [blame] | 68 | bool Install(const base::DictionaryValue& manifest, |
69 | const base::FilePath& unpack_path) override; | ||||
[email protected] | e3e696d3 | 2013-06-21 20:41:36 | [diff] [blame] | 70 | |
dcheng | 00ea022b | 2014-10-21 11:24:56 | [diff] [blame] | 71 | bool GetInstalledFile(const std::string& file, |
72 | base::FilePath* installed_file) override; | ||||
[email protected] | e3e696d3 | 2013-06-21 20:41:36 | [diff] [blame] | 73 | |
74 | private: | ||||
bauerb | 810e60f4 | 2015-02-05 01:09:10 | [diff] [blame] | 75 | ~VersionedTestInstaller() override; |
76 | |||||
[email protected] | e3e696d3 | 2013-06-21 20:41:36 | [diff] [blame] | 77 | base::FilePath install_directory_; |
thakis | 37be69c | 2015-08-19 03:26:57 | [diff] [blame] | 78 | Version current_version_; |
[email protected] | e3e696d3 | 2013-06-21 20:41:36 | [diff] [blame] | 79 | }; |
80 | |||||
sorin | 52ac088 | 2015-01-24 01:15:00 | [diff] [blame] | 81 | } // namespace update_client |
[email protected] | 055981f | 2014-01-17 20:22:32 | [diff] [blame] | 82 | |
sorin | b120440b | 2015-04-27 16:34:15 | [diff] [blame] | 83 | #endif // COMPONENTS_UPDATE_CLIENT_TEST_INSTALLER_H_ |