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" |
11 #include "ash/shelf/shelf.h" | 11 #include "ash/shelf/shelf.h" |
12 #include "ash/shelf/shelf_widget.h" | 12 #include "ash/shelf/shelf_widget.h" |
13 #include "ash/shell.h" | 13 #include "ash/shell.h" |
14 #include "ash/shell_window_ids.h" | 14 #include "ash/shell_window_ids.h" |
15 #include "ash/test/ash_test_base.h" | 15 #include "ash/test/ash_test_base.h" |
16 #include "ash/test/shelf_test_api.h" | 16 #include "ash/test/shelf_test_api.h" |
17 #include "ash/test/shelf_view_test_api.h" | 17 #include "ash/test/shelf_view_test_api.h" |
18 #include "ash/test/shell_test_api.h" | 18 #include "ash/test/shell_test_api.h" |
19 #include "ash/test/test_shelf_delegate.h" | 19 #include "ash/test/test_shelf_delegate.h" |
20 #include "ash/wm/maximize_mode/maximize_mode_controller.h" | 20 #include "ash/wm/maximize_mode/maximize_mode_controller.h" |
21 #include "ash/wm/mru_window_tracker.h" | 21 #include "ash/wm/mru_window_tracker.h" |
22 #include "ash/wm/overview/overview_window_button.h" | |
23 #include "ash/wm/overview/window_grid.h" | 22 #include "ash/wm/overview/window_grid.h" |
24 #include "ash/wm/overview/window_selector.h" | 23 #include "ash/wm/overview/window_selector.h" |
25 #include "ash/wm/overview/window_selector_controller.h" | 24 #include "ash/wm/overview/window_selector_controller.h" |
26 #include "ash/wm/overview/window_selector_item.h" | 25 #include "ash/wm/overview/window_selector_item.h" |
27 #include "ash/wm/panels/panel_layout_manager.h" | 26 #include "ash/wm/panels/panel_layout_manager.h" |
28 #include "ash/wm/window_state.h" | 27 #include "ash/wm/window_state.h" |
29 #include "ash/wm/window_util.h" | 28 #include "ash/wm/window_util.h" |
30 #include "ash/wm/wm_event.h" | 29 #include "ash/wm/wm_event.h" |
31 #include "base/basictypes.h" | 30 #include "base/basictypes.h" |
32 #include "base/compiler_specific.h" | 31 #include "base/compiler_specific.h" |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 window_selector_controller()->window_selector_.get(); | 208 window_selector_controller()->window_selector_.get(); |
210 return ws->text_filter_widget_->GetNativeWindow()->layer()-> | 209 return ws->text_filter_widget_->GetNativeWindow()->layer()-> |
211 GetTargetTransform().IsIdentity(); | 210 GetTargetTransform().IsIdentity(); |
212 } | 211 } |
213 | 212 |
214 views::Widget* GetCloseButton(ash::WindowSelectorItem* window) { | 213 views::Widget* GetCloseButton(ash::WindowSelectorItem* window) { |
215 return &(window->close_button_widget_); | 214 return &(window->close_button_widget_); |
216 } | 215 } |
217 | 216 |
218 views::LabelButton* GetLabelButtonView(ash::WindowSelectorItem* window) { | 217 views::LabelButton* GetLabelButtonView(ash::WindowSelectorItem* window) { |
219 return static_cast<views::LabelButton*>( | 218 return window->window_label_button_view_; |
220 window->overview_window_button_->window_label_->GetContentsView()); | |
221 } | 219 } |
222 | 220 |
223 // Tests that a window is contained within a given WindowSelectorItem, and | 221 // Tests that a window is contained within a given WindowSelectorItem, and |
224 // that both the window and its matching close button are within the same | 222 // that both the window and its matching close button are within the same |
225 // screen. | 223 // screen. |
226 void IsWindowAndCloseButtonInScreen(aura::Window* window, | 224 void IsWindowAndCloseButtonInScreen(aura::Window* window, |
227 WindowSelectorItem* window_item) { | 225 WindowSelectorItem* window_item) { |
228 aura::Window* root_window = window_item->root_window(); | 226 aura::Window* root_window = window_item->root_window(); |
229 EXPECT_TRUE(window_item->Contains(window)); | 227 EXPECT_TRUE(window_item->Contains(window)); |
230 EXPECT_TRUE(root_window->GetBoundsInScreen().Contains( | 228 EXPECT_TRUE(root_window->GetBoundsInScreen().Contains( |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 EXPECT_TRUE(wm::IsActiveWindow(window2.get())); | 364 EXPECT_TRUE(wm::IsActiveWindow(window2.get())); |
367 | 365 |
368 ToggleOverview(); | 366 ToggleOverview(); |
369 | 367 |
370 gfx::Rect window1_bounds = | 368 gfx::Rect window1_bounds = |
371 gfx::ToEnclosingRect(GetTransformedBoundsInRootWindow(window1.get())); | 369 gfx::ToEnclosingRect(GetTransformedBoundsInRootWindow(window1.get())); |
372 ui::test::EventGenerator event_generator(window1->GetRootWindow(), | 370 ui::test::EventGenerator event_generator(window1->GetRootWindow(), |
373 window1_bounds.CenterPoint()); | 371 window1_bounds.CenterPoint()); |
374 | 372 |
375 // Clicking on |window2| while touching on |window1| should not cause a | 373 // Clicking on |window2| while touching on |window1| should not cause a |
376 // crash, and |window2| should be selected. | 374 // crash, overview mode should be disengaged and |window2| should be active. |
377 const int kTouchId = 19; | 375 const int kTouchId = 19; |
378 event_generator.PressTouchId(kTouchId); | 376 event_generator.PressTouchId(kTouchId); |
379 event_generator.MoveMouseToCenterOf(window2.get()); | 377 event_generator.MoveMouseToCenterOf(window2.get()); |
380 event_generator.ClickLeftButton(); | 378 event_generator.ClickLeftButton(); |
381 EXPECT_FALSE(IsSelecting()); | 379 EXPECT_FALSE(IsSelecting()); |
| 380 EXPECT_TRUE(wm::IsActiveWindow(window2.get())); |
382 event_generator.ReleaseTouchId(kTouchId); | 381 event_generator.ReleaseTouchId(kTouchId); |
383 | 382 |
384 ToggleOverview(); | 383 ToggleOverview(); |
385 | 384 |
386 // Clicking on |window1| while touching on |window1| should not cause | 385 // Clicking on |window1| while touching on |window1| should not cause |
387 // a crash, overview mode should be disengaged, and |window1| should | 386 // a crash, overview mode should be disengaged, and |window1| should |
388 // be active. | 387 // be active. |
389 event_generator.MoveMouseToCenterOf(window1.get()); | 388 event_generator.MoveMouseToCenterOf(window1.get()); |
390 event_generator.PressTouchId(kTouchId); | 389 event_generator.PressTouchId(kTouchId); |
391 event_generator.ClickLeftButton(); | 390 event_generator.ClickLeftButton(); |
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
920 // Verify the label matches the window title. | 919 // Verify the label matches the window title. |
921 EXPECT_EQ(label->GetText(), window_title); | 920 EXPECT_EQ(label->GetText(), window_title); |
922 | 921 |
923 // Update the window title and check that the label is updated, too. | 922 // Update the window title and check that the label is updated, too. |
924 base::string16 updated_title = base::UTF8ToUTF16("Updated title"); | 923 base::string16 updated_title = base::UTF8ToUTF16("Updated title"); |
925 window->SetTitle(updated_title); | 924 window->SetTitle(updated_title); |
926 EXPECT_EQ(label->GetText(), updated_title); | 925 EXPECT_EQ(label->GetText(), updated_title); |
927 | 926 |
928 // Labels are located based on target_bounds, not the actual window item | 927 // Labels are located based on target_bounds, not the actual window item |
929 // bounds. | 928 // bounds. |
930 gfx::Rect target_bounds(window_item->target_bounds()); | 929 gfx::Rect label_bounds = label->GetWidget()->GetNativeWindow()->bounds(); |
931 gfx::Rect expected_label_bounds(target_bounds.x(), | 930 EXPECT_EQ(label_bounds, window_item->target_bounds()); |
932 target_bounds.bottom() - label-> | |
933 GetPreferredSize().height(), | |
934 target_bounds.width(), | |
935 label->GetPreferredSize().height()); | |
936 gfx::Rect real_label_bounds = label->GetWidget()->GetNativeWindow()->bounds(); | |
937 EXPECT_EQ(real_label_bounds, expected_label_bounds); | |
938 } | 931 } |
939 | 932 |
940 // Tests that overview updates the window positions if the display orientation | 933 // Tests that overview updates the window positions if the display orientation |
941 // changes. | 934 // changes. |
942 TEST_F(WindowSelectorTest, DisplayOrientationChanged) { | 935 TEST_F(WindowSelectorTest, DisplayOrientationChanged) { |
943 if (!SupportsHostWindowResize()) | 936 if (!SupportsHostWindowResize()) |
944 return; | 937 return; |
945 | 938 |
946 aura::Window* root_window = Shell::GetInstance()->GetPrimaryRootWindow(); | 939 aura::Window* root_window = Shell::GetInstance()->GetPrimaryRootWindow(); |
947 UpdateDisplay("600x200"); | 940 UpdateDisplay("600x200"); |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1247 // Switch to overview mode. | 1240 // Switch to overview mode. |
1248 ToggleOverview(); | 1241 ToggleOverview(); |
1249 ASSERT_TRUE(IsSelecting()); | 1242 ASSERT_TRUE(IsSelecting()); |
1250 | 1243 |
1251 // Tap should now exit overview mode. | 1244 // Tap should now exit overview mode. |
1252 generator.GestureTapAt(point_in_background_page); | 1245 generator.GestureTapAt(point_in_background_page); |
1253 EXPECT_FALSE(IsSelecting()); | 1246 EXPECT_FALSE(IsSelecting()); |
1254 } | 1247 } |
1255 | 1248 |
1256 } // namespace ash | 1249 } // namespace ash |
OLD | NEW |