• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 CHROME_BROWSER_COMPONENT_UPDATER_TEST_TEST_INSTALLER_H_
6 #define CHROME_BROWSER_COMPONENT_UPDATER_TEST_TEST_INSTALLER_H_
7 
8 #include "base/compiler_specific.h"
9 #include "base/files/file_path.h"
10 #include "chrome/browser/component_updater/component_updater_service.h"
11 
12 namespace base {
13 class DictionaryValue;
14 }
15 
16 // A TestInstaller is an installer that does nothing for installation except
17 // increment a counter.
18 class TestInstaller : public ComponentInstaller {
19  public:
20   explicit TestInstaller();
21 
22   virtual void OnUpdateError(int error) OVERRIDE;
23 
24   virtual bool Install(const base::DictionaryValue& manifest,
25                        const base::FilePath& unpack_path) OVERRIDE;
26 
27   virtual bool GetInstalledFile(const std::string& file,
28                                 base::FilePath* installed_file) OVERRIDE;
29 
30   int error() const;
31 
32   int install_count() const;
33 
34  protected:
35   int error_;
36   int install_count_;
37 };
38 
39 // A ReadOnlyTestInstaller is an installer that knows about files in an existing
40 // directory. It will not write to the directory.
41 class ReadOnlyTestInstaller : public TestInstaller {
42  public:
43   explicit ReadOnlyTestInstaller(const base::FilePath& installed_path);
44 
45   virtual ~ReadOnlyTestInstaller();
46 
47   virtual bool GetInstalledFile(const std::string& file,
48                                 base::FilePath* installed_file) OVERRIDE;
49 
50  private:
51   base::FilePath install_directory_;
52 };
53 
54 // A VersionedTestInstaller is an installer that installs files into versioned
55 // directories (e.g. somedir/25.23.89.141/<files>).
56 class VersionedTestInstaller : public TestInstaller {
57  public :
58   explicit VersionedTestInstaller();
59 
60   virtual ~VersionedTestInstaller();
61 
62   virtual bool Install(const base::DictionaryValue& manifest,
63                        const base::FilePath& unpack_path) OVERRIDE;
64 
65   virtual bool GetInstalledFile(const std::string& file,
66                                 base::FilePath* installed_file) OVERRIDE;
67 
68  private:
69   base::FilePath install_directory_;
70   Version current_version_;
71 };
72 
73 #endif  // CHROME_BROWSER_COMPONENT_UPDATER_TEST_TEST_INSTALLER_H_
74