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

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

Issue 2978273002: Revert of Cros Tablet Window management - Split Screen part II (Closed)
Patch Set: Created 3 years, 5 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 | « ash/wm/overview/window_selector_item.cc ('k') | ash/wm/splitview/split_view_controller.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <algorithm> 5 #include <algorithm>
6 #include <vector> 6 #include <vector>
7 7
8 #include "ash/accessibility_delegate.h" 8 #include "ash/accessibility_delegate.h"
9 #include "ash/accessibility_types.h" 9 #include "ash/accessibility_types.h"
10 #include "ash/drag_drop/drag_drop_controller.h" 10 #include "ash/drag_drop/drag_drop_controller.h"
11 #include "ash/public/cpp/config.h" 11 #include "ash/public/cpp/config.h"
12 #include "ash/public/cpp/window_properties.h" 12 #include "ash/public/cpp/window_properties.h"
13 #include "ash/shelf/shelf.h" 13 #include "ash/shelf/shelf.h"
14 #include "ash/shell.h" 14 #include "ash/shell.h"
15 #include "ash/system/tray/system_tray.h" 15 #include "ash/system/tray/system_tray.h"
16 #include "ash/test/ash_test_base.h" 16 #include "ash/test/ash_test_base.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_app_list_view_presenter_impl.h" 19 #include "ash/test/test_app_list_view_presenter_impl.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/overview/window_grid.h" 21 #include "ash/wm/overview/window_grid.h"
22 #include "ash/wm/overview/window_selector.h" 22 #include "ash/wm/overview/window_selector.h"
23 #include "ash/wm/overview/window_selector_controller.h" 23 #include "ash/wm/overview/window_selector_controller.h"
24 #include "ash/wm/overview/window_selector_item.h" 24 #include "ash/wm/overview/window_selector_item.h"
25 #include "ash/wm/panels/panel_layout_manager.h" 25 #include "ash/wm/panels/panel_layout_manager.h"
26 #include "ash/wm/splitview/split_view_controller.h"
27 #include "ash/wm/window_state.h" 26 #include "ash/wm/window_state.h"
28 #include "ash/wm/window_util.h" 27 #include "ash/wm/window_util.h"
29 #include "ash/wm/wm_event.h" 28 #include "ash/wm/wm_event.h"
30 #include "ash/wm/workspace/workspace_window_resizer.h" 29 #include "ash/wm/workspace/workspace_window_resizer.h"
31 #include "base/strings/string_number_conversions.h" 30 #include "base/strings/string_number_conversions.h"
32 #include "base/strings/utf_string_conversions.h" 31 #include "base/strings/utf_string_conversions.h"
33 #include "base/test/user_action_tester.h" 32 #include "base/test/user_action_tester.h"
34 #include "ui/aura/client/aura_constants.h" 33 #include "ui/aura/client/aura_constants.h"
35 #include "ui/aura/client/focus_client.h" 34 #include "ui/aura/client/focus_client.h"
36 #include "ui/aura/test/test_windows.h" 35 #include "ui/aura/test/test_windows.h"
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 } 158 }
160 159
161 WindowSelectorController* window_selector_controller() { 160 WindowSelectorController* window_selector_controller() {
162 return Shell::Get()->window_selector_controller(); 161 return Shell::Get()->window_selector_controller();
163 } 162 }
164 163
165 WindowSelector* window_selector() { 164 WindowSelector* window_selector() {
166 return window_selector_controller()->window_selector_.get(); 165 return window_selector_controller()->window_selector_.get();
167 } 166 }
168 167
169 SplitViewController* split_view_controller() {
170 return Shell::Get()->split_view_controller();
171 }
172
173 void ToggleOverview() { window_selector_controller()->ToggleOverview(); } 168 void ToggleOverview() { window_selector_controller()->ToggleOverview(); }
174 169
175 aura::Window* GetOverviewWindowForMinimizedState(int index, 170 aura::Window* GetOverviewWindowForMinimizedState(int index,
176 aura::Window* window) { 171 aura::Window* window) {
177 WindowSelectorItem* selector = GetWindowItemForWindow(index, window); 172 WindowSelectorItem* selector = GetWindowItemForWindow(index, window);
178 return selector->GetOverviewWindowForMinimizedStateForTest(); 173 return selector->GetOverviewWindowForMinimizedStateForTest();
179 } 174 }
180 175
181 gfx::Rect GetTransformedBounds(aura::Window* window) { 176 gfx::Rect GetTransformedBounds(aura::Window* window) {
182 gfx::Rect bounds_in_screen = window->layer()->bounds(); 177 gfx::Rect bounds_in_screen = window->layer()->bounds();
(...skipping 1706 matching lines...) Expand 10 before | Expand all | Expand 10 after
1889 std::unique_ptr<WindowResizer> resizer(CreateWindowResizer( 1884 std::unique_ptr<WindowResizer> resizer(CreateWindowResizer(
1890 window.get(), gfx::Point(), HTCAPTION, ::wm::WINDOW_MOVE_SOURCE_MOUSE)); 1885 window.get(), gfx::Point(), HTCAPTION, ::wm::WINDOW_MOVE_SOURCE_MOUSE));
1891 ASSERT_TRUE(resizer.get()); 1886 ASSERT_TRUE(resizer.get());
1892 gfx::Point location = resizer->GetInitialLocation(); 1887 gfx::Point location = resizer->GetInitialLocation();
1893 location.Offset(20, 20); 1888 location.Offset(20, 20);
1894 resizer->Drag(location, 0); 1889 resizer->Drag(location, 0);
1895 ToggleOverview(); 1890 ToggleOverview();
1896 resizer->RevertDrag(); 1891 resizer->RevertDrag();
1897 } 1892 }
1898 1893
1899 // Tests that dragging a overview window selector item to the edge of the screen
1900 // snaps the window. If two windows are snapped to left and right side of the
1901 // screen, exit the overview mode.
1902 TEST_F(WindowSelectorTest, DragOverviewWindowToSnap) {
1903 const gfx::Rect bounds(0, 0, 400, 400);
1904 std::unique_ptr<aura::Window> window1(CreateWindow(bounds));
1905 std::unique_ptr<aura::Window> window2(CreateWindow(bounds));
1906 std::unique_ptr<aura::Window> window3(CreateWindow(bounds));
1907
1908 ToggleOverview();
1909 EXPECT_TRUE(window_selector_controller()->IsSelecting());
1910 EXPECT_EQ(split_view_controller()->IsSplitViewModeActive(), false);
1911
1912 // Drag |window1| selector item to snap to left.
1913 const int grid_index = 0;
1914 WindowSelectorItem* selector_item1 =
1915 GetWindowItemForWindow(grid_index, window1.get());
1916 const gfx::Rect selector_item_bounds1 = selector_item1->target_bounds();
1917 // Start drag in the middle of the seletor item.
1918 const gfx::Point start_location1(selector_item_bounds1.CenterPoint());
1919 window_selector()->InitiateDrag(selector_item1, start_location1);
1920 const gfx::Point end_location1(0, 0);
1921 window_selector()->Drag(selector_item1, end_location1);
1922 window_selector()->CompleteDrag(selector_item1);
1923
1924 EXPECT_EQ(split_view_controller()->IsSplitViewModeActive(), true);
1925 EXPECT_EQ(split_view_controller()->state(),
1926 SplitViewController::LEFT_SNAPPED);
1927 EXPECT_EQ(split_view_controller()->left_window(), window1.get());
1928
1929 // Drag |window2| selector item to snap to left.
1930 WindowSelectorItem* selector_item2 =
1931 GetWindowItemForWindow(grid_index, window2.get());
1932 const gfx::Rect selector_item_bounds2 = selector_item2->target_bounds();
1933 // Start drag in the middle of the seletor item.
1934 const gfx::Point start_location2(selector_item_bounds2.CenterPoint());
1935 window_selector()->InitiateDrag(selector_item2, start_location2);
1936 const gfx::Point end_location2(0, 0);
1937 window_selector()->Drag(selector_item2, end_location2);
1938 window_selector()->CompleteDrag(selector_item2);
1939
1940 EXPECT_EQ(split_view_controller()->state(),
1941 SplitViewController::LEFT_SNAPPED);
1942 EXPECT_EQ(split_view_controller()->left_window(), window2.get());
1943
1944 // Drag |window3| selector item to snap to right.
1945 WindowSelectorItem* selector_item3 =
1946 GetWindowItemForWindow(grid_index, window3.get());
1947 const gfx::Rect selector_item_bounds3 = selector_item3->target_bounds();
1948 // Start drag in the middle of the seletor item.
1949 const gfx::Point start_location3(selector_item_bounds3.CenterPoint());
1950 window_selector()->InitiateDrag(selector_item3, start_location3);
1951 const gfx::Rect work_area_rect =
1952 split_view_controller()->GetDisplayWorkAreaBoundsInScreen(window2.get());
1953 const gfx::Point end_location3(work_area_rect.width(), 0);
1954 window_selector()->Drag(selector_item3, end_location3);
1955 window_selector()->CompleteDrag(selector_item3);
1956
1957 EXPECT_EQ(split_view_controller()->state(),
1958 SplitViewController::BOTH_SNAPPED);
1959 EXPECT_EQ(split_view_controller()->right_window(), window3.get());
1960 EXPECT_FALSE(window_selector_controller()->IsSelecting());
1961 }
1962
1963 } // namespace ash 1894 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/overview/window_selector_item.cc ('k') | ash/wm/splitview/split_view_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698