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

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

Issue 2651753003: Wires up ShouldDescendIntoChildForEventHandling() for DesktopNativeWidgetAura (Closed)
Patch Set: improve comments Created 3 years, 10 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
« no previous file with comments | « ui/views/widget/native_widget_aura.cc ('k') | ui/views/widget/native_widget_delegate.h » ('j') | 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 <memory> 7 #include <memory>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 510
511 EXPECT_EQ(child->GetNativeWindow(), 511 EXPECT_EQ(child->GetNativeWindow(),
512 parent->GetNativeWindow()->GetEventHandlerForPoint( 512 parent->GetNativeWindow()->GetEventHandlerForPoint(
513 gfx::Point(20, 20))); 513 gfx::Point(20, 20)));
514 514
515 // Work around for bug in NativeWidgetAura. 515 // Work around for bug in NativeWidgetAura.
516 // TODO: fix bug and remove this. 516 // TODO: fix bug and remove this.
517 parent->Close(); 517 parent->Close();
518 } 518 }
519 519
520 // Verifies views with layers are targeted for events properly.
521 TEST_F(NativeWidgetAuraTest,
522 ShouldDescendIntoChildForEventHandlingChecksVisibleBounds) {
523 // Create two widgets: |parent| and |child|. |child| is a child of |parent|.
524 View* parent_root_view = new View;
525 Widget parent;
526 Widget::InitParams parent_params(Widget::InitParams::TYPE_WINDOW_FRAMELESS);
527 parent_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
528 parent_params.context = root_window();
529 parent.Init(parent_params);
530 parent.SetContentsView(parent_root_view);
531 parent.SetBounds(gfx::Rect(0, 0, 400, 400));
532 parent.Show();
533
534 Widget child;
535 Widget::InitParams child_params(Widget::InitParams::TYPE_CONTROL);
536 child_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
537 child_params.parent = parent.GetNativeWindow();
538 child.Init(child_params);
539 child.SetBounds(gfx::Rect(0, 0, 200, 200));
540 child.Show();
541
542 // Point is over |child|.
543 EXPECT_EQ(
544 child.GetNativeWindow(),
545 parent.GetNativeWindow()->GetEventHandlerForPoint(gfx::Point(50, 50)));
546
547 View* parent_root_view_child = new View;
548 parent_root_view->AddChildView(parent_root_view_child);
549 parent_root_view_child->SetBounds(0, 0, 10, 10);
550
551 // Create a View whose layer extends outside the bounds of its parent. Event
552 // targetting should only consider the visible bounds.
553 View* parent_root_view_child_child = new View;
554 parent_root_view_child->AddChildView(parent_root_view_child_child);
555 parent_root_view_child_child->SetBounds(0, 0, 100, 100);
556 parent_root_view_child_child->SetPaintToLayer();
557 parent_root_view_child_child->layer()->parent()->StackAtTop(
558 parent_root_view_child_child->layer());
559
560 // 20,20 is over |parent_root_view_child_child|'s layer, but not the visible
561 // bounds of |parent_root_view_child_child|, so |child| should be the event
562 // target.
563 EXPECT_EQ(
564 child.GetNativeWindow(),
565 parent.GetNativeWindow()->GetEventHandlerForPoint(gfx::Point(20, 20)));
566 }
567
520 // Verifies that widget->FlashFrame() sets aura::client::kDrawAttentionKey, 568 // Verifies that widget->FlashFrame() sets aura::client::kDrawAttentionKey,
521 // and activating the window clears it. 569 // and activating the window clears it.
522 TEST_F(NativeWidgetAuraTest, FlashFrame) { 570 TEST_F(NativeWidgetAuraTest, FlashFrame) {
523 std::unique_ptr<Widget> widget(new Widget()); 571 std::unique_ptr<Widget> widget(new Widget());
524 Widget::InitParams params(Widget::InitParams::TYPE_WINDOW); 572 Widget::InitParams params(Widget::InitParams::TYPE_WINDOW);
525 params.context = root_window(); 573 params.context = root_window();
526 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 574 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
527 widget->Init(params); 575 widget->Init(params);
528 aura::Window* window = widget->GetNativeWindow(); 576 aura::Window* window = widget->GetNativeWindow();
529 EXPECT_FALSE(window->GetProperty(aura::client::kDrawAttentionKey)); 577 EXPECT_FALSE(window->GetProperty(aura::client::kDrawAttentionKey));
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 EXPECT_FALSE(delegate.view()->HasFocus()); 645 EXPECT_FALSE(delegate.view()->HasFocus());
598 646
599 test_focus_rules()->set_can_activate(true); 647 test_focus_rules()->set_can_activate(true);
600 views::test::TestInitialFocusWidgetDelegate delegate2(root_window()); 648 views::test::TestInitialFocusWidgetDelegate delegate2(root_window());
601 delegate2.GetWidget()->Show(); 649 delegate2.GetWidget()->Show();
602 EXPECT_TRUE(delegate2.view()->HasFocus()); 650 EXPECT_TRUE(delegate2.view()->HasFocus());
603 } 651 }
604 652
605 } // namespace 653 } // namespace
606 } // namespace views 654 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/widget/native_widget_aura.cc ('k') | ui/views/widget/native_widget_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698