ServiceWorker: Consolidate version manipulation functions in SWProviderContext
[chromium-blink-merge.git] / components / component_updater / test / test_installer.h
blobe44c48dc8361a3f24330564941c2c74314ad6d7c
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.
5 #ifndef CHROME_BROWSER_COMPONENT_UPDATER_TEST_TEST_INSTALLER_H_
6 #define CHROME_BROWSER_COMPONENT_UPDATER_TEST_TEST_INSTALLER_H_
8 #include <string>
10 #include "base/compiler_specific.h"
11 #include "base/files/file_path.h"
12 #include "components/component_updater/component_updater_service.h"
14 namespace base {
15 class DictionaryValue;
18 namespace component_updater {
20 // A TestInstaller is an installer that does nothing for installation except
21 // increment a counter.
22 class TestInstaller : public ComponentInstaller {
23 public:
24 TestInstaller();
26 void OnUpdateError(int error) override;
28 bool Install(const base::DictionaryValue& manifest,
29 const base::FilePath& unpack_path) override;
31 bool GetInstalledFile(const std::string& file,
32 base::FilePath* installed_file) override;
34 int error() const;
36 int install_count() const;
38 protected:
39 int error_;
40 int install_count_;
43 // A ReadOnlyTestInstaller is an installer that knows about files in an existing
44 // directory. It will not write to the directory.
45 class ReadOnlyTestInstaller : public TestInstaller {
46 public:
47 explicit ReadOnlyTestInstaller(const base::FilePath& installed_path);
49 ~ReadOnlyTestInstaller() override;
51 bool GetInstalledFile(const std::string& file,
52 base::FilePath* installed_file) override;
54 private:
55 base::FilePath install_directory_;
58 // A VersionedTestInstaller is an installer that installs files into versioned
59 // directories (e.g. somedir/25.23.89.141/<files>).
60 class VersionedTestInstaller : public TestInstaller {
61 public:
62 VersionedTestInstaller();
64 ~VersionedTestInstaller() override;
66 bool Install(const base::DictionaryValue& manifest,
67 const base::FilePath& unpack_path) override;
69 bool GetInstalledFile(const std::string& file,
70 base::FilePath* installed_file) override;
72 private:
73 base::FilePath install_directory_;
74 Version current_version_;
77 } // namespace component_updater
79 #endif // CHROME_BROWSER_COMPONENT_UPDATER_TEST_TEST_INSTALLER_H_