Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(194)

Side by Side Diff: chrome/browser/ui/test/test_browser_dialog.h

Issue 2660813002: Add WidgetTest::GetAllWidgets() to find dialogs created by TestBrowserDialog. (Closed)
Patch Set: respond to comments Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/ui/test/test_browser_dialog.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "chrome/browser/ui/browser_window.h"
13 #include "chrome/test/base/in_process_browser_test.h" 12 #include "chrome/test/base/in_process_browser_test.h"
14 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
15 #include "ui/gfx/native_widget_types.h" 14 #include "ui/gfx/native_widget_types.h"
16 15
17 // TestBrowserDialog provides a way to register an InProcessBrowserTest testing 16 // TestBrowserDialog provides a way to register an InProcessBrowserTest testing
18 // harness with a framework that invokes Chrome browser dialogs in a consistent 17 // harness with a framework that invokes Chrome browser dialogs in a consistent
19 // way. It optionally provides a way to invoke dialogs "interactively". This 18 // way. It optionally provides a way to invoke dialogs "interactively". This
20 // allows screenshots to be generated easily, with the same test data, to assist 19 // allows screenshots to be generated easily, with the same test data, to assist
21 // with UI review. It also provides a registry of dialogs so they can be 20 // with UI review. It also provides a registry of dialogs so they can be
22 // systematically checked for subtle changes and regressions. 21 // systematically checked for subtle changes and regressions.
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 class TestBrowserDialog { 57 class TestBrowserDialog {
59 protected: 58 protected:
60 TestBrowserDialog(); 59 TestBrowserDialog();
61 60
62 // Runs the dialog whose name corresponds to the current test case. 61 // Runs the dialog whose name corresponds to the current test case.
63 void RunDialog(); 62 void RunDialog();
64 63
65 // Show the dialog corresponding to |name| and leave it open. 64 // Show the dialog corresponding to |name| and leave it open.
66 virtual void ShowDialog(const std::string& name) = 0; 65 virtual void ShowDialog(const std::string& name) = 0;
67 66
68 // The window that owns the dialogs. Used to find where the dialog appears.
69 virtual gfx::NativeWindow DialogParent() = 0;
70
71 private: 67 private:
72 DISALLOW_COPY_AND_ASSIGN(TestBrowserDialog); 68 DISALLOW_COPY_AND_ASSIGN(TestBrowserDialog);
73 }; 69 };
74 70
75 // 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|
76 // must be a descendant of InProcessBrowserTest. 72 // must be a descendant of InProcessBrowserTest.
77 template <class Base> 73 template <class Base>
78 class SupportsTestDialog : public Base, public TestBrowserDialog { 74 class SupportsTestDialog : public Base, public TestBrowserDialog {
79 protected: 75 protected:
80 SupportsTestDialog() {} 76 SupportsTestDialog() {}
81 77
82 // TestBrowserDialog:
83 gfx::NativeWindow DialogParent() override {
84 return this->browser()->window()->GetNativeWindow();
85 }
86
87 private: 78 private:
88 DISALLOW_COPY_AND_ASSIGN(SupportsTestDialog); 79 DISALLOW_COPY_AND_ASSIGN(SupportsTestDialog);
89 }; 80 };
90 81
91 using DialogBrowserTest = SupportsTestDialog<InProcessBrowserTest>; 82 using DialogBrowserTest = SupportsTestDialog<InProcessBrowserTest>;
92 83
93 namespace internal { 84 namespace internal {
94 85
95 // 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.
96 constexpr const char kInteractiveSwitch[] = "interactive"; 87 constexpr const char kInteractiveSwitch[] = "interactive";
97 88
98 } // namespace internal 89 } // namespace internal
99 90
100 #endif // CHROME_BROWSER_UI_TEST_TEST_BROWSER_DIALOG_H_ 91 #endif // CHROME_BROWSER_UI_TEST_TEST_BROWSER_DIALOG_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/test/test_browser_dialog.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698