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

Side by Side Diff: ash/wm/overview/window_selector_unittest.cc

Issue 251103005: Added arrow key navigation to Overview Mode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Simplified RemoveWindow() Created 6 years, 6 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
OLDNEW
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 "ash/accessibility_delegate.h" 5 #include "ash/accessibility_delegate.h"
6 #include "ash/drag_drop/drag_drop_controller.h" 6 #include "ash/drag_drop/drag_drop_controller.h"
7 #include "ash/root_window_controller.h" 7 #include "ash/root_window_controller.h"
8 #include "ash/screen_util.h" 8 #include "ash/screen_util.h"
9 #include "ash/shelf/shelf.h" 9 #include "ash/shelf/shelf.h"
10 #include "ash/shelf/shelf_widget.h" 10 #include "ash/shelf/shelf_widget.h"
11 #include "ash/shell.h" 11 #include "ash/shell.h"
12 #include "ash/shell_window_ids.h" 12 #include "ash/shell_window_ids.h"
13 #include "ash/test/ash_test_base.h" 13 #include "ash/test/ash_test_base.h"
14 #include "ash/test/shelf_test_api.h" 14 #include "ash/test/shelf_test_api.h"
15 #include "ash/test/shelf_view_test_api.h" 15 #include "ash/test/shelf_view_test_api.h"
16 #include "ash/test/shell_test_api.h" 16 #include "ash/test/shell_test_api.h"
17 #include "ash/test/test_shelf_delegate.h" 17 #include "ash/test/test_shelf_delegate.h"
18 #include "ash/wm/mru_window_tracker.h" 18 #include "ash/wm/mru_window_tracker.h"
19 #include "ash/wm/overview/window_grid.h"
19 #include "ash/wm/overview/window_selector.h" 20 #include "ash/wm/overview/window_selector.h"
20 #include "ash/wm/overview/window_selector_controller.h" 21 #include "ash/wm/overview/window_selector_controller.h"
21 #include "ash/wm/overview/window_selector_item.h" 22 #include "ash/wm/overview/window_selector_item.h"
22 #include "ash/wm/window_state.h" 23 #include "ash/wm/window_state.h"
23 #include "ash/wm/window_util.h" 24 #include "ash/wm/window_util.h"
24 #include "ash/wm/wm_event.h" 25 #include "ash/wm/wm_event.h"
25 #include "base/basictypes.h" 26 #include "base/basictypes.h"
26 #include "base/compiler_specific.h" 27 #include "base/compiler_specific.h"
27 #include "base/memory/scoped_vector.h" 28 #include "base/memory/scoped_vector.h"
28 #include "base/run_loop.h" 29 #include "base/run_loop.h"
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 bool IsSelecting() { 158 bool IsSelecting() {
158 return ash::Shell::GetInstance()->window_selector_controller()-> 159 return ash::Shell::GetInstance()->window_selector_controller()->
159 IsSelecting(); 160 IsSelecting();
160 } 161 }
161 162
162 aura::Window* GetFocusedWindow() { 163 aura::Window* GetFocusedWindow() {
163 return aura::client::GetFocusClient( 164 return aura::client::GetFocusClient(
164 Shell::GetPrimaryRootWindow())->GetFocusedWindow(); 165 Shell::GetPrimaryRootWindow())->GetFocusedWindow();
165 } 166 }
166 167
167 ScopedVector<WindowSelectorItem>* GetWindowItems() { 168 const std::vector<WindowSelectorItem*>& GetWindowItemsForRoot(int index) {
168 return &(ash::Shell::GetInstance()->window_selector_controller()-> 169 return ash::Shell::GetInstance()->window_selector_controller()->
169 window_selector_->windows_); 170 window_selector_->grid_list_[index]->window_list();
170 } 171 }
171 172
172 views::Widget* GetLabelWidget(ash::WindowSelectorItem* window) { 173 views::Widget* GetLabelWidget(ash::WindowSelectorItem* window) {
173 return window->window_label_.get(); 174 return window->window_label_.get();
174 } 175 }
175 176
176 test::ShelfViewTestAPI* shelf_view_test() { 177 test::ShelfViewTestAPI* shelf_view_test() {
177 return shelf_view_test_.get(); 178 return shelf_view_test_.get();
178 } 179 }
179 180
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after
692 ASSERT_TRUE(IsSelecting()); 693 ASSERT_TRUE(IsSelecting());
693 RunAllPendingInMessageLoop(); 694 RunAllPendingInMessageLoop();
694 } 695 }
695 696
696 // Test that a label is created under the window on entering overview mode. 697 // Test that a label is created under the window on entering overview mode.
697 TEST_F(WindowSelectorTest, CreateLabelUnderWindow) { 698 TEST_F(WindowSelectorTest, CreateLabelUnderWindow) {
698 scoped_ptr<aura::Window> window(CreateWindow(gfx::Rect(0, 0, 100, 100))); 699 scoped_ptr<aura::Window> window(CreateWindow(gfx::Rect(0, 0, 100, 100)));
699 base::string16 window_title = base::UTF8ToUTF16("My window"); 700 base::string16 window_title = base::UTF8ToUTF16("My window");
700 window->set_title(window_title); 701 window->set_title(window_title);
701 ToggleOverview(); 702 ToggleOverview();
702 WindowSelectorItem* window_item = GetWindowItems()->back(); 703 WindowSelectorItem* window_item = GetWindowItemsForRoot(0).back();
703 views::Widget* widget = GetLabelWidget(window_item); 704 views::Widget* widget = GetLabelWidget(window_item);
704 // Has the label widget been created? 705 // Has the label widget been created?
705 ASSERT_TRUE(widget); 706 ASSERT_TRUE(widget);
706 views::Label* label = static_cast<views::Label*>(widget->GetContentsView()); 707 views::Label* label = static_cast<views::Label*>(widget->GetContentsView());
707 // Verify the label matches the window title. 708 // Verify the label matches the window title.
708 EXPECT_EQ(label->text(), window_title); 709 EXPECT_EQ(label->text(), window_title);
709 // Labels are located based on target_bounds, not the actual window item 710 // Labels are located based on target_bounds, not the actual window item
710 // bounds. 711 // bounds.
711 gfx::Rect target_bounds(window_item->target_bounds()); 712 gfx::Rect target_bounds(window_item->target_bounds());
712 gfx::Rect expected_label_bounds(target_bounds.x(), 713 gfx::Rect expected_label_bounds(target_bounds.x(),
713 target_bounds.bottom(), 714 target_bounds.bottom(),
714 target_bounds.width(), 715 target_bounds.width(),
715 label->GetPreferredSize().height()); 716 label->GetPreferredSize().height());
716 gfx::Rect real_label_bounds = widget->GetNativeWindow()->bounds(); 717 gfx::Rect real_label_bounds = widget->GetNativeWindow()->bounds();
717 EXPECT_EQ(widget->GetNativeWindow()->bounds(), real_label_bounds); 718 EXPECT_EQ(widget->GetNativeWindow()->bounds(), real_label_bounds);
718 } 719 }
719 720
720 // Tests that a label is created for the active panel in a group of panels in 721 // Tests that a label is created for the active panel in a group of panels in
721 // overview mode. 722 // overview mode.
722 TEST_F(WindowSelectorTest, CreateLabelUnderPanel) { 723 TEST_F(WindowSelectorTest, CreateLabelUnderPanel) {
723 scoped_ptr<aura::Window> panel1(CreatePanelWindow(gfx::Rect(0, 0, 100, 100))); 724 scoped_ptr<aura::Window> panel1(CreatePanelWindow(gfx::Rect(0, 0, 100, 100)));
724 scoped_ptr<aura::Window> panel2(CreatePanelWindow(gfx::Rect(0, 0, 100, 100))); 725 scoped_ptr<aura::Window> panel2(CreatePanelWindow(gfx::Rect(0, 0, 100, 100)));
725 base::string16 panel1_title = base::UTF8ToUTF16("My panel"); 726 base::string16 panel1_title = base::UTF8ToUTF16("My panel");
726 base::string16 panel2_title = base::UTF8ToUTF16("Another panel"); 727 base::string16 panel2_title = base::UTF8ToUTF16("Another panel");
727 panel1->set_title(panel1_title); 728 panel1->set_title(panel1_title);
728 panel2->set_title(panel2_title); 729 panel2->set_title(panel2_title);
729 wm::ActivateWindow(panel1.get()); 730 wm::ActivateWindow(panel1.get());
730 ToggleOverview(); 731 ToggleOverview();
731 WindowSelectorItem* window_item = GetWindowItems()->back(); 732 WindowSelectorItem* window_item = GetWindowItemsForRoot(0).back();
732 views::Widget* widget = GetLabelWidget(window_item); 733 views::Widget* widget = GetLabelWidget(window_item);
733 // Has the label widget been created? 734 // Has the label widget been created?
734 ASSERT_TRUE(widget); 735 ASSERT_TRUE(widget);
735 views::Label* label = static_cast<views::Label*>(widget->GetContentsView()); 736 views::Label* label = static_cast<views::Label*>(widget->GetContentsView());
736 // Verify the label matches the active window title. 737 // Verify the label matches the active window title.
737 EXPECT_EQ(label->text(), panel1_title); 738 EXPECT_EQ(label->text(), panel1_title);
738 } 739 }
739 740
740 // Tests that overview updates the window positions if the display orientation 741 // Tests that overview updates the window positions if the display orientation
741 // changes. 742 // changes.
(...skipping 22 matching lines...) Expand all
764 UpdateDisplay("600x200/r"); 765 UpdateDisplay("600x200/r");
765 EXPECT_EQ("0,0 200x600", root_window->bounds().ToString()); 766 EXPECT_EQ("0,0 200x600", root_window->bounds().ToString());
766 for (ScopedVector<aura::Window>::iterator iter = windows.begin(); 767 for (ScopedVector<aura::Window>::iterator iter = windows.begin();
767 iter != windows.end(); ++iter) { 768 iter != windows.end(); ++iter) {
768 EXPECT_TRUE(root_window->bounds().Contains( 769 EXPECT_TRUE(root_window->bounds().Contains(
769 ToEnclosingRect(GetTransformedTargetBounds(*iter)))); 770 ToEnclosingRect(GetTransformedTargetBounds(*iter))));
770 } 771 }
771 } 772 }
772 773
773 } // namespace ash 774 } // namespace ash
OLDNEW
« ash/wm/overview/window_selector.cc ('K') | « ash/wm/overview/window_selector_item.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698