Roll src/third_party/skia de7665a:76033be
[chromium-blink-merge.git] / components / update_client / test / test_installer.h
bloba31c4994d5ea0feb8debadb247d9494c1ec802c1
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 COMPONENTS_UPDATE_CLIENT_TEST_TEST_INSTALLER_H_
6 #define COMPONENTS_UPDATE_CLIENT_TEST_TEST_INSTALLER_H_
8 #include <string>
10 #include "base/compiler_specific.h"
11 #include "base/files/file_path.h"
12 #include "components/update_client/update_client.h"
14 namespace base {
15 class DictionaryValue;
18 namespace update_client {
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 bool Uninstall() override;
36 int error() const {
37 return error_;
40 int install_count() const {
41 return install_count_;
44 protected:
45 ~TestInstaller() override;
47 int error_;
48 int install_count_;
51 // A ReadOnlyTestInstaller is an installer that knows about files in an existing
52 // directory. It will not write to the directory.
53 class ReadOnlyTestInstaller : public TestInstaller {
54 public:
55 explicit ReadOnlyTestInstaller(const base::FilePath& installed_path);
57 bool GetInstalledFile(const std::string& file,
58 base::FilePath* installed_file) override;
60 private:
61 ~ReadOnlyTestInstaller() override;
63 base::FilePath install_directory_;
66 // A VersionedTestInstaller is an installer that installs files into versioned
67 // directories (e.g. somedir/25.23.89.141/<files>).
68 class VersionedTestInstaller : public TestInstaller {
69 public:
70 VersionedTestInstaller();
72 bool Install(const base::DictionaryValue& manifest,
73 const base::FilePath& unpack_path) override;
75 bool GetInstalledFile(const std::string& file,
76 base::FilePath* installed_file) override;
78 private:
79 ~VersionedTestInstaller() override;
81 base::FilePath install_directory_;
82 Version current_version_;
85 } // namespace update_client
87 #endif // COMPONENTS_UPDATE_CLIENT_TEST_TEST_INSTALLER_H_