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

Side by Side Diff: chrome/test/base/view_event_test_base.h

Issue 1228213003: Just set borders once when creating a views::LabelButton (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: self review Created 5 years, 5 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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_TEST_BASE_VIEW_EVENT_TEST_BASE_H_ 5 #ifndef CHROME_TEST_BASE_VIEW_EVENT_TEST_BASE_H_
6 #define CHROME_TEST_BASE_VIEW_EVENT_TEST_BASE_H_ 6 #define CHROME_TEST_BASE_VIEW_EVENT_TEST_BASE_H_
7 7
8 // We only want to use ViewEventTestBase in test targets which properly 8 // We only want to use ViewEventTestBase in test targets which properly
9 // isolate each test case by running each test in a separate process. 9 // isolate each test case by running each test in a separate process.
10 // This way if a test hangs the test launcher can reliably terminate it. 10 // This way if a test hangs the test launcher can reliably terminate it.
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 void Done(); 78 void Done();
79 79
80 static void SetUpTestCase(); 80 static void SetUpTestCase();
81 81
82 // Creates a window. 82 // Creates a window.
83 void SetUp() override; 83 void SetUp() override;
84 84
85 // Destroys the window. 85 // Destroys the window.
86 void TearDown() override; 86 void TearDown() override;
87 87
88 // Returns an empty Size. Subclasses that want a preferred size other than
89 // that of the View returned by CreateContentsView should override this
90 // appropriately.
91 virtual gfx::Size GetPreferredSize() const;
92
88 // Overridden from views::WidgetDelegate: 93 // Overridden from views::WidgetDelegate:
89 bool CanResize() const override; 94 bool CanResize() const override;
90 views::View* GetContentsView() override; 95 views::View* GetContentsView() override;
91 const views::Widget* GetWidget() const override; 96 const views::Widget* GetWidget() const override;
92 views::Widget* GetWidget() override; 97 views::Widget* GetWidget() override;
93 98
94 // Overridden to do nothing so that this class can be used in runnable tasks. 99 // Overridden to do nothing so that this class can be used in runnable tasks.
95 void AddRef() {} 100 void AddRef() {}
96 void Release() {} 101 void Release() {}
97 102
98 protected: 103 protected:
99 ~ViewEventTestBase() override; 104 ~ViewEventTestBase() override;
100 105
101 // Returns the view that is added to the window. 106 // Returns the view that is added to the window.
102 virtual views::View* CreateContentsView() = 0; 107 virtual views::View* CreateContentsView() = 0;
103 108
104 // Called once the message loop is running. 109 // Called once the message loop is running.
105 virtual void DoTestOnMessageLoop() = 0; 110 virtual void DoTestOnMessageLoop() = 0;
106 111
107 // Invoke from test main. Shows the window, starts the message loop and 112 // Invoke from test main. Shows the window, starts the message loop and
108 // schedules a task that invokes DoTestOnMessageLoop. 113 // schedules a task that invokes DoTestOnMessageLoop.
109 void StartMessageLoopAndRunTest(); 114 void StartMessageLoopAndRunTest();
110 115
111 // Returns an empty Size. Subclasses that want a preferred size other than
112 // that of the View returned by CreateContentsView should override this
113 // appropriately.
114 virtual gfx::Size GetPreferredSize() const;
115
116 // Creates a task that calls the specified method back. The specified 116 // Creates a task that calls the specified method back. The specified
117 // method is called in such a way that if there are any test failures 117 // method is called in such a way that if there are any test failures
118 // Done is invoked. 118 // Done is invoked.
119 template <class T, class Method> 119 template <class T, class Method>
120 base::Closure CreateEventTask(T* target, Method method) { 120 base::Closure CreateEventTask(T* target, Method method) {
121 return base::Bind(&ViewEventTestBase::RunTestMethod, this, 121 return base::Bind(&ViewEventTestBase::RunTestMethod, this,
122 base::Bind(method, target)); 122 base::Bind(method, target));
123 } 123 }
124 124
125 // Spawns a new thread posts a MouseMove in the background. 125 // Spawns a new thread posts a MouseMove in the background.
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 // Convenience macro for defining a ViewEventTestBase. See class description 159 // Convenience macro for defining a ViewEventTestBase. See class description
160 // of ViewEventTestBase for details. 160 // of ViewEventTestBase for details.
161 #define VIEW_TEST(test_class, name) \ 161 #define VIEW_TEST(test_class, name) \
162 TEST_F(test_class, name) {\ 162 TEST_F(test_class, name) {\
163 StartMessageLoopAndRunTest();\ 163 StartMessageLoopAndRunTest();\
164 } 164 }
165 165
166 #endif // defined(HAS_OUT_OF_PROC_TEST_RUNNER) 166 #endif // defined(HAS_OUT_OF_PROC_TEST_RUNNER)
167 167
168 #endif // CHROME_TEST_BASE_VIEW_EVENT_TEST_BASE_H_ 168 #endif // CHROME_TEST_BASE_VIEW_EVENT_TEST_BASE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698