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 #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/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 scoped_ptr<TestWidget> widget(new TestWidget()); | 241 scoped_ptr<TestWidget> widget(new TestWidget()); |
242 Widget::InitParams params(Widget::InitParams::TYPE_WINDOW_FRAMELESS); | 242 Widget::InitParams params(Widget::InitParams::TYPE_WINDOW_FRAMELESS); |
243 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 243 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
244 params.context = root_window(); | 244 params.context = root_window(); |
245 params.bounds = gfx::Rect(0, 0, 100, 200); | 245 params.bounds = gfx::Rect(0, 0, 100, 200); |
246 widget->Init(params); | 246 widget->Init(params); |
247 widget->SetContentsView(view); | 247 widget->SetContentsView(view); |
248 widget->Show(); | 248 widget->Show(); |
249 | 249 |
250 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(41, 51), 1, | 250 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(41, 51), 1, |
251 base::TimeDelta()); | 251 base::TimeDelta()); |
252 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press); | 252 ui::EventDispatchDetails details = dispatcher()->OnEventFromSource(&press); |
| 253 ASSERT_FALSE(details.dispatcher_destroyed); |
253 // Both views should get the press. | 254 // Both views should get the press. |
254 EXPECT_TRUE(view->got_gesture_event()); | 255 EXPECT_TRUE(view->got_gesture_event()); |
255 EXPECT_TRUE(child->got_gesture_event()); | 256 EXPECT_TRUE(child->got_gesture_event()); |
256 view->clear_got_gesture_event(); | 257 view->clear_got_gesture_event(); |
257 child->clear_got_gesture_event(); | 258 child->clear_got_gesture_event(); |
258 // Touch events should not automatically grab capture. | 259 // Touch events should not automatically grab capture. |
259 EXPECT_FALSE(widget->HasCapture()); | 260 EXPECT_FALSE(widget->HasCapture()); |
260 | 261 |
261 // Release touch. Only |view| should get the release since that it consumed | 262 // Release touch. Only |view| should get the release since that it consumed |
262 // the press. | 263 // the press. |
263 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(250, 251), 1, | 264 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(250, 251), 1, |
264 base::TimeDelta()); | 265 base::TimeDelta()); |
265 dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release); | 266 details = dispatcher()->OnEventFromSource(&release); |
| 267 ASSERT_FALSE(details.dispatcher_destroyed); |
266 EXPECT_TRUE(view->got_gesture_event()); | 268 EXPECT_TRUE(view->got_gesture_event()); |
267 EXPECT_FALSE(child->got_gesture_event()); | 269 EXPECT_FALSE(child->got_gesture_event()); |
268 view->clear_got_gesture_event(); | 270 view->clear_got_gesture_event(); |
269 | 271 |
270 // Work around for bug in NativeWidgetAura. | 272 // Work around for bug in NativeWidgetAura. |
271 // TODO: fix bug and remove this. | 273 // TODO: fix bug and remove this. |
272 widget->Close(); | 274 widget->Close(); |
273 } | 275 } |
274 | 276 |
275 // Verifies views with layers are targeted for events properly. | 277 // Verifies views with layers are targeted for events properly. |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 scoped_ptr<Widget> widget(new Widget()); | 364 scoped_ptr<Widget> widget(new Widget()); |
363 NativeWidgetAura* window = Init(parent.get(), widget.get()); | 365 NativeWidgetAura* window = Init(parent.get(), widget.get()); |
364 window->Show(); | 366 window->Show(); |
365 window->Close(); | 367 window->Close(); |
366 base::MessageLoop::current()->RunUntilIdle(); | 368 base::MessageLoop::current()->RunUntilIdle(); |
367 widget->GetNativeTheme(); // Shouldn't crash. | 369 widget->GetNativeTheme(); // Shouldn't crash. |
368 } | 370 } |
369 | 371 |
370 } // namespace | 372 } // namespace |
371 } // namespace views | 373 } // namespace views |
OLD | NEW |