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

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

Issue 2859333003: cros: Fix bubble dialog shows on desktop when parent window is invisible (Closed)
Patch Set: feedback Created 3 years, 7 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') | 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 <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"
11 #include "base/run_loop.h" 11 #include "base/run_loop.h"
12 #include "services/ui/public/interfaces/window_manager_constants.mojom.h" 12 #include "services/ui/public/interfaces/window_manager_constants.mojom.h"
13 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
14 #include "ui/aura/client/aura_constants.h" 14 #include "ui/aura/client/aura_constants.h"
15 #include "ui/aura/env.h" 15 #include "ui/aura/env.h"
16 #include "ui/aura/layout_manager.h" 16 #include "ui/aura/layout_manager.h"
17 #include "ui/aura/test/aura_test_base.h" 17 #include "ui/aura/test/aura_test_base.h"
18 #include "ui/aura/window.h" 18 #include "ui/aura/window.h"
19 #include "ui/aura/window_observer.h" 19 #include "ui/aura/window_observer.h"
20 #include "ui/aura/window_tree_host.h" 20 #include "ui/aura/window_tree_host.h"
21 #include "ui/events/event.h" 21 #include "ui/events/event.h"
22 #include "ui/events/event_utils.h" 22 #include "ui/events/event_utils.h"
23 #include "ui/views/layout/fill_layout.h" 23 #include "ui/views/layout/fill_layout.h"
24 #include "ui/views/test/widget_test.h" 24 #include "ui/views/test/widget_test.h"
25 #include "ui/views/widget/root_view.h" 25 #include "ui/views/widget/root_view.h"
26 #include "ui/views/widget/widget_delegate.h" 26 #include "ui/views/widget/widget_delegate.h"
27 #include "ui/wm/core/base_focus_rules.h" 27 #include "ui/wm/core/base_focus_rules.h"
28 #include "ui/wm/core/default_activation_client.h" 28 #include "ui/wm/core/default_activation_client.h"
29 #include "ui/wm/core/focus_controller.h" 29 #include "ui/wm/core/focus_controller.h"
30 #include "ui/wm/core/transient_window_manager.h"
30 31
31 namespace views { 32 namespace views {
32 namespace { 33 namespace {
33 34
34 NativeWidgetAura* Init(aura::Window* parent, Widget* widget) { 35 NativeWidgetAura* Init(aura::Window* parent, Widget* widget) {
35 Widget::InitParams params(Widget::InitParams::TYPE_POPUP); 36 Widget::InitParams params(Widget::InitParams::TYPE_POPUP);
36 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 37 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
37 params.parent = parent; 38 params.parent = parent;
38 widget->Init(params); 39 widget->Init(params);
39 return static_cast<NativeWidgetAura*>(widget->native_widget()); 40 return static_cast<NativeWidgetAura*>(widget->native_widget());
(...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after
644 views::test::TestInitialFocusWidgetDelegate delegate(root_window()); 645 views::test::TestInitialFocusWidgetDelegate delegate(root_window());
645 delegate.GetWidget()->Show(); 646 delegate.GetWidget()->Show();
646 EXPECT_FALSE(delegate.view()->HasFocus()); 647 EXPECT_FALSE(delegate.view()->HasFocus());
647 648
648 test_focus_rules()->set_can_activate(true); 649 test_focus_rules()->set_can_activate(true);
649 views::test::TestInitialFocusWidgetDelegate delegate2(root_window()); 650 views::test::TestInitialFocusWidgetDelegate delegate2(root_window());
650 delegate2.GetWidget()->Show(); 651 delegate2.GetWidget()->Show();
651 EXPECT_TRUE(delegate2.view()->HasFocus()); 652 EXPECT_TRUE(delegate2.view()->HasFocus());
652 } 653 }
653 654
655 // Tests that the transient child bubble window is only visible if the parent is
656 // visible.
657 TEST_F(NativeWidgetAuraTest, VisibilityOfChildBubbleWindow) {
658 // Create a parent window.
659 std::unique_ptr<Widget> parent(new Widget);
sky 2017/05/08 22:42:11 No need for the unique_ptr here, declare parent on
Qiang(Joe) Xu 2017/05/08 22:55:57 Done.
660 Widget::InitParams parent_params(Widget::InitParams::TYPE_WINDOW);
661 parent_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
662 parent_params.context = root_window();
663 parent->Init(parent_params);
664 parent->SetBounds(gfx::Rect(0, 0, 480, 320));
665
666 // Add a child bubble window to the above parent window and show it.
667 std::unique_ptr<Widget> child(new Widget);
sky 2017/05/08 22:42:11 Same comment here.
Qiang(Joe) Xu 2017/05/08 22:55:57 Done.
668 Widget::InitParams child_params(Widget::InitParams::TYPE_BUBBLE);
669 child_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
670 child_params.parent = parent->GetNativeWindow();
671 child->Init(child_params);
672 child->SetBounds(gfx::Rect(0, 0, 200, 200));
673 child->Show();
674
675 // Check that the bubble window is added as the transient child and it is
676 // hidden because parent window is hidden.
677 wm::TransientWindowManager* manager =
678 wm::TransientWindowManager::Get(child->GetNativeWindow());
679 EXPECT_EQ(parent->GetNativeWindow(), manager->transient_parent());
680 EXPECT_FALSE(parent->IsVisible());
681 EXPECT_FALSE(child->IsVisible());
682
683 // Show the parent window should make the transient child bubble visible.
684 parent->Show();
685 EXPECT_TRUE(parent->IsVisible());
686 EXPECT_TRUE(child->IsVisible());
687 }
688
654 } // namespace 689 } // namespace
655 } // namespace views 690 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/widget/native_widget_aura.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698