| 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 #include <vector> | 6 #include <vector> |
| 7 | 7 |
| 8 #include "ash/aura/wm_window_aura.h" | 8 #include "ash/aura/wm_window_aura.h" |
| 9 #include "ash/common/accessibility_delegate.h" | 9 #include "ash/common/accessibility_delegate.h" |
| 10 #include "ash/common/accessibility_types.h" | 10 #include "ash/common/accessibility_types.h" |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 return CreateTestWindowInShellWithDelegate(&delegate_, -1, bounds); | 133 return CreateTestWindowInShellWithDelegate(&delegate_, -1, bounds); |
| 134 } | 134 } |
| 135 | 135 |
| 136 aura::Window* CreateWindowWithId(const gfx::Rect& bounds, int id) { | 136 aura::Window* CreateWindowWithId(const gfx::Rect& bounds, int id) { |
| 137 return CreateTestWindowInShellWithDelegate(&delegate_, id, bounds); | 137 return CreateTestWindowInShellWithDelegate(&delegate_, id, bounds); |
| 138 } | 138 } |
| 139 aura::Window* CreateNonActivatableWindow(const gfx::Rect& bounds) { | 139 aura::Window* CreateNonActivatableWindow(const gfx::Rect& bounds) { |
| 140 aura::Window* window = CreateWindow(bounds); | 140 aura::Window* window = CreateWindow(bounds); |
| 141 aura::client::SetActivationDelegate(window, | 141 aura::client::SetActivationDelegate(window, |
| 142 &non_activatable_activation_delegate_); | 142 &non_activatable_activation_delegate_); |
| 143 EXPECT_FALSE(ash::wm::CanActivateWindow(window)); | 143 EXPECT_FALSE(wm::CanActivateWindow(window)); |
| 144 return window; | 144 return window; |
| 145 } | 145 } |
| 146 | 146 |
| 147 // Creates a Widget containing a Window with the given |bounds|. This should | 147 // Creates a Widget containing a Window with the given |bounds|. This should |
| 148 // be used when the test requires a Widget. For example any test that will | 148 // be used when the test requires a Widget. For example any test that will |
| 149 // cause a window to be closed via | 149 // cause a window to be closed via |
| 150 // views::Widget::GetWidgetForNativeView(window)->Close(). | 150 // views::Widget::GetWidgetForNativeView(window)->Close(). |
| 151 std::unique_ptr<views::Widget> CreateWindowWidget(const gfx::Rect& bounds) { | 151 std::unique_ptr<views::Widget> CreateWindowWidget(const gfx::Rect& bounds) { |
| 152 std::unique_ptr<views::Widget> widget(new views::Widget); | 152 std::unique_ptr<views::Widget> widget(new views::Widget); |
| 153 views::Widget::InitParams params; | 153 views::Widget::InitParams params; |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 } | 283 } |
| 284 | 284 |
| 285 bool showing_filter_widget() { | 285 bool showing_filter_widget() { |
| 286 return window_selector() | 286 return window_selector() |
| 287 ->text_filter_widget_->GetNativeWindow() | 287 ->text_filter_widget_->GetNativeWindow() |
| 288 ->layer() | 288 ->layer() |
| 289 ->GetTargetTransform() | 289 ->GetTargetTransform() |
| 290 .IsIdentity(); | 290 .IsIdentity(); |
| 291 } | 291 } |
| 292 | 292 |
| 293 views::Widget* GetCloseButton(ash::WindowSelectorItem* window) { | 293 views::Widget* GetCloseButton(WindowSelectorItem* window) { |
| 294 return window->close_button_->GetWidget(); | 294 return window->close_button_->GetWidget(); |
| 295 } | 295 } |
| 296 | 296 |
| 297 views::LabelButton* GetLabelButtonView(ash::WindowSelectorItem* window) { | 297 views::LabelButton* GetLabelButtonView(WindowSelectorItem* window) { |
| 298 return window->window_label_button_view_; | 298 return window->window_label_button_view_; |
| 299 } | 299 } |
| 300 | 300 |
| 301 // Tests that a window is contained within a given WindowSelectorItem, and | 301 // Tests that a window is contained within a given WindowSelectorItem, and |
| 302 // that both the window and its matching close button are within the same | 302 // that both the window and its matching close button are within the same |
| 303 // screen. | 303 // screen. |
| 304 void IsWindowAndCloseButtonInScreen(aura::Window* window, | 304 void IsWindowAndCloseButtonInScreen(aura::Window* window, |
| 305 WindowSelectorItem* window_item) { | 305 WindowSelectorItem* window_item) { |
| 306 aura::Window* root_window = | 306 aura::Window* root_window = |
| 307 WmWindowAura::GetAuraWindow(window_item->root_window()); | 307 WmWindowAura::GetAuraWindow(window_item->root_window()); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 384 expected_bounds = gfx::Rect(112, -32, 75, 32); | 384 expected_bounds = gfx::Rect(112, -32, 75, 32); |
| 385 expected_bounds_MD = gfx::Rect(10, -40, 280, 40); | 385 expected_bounds_MD = gfx::Rect(10, -40, 280, 40); |
| 386 EXPECT_EQ((material ? expected_bounds_MD : expected_bounds).ToString(), | 386 EXPECT_EQ((material ? expected_bounds_MD : expected_bounds).ToString(), |
| 387 text_filter->GetClientAreaBoundsInScreen().ToString()); | 387 text_filter->GetClientAreaBoundsInScreen().ToString()); |
| 388 } | 388 } |
| 389 #endif | 389 #endif |
| 390 | 390 |
| 391 // Tests that an a11y alert is sent on entering overview mode. | 391 // Tests that an a11y alert is sent on entering overview mode. |
| 392 TEST_P(WindowSelectorTest, A11yAlertOnOverviewMode) { | 392 TEST_P(WindowSelectorTest, A11yAlertOnOverviewMode) { |
| 393 gfx::Rect bounds(0, 0, 400, 400); | 393 gfx::Rect bounds(0, 0, 400, 400); |
| 394 AccessibilityDelegate* delegate = | 394 AccessibilityDelegate* delegate = WmShell::Get()->GetAccessibilityDelegate(); |
| 395 ash::Shell::GetInstance()->accessibility_delegate(); | |
| 396 std::unique_ptr<aura::Window> window1(CreateWindow(bounds)); | 395 std::unique_ptr<aura::Window> window1(CreateWindow(bounds)); |
| 397 EXPECT_NE(delegate->GetLastAccessibilityAlert(), | 396 EXPECT_NE(delegate->GetLastAccessibilityAlert(), |
| 398 A11Y_ALERT_WINDOW_OVERVIEW_MODE_ENTERED); | 397 A11Y_ALERT_WINDOW_OVERVIEW_MODE_ENTERED); |
| 399 ToggleOverview(); | 398 ToggleOverview(); |
| 400 EXPECT_EQ(delegate->GetLastAccessibilityAlert(), | 399 EXPECT_EQ(delegate->GetLastAccessibilityAlert(), |
| 401 A11Y_ALERT_WINDOW_OVERVIEW_MODE_ENTERED); | 400 A11Y_ALERT_WINDOW_OVERVIEW_MODE_ENTERED); |
| 402 } | 401 } |
| 403 | 402 |
| 404 // Tests that there are no crashes when there is not enough screen space | 403 // Tests that there are no crashes when there is not enough screen space |
| 405 // available to show all of the windows. | 404 // available to show all of the windows. |
| (...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 923 EXPECT_TRUE(wm::GetWindowState(window1.get())->IsFullscreen()); | 922 EXPECT_TRUE(wm::GetWindowState(window1.get())->IsFullscreen()); |
| 924 } | 923 } |
| 925 | 924 |
| 926 // Tests that the shelf dimming state is removed while in overview and restored | 925 // Tests that the shelf dimming state is removed while in overview and restored |
| 927 // on exiting overview. | 926 // on exiting overview. |
| 928 TEST_P(WindowSelectorTest, OverviewUndimsShelf) { | 927 TEST_P(WindowSelectorTest, OverviewUndimsShelf) { |
| 929 gfx::Rect bounds(0, 0, 400, 400); | 928 gfx::Rect bounds(0, 0, 400, 400); |
| 930 std::unique_ptr<aura::Window> window1(CreateWindow(bounds)); | 929 std::unique_ptr<aura::Window> window1(CreateWindow(bounds)); |
| 931 wm::WindowState* window_state = wm::GetWindowState(window1.get()); | 930 wm::WindowState* window_state = wm::GetWindowState(window1.get()); |
| 932 window_state->Maximize(); | 931 window_state->Maximize(); |
| 933 ash::ShelfWidget* shelf = | 932 ShelfWidget* shelf = Shell::GetPrimaryRootWindowController()->shelf_widget(); |
| 934 Shell::GetPrimaryRootWindowController()->shelf_widget(); | |
| 935 EXPECT_TRUE(shelf->GetDimsShelf()); | 933 EXPECT_TRUE(shelf->GetDimsShelf()); |
| 936 ToggleOverview(); | 934 ToggleOverview(); |
| 937 EXPECT_FALSE(shelf->GetDimsShelf()); | 935 EXPECT_FALSE(shelf->GetDimsShelf()); |
| 938 ToggleOverview(); | 936 ToggleOverview(); |
| 939 EXPECT_TRUE(shelf->GetDimsShelf()); | 937 EXPECT_TRUE(shelf->GetDimsShelf()); |
| 940 } | 938 } |
| 941 | 939 |
| 942 // Tests that entering overview when a fullscreen window is active in maximized | 940 // Tests that entering overview when a fullscreen window is active in maximized |
| 943 // mode correctly applies the transformations to the window and correctly | 941 // mode correctly applies the transformations to the window and correctly |
| 944 // updates the window bounds on exiting overview mode: http://crbug.com/401664. | 942 // updates the window bounds on exiting overview mode: http://crbug.com/401664. |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1268 } | 1266 } |
| 1269 | 1267 |
| 1270 // Tests starting overview during a drag and drop tracking operation. | 1268 // Tests starting overview during a drag and drop tracking operation. |
| 1271 // TODO(flackr): Fix memory corruption crash when running locally (not failing | 1269 // TODO(flackr): Fix memory corruption crash when running locally (not failing |
| 1272 // on bots). See http://crbug.com/342528. | 1270 // on bots). See http://crbug.com/342528. |
| 1273 TEST_P(WindowSelectorTest, DISABLED_DragDropInProgress) { | 1271 TEST_P(WindowSelectorTest, DISABLED_DragDropInProgress) { |
| 1274 bool drag_canceled_by_test = false; | 1272 bool drag_canceled_by_test = false; |
| 1275 gfx::Rect bounds(0, 0, 400, 400); | 1273 gfx::Rect bounds(0, 0, 400, 400); |
| 1276 std::unique_ptr<aura::Window> window(CreateWindow(bounds)); | 1274 std::unique_ptr<aura::Window> window(CreateWindow(bounds)); |
| 1277 test::ShellTestApi shell_test_api(Shell::GetInstance()); | 1275 test::ShellTestApi shell_test_api(Shell::GetInstance()); |
| 1278 ash::DragDropController* drag_drop_controller = | 1276 DragDropController* drag_drop_controller = |
| 1279 shell_test_api.drag_drop_controller(); | 1277 shell_test_api.drag_drop_controller(); |
| 1280 ui::OSExchangeData data; | 1278 ui::OSExchangeData data; |
| 1281 base::ThreadTaskRunnerHandle::Get()->PostTask( | 1279 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 1282 FROM_HERE, | 1280 FROM_HERE, |
| 1283 base::Bind(&WindowSelectorTest::ToggleOverview, base::Unretained(this))); | 1281 base::Bind(&WindowSelectorTest::ToggleOverview, base::Unretained(this))); |
| 1284 base::ThreadTaskRunnerHandle::Get()->PostTask( | 1282 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 1285 FROM_HERE, | 1283 FROM_HERE, |
| 1286 base::Bind(&CancelDrag, drag_drop_controller, &drag_canceled_by_test)); | 1284 base::Bind(&CancelDrag, drag_drop_controller, &drag_canceled_by_test)); |
| 1287 data.SetString(base::UTF8ToUTF16("I am being dragged")); | 1285 data.SetString(base::UTF8ToUTF16("I am being dragged")); |
| 1288 drag_drop_controller->StartDragAndDrop( | 1286 drag_drop_controller->StartDragAndDrop( |
| (...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1822 bounds.y()); | 1820 bounds.y()); |
| 1823 EXPECT_LE(transformed_rect.bottom(), bounds.bottom()); | 1821 EXPECT_LE(transformed_rect.bottom(), bounds.bottom()); |
| 1824 EXPECT_NEAR(transformed_rect.x() - bounds.x(), | 1822 EXPECT_NEAR(transformed_rect.x() - bounds.x(), |
| 1825 bounds.right() - transformed_rect.right(), 1); | 1823 bounds.right() - transformed_rect.right(), 1); |
| 1826 EXPECT_NEAR( | 1824 EXPECT_NEAR( |
| 1827 transformed_rect.y() + (int)(scale * inset) - header_height - bounds.y(), | 1825 transformed_rect.y() + (int)(scale * inset) - header_height - bounds.y(), |
| 1828 bounds.bottom() - transformed_rect.bottom(), 1); | 1826 bounds.bottom() - transformed_rect.bottom(), 1); |
| 1829 } | 1827 } |
| 1830 | 1828 |
| 1831 } // namespace ash | 1829 } // namespace ash |
| OLD | NEW |