OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_UI_TEST_TEST_BROWSER_DIALOG_H_ | 5 #ifndef CHROME_BROWSER_UI_TEST_TEST_BROWSER_DIALOG_H_ |
6 #define CHROME_BROWSER_UI_TEST_TEST_BROWSER_DIALOG_H_ | 6 #define CHROME_BROWSER_UI_TEST_TEST_BROWSER_DIALOG_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 class TestBrowserDialog { | 57 class TestBrowserDialog { |
58 protected: | 58 protected: |
59 TestBrowserDialog(); | 59 TestBrowserDialog(); |
60 | 60 |
61 // Runs the dialog whose name corresponds to the current test case. | 61 // Runs the dialog whose name corresponds to the current test case. |
62 void RunDialog(); | 62 void RunDialog(); |
63 | 63 |
64 // Show the dialog corresponding to |name| and leave it open. | 64 // Show the dialog corresponding to |name| and leave it open. |
65 virtual void ShowDialog(const std::string& name) = 0; | 65 virtual void ShowDialog(const std::string& name) = 0; |
66 | 66 |
67 // Whether to always close asynchronously using Widget::Close(). This covers | |
68 // codepaths relying on DialogDelegate::Close(), which isn't invoked by | |
69 // Widget::CloseNow(). Dialogs should support both, since the OS can initiate | |
70 // the destruction of dialogs, e.g., during logoff which bypass | |
71 // Widget::CanClose() and DialogDelegate::Close(). | |
72 virtual bool AlwaysCloseAsynchronously(); | |
73 | |
74 private: | 67 private: |
75 DISALLOW_COPY_AND_ASSIGN(TestBrowserDialog); | 68 DISALLOW_COPY_AND_ASSIGN(TestBrowserDialog); |
76 }; | 69 }; |
77 | 70 |
78 // Helper to mix in a TestBrowserDialog to an existing test harness. |Base| | 71 // Helper to mix in a TestBrowserDialog to an existing test harness. |Base| |
79 // must be a descendant of InProcessBrowserTest. | 72 // must be a descendant of InProcessBrowserTest. |
80 template <class Base> | 73 template <class Base> |
81 class SupportsTestDialog : public Base, public TestBrowserDialog { | 74 class SupportsTestDialog : public Base, public TestBrowserDialog { |
82 protected: | 75 protected: |
83 SupportsTestDialog() {} | 76 SupportsTestDialog() {} |
84 | 77 |
85 private: | 78 private: |
86 DISALLOW_COPY_AND_ASSIGN(SupportsTestDialog); | 79 DISALLOW_COPY_AND_ASSIGN(SupportsTestDialog); |
87 }; | 80 }; |
88 | 81 |
89 using DialogBrowserTest = SupportsTestDialog<InProcessBrowserTest>; | 82 using DialogBrowserTest = SupportsTestDialog<InProcessBrowserTest>; |
90 | 83 |
91 namespace internal { | 84 namespace internal { |
92 | 85 |
93 // When present on the command line, runs the test in an interactive mode. | 86 // When present on the command line, runs the test in an interactive mode. |
94 constexpr const char kInteractiveSwitch[] = "interactive"; | 87 constexpr const char kInteractiveSwitch[] = "interactive"; |
95 | 88 |
96 } // namespace internal | 89 } // namespace internal |
97 | 90 |
98 #endif // CHROME_BROWSER_UI_TEST_TEST_BROWSER_DIALOG_H_ | 91 #endif // CHROME_BROWSER_UI_TEST_TEST_BROWSER_DIALOG_H_ |
OLD | NEW |