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

Side by Side Diff: ui/views/widget/native_widget_aura_unittest.cc

Issue 10825050: Introduce RootWindowHostDelegate. The RootWindowHost performs most of its communication with RootWi… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « ui/aura/window_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "ui/views/widget/native_widget_aura.h" 5 #include "ui/views/widget/native_widget_aura.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 scoped_ptr<TestWidget> widget(new TestWidget()); 247 scoped_ptr<TestWidget> widget(new TestWidget());
248 Widget::InitParams params(Widget::InitParams::TYPE_WINDOW); 248 Widget::InitParams params(Widget::InitParams::TYPE_WINDOW);
249 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 249 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
250 params.bounds = gfx::Rect(0, 0, 100, 200); 250 params.bounds = gfx::Rect(0, 0, 100, 200);
251 widget->Init(params); 251 widget->Init(params);
252 widget->SetContentsView(view); 252 widget->SetContentsView(view);
253 widget->Show(); 253 widget->Show();
254 254
255 aura::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(41, 51), 1, 255 aura::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(41, 51), 1,
256 base::TimeDelta()); 256 base::TimeDelta());
257 root_window()->DispatchTouchEvent(&press); 257 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press);
258 // Both views should get the press. 258 // Both views should get the press.
259 EXPECT_TRUE(view->got_gesture_event()); 259 EXPECT_TRUE(view->got_gesture_event());
260 EXPECT_TRUE(child->got_gesture_event()); 260 EXPECT_TRUE(child->got_gesture_event());
261 view->clear_got_gesture_event(); 261 view->clear_got_gesture_event();
262 child->clear_got_gesture_event(); 262 child->clear_got_gesture_event();
263 // Touch events should not automatically grab capture. 263 // Touch events should not automatically grab capture.
264 EXPECT_FALSE(widget->HasCapture()); 264 EXPECT_FALSE(widget->HasCapture());
265 265
266 // Release touch. Only |view| should get the release since that it consumed 266 // Release touch. Only |view| should get the release since that it consumed
267 // the press. 267 // the press.
268 aura::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(250, 251), 1, 268 aura::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(250, 251), 1,
269 base::TimeDelta()); 269 base::TimeDelta());
270 root_window()->DispatchTouchEvent(&release); 270 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release);
271 EXPECT_TRUE(view->got_gesture_event()); 271 EXPECT_TRUE(view->got_gesture_event());
272 EXPECT_FALSE(child->got_gesture_event()); 272 EXPECT_FALSE(child->got_gesture_event());
273 view->clear_got_gesture_event(); 273 view->clear_got_gesture_event();
274 274
275 // Work around for bug in NativeWidgetAura. 275 // Work around for bug in NativeWidgetAura.
276 // TODO: fix bug and remove this. 276 // TODO: fix bug and remove this.
277 widget->Close(); 277 widget->Close();
278 } 278 }
279 279
280 TEST_F(NativeWidgetAuraTest, ReleaseCaptureOnTouchRelease) { 280 TEST_F(NativeWidgetAuraTest, ReleaseCaptureOnTouchRelease) {
281 GestureTrackingView* view = new GestureTrackingView(); 281 GestureTrackingView* view = new GestureTrackingView();
282 scoped_ptr<TestWidget> widget(new TestWidget()); 282 scoped_ptr<TestWidget> widget(new TestWidget());
283 Widget::InitParams params(Widget::InitParams::TYPE_WINDOW); 283 Widget::InitParams params(Widget::InitParams::TYPE_WINDOW);
284 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 284 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
285 params.bounds = gfx::Rect(0, 0, 100, 200); 285 params.bounds = gfx::Rect(0, 0, 100, 200);
286 widget->Init(params); 286 widget->Init(params);
287 widget->SetContentsView(view); 287 widget->SetContentsView(view);
288 widget->Show(); 288 widget->Show();
289 289
290 aura::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(41, 51), 1, 290 aura::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(41, 51), 1,
291 base::TimeDelta()); 291 base::TimeDelta());
292 root_window()->DispatchTouchEvent(&press); 292 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press);
293 EXPECT_TRUE(view->got_gesture_event()); 293 EXPECT_TRUE(view->got_gesture_event());
294 view->clear_got_gesture_event(); 294 view->clear_got_gesture_event();
295 // Set the capture. 295 // Set the capture.
296 widget->SetCapture(view); 296 widget->SetCapture(view);
297 EXPECT_TRUE(widget->HasCapture()); 297 EXPECT_TRUE(widget->HasCapture());
298 298
299 // Generate a release, this should trigger releasing capture. 299 // Generate a release, this should trigger releasing capture.
300 aura::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(41, 51), 1, 300 aura::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(41, 51), 1,
301 base::TimeDelta()); 301 base::TimeDelta());
302 root_window()->DispatchTouchEvent(&release); 302 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release);
303 EXPECT_TRUE(view->got_gesture_event()); 303 EXPECT_TRUE(view->got_gesture_event());
304 view->clear_got_gesture_event(); 304 view->clear_got_gesture_event();
305 EXPECT_FALSE(widget->HasCapture()); 305 EXPECT_FALSE(widget->HasCapture());
306 306
307 // Work around for bug in NativeWidgetAura. 307 // Work around for bug in NativeWidgetAura.
308 // TODO: fix bug and remove this. 308 // TODO: fix bug and remove this.
309 widget->Close(); 309 widget->Close();
310 } 310 }
311 311
312 // Verifies views with layers are targeted for events properly. 312 // Verifies views with layers are targeted for events properly.
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 parent->GetNativeWindow()->GetEventHandlerForPoint( 366 parent->GetNativeWindow()->GetEventHandlerForPoint(
367 gfx::Point(20, 20))); 367 gfx::Point(20, 20)));
368 368
369 // Work around for bug in NativeWidgetAura. 369 // Work around for bug in NativeWidgetAura.
370 // TODO: fix bug and remove this. 370 // TODO: fix bug and remove this.
371 parent->Close(); 371 parent->Close();
372 } 372 }
373 373
374 } // namespace 374 } // namespace
375 } // namespace views 375 } // namespace views
OLDNEW
« no previous file with comments | « ui/aura/window_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698