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

Side by Side Diff: ash/root_window_controller_unittest.cc

Issue 93873013: Make sure the dragged window is smaller than work area in the target display (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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 | Annotate | Revision Log
« no previous file with comments | « ash/root_window_controller.cc ('k') | ash/wm/drag_window_resizer.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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/root_window_controller.h" 5 #include "ash/root_window_controller.h"
6 6
7 #include "ash/session_state_delegate.h" 7 #include "ash/session_state_delegate.h"
8 #include "ash/shelf/shelf_layout_manager.h" 8 #include "ash/shelf/shelf_layout_manager.h"
9 #include "ash/shell.h" 9 #include "ash/shell.h"
10 #include "ash/shell_window_ids.h" 10 #include "ash/shell_window_ids.h"
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 aura::Window* GetModalContainer(aura::Window* root_window) { 120 aura::Window* GetModalContainer(aura::Window* root_window) {
121 return Shell::GetContainer( 121 return Shell::GetContainer(
122 root_window, 122 root_window,
123 ash::internal::kShellWindowId_SystemModalContainer); 123 ash::internal::kShellWindowId_SystemModalContainer);
124 } 124 }
125 }; 125 };
126 126
127 TEST_F(RootWindowControllerTest, MoveWindows_Basic) { 127 TEST_F(RootWindowControllerTest, MoveWindows_Basic) {
128 if (!SupportsMultipleDisplays()) 128 if (!SupportsMultipleDisplays())
129 return; 129 return;
130 130 // Windows origin should be doubled when moved to the 1st display.
131 UpdateDisplay("600x600,500x500"); 131 UpdateDisplay("600x600,300x300");
132 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 132 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
133 internal::RootWindowController* controller = 133 internal::RootWindowController* controller =
134 Shell::GetPrimaryRootWindowController(); 134 Shell::GetPrimaryRootWindowController();
135 internal::ShelfLayoutManager* shelf_layout_manager = 135 internal::ShelfLayoutManager* shelf_layout_manager =
136 controller->GetShelfLayoutManager(); 136 controller->GetShelfLayoutManager();
137 shelf_layout_manager->SetAutoHideBehavior( 137 shelf_layout_manager->SetAutoHideBehavior(
138 ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); 138 ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
139 139
140 views::Widget* normal = CreateTestWidget(gfx::Rect(650, 10, 100, 100)); 140 views::Widget* normal = CreateTestWidget(gfx::Rect(650, 10, 100, 100));
141 EXPECT_EQ(root_windows[1], normal->GetNativeView()->GetRootWindow()); 141 EXPECT_EQ(root_windows[1], normal->GetNativeView()->GetRootWindow());
142 EXPECT_EQ("650,10 100x100", normal->GetWindowBoundsInScreen().ToString()); 142 EXPECT_EQ("650,10 100x100", normal->GetWindowBoundsInScreen().ToString());
143 EXPECT_EQ("50,10 100x100", 143 EXPECT_EQ("50,10 100x100",
144 normal->GetNativeView()->GetBoundsInRootWindow().ToString()); 144 normal->GetNativeView()->GetBoundsInRootWindow().ToString());
145 145
146 views::Widget* maximized = CreateTestWidget(gfx::Rect(700, 10, 100, 100)); 146 views::Widget* maximized = CreateTestWidget(gfx::Rect(700, 10, 100, 100));
147 maximized->Maximize(); 147 maximized->Maximize();
148 EXPECT_EQ(root_windows[1], maximized->GetNativeView()->GetRootWindow()); 148 EXPECT_EQ(root_windows[1], maximized->GetNativeView()->GetRootWindow());
149 EXPECT_EQ("600,0 500x453", maximized->GetWindowBoundsInScreen().ToString()); 149 EXPECT_EQ("600,0 300x253", maximized->GetWindowBoundsInScreen().ToString());
150 EXPECT_EQ("0,0 500x453", 150 EXPECT_EQ("0,0 300x253",
151 maximized->GetNativeView()->GetBoundsInRootWindow().ToString()); 151 maximized->GetNativeView()->GetBoundsInRootWindow().ToString());
152 152
153 views::Widget* minimized = CreateTestWidget(gfx::Rect(800, 10, 100, 100)); 153 views::Widget* minimized = CreateTestWidget(gfx::Rect(800, 10, 100, 100));
154 minimized->Minimize(); 154 minimized->Minimize();
155 EXPECT_EQ(root_windows[1], minimized->GetNativeView()->GetRootWindow()); 155 EXPECT_EQ(root_windows[1], minimized->GetNativeView()->GetRootWindow());
156 EXPECT_EQ("800,10 100x100", 156 EXPECT_EQ("800,10 100x100",
157 minimized->GetWindowBoundsInScreen().ToString()); 157 minimized->GetWindowBoundsInScreen().ToString());
158 158
159 views::Widget* fullscreen = CreateTestWidget(gfx::Rect(900, 10, 100, 100)); 159 views::Widget* fullscreen = CreateTestWidget(gfx::Rect(850, 10, 100, 100));
160 fullscreen->SetFullscreen(true); 160 fullscreen->SetFullscreen(true);
161 EXPECT_EQ(root_windows[1], fullscreen->GetNativeView()->GetRootWindow()); 161 EXPECT_EQ(root_windows[1], fullscreen->GetNativeView()->GetRootWindow());
162 162
163 EXPECT_EQ("600,0 500x500", 163 EXPECT_EQ("600,0 300x300",
164 fullscreen->GetWindowBoundsInScreen().ToString()); 164 fullscreen->GetWindowBoundsInScreen().ToString());
165 EXPECT_EQ("0,0 500x500", 165 EXPECT_EQ("0,0 300x300",
166 fullscreen->GetNativeView()->GetBoundsInRootWindow().ToString()); 166 fullscreen->GetNativeView()->GetBoundsInRootWindow().ToString());
167 167
168 views::Widget* unparented_control = new Widget; 168 views::Widget* unparented_control = new Widget;
169 Widget::InitParams params; 169 Widget::InitParams params;
170 params.bounds = gfx::Rect(650, 10, 100, 100); 170 params.bounds = gfx::Rect(650, 10, 100, 100);
171 params.context = CurrentContext(); 171 params.context = CurrentContext();
172 params.type = Widget::InitParams::TYPE_CONTROL; 172 params.type = Widget::InitParams::TYPE_CONTROL;
173 unparented_control->Init(params); 173 unparented_control->Init(params);
174 EXPECT_EQ(root_windows[1], 174 EXPECT_EQ(root_windows[1],
175 unparented_control->GetNativeView()->GetRootWindow()); 175 unparented_control->GetNativeView()->GetRootWindow());
(...skipping 14 matching lines...) Expand all
190 delete_on_blur_delegate.SetWindow(d2); 190 delete_on_blur_delegate.SetWindow(d2);
191 aura::client::GetFocusClient(root_windows[0])->FocusWindow(d2); 191 aura::client::GetFocusClient(root_windows[0])->FocusWindow(d2);
192 tracker.Add(d2); 192 tracker.Add(d2);
193 193
194 UpdateDisplay("600x600"); 194 UpdateDisplay("600x600");
195 195
196 // d2 must have been deleted. 196 // d2 must have been deleted.
197 EXPECT_FALSE(tracker.Contains(d2)); 197 EXPECT_FALSE(tracker.Contains(d2));
198 198
199 EXPECT_EQ(root_windows[0], normal->GetNativeView()->GetRootWindow()); 199 EXPECT_EQ(root_windows[0], normal->GetNativeView()->GetRootWindow());
200 EXPECT_EQ("50,10 100x100", normal->GetWindowBoundsInScreen().ToString()); 200 EXPECT_EQ("100,20 100x100", normal->GetWindowBoundsInScreen().ToString());
201 EXPECT_EQ("50,10 100x100", 201 EXPECT_EQ("100,20 100x100",
202 normal->GetNativeView()->GetBoundsInRootWindow().ToString()); 202 normal->GetNativeView()->GetBoundsInRootWindow().ToString());
203 203
204 // Maximized area on primary display has 3px (given as 204 // Maximized area on primary display has 3px (given as
205 // kAutoHideSize in shelf_layout_manager.cc) inset at the bottom. 205 // kAutoHideSize in shelf_layout_manager.cc) inset at the bottom.
206 206
207 // First clear fullscreen status, since both fullscreen and maximized windows 207 // First clear fullscreen status, since both fullscreen and maximized windows
208 // share the same desktop workspace, which cancels the shelf status. 208 // share the same desktop workspace, which cancels the shelf status.
209 fullscreen->SetFullscreen(false); 209 fullscreen->SetFullscreen(false);
210 EXPECT_EQ(root_windows[0], maximized->GetNativeView()->GetRootWindow()); 210 EXPECT_EQ(root_windows[0], maximized->GetNativeView()->GetRootWindow());
211 EXPECT_EQ("0,0 600x597", 211 EXPECT_EQ("0,0 600x597",
212 maximized->GetWindowBoundsInScreen().ToString()); 212 maximized->GetWindowBoundsInScreen().ToString());
213 EXPECT_EQ("0,0 600x597", 213 EXPECT_EQ("0,0 600x597",
214 maximized->GetNativeView()->GetBoundsInRootWindow().ToString()); 214 maximized->GetNativeView()->GetBoundsInRootWindow().ToString());
215 215
216 // Set fullscreen to true. In that case the 3px inset becomes invisible so 216 // Set fullscreen to true. In that case the 3px inset becomes invisible so
217 // the maximized window can also use the area fully. 217 // the maximized window can also use the area fully.
218 fullscreen->SetFullscreen(true); 218 fullscreen->SetFullscreen(true);
219 EXPECT_EQ(root_windows[0], maximized->GetNativeView()->GetRootWindow()); 219 EXPECT_EQ(root_windows[0], maximized->GetNativeView()->GetRootWindow());
220 EXPECT_EQ("0,0 600x600", 220 EXPECT_EQ("0,0 600x600",
221 maximized->GetWindowBoundsInScreen().ToString()); 221 maximized->GetWindowBoundsInScreen().ToString());
222 EXPECT_EQ("0,0 600x600", 222 EXPECT_EQ("0,0 600x600",
223 maximized->GetNativeView()->GetBoundsInRootWindow().ToString()); 223 maximized->GetNativeView()->GetBoundsInRootWindow().ToString());
224 224
225 EXPECT_EQ(root_windows[0], minimized->GetNativeView()->GetRootWindow()); 225 EXPECT_EQ(root_windows[0], minimized->GetNativeView()->GetRootWindow());
226 EXPECT_EQ("200,10 100x100", 226 EXPECT_EQ("400,20 100x100",
227 minimized->GetWindowBoundsInScreen().ToString()); 227 minimized->GetWindowBoundsInScreen().ToString());
228 228
229 EXPECT_EQ(root_windows[0], fullscreen->GetNativeView()->GetRootWindow()); 229 EXPECT_EQ(root_windows[0], fullscreen->GetNativeView()->GetRootWindow());
230 EXPECT_TRUE(fullscreen->IsFullscreen()); 230 EXPECT_TRUE(fullscreen->IsFullscreen());
231 EXPECT_EQ("0,0 600x600", 231 EXPECT_EQ("0,0 600x600",
232 fullscreen->GetWindowBoundsInScreen().ToString()); 232 fullscreen->GetWindowBoundsInScreen().ToString());
233 EXPECT_EQ("0,0 600x600", 233 EXPECT_EQ("0,0 600x600",
234 fullscreen->GetNativeView()->GetBoundsInRootWindow().ToString()); 234 fullscreen->GetNativeView()->GetBoundsInRootWindow().ToString());
235 235
236 // Test if the restore bounds are correctly updated. 236 // Test if the restore bounds are correctly updated.
237 wm::GetWindowState(maximized->GetNativeView())->Restore(); 237 wm::GetWindowState(maximized->GetNativeView())->Restore();
238 EXPECT_EQ("100,10 100x100", maximized->GetWindowBoundsInScreen().ToString()); 238 EXPECT_EQ("200,20 100x100", maximized->GetWindowBoundsInScreen().ToString());
239 EXPECT_EQ("100,10 100x100", 239 EXPECT_EQ("200,20 100x100",
240 maximized->GetNativeView()->GetBoundsInRootWindow().ToString()); 240 maximized->GetNativeView()->GetBoundsInRootWindow().ToString());
241 241
242 fullscreen->SetFullscreen(false); 242 fullscreen->SetFullscreen(false);
243 EXPECT_EQ("300,10 100x100", 243 EXPECT_EQ("500,20 100x100",
244 fullscreen->GetWindowBoundsInScreen().ToString()); 244 fullscreen->GetWindowBoundsInScreen().ToString());
245 EXPECT_EQ("300,10 100x100", 245 EXPECT_EQ("500,20 100x100",
246 fullscreen->GetNativeView()->GetBoundsInRootWindow().ToString()); 246 fullscreen->GetNativeView()->GetBoundsInRootWindow().ToString());
247 247
248 // Test if the unparented widget has moved. 248 // Test if the unparented widget has moved.
249 EXPECT_EQ(root_windows[0], 249 EXPECT_EQ(root_windows[0],
250 unparented_control->GetNativeView()->GetRootWindow()); 250 unparented_control->GetNativeView()->GetRootWindow());
251 EXPECT_EQ(internal::kShellWindowId_UnparentedControlContainer, 251 EXPECT_EQ(internal::kShellWindowId_UnparentedControlContainer,
252 unparented_control->GetNativeView()->parent()->id()); 252 unparented_control->GetNativeView()->parent()->id());
253 253
254 // Test if the panel has moved. 254 // Test if the panel has moved.
255 EXPECT_EQ(root_windows[0], panel->GetRootWindow()); 255 EXPECT_EQ(root_windows[0], panel->GetRootWindow());
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
656 aura::WindowTracker tracker; 656 aura::WindowTracker tracker;
657 tracker.Add(keyboard_container); 657 tracker.Add(keyboard_container);
658 // Mock a login user profile change to reinitialize the keyboard. 658 // Mock a login user profile change to reinitialize the keyboard.
659 ash::Shell::GetInstance()->OnLoginUserProfilePrepared(); 659 ash::Shell::GetInstance()->OnLoginUserProfilePrepared();
660 // keyboard_container should no longer be present. 660 // keyboard_container should no longer be present.
661 EXPECT_FALSE(tracker.Contains(keyboard_container)); 661 EXPECT_FALSE(tracker.Contains(keyboard_container));
662 } 662 }
663 663
664 } // namespace test 664 } // namespace test
665 } // namespace ash 665 } // namespace ash
OLDNEW
« no previous file with comments | « ash/root_window_controller.cc ('k') | ash/wm/drag_window_resizer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698