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

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

Issue 8585015: Implement ui_controls for aura (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: no mask for xsendevent Created 9 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #include "chrome/test/base/view_event_test_base.h" 5 #include "chrome/test/base/view_event_test_base.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <ole2.h> 8 #include <ole2.h>
9 #endif 9 #endif
10 10
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 #endif 81 #endif
82 window_ = views::Widget::CreateWindow(this); 82 window_ = views::Widget::CreateWindow(this);
83 } 83 }
84 84
85 void ViewEventTestBase::TearDown() { 85 void ViewEventTestBase::TearDown() {
86 if (window_) { 86 if (window_) {
87 #if defined(OS_WIN) 87 #if defined(OS_WIN)
88 DestroyWindow(window_->GetNativeWindow()); 88 DestroyWindow(window_->GetNativeWindow());
89 #else 89 #else
90 window_->Close(); 90 window_->Close();
91 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); 91 ui_test_utils::RunAllPendingInMessageLoop();
92 ui_test_utils::RunMessageLoop();
93 #endif 92 #endif
94 window_ = NULL; 93 window_ = NULL;
95 } 94 }
96 #if defined(OS_WIN) 95 #if defined(OS_WIN)
97 OleUninitialize(); 96 OleUninitialize();
98 #endif 97 #endif
99 } 98 }
100 99
101 bool ViewEventTestBase::CanResize() const { 100 bool ViewEventTestBase::CanResize() const {
102 return true; 101 return true;
(...skipping 24 matching lines...) Expand all
127 126
128 void ViewEventTestBase::StartMessageLoopAndRunTest() { 127 void ViewEventTestBase::StartMessageLoopAndRunTest() {
129 window_->Show(); 128 window_->Show();
130 // Make sure the window is the foreground window, otherwise none of the 129 // Make sure the window is the foreground window, otherwise none of the
131 // mouse events are going to be targeted correctly. 130 // mouse events are going to be targeted correctly.
132 #if defined(OS_WIN) 131 #if defined(OS_WIN)
133 SetForegroundWindow(window_->GetNativeWindow()); 132 SetForegroundWindow(window_->GetNativeWindow());
134 #endif 133 #endif
135 134
136 // Flush any pending events to make sure we start with a clean slate. 135 // Flush any pending events to make sure we start with a clean slate.
137 MessageLoop::current()->RunAllPending(); 136 ui_test_utils::RunAllPendingInMessageLoop();
138 137
139 // Schedule a task that starts the test. Need to do this as we're going to 138 // Schedule a task that starts the test. Need to do this as we're going to
140 // run the message loop. 139 // run the message loop.
141 MessageLoop::current()->PostTask( 140 MessageLoop::current()->PostTask(
142 FROM_HERE, 141 FROM_HERE,
143 base::Bind(&ViewEventTestBase::DoTestOnMessageLoop, this)); 142 base::Bind(&ViewEventTestBase::DoTestOnMessageLoop, this));
144 143
145 MessageLoop::current()->Run(); 144 ui_test_utils::RunMessageLoop();
146 } 145 }
147 146
148 gfx::Size ViewEventTestBase::GetPreferredSize() { 147 gfx::Size ViewEventTestBase::GetPreferredSize() {
149 return gfx::Size(); 148 return gfx::Size();
150 } 149 }
151 150
152 void ViewEventTestBase::ScheduleMouseMoveInBackground(int x, int y) { 151 void ViewEventTestBase::ScheduleMouseMoveInBackground(int x, int y) {
153 if (!dnd_thread_.get()) { 152 if (!dnd_thread_.get()) {
154 dnd_thread_.reset(new base::Thread("mouse-move-thread")); 153 dnd_thread_.reset(new base::Thread("mouse-move-thread"));
155 dnd_thread_->Start(); 154 dnd_thread_->Start();
156 } 155 }
157 dnd_thread_->message_loop()->PostDelayedTask( 156 dnd_thread_->message_loop()->PostDelayedTask(
158 FROM_HERE, 157 FROM_HERE,
159 base::IgnoreReturn<bool>(base::Bind(&ui_controls::SendMouseMove, x, y)), 158 base::IgnoreReturn<bool>(base::Bind(&ui_controls::SendMouseMove, x, y)),
160 kMouseMoveDelayMS); 159 kMouseMoveDelayMS);
161 } 160 }
162 161
163 void ViewEventTestBase::StopBackgroundThread() { 162 void ViewEventTestBase::StopBackgroundThread() {
164 dnd_thread_.reset(NULL); 163 dnd_thread_.reset(NULL);
165 } 164 }
166 165
167 void ViewEventTestBase::RunTestMethod(const base::Closure& task) { 166 void ViewEventTestBase::RunTestMethod(const base::Closure& task) {
168 StopBackgroundThread(); 167 StopBackgroundThread();
169 168
170 task.Run(); 169 task.Run();
171 if (HasFatalFailure()) 170 if (HasFatalFailure())
172 Done(); 171 Done();
173 } 172 }
OLDNEW
« no previous file with comments | « chrome/test/automation/automation_proxy.cc ('k') | content/browser/renderer_host/test_render_view_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698