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 3 // found in the LICENSE file. 4 5 #ifndef CHROME_BROWSER_UI_COCOA_EXTENSIONS_EXTENSION_INSTALL_PROMPT_TEST_UTILS_H_ 6 #define CHROME_BROWSER_UI_COCOA_EXTENSIONS_EXTENSION_INSTALL_PROMPT_TEST_UTILS_H_ 7 8 #include "base/memory/ref_counted.h" 9 #include "chrome/browser/extensions/extension_install_prompt.h" 10 11 namespace chrome { 12 13 // A simple delegate implementation that counts the number of times 14 // |InstallUIProceed| and |InstallUIAbort| are called. 15 class MockExtensionInstallPromptDelegate 16 : public ExtensionInstallPrompt::Delegate { 17 public: MockExtensionInstallPromptDelegate()18 MockExtensionInstallPromptDelegate() 19 : proceed_count_(0), 20 abort_count_(0) {} 21 22 // ExtensionInstallPrompt::Delegate overrides. 23 virtual void InstallUIProceed() OVERRIDE; 24 virtual void InstallUIAbort(bool user_initiated) OVERRIDE; 25 proceed_count()26 int proceed_count() { return proceed_count_; } abort_count()27 int abort_count() { return abort_count_; } 28 29 protected: 30 int proceed_count_; 31 int abort_count_; 32 }; 33 34 // Loads the test extension from the given test directory and manifest file. 35 scoped_refptr<extensions::Extension> LoadInstallPromptExtension( 36 const char* extension_dir_name, 37 const char* manifest_file); 38 39 // Loads the default install_prompt test extension. 40 scoped_refptr<extensions::Extension> LoadInstallPromptExtension(); 41 42 // Loads the icon for the install prompt extension. 43 gfx::Image LoadInstallPromptIcon(); 44 45 // Builds a prompt using the given extension. 46 scoped_refptr<ExtensionInstallPrompt::Prompt> BuildExtensionInstallPrompt( 47 extensions::Extension* extension); 48 49 scoped_refptr<ExtensionInstallPrompt::Prompt> 50 BuildExtensionPostInstallPermissionsPrompt( 51 extensions::Extension* extension); 52 53 } // namespace chrome 54 55 #endif // CHROME_BROWSER_UI_COCOA_EXTENSIONS_EXTENSION_INSTALL_PROMPT_TEST_UTILS_H_ 56