OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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_INSTALL_PROMPT_TEST_HELPER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_PROMPT_TEST_HELPER_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_PROMPT_TEST_HELPER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_PROMPT_TEST_HELPER_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "chrome/browser/extensions/extension_install_prompt.h" | 9 #include "chrome/browser/extensions/extension_install_prompt.h" |
10 | 10 |
11 // A helper class to be used with ExtensionInstallPrompt that keeps track of the | 11 // A helper class to be used with ExtensionInstallPrompt that keeps track of the |
12 // result. Note that this class does no lifetime management. | 12 // result. Note that this class does no lifetime management. |
13 class ExtensionInstallPromptTestHelper { | 13 class ExtensionInstallPromptTestHelper { |
14 public: | 14 public: |
15 ExtensionInstallPromptTestHelper(); | 15 ExtensionInstallPromptTestHelper(); |
16 explicit ExtensionInstallPromptTestHelper(const base::Closure& quit_closure); | 16 explicit ExtensionInstallPromptTestHelper(const base::Closure& quit_closure); |
17 ~ExtensionInstallPromptTestHelper(); | 17 ~ExtensionInstallPromptTestHelper(); |
18 | 18 |
19 // Returns a callback to be used with the ExtensionInstallPrompt. | 19 // Returns a callback to be used with the ExtensionInstallPrompt. |
20 ExtensionInstallPrompt::DoneCallback GetCallback(); | 20 ExtensionInstallPrompt::DoneCallback GetCallback(); |
21 | 21 |
22 // Note: This ADD_FAILURE()s if result_ has not been set. | 22 // Note: This ADD_FAILURE()s if result_ has not been set. |
23 ExtensionInstallPrompt::Result result() const; | 23 ExtensionInstallPrompt::Result result() const; |
24 | 24 |
25 bool has_result() const { return result_.get() != nullptr; } | 25 bool has_result() const { return result_ != nullptr; } |
26 | 26 |
27 private: | 27 private: |
28 void HandleResult(ExtensionInstallPrompt::Result result); | 28 void HandleResult(ExtensionInstallPrompt::Result result); |
29 | 29 |
30 std::unique_ptr<ExtensionInstallPrompt::Result> result_; | 30 std::unique_ptr<ExtensionInstallPrompt::Result> result_; |
31 | 31 |
32 // A closure to run once HandleResult() has been called; used for exiting | 32 // A closure to run once HandleResult() has been called; used for exiting |
33 // run loops in tests. | 33 // run loops in tests. |
34 base::Closure quit_closure_; | 34 base::Closure quit_closure_; |
35 | 35 |
36 DISALLOW_COPY_AND_ASSIGN(ExtensionInstallPromptTestHelper); | 36 DISALLOW_COPY_AND_ASSIGN(ExtensionInstallPromptTestHelper); |
37 }; | 37 }; |
38 | 38 |
39 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_PROMPT_TEST_HELPER_H_ | 39 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_PROMPT_TEST_HELPER_H_ |
OLD | NEW |