Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 106 | 106 |
| 107 // Invoke from test main. Shows the window, starts the message loop and | 107 // Invoke from test main. Shows the window, starts the message loop and |
| 108 // schedules a task that invokes DoTestOnMessageLoop. | 108 // schedules a task that invokes DoTestOnMessageLoop. |
| 109 void StartMessageLoopAndRunTest(); | 109 void StartMessageLoopAndRunTest(); |
| 110 | 110 |
| 111 // Returns an empty Size. Subclasses that want a preferred size other than | 111 // Returns an empty Size. Subclasses that want a preferred size other than |
| 112 // that of the View returned by CreateContentsView should override this | 112 // that of the View returned by CreateContentsView should override this |
| 113 // appropriately. | 113 // appropriately. |
| 114 virtual gfx::Size GetPreferredSize() const; | 114 virtual gfx::Size GetPreferredSize() const; |
| 115 | 115 |
| 116 // Creates a task that calls the specified method back. The specified | 116 // Creates a task that calls the specified |method| on instance |target|. The |
| 117 // method is called in such a way that if there are any test failures | 117 // specified method is called in such a way that if there are any test |
| 118 // Done is invoked. | 118 // failures 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 // Creates a task that calls the specified |closure|. The specified closure | |
| 126 // is called in such a way that if there are any test failures Done is | |
| 127 // invoked. | |
| 128 base::Closure CreateEventTask(base::Closure closure) { | |
|
sadrul
2015/05/14 08:04:35
const &?
| |
| 129 return base::Bind(&ViewEventTestBase::RunTestMethod, this, closure); | |
| 130 } | |
| 131 | |
| 125 // Spawns a new thread posts a MouseMove in the background. | 132 // Spawns a new thread posts a MouseMove in the background. |
| 126 void ScheduleMouseMoveInBackground(int x, int y); | 133 void ScheduleMouseMoveInBackground(int x, int y); |
| 127 | 134 |
| 128 views::Widget* window_; | 135 views::Widget* window_; |
| 129 | 136 |
| 130 private: | 137 private: |
| 131 // Stops the thread started by ScheduleMouseMoveInBackground. | 138 // Stops the thread started by ScheduleMouseMoveInBackground. |
| 132 void StopBackgroundThread(); | 139 void StopBackgroundThread(); |
| 133 | 140 |
| 134 // Callback from CreateEventTask. Stops the background thread, runs the | 141 // Callback from CreateEventTask. Stops the background thread, runs the |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 159 // Convenience macro for defining a ViewEventTestBase. See class description | 166 // Convenience macro for defining a ViewEventTestBase. See class description |
| 160 // of ViewEventTestBase for details. | 167 // of ViewEventTestBase for details. |
| 161 #define VIEW_TEST(test_class, name) \ | 168 #define VIEW_TEST(test_class, name) \ |
| 162 TEST_F(test_class, name) {\ | 169 TEST_F(test_class, name) {\ |
| 163 StartMessageLoopAndRunTest();\ | 170 StartMessageLoopAndRunTest();\ |
| 164 } | 171 } |
| 165 | 172 |
| 166 #endif // defined(HAS_OUT_OF_PROC_TEST_RUNNER) | 173 #endif // defined(HAS_OUT_OF_PROC_TEST_RUNNER) |
| 167 | 174 |
| 168 #endif // CHROME_TEST_BASE_VIEW_EVENT_TEST_BASE_H_ | 175 #endif // CHROME_TEST_BASE_VIEW_EVENT_TEST_BASE_H_ |
| OLD | NEW |