OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2015 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_EXTENSIONS_EXTENSION_SERVICE_TEST_WITH_INSTALL_H_ | |
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_TEST_WITH_INSTALL_H_ | |
7 | |
8 #include <string> | |
9 | |
10 #include "base/files/file_path.h" | |
11 #include "chrome/browser/extensions/extension_service_test_base.h" | |
12 #include "content/public/browser/notification_observer.h" | |
13 #include "content/public/browser/notification_registrar.h" | |
14 #include "extensions/common/extension.h" | |
15 | |
16 namespace extensions { | |
17 | |
18 // An enhancement of ExtensionServiceTestBase that provides helpers to install, | |
19 // update, and uninstall extensions. | |
20 class ExtensionServiceTestWithInstall : public ExtensionServiceTestBase, | |
Marc Treib
2015/10/19 09:57:26
All this could have just been moved into Extension
Devlin
2015/10/20 17:42:15
I agree.
| |
21 public content::NotificationObserver { | |
22 public: | |
23 ExtensionServiceTestWithInstall(); | |
24 ~ExtensionServiceTestWithInstall() override; | |
25 | |
26 protected: | |
27 static std::vector<base::string16> GetErrors(); | |
28 | |
29 void PackCRX(const base::FilePath& dir_path, | |
30 const base::FilePath& pem_path, | |
31 const base::FilePath& crx_path); | |
32 | |
33 enum InstallState { | |
34 INSTALL_FAILED, | |
35 INSTALL_UPDATED, | |
36 INSTALL_NEW, | |
37 INSTALL_WITHOUT_LOAD, | |
38 }; | |
39 | |
40 const Extension* PackAndInstallCRX(const base::FilePath& dir_path, | |
41 const base::FilePath& pem_path, | |
42 InstallState install_state, | |
43 int creation_flags); | |
44 const Extension* PackAndInstallCRX(const base::FilePath& dir_path, | |
45 const base::FilePath& pem_path, | |
46 InstallState install_state); | |
47 const Extension* PackAndInstallCRX(const base::FilePath& dir_path, | |
48 InstallState install_state); | |
49 | |
50 const Extension* InstallCRX(const base::FilePath& path, | |
51 InstallState install_state, | |
52 int creation_flags, | |
53 const std::string& expected_old_name); | |
54 const Extension* InstallCRX(const base::FilePath& path, | |
55 InstallState install_state, | |
56 int creation_flags); | |
57 const Extension* InstallCRX(const base::FilePath& path, | |
58 InstallState install_state); | |
59 const Extension* InstallCRXFromWebStore(const base::FilePath& path, | |
60 InstallState install_state); | |
61 const Extension* InstallCRXWithLocation(const base::FilePath& crx_path, | |
62 Manifest::Location install_location, | |
63 InstallState install_state); | |
64 | |
65 const Extension* VerifyCrxInstall(const base::FilePath& path, | |
66 InstallState install_state); | |
67 const Extension* VerifyCrxInstall(const base::FilePath& path, | |
68 InstallState install_state, | |
69 const std::string& expected_old_name); | |
70 | |
71 enum UpdateState { | |
72 FAILED_SILENTLY, | |
73 FAILED, | |
74 UPDATED, | |
75 INSTALLED, | |
76 DISABLED, | |
77 ENABLED | |
78 }; | |
79 | |
80 void PackCRXAndUpdateExtension(const std::string& id, | |
81 const base::FilePath& dir_path, | |
82 const base::FilePath& pem_path, | |
83 UpdateState expected_state); | |
84 | |
85 void UpdateExtension(const std::string& id, | |
86 const base::FilePath& in_path, | |
87 UpdateState expected_state); | |
88 | |
89 void UninstallExtension(const std::string& id, bool use_helper); | |
90 void UninstallExtension(const std::string& id, | |
91 bool use_helper, | |
92 Extension::State expected_state); | |
93 | |
94 void TerminateExtension(const std::string& id); | |
95 | |
96 // TODO(treib,rdcronin): Make these private and add accessors as needed. | |
Devlin
2015/10/20 17:42:15
nit: s/rdcronin/devlin
Marc Treib
2015/10/21 12:51:54
Done.
| |
97 extensions::ExtensionList loaded_; | |
98 const Extension* installed_; | |
99 bool was_update_; | |
100 std::string old_name_; | |
101 std::string unloaded_id_; | |
102 UnloadedExtensionInfo::Reason unloaded_reason_; | |
103 | |
104 private: | |
105 void Observe(int type, | |
106 const content::NotificationSource& source, | |
107 const content::NotificationDetails& details) override; | |
108 | |
109 void InstallCRXInternal(const base::FilePath& crx_path, int creation_flags); | |
110 | |
111 content::NotificationRegistrar registrar_; | |
112 size_t expected_extensions_count_; | |
113 }; | |
114 | |
115 } // namespace extensions | |
116 | |
117 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_TEST_WITH_INSTALL_H_ | |
OLD | NEW |