OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_TEST_API_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_TEST_TEST_API_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_TEST_API_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_TEST_TEST_API_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "chrome/browser/extensions/extension_function.h" | 10 #include "chrome/browser/extensions/extension_function.h" |
11 | 11 |
12 template <typename T> struct DefaultSingletonTraits; | 12 template <typename T> struct DefaultSingletonTraits; |
13 | 13 |
| 14 namespace extensions { |
| 15 |
14 // A function that is only available in tests. | 16 // A function that is only available in tests. |
15 // Prior to running, checks that we are in an extension process. | 17 // Prior to running, checks that we are in an extension process. |
16 class TestExtensionFunction : public SyncExtensionFunction { | 18 class TestExtensionFunction : public SyncExtensionFunction { |
17 protected: | 19 protected: |
18 virtual ~TestExtensionFunction(); | 20 virtual ~TestExtensionFunction(); |
19 | 21 |
20 // ExtensionFunction: | 22 // ExtensionFunction: |
21 virtual void Run() OVERRIDE; | 23 virtual void Run() OVERRIDE; |
22 }; | 24 }; |
23 | 25 |
24 class ExtensionTestPassFunction : public TestExtensionFunction { | 26 class TestNotifyPassFunction : public TestExtensionFunction { |
25 public: | 27 public: |
26 DECLARE_EXTENSION_FUNCTION_NAME("test.notifyPass") | 28 DECLARE_EXTENSION_FUNCTION_NAME("test.notifyPass") |
27 | 29 |
28 protected: | 30 protected: |
29 virtual ~ExtensionTestPassFunction(); | 31 virtual ~TestNotifyPassFunction(); |
30 | 32 |
31 // ExtensionFunction: | 33 // ExtensionFunction: |
32 virtual bool RunImpl() OVERRIDE; | 34 virtual bool RunImpl() OVERRIDE; |
33 }; | 35 }; |
34 | 36 |
35 class ExtensionTestFailFunction : public TestExtensionFunction { | 37 class TestFailFunction : public TestExtensionFunction { |
36 public: | 38 public: |
37 DECLARE_EXTENSION_FUNCTION_NAME("test.notifyFail") | 39 DECLARE_EXTENSION_FUNCTION_NAME("test.notifyFail") |
38 | 40 |
39 protected: | 41 protected: |
40 virtual ~ExtensionTestFailFunction(); | 42 virtual ~TestFailFunction(); |
41 | 43 |
42 // ExtensionFunction: | 44 // ExtensionFunction: |
43 virtual bool RunImpl() OVERRIDE; | 45 virtual bool RunImpl() OVERRIDE; |
44 }; | 46 }; |
45 | 47 |
46 class ExtensionTestLogFunction : public TestExtensionFunction { | 48 class TestLogFunction : public TestExtensionFunction { |
47 public: | 49 public: |
48 DECLARE_EXTENSION_FUNCTION_NAME("test.log") | 50 DECLARE_EXTENSION_FUNCTION_NAME("test.log") |
49 | 51 |
50 protected: | 52 protected: |
51 virtual ~ExtensionTestLogFunction(); | 53 virtual ~TestLogFunction(); |
52 | 54 |
53 // ExtensionFunction: | 55 // ExtensionFunction: |
54 virtual bool RunImpl() OVERRIDE; | 56 virtual bool RunImpl() OVERRIDE; |
55 }; | 57 }; |
56 | 58 |
57 class ExtensionTestQuotaResetFunction : public TestExtensionFunction { | 59 class TestResetQuotaFunction : public TestExtensionFunction { |
58 public: | 60 public: |
59 DECLARE_EXTENSION_FUNCTION_NAME("test.resetQuota") | 61 DECLARE_EXTENSION_FUNCTION_NAME("test.resetQuota") |
60 | 62 |
61 protected: | 63 protected: |
62 virtual ~ExtensionTestQuotaResetFunction(); | 64 virtual ~TestResetQuotaFunction(); |
63 | 65 |
64 // ExtensionFunction: | 66 // ExtensionFunction: |
65 virtual bool RunImpl() OVERRIDE; | 67 virtual bool RunImpl() OVERRIDE; |
66 }; | 68 }; |
67 | 69 |
68 class ExtensionTestCreateIncognitoTabFunction : public TestExtensionFunction { | 70 class TestCreateIncognitoTabFunction : public TestExtensionFunction { |
69 public: | 71 public: |
70 DECLARE_EXTENSION_FUNCTION_NAME("test.createIncognitoTab") | 72 DECLARE_EXTENSION_FUNCTION_NAME("test.createIncognitoTab") |
71 | 73 |
72 protected: | 74 protected: |
73 virtual ~ExtensionTestCreateIncognitoTabFunction(); | 75 virtual ~TestCreateIncognitoTabFunction(); |
74 | 76 |
75 // ExtensionFunction: | 77 // ExtensionFunction: |
76 virtual bool RunImpl() OVERRIDE; | 78 virtual bool RunImpl() OVERRIDE; |
77 }; | 79 }; |
78 | 80 |
79 class ExtensionTestSendMessageFunction : public AsyncExtensionFunction { | 81 class TestSendMessageFunction : public AsyncExtensionFunction { |
80 public: | 82 public: |
81 DECLARE_EXTENSION_FUNCTION_NAME("test.sendMessage") | 83 DECLARE_EXTENSION_FUNCTION_NAME("test.sendMessage") |
82 | 84 |
83 // Sends a reply back to the calling extension. Many extensions don't need | 85 // Sends a reply back to the calling extension. Many extensions don't need |
84 // a reply and will just ignore it. | 86 // a reply and will just ignore it. |
85 void Reply(const std::string& message); | 87 void Reply(const std::string& message); |
86 | 88 |
87 protected: | 89 protected: |
88 virtual ~ExtensionTestSendMessageFunction(); | 90 virtual ~TestSendMessageFunction(); |
89 | 91 |
90 // ExtensionFunction: | 92 // ExtensionFunction: |
91 virtual bool RunImpl() OVERRIDE; | 93 virtual bool RunImpl() OVERRIDE; |
92 }; | 94 }; |
93 | 95 |
94 class ExtensionTestGetConfigFunction : public SyncExtensionFunction { | 96 class TestGetConfigFunction : public SyncExtensionFunction { |
95 public: | 97 public: |
96 DECLARE_EXTENSION_FUNCTION_NAME("test.getConfig") | 98 DECLARE_EXTENSION_FUNCTION_NAME("test.getConfig") |
97 | 99 |
98 // Set the dictionary returned by chrome.test.getConfig(). | 100 // Set the dictionary returned by chrome.test.getConfig(). |
99 // Does not take ownership of |value|. | 101 // Does not take ownership of |value|. |
100 static void set_test_config_state(DictionaryValue* value); | 102 static void set_test_config_state(DictionaryValue* value); |
101 | 103 |
102 protected: | 104 protected: |
103 // Tests that set configuration state do so by calling | 105 // Tests that set configuration state do so by calling |
104 // set_test_config_state() as part of test set up, and unsetting it | 106 // set_test_config_state() as part of test set up, and unsetting it |
(...skipping 13 matching lines...) Expand all Loading... |
118 | 120 |
119 private: | 121 private: |
120 friend struct DefaultSingletonTraits<TestConfigState>; | 122 friend struct DefaultSingletonTraits<TestConfigState>; |
121 TestConfigState(); | 123 TestConfigState(); |
122 | 124 |
123 DictionaryValue* config_state_; | 125 DictionaryValue* config_state_; |
124 | 126 |
125 DISALLOW_COPY_AND_ASSIGN(TestConfigState); | 127 DISALLOW_COPY_AND_ASSIGN(TestConfigState); |
126 }; | 128 }; |
127 | 129 |
128 virtual ~ExtensionTestGetConfigFunction(); | 130 virtual ~TestGetConfigFunction(); |
129 | 131 |
130 // ExtensionFunction: | 132 // ExtensionFunction: |
131 virtual bool RunImpl() OVERRIDE; | 133 virtual bool RunImpl() OVERRIDE; |
132 }; | 134 }; |
133 | 135 |
134 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_TEST_API_H_ | 136 } // namespace extensions |
| 137 |
| 138 #endif // CHROME_BROWSER_EXTENSIONS_API_TEST_TEST_API_H_ |
OLD | NEW |