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

Side by Side Diff: ash/wm/window_positioner_unittest.cc

Issue 2618143002: cros: Remove some OS platform ifdefs from ash (Closed)
Patch Set: rebase Created 3 years, 11 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/window_manager_unittest.cc ('k') | ash/wm/workspace/workspace_event_handler_unittest.cc » ('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 "ash/common/wm/window_positioner.h" 5 #include "ash/common/wm/window_positioner.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "ash/common/material_design/material_design_controller.h" 9 #include "ash/common/material_design/material_design_controller.h"
10 #include "ash/common/scoped_root_window_for_new_windows.h" 10 #include "ash/common/scoped_root_window_for_new_windows.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 params.can_resize = true; 46 params.can_resize = true;
47 params.can_maximize = true; 47 params.can_maximize = true;
48 views::Widget* widget = shell::ToplevelWindow::CreateToplevelWindow(params); 48 views::Widget* widget = shell::ToplevelWindow::CreateToplevelWindow(params);
49 EXPECT_EQ(gfx::Rect(400, 0, 500, 453 + height_offset).ToString(), 49 EXPECT_EQ(gfx::Rect(400, 0, 500, 453 + height_offset).ToString(),
50 widget->GetWindowBoundsInScreen().ToString()); 50 widget->GetWindowBoundsInScreen().ToString());
51 } 51 }
52 52
53 TEST_P(WindowPositionerTest, OpenDefaultWindowOnSecondDisplay) { 53 TEST_P(WindowPositionerTest, OpenDefaultWindowOnSecondDisplay) {
54 if (!SupportsMultipleDisplays()) 54 if (!SupportsMultipleDisplays())
55 return; 55 return;
56 #if defined(OS_WIN) 56
57 ash::WindowPositioner::SetMaximizeFirstWindow(true);
58 #endif
59 UpdateDisplay("400x400,1400x900"); 57 UpdateDisplay("400x400,1400x900");
60 WmWindow* second_root_window = WmShell::Get()->GetAllRootWindows()[1]; 58 WmWindow* second_root_window = WmShell::Get()->GetAllRootWindows()[1];
61 ScopedRootWindowForNewWindows root_for_new_windows(second_root_window); 59 ScopedRootWindowForNewWindows root_for_new_windows(second_root_window);
62 shell::ToplevelWindow::CreateParams params; 60 shell::ToplevelWindow::CreateParams params;
63 params.can_resize = true; 61 params.can_resize = true;
64 params.can_maximize = true; 62 params.can_maximize = true;
65 views::Widget* widget = shell::ToplevelWindow::CreateToplevelWindow(params); 63 views::Widget* widget = shell::ToplevelWindow::CreateToplevelWindow(params);
66 gfx::Rect bounds = widget->GetWindowBoundsInScreen(); 64 gfx::Rect bounds = widget->GetWindowBoundsInScreen();
67 #if defined(OS_WIN) 65
68 EXPECT_TRUE(widget->IsMaximized());
69 #else
70 // The window should be in the 2nd display with the default size. 66 // The window should be in the 2nd display with the default size.
71 EXPECT_EQ("300x300", bounds.size().ToString()); 67 EXPECT_EQ("300x300", bounds.size().ToString());
72 #endif
73
74 EXPECT_TRUE( 68 EXPECT_TRUE(
75 second_root_window->GetDisplayNearestWindow().bounds().Contains(bounds)); 69 second_root_window->GetDisplayNearestWindow().bounds().Contains(bounds));
76 } 70 }
77 71
78 // Tests that second window inherits first window's maximized state as well as 72 // Tests that second window inherits first window's maximized state as well as
79 // its restore bounds. 73 // its restore bounds.
80 // TODO(msw): Broken on Windows. http://crbug.com/584038
81 #if defined(OS_CHROMEOS)
82 TEST_P(WindowPositionerTest, SecondMaximizedWindowHasProperRestoreSize) { 74 TEST_P(WindowPositionerTest, SecondMaximizedWindowHasProperRestoreSize) {
83 const int height_offset = GetMdMaximizedWindowHeightOffset(); 75 const int height_offset = GetMdMaximizedWindowHeightOffset();
84 UpdateDisplay("1400x900"); 76 UpdateDisplay("1400x900");
85 shell::ToplevelWindow::CreateParams params; 77 shell::ToplevelWindow::CreateParams params;
86 params.can_resize = true; 78 params.can_resize = true;
87 params.can_maximize = true; 79 params.can_maximize = true;
88 views::Widget* widget1 = shell::ToplevelWindow::CreateToplevelWindow(params); 80 views::Widget* widget1 = shell::ToplevelWindow::CreateToplevelWindow(params);
89 gfx::Rect bounds = widget1->GetWindowBoundsInScreen(); 81 gfx::Rect bounds = widget1->GetWindowBoundsInScreen();
90 82
91 // The window should have default size. 83 // The window should have default size.
(...skipping 14 matching lines...) Expand all
106 bounds = widget2->GetWindowBoundsInScreen(); 98 bounds = widget2->GetWindowBoundsInScreen();
107 EXPECT_TRUE(widget2->IsMaximized()); 99 EXPECT_TRUE(widget2->IsMaximized());
108 EXPECT_EQ(gfx::Rect(0, 0, 1400, 853 + height_offset).ToString(), 100 EXPECT_EQ(gfx::Rect(0, 0, 1400, 853 + height_offset).ToString(),
109 bounds.ToString()); 101 bounds.ToString());
110 102
111 widget2->Restore(); 103 widget2->Restore();
112 // Second window's restored size should be set to default size. 104 // Second window's restored size should be set to default size.
113 bounds = widget2->GetWindowBoundsInScreen(); 105 bounds = widget2->GetWindowBoundsInScreen();
114 EXPECT_EQ("300x300", bounds.size().ToString()); 106 EXPECT_EQ("300x300", bounds.size().ToString());
115 } 107 }
116 #endif // defined(OS_CHROMEOS)
117 108
118 namespace { 109 namespace {
119 110
120 // A WidgetDelegate that returns the out of display saved bounds. 111 // A WidgetDelegate that returns the out of display saved bounds.
121 class OutOfDisplayDelegate : public views::WidgetDelegate { 112 class OutOfDisplayDelegate : public views::WidgetDelegate {
122 public: 113 public:
123 explicit OutOfDisplayDelegate(views::Widget* widget) : widget_(widget) {} 114 explicit OutOfDisplayDelegate(views::Widget* widget) : widget_(widget) {}
124 ~OutOfDisplayDelegate() override {} 115 ~OutOfDisplayDelegate() override {}
125 116
126 // Overridden from WidgetDelegate: 117 // Overridden from WidgetDelegate:
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 widget1->SetFullscreen(false); 219 widget1->SetFullscreen(false);
229 ASSERT_EQ("300x300", widget1->GetWindowBoundsInScreen().size().ToString()); 220 ASSERT_EQ("300x300", widget1->GetWindowBoundsInScreen().size().ToString());
230 221
231 // Closing 2nd widget triggers the rearrange logic but the 1st 222 // Closing 2nd widget triggers the rearrange logic but the 1st
232 // widget should stay in the current size. 223 // widget should stay in the current size.
233 widget2->CloseNow(); 224 widget2->CloseNow();
234 ASSERT_EQ("300x300", widget1->GetWindowBoundsInScreen().size().ToString()); 225 ASSERT_EQ("300x300", widget1->GetWindowBoundsInScreen().size().ToString());
235 } 226 }
236 227
237 } // namespace ash 228 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/window_manager_unittest.cc ('k') | ash/wm/workspace/workspace_event_handler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698