1 // Copyright (c) 2009 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_TEST_API_H_ 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_TEST_API_H_ 7 #pragma once 8 9 #include "base/values.h" 10 #include "chrome/browser/extensions/extension_function.h" 11 12 template <typename T> struct DefaultSingletonTraits; 13 14 class ExtensionTestPassFunction : public SyncExtensionFunction { 15 ~ExtensionTestPassFunction(); 16 virtual bool RunImpl(); 17 DECLARE_EXTENSION_FUNCTION_NAME("test.notifyPass") 18 }; 19 20 class ExtensionTestFailFunction : public SyncExtensionFunction { 21 ~ExtensionTestFailFunction(); 22 virtual bool RunImpl(); 23 DECLARE_EXTENSION_FUNCTION_NAME("test.notifyFail") 24 }; 25 26 class ExtensionTestLogFunction : public SyncExtensionFunction { 27 ~ExtensionTestLogFunction(); 28 virtual bool RunImpl(); 29 DECLARE_EXTENSION_FUNCTION_NAME("test.log") 30 }; 31 32 class ExtensionTestQuotaResetFunction : public SyncExtensionFunction { 33 ~ExtensionTestQuotaResetFunction(); 34 virtual bool RunImpl(); 35 DECLARE_EXTENSION_FUNCTION_NAME("test.resetQuota") 36 }; 37 38 class ExtensionTestCreateIncognitoTabFunction : public SyncExtensionFunction { 39 ~ExtensionTestCreateIncognitoTabFunction(); 40 virtual bool RunImpl(); 41 DECLARE_EXTENSION_FUNCTION_NAME("test.createIncognitoTab") 42 }; 43 44 class ExtensionTestSendMessageFunction : public AsyncExtensionFunction { 45 public: 46 // Sends a reply back to the calling extension. Many extensions don't need 47 // a reply and will just ignore it. 48 void Reply(const std::string& message); 49 50 private: 51 ~ExtensionTestSendMessageFunction(); 52 virtual bool RunImpl(); 53 DECLARE_EXTENSION_FUNCTION_NAME("test.sendMessage") 54 }; 55 56 class ExtensionTestGetConfigFunction : public SyncExtensionFunction { 57 public: 58 // Set the dictionary returned by chrome.test.getConfig(). 59 // Does not take ownership of |value|. 60 static void set_test_config_state(DictionaryValue* value); 61 62 private: 63 // Tests that set configuration state do so by calling 64 // set_test_config_state() as part of test set up, and unsetting it 65 // during tear down. This singleton class holds a pointer to that 66 // state, owned by the test code. 67 class TestConfigState { 68 public: 69 static TestConfigState* GetInstance(); 70 set_config_state(DictionaryValue * config_state)71 void set_config_state(DictionaryValue* config_state) { 72 config_state_ = config_state; 73 } config_state()74 const DictionaryValue* config_state() { 75 return config_state_; 76 } 77 private: 78 friend struct DefaultSingletonTraits<TestConfigState>; 79 TestConfigState(); 80 DictionaryValue* config_state_; 81 DISALLOW_COPY_AND_ASSIGN(TestConfigState); 82 }; 83 84 ~ExtensionTestGetConfigFunction(); 85 virtual bool RunImpl(); 86 DECLARE_EXTENSION_FUNCTION_NAME("test.getConfig") 87 }; 88 89 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_TEST_API_H_ 90