| OLD | NEW |
| (Empty) |
| 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 | |
| 5 #ifndef COMPONENTS_UPDATE_CLIENT_TEST_TEST_INSTALLER_H_ | |
| 6 #define COMPONENTS_UPDATE_CLIENT_TEST_TEST_INSTALLER_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 10 #include "base/compiler_specific.h" | |
| 11 #include "base/files/file_path.h" | |
| 12 #include "components/update_client/update_client.h" | |
| 13 | |
| 14 namespace base { | |
| 15 class DictionaryValue; | |
| 16 } | |
| 17 | |
| 18 namespace update_client { | |
| 19 | |
| 20 // TODO(sorin): consider reducing the number of the installer mocks. | |
| 21 // A TestInstaller is an installer that does nothing for installation except | |
| 22 // increment a counter. | |
| 23 class TestInstaller : public CrxInstaller { | |
| 24 public: | |
| 25 TestInstaller(); | |
| 26 | |
| 27 void OnUpdateError(int error) override; | |
| 28 | |
| 29 bool Install(const base::DictionaryValue& manifest, | |
| 30 const base::FilePath& unpack_path) override; | |
| 31 | |
| 32 bool GetInstalledFile(const std::string& file, | |
| 33 base::FilePath* installed_file) override; | |
| 34 | |
| 35 bool Uninstall() override; | |
| 36 | |
| 37 int error() const { | |
| 38 return error_; | |
| 39 } | |
| 40 | |
| 41 int install_count() const { | |
| 42 return install_count_; | |
| 43 } | |
| 44 | |
| 45 protected: | |
| 46 ~TestInstaller() override; | |
| 47 | |
| 48 int error_; | |
| 49 int install_count_; | |
| 50 }; | |
| 51 | |
| 52 // A ReadOnlyTestInstaller is an installer that knows about files in an existing | |
| 53 // directory. It will not write to the directory. | |
| 54 class ReadOnlyTestInstaller : public TestInstaller { | |
| 55 public: | |
| 56 explicit ReadOnlyTestInstaller(const base::FilePath& installed_path); | |
| 57 | |
| 58 bool GetInstalledFile(const std::string& file, | |
| 59 base::FilePath* installed_file) override; | |
| 60 | |
| 61 private: | |
| 62 ~ReadOnlyTestInstaller() override; | |
| 63 | |
| 64 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>). | |
| 69 class VersionedTestInstaller : public TestInstaller { | |
| 70 public: | |
| 71 VersionedTestInstaller(); | |
| 72 | |
| 73 bool Install(const base::DictionaryValue& manifest, | |
| 74 const base::FilePath& unpack_path) override; | |
| 75 | |
| 76 bool GetInstalledFile(const std::string& file, | |
| 77 base::FilePath* installed_file) override; | |
| 78 | |
| 79 private: | |
| 80 ~VersionedTestInstaller() override; | |
| 81 | |
| 82 base::FilePath install_directory_; | |
| 83 Version current_version_; | |
| 84 }; | |
| 85 | |
| 86 } // namespace update_client | |
| 87 | |
| 88 #endif // COMPONENTS_UPDATE_CLIENT_TEST_TEST_INSTALLER_H_ | |
| OLD | NEW |