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" |
11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
12 #include "ui/aura/client/aura_constants.h" | 12 #include "ui/aura/client/aura_constants.h" |
13 #include "ui/aura/env.h" | 13 #include "ui/aura/env.h" |
14 #include "ui/aura/layout_manager.h" | 14 #include "ui/aura/layout_manager.h" |
15 #include "ui/aura/test/aura_test_base.h" | 15 #include "ui/aura/test/aura_test_base.h" |
16 #include "ui/aura/window.h" | 16 #include "ui/aura/window.h" |
17 #include "ui/aura/window_tree_host.h" | 17 #include "ui/aura/window_tree_host.h" |
18 #include "ui/events/event.h" | 18 #include "ui/events/event.h" |
| 19 #include "ui/events/event_utils.h" |
19 #include "ui/gfx/screen.h" | 20 #include "ui/gfx/screen.h" |
20 #include "ui/views/layout/fill_layout.h" | 21 #include "ui/views/layout/fill_layout.h" |
21 #include "ui/views/widget/root_view.h" | 22 #include "ui/views/widget/root_view.h" |
22 #include "ui/views/widget/widget_delegate.h" | 23 #include "ui/views/widget/widget_delegate.h" |
23 #include "ui/wm/core/default_activation_client.h" | 24 #include "ui/wm/core/default_activation_client.h" |
24 | 25 |
25 namespace views { | 26 namespace views { |
26 namespace { | 27 namespace { |
27 | 28 |
28 NativeWidgetAura* Init(aura::Window* parent, Widget* widget) { | 29 NativeWidgetAura* Init(aura::Window* parent, Widget* widget) { |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 view->AddChildView(child); | 310 view->AddChildView(child); |
310 scoped_ptr<TestWidget> widget(new TestWidget()); | 311 scoped_ptr<TestWidget> widget(new TestWidget()); |
311 Widget::InitParams params(Widget::InitParams::TYPE_WINDOW_FRAMELESS); | 312 Widget::InitParams params(Widget::InitParams::TYPE_WINDOW_FRAMELESS); |
312 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 313 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
313 params.context = root_window(); | 314 params.context = root_window(); |
314 params.bounds = gfx::Rect(0, 0, 100, 200); | 315 params.bounds = gfx::Rect(0, 0, 100, 200); |
315 widget->Init(params); | 316 widget->Init(params); |
316 widget->SetContentsView(view); | 317 widget->SetContentsView(view); |
317 widget->Show(); | 318 widget->Show(); |
318 | 319 |
319 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(41, 51), 1, | 320 ui::TouchEvent press( |
320 base::TimeDelta()); | 321 ui::ET_TOUCH_PRESSED, gfx::Point(41, 51), 1, ui::EventTimeForNow()); |
321 ui::EventDispatchDetails details = | 322 ui::EventDispatchDetails details = |
322 event_processor()->OnEventFromSource(&press); | 323 event_processor()->OnEventFromSource(&press); |
323 ASSERT_FALSE(details.dispatcher_destroyed); | 324 ASSERT_FALSE(details.dispatcher_destroyed); |
324 // Both views should get the press. | 325 // Both views should get the press. |
325 EXPECT_TRUE(view->got_gesture_event()); | 326 EXPECT_TRUE(view->got_gesture_event()); |
326 EXPECT_TRUE(child->got_gesture_event()); | 327 EXPECT_TRUE(child->got_gesture_event()); |
327 view->clear_got_gesture_event(); | 328 view->clear_got_gesture_event(); |
328 child->clear_got_gesture_event(); | 329 child->clear_got_gesture_event(); |
329 // Touch events should not automatically grab capture. | 330 // Touch events should not automatically grab capture. |
330 EXPECT_FALSE(widget->HasCapture()); | 331 EXPECT_FALSE(widget->HasCapture()); |
331 | 332 |
332 // Release touch. Only |view| should get the release since that it consumed | 333 // Release touch. Only |view| should get the release since that it consumed |
333 // the press. | 334 // the press. |
334 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(250, 251), 1, | 335 ui::TouchEvent release( |
335 base::TimeDelta()); | 336 ui::ET_TOUCH_RELEASED, gfx::Point(250, 251), 1, ui::EventTimeForNow()); |
336 details = event_processor()->OnEventFromSource(&release); | 337 details = event_processor()->OnEventFromSource(&release); |
337 ASSERT_FALSE(details.dispatcher_destroyed); | 338 ASSERT_FALSE(details.dispatcher_destroyed); |
338 EXPECT_TRUE(view->got_gesture_event()); | 339 EXPECT_TRUE(view->got_gesture_event()); |
339 EXPECT_FALSE(child->got_gesture_event()); | 340 EXPECT_FALSE(child->got_gesture_event()); |
340 view->clear_got_gesture_event(); | 341 view->clear_got_gesture_event(); |
341 | 342 |
342 // Work around for bug in NativeWidgetAura. | 343 // Work around for bug in NativeWidgetAura. |
343 // TODO: fix bug and remove this. | 344 // TODO: fix bug and remove this. |
344 widget->Close(); | 345 widget->Close(); |
345 } | 346 } |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
472 delegate->ClearGotMove(); | 473 delegate->ClearGotMove(); |
473 // Simulate a maximize with animation. | 474 // Simulate a maximize with animation. |
474 delete widget->GetNativeView()->RecreateLayer().release(); | 475 delete widget->GetNativeView()->RecreateLayer().release(); |
475 widget->SetBounds(gfx::Rect(0, 0, 500, 500)); | 476 widget->SetBounds(gfx::Rect(0, 0, 500, 500)); |
476 EXPECT_TRUE(delegate->got_move()); | 477 EXPECT_TRUE(delegate->got_move()); |
477 widget->CloseNow(); | 478 widget->CloseNow(); |
478 } | 479 } |
479 | 480 |
480 } // namespace | 481 } // namespace |
481 } // namespace views | 482 } // namespace views |
OLD | NEW |