| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <algorithm> | 5 #include <algorithm> |
| 6 | 6 |
| 7 #include "ash/accessibility_delegate.h" | 7 #include "ash/accessibility_delegate.h" |
| 8 #include "ash/drag_drop/drag_drop_controller.h" | 8 #include "ash/drag_drop/drag_drop_controller.h" |
| 9 #include "ash/root_window_controller.h" | 9 #include "ash/root_window_controller.h" |
| 10 #include "ash/screen_util.h" | 10 #include "ash/screen_util.h" |
| (...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 727 RunAllPendingInMessageLoop(); | 727 RunAllPendingInMessageLoop(); |
| 728 EXPECT_FALSE(drag_canceled_by_test); | 728 EXPECT_FALSE(drag_canceled_by_test); |
| 729 ASSERT_TRUE(IsSelecting()); | 729 ASSERT_TRUE(IsSelecting()); |
| 730 RunAllPendingInMessageLoop(); | 730 RunAllPendingInMessageLoop(); |
| 731 } | 731 } |
| 732 | 732 |
| 733 // Test that a label is created under the window on entering overview mode. | 733 // Test that a label is created under the window on entering overview mode. |
| 734 TEST_F(WindowSelectorTest, CreateLabelUnderWindow) { | 734 TEST_F(WindowSelectorTest, CreateLabelUnderWindow) { |
| 735 scoped_ptr<aura::Window> window(CreateWindow(gfx::Rect(0, 0, 100, 100))); | 735 scoped_ptr<aura::Window> window(CreateWindow(gfx::Rect(0, 0, 100, 100))); |
| 736 base::string16 window_title = base::UTF8ToUTF16("My window"); | 736 base::string16 window_title = base::UTF8ToUTF16("My window"); |
| 737 window->set_title(window_title); | 737 window->SetTitle(window_title); |
| 738 ToggleOverview(); | 738 ToggleOverview(); |
| 739 WindowSelectorItem* window_item = GetWindowItemsForRoot(0).back(); | 739 WindowSelectorItem* window_item = GetWindowItemsForRoot(0).back(); |
| 740 views::Widget* widget = GetLabelWidget(window_item); | 740 views::Widget* widget = GetLabelWidget(window_item); |
| 741 // Has the label widget been created? | 741 // Has the label widget been created? |
| 742 ASSERT_TRUE(widget); | 742 ASSERT_TRUE(widget); |
| 743 views::Label* label = static_cast<views::Label*>(widget->GetContentsView()); | 743 views::Label* label = static_cast<views::Label*>(widget->GetContentsView()); |
| 744 // Verify the label matches the window title. | 744 // Verify the label matches the window title. |
| 745 EXPECT_EQ(label->text(), window_title); | 745 EXPECT_EQ(label->text(), window_title); |
| 746 |
| 747 // Update the window title and check that the label is updated, too. |
| 748 base::string16 updated_title = base::UTF8ToUTF16("Updated title"); |
| 749 window->SetTitle(updated_title); |
| 750 EXPECT_EQ(label->text(), updated_title); |
| 751 |
| 746 // Labels are located based on target_bounds, not the actual window item | 752 // Labels are located based on target_bounds, not the actual window item |
| 747 // bounds. | 753 // bounds. |
| 748 gfx::Rect target_bounds(window_item->target_bounds()); | 754 gfx::Rect target_bounds(window_item->target_bounds()); |
| 749 gfx::Rect expected_label_bounds(target_bounds.x(), | 755 gfx::Rect expected_label_bounds(target_bounds.x(), |
| 750 target_bounds.bottom(), | 756 target_bounds.bottom(), |
| 751 target_bounds.width(), | 757 target_bounds.width(), |
| 752 label->GetPreferredSize().height()); | 758 label->GetPreferredSize().height()); |
| 753 gfx::Rect real_label_bounds = widget->GetNativeWindow()->bounds(); | 759 gfx::Rect real_label_bounds = widget->GetNativeWindow()->bounds(); |
| 754 EXPECT_EQ(widget->GetNativeWindow()->bounds(), real_label_bounds); | 760 EXPECT_EQ(widget->GetNativeWindow()->bounds(), real_label_bounds); |
| 755 } | 761 } |
| 756 | 762 |
| 757 // Tests that a label is created for the active panel in a group of panels in | 763 // Tests that a label is created for the active panel in a group of panels in |
| 758 // overview mode. | 764 // overview mode. |
| 759 TEST_F(WindowSelectorTest, CreateLabelUnderPanel) { | 765 TEST_F(WindowSelectorTest, CreateLabelUnderPanel) { |
| 760 scoped_ptr<aura::Window> panel1(CreatePanelWindow(gfx::Rect(0, 0, 100, 100))); | 766 scoped_ptr<aura::Window> panel1(CreatePanelWindow(gfx::Rect(0, 0, 100, 100))); |
| 761 scoped_ptr<aura::Window> panel2(CreatePanelWindow(gfx::Rect(0, 0, 100, 100))); | 767 scoped_ptr<aura::Window> panel2(CreatePanelWindow(gfx::Rect(0, 0, 100, 100))); |
| 762 base::string16 panel1_title = base::UTF8ToUTF16("My panel"); | 768 base::string16 panel1_title = base::UTF8ToUTF16("My panel"); |
| 763 base::string16 panel2_title = base::UTF8ToUTF16("Another panel"); | 769 base::string16 panel2_title = base::UTF8ToUTF16("Another panel"); |
| 764 panel1->set_title(panel1_title); | 770 panel1->SetTitle(panel1_title); |
| 765 panel2->set_title(panel2_title); | 771 panel2->SetTitle(panel2_title); |
| 766 wm::ActivateWindow(panel1.get()); | 772 wm::ActivateWindow(panel1.get()); |
| 767 ToggleOverview(); | 773 ToggleOverview(); |
| 768 WindowSelectorItem* window_item = GetWindowItemsForRoot(0).back(); | 774 WindowSelectorItem* window_item = GetWindowItemsForRoot(0).back(); |
| 769 views::Widget* widget = GetLabelWidget(window_item); | 775 views::Widget* widget = GetLabelWidget(window_item); |
| 770 // Has the label widget been created? | 776 // Has the label widget been created? |
| 771 ASSERT_TRUE(widget); | 777 ASSERT_TRUE(widget); |
| 772 views::Label* label = static_cast<views::Label*>(widget->GetContentsView()); | 778 views::Label* label = static_cast<views::Label*>(widget->GetContentsView()); |
| 773 // Verify the label matches the active window title. | 779 // Verify the label matches the active window title. |
| 774 EXPECT_EQ(label->text(), panel1_title); | 780 EXPECT_EQ(label->text(), panel1_title); |
| 775 } | 781 } |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 941 // cause selection to end. | 947 // cause selection to end. |
| 942 TEST_F(WindowSelectorTest, CloseButtonOnPanels) { | 948 TEST_F(WindowSelectorTest, CloseButtonOnPanels) { |
| 943 scoped_ptr<views::Widget> widget1(CreatePanelWindowWidget( | 949 scoped_ptr<views::Widget> widget1(CreatePanelWindowWidget( |
| 944 gfx::Rect(0, 0, 300, 100))); | 950 gfx::Rect(0, 0, 300, 100))); |
| 945 scoped_ptr<views::Widget> widget2(CreatePanelWindowWidget( | 951 scoped_ptr<views::Widget> widget2(CreatePanelWindowWidget( |
| 946 gfx::Rect(100, 0, 100, 100))); | 952 gfx::Rect(100, 0, 100, 100))); |
| 947 aura::Window* window1 = widget1->GetNativeWindow(); | 953 aura::Window* window1 = widget1->GetNativeWindow(); |
| 948 aura::Window* window2 = widget2->GetNativeWindow(); | 954 aura::Window* window2 = widget2->GetNativeWindow(); |
| 949 base::string16 panel1_title = base::UTF8ToUTF16("Panel 1"); | 955 base::string16 panel1_title = base::UTF8ToUTF16("Panel 1"); |
| 950 base::string16 panel2_title = base::UTF8ToUTF16("Panel 2"); | 956 base::string16 panel2_title = base::UTF8ToUTF16("Panel 2"); |
| 951 window1->set_title(panel1_title); | 957 window1->SetTitle(panel1_title); |
| 952 window2->set_title(panel2_title); | 958 window2->SetTitle(panel2_title); |
| 953 wm::ActivateWindow(window1); | 959 wm::ActivateWindow(window1); |
| 954 ToggleOverview(); | 960 ToggleOverview(); |
| 955 | 961 |
| 956 gfx::RectF bounds1 = GetTransformedBoundsInRootWindow(window1); | 962 gfx::RectF bounds1 = GetTransformedBoundsInRootWindow(window1); |
| 957 gfx::Point point1(bounds1.top_right().x() - 1, bounds1.top_right().y() - 1); | 963 gfx::Point point1(bounds1.top_right().x() - 1, bounds1.top_right().y() - 1); |
| 958 aura::test::EventGenerator event_generator1(window1->GetRootWindow(), point1); | 964 aura::test::EventGenerator event_generator1(window1->GetRootWindow(), point1); |
| 959 | 965 |
| 960 EXPECT_FALSE(widget1->IsClosed()); | 966 EXPECT_FALSE(widget1->IsClosed()); |
| 961 event_generator1.ClickLeftButton(); | 967 event_generator1.ClickLeftButton(); |
| 962 EXPECT_TRUE(widget1->IsClosed()); | 968 EXPECT_TRUE(widget1->IsClosed()); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 976 aura::test::EventGenerator event_generator2(window2->GetRootWindow(), point2); | 982 aura::test::EventGenerator event_generator2(window2->GetRootWindow(), point2); |
| 977 | 983 |
| 978 EXPECT_FALSE(widget2->IsClosed()); | 984 EXPECT_FALSE(widget2->IsClosed()); |
| 979 event_generator2.ClickLeftButton(); | 985 event_generator2.ClickLeftButton(); |
| 980 EXPECT_TRUE(widget2->IsClosed()); | 986 EXPECT_TRUE(widget2->IsClosed()); |
| 981 RunAllPendingInMessageLoop(); | 987 RunAllPendingInMessageLoop(); |
| 982 EXPECT_FALSE(IsSelecting()); | 988 EXPECT_FALSE(IsSelecting()); |
| 983 } | 989 } |
| 984 | 990 |
| 985 } // namespace ash | 991 } // namespace ash |
| OLD | NEW |