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

Side by Side Diff: ash/wm/dock/docked_window_layout_manager_unittest.cc

Issue 24108003: [Cleanup] Rename WindowSettings to WindowState (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/wm/dock/docked_window_layout_manager.h" 5 #include "ash/wm/dock/docked_window_layout_manager.h"
6 6
7 #include "ash/ash_switches.h" 7 #include "ash/ash_switches.h"
8 #include "ash/display/display_controller.h" 8 #include "ash/display/display_controller.h"
9 #include "ash/launcher/launcher.h" 9 #include "ash/launcher/launcher.h"
10 #include "ash/launcher/launcher_model.h" 10 #include "ash/launcher/launcher_model.h"
11 #include "ash/root_window_controller.h" 11 #include "ash/root_window_controller.h"
12 #include "ash/screen_ash.h" 12 #include "ash/screen_ash.h"
13 #include "ash/shelf/shelf_layout_manager.h" 13 #include "ash/shelf/shelf_layout_manager.h"
14 #include "ash/shelf/shelf_types.h" 14 #include "ash/shelf/shelf_types.h"
15 #include "ash/shelf/shelf_widget.h" 15 #include "ash/shelf/shelf_widget.h"
16 #include "ash/shell.h" 16 #include "ash/shell.h"
17 #include "ash/shell_window_ids.h" 17 #include "ash/shell_window_ids.h"
18 #include "ash/test/ash_test_base.h" 18 #include "ash/test/ash_test_base.h"
19 #include "ash/test/launcher_test_api.h" 19 #include "ash/test/launcher_test_api.h"
20 #include "ash/test/launcher_view_test_api.h" 20 #include "ash/test/launcher_view_test_api.h"
21 #include "ash/test/shell_test_api.h" 21 #include "ash/test/shell_test_api.h"
22 #include "ash/test/test_launcher_delegate.h" 22 #include "ash/test/test_launcher_delegate.h"
23 #include "ash/wm/coordinate_conversion.h" 23 #include "ash/wm/coordinate_conversion.h"
24 #include "ash/wm/panels/panel_layout_manager.h" 24 #include "ash/wm/panels/panel_layout_manager.h"
25 #include "ash/wm/window_resizer.h" 25 #include "ash/wm/window_resizer.h"
26 #include "ash/wm/window_settings.h" 26 #include "ash/wm/window_state.h"
27 #include "ash/wm/window_util.h" 27 #include "ash/wm/window_util.h"
28 #include "base/basictypes.h" 28 #include "base/basictypes.h"
29 #include "base/command_line.h" 29 #include "base/command_line.h"
30 #include "base/strings/string_number_conversions.h" 30 #include "base/strings/string_number_conversions.h"
31 #include "ui/aura/client/aura_constants.h" 31 #include "ui/aura/client/aura_constants.h"
32 #include "ui/aura/root_window.h" 32 #include "ui/aura/root_window.h"
33 #include "ui/aura/window.h" 33 #include "ui/aura/window.h"
34 #include "ui/base/hit_test.h" 34 #include "ui/base/hit_test.h"
35 #include "ui/gfx/screen.h" 35 #include "ui/gfx/screen.h"
36 #include "ui/views/widget/widget.h" 36 #include "ui/views/widget/widget.h"
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 else if (edge == DOCKED_EDGE_RIGHT) 183 else if (edge == DOCKED_EDGE_RIGHT)
184 dx += work_area.right() - 1 - initial_location_in_screen.x(); 184 dx += work_area.right() - 1 - initial_location_in_screen.x();
185 DragMove(dx, dy); 185 DragMove(dx, dy);
186 EXPECT_EQ(CorrectContainerIdDuringDrag(), window->parent()->id()); 186 EXPECT_EQ(CorrectContainerIdDuringDrag(), window->parent()->id());
187 // Release the mouse and the panel should be attached to the dock. 187 // Release the mouse and the panel should be attached to the dock.
188 DragEnd(); 188 DragEnd();
189 189
190 // x-coordinate can get adjusted by snapping or sticking. 190 // x-coordinate can get adjusted by snapping or sticking.
191 // y-coordinate could be changed by possible automatic layout if docked. 191 // y-coordinate could be changed by possible automatic layout if docked.
192 if (window->parent()->id() != internal::kShellWindowId_DockedContainer && 192 if (window->parent()->id() != internal::kShellWindowId_DockedContainer &&
193 GetRestoreBoundsInScreen(window) == NULL) { 193 !wm::GetWindowState(window)->HasRestoreBounds()) {
194 EXPECT_EQ(initial_bounds.y() + dy, window->GetBoundsInScreen().y()); 194 EXPECT_EQ(initial_bounds.y() + dy, window->GetBoundsInScreen().y());
195 } 195 }
196 } 196 }
197 197
198 private: 198 private:
199 scoped_ptr<WindowResizer> resizer_; 199 scoped_ptr<WindowResizer> resizer_;
200 scoped_ptr<test::LauncherViewTestAPI> launcher_view_test_; 200 scoped_ptr<test::LauncherViewTestAPI> launcher_view_test_;
201 aura::client::WindowType window_type_; 201 aura::client::WindowType window_type_;
202 202
203 // Location at start of the drag in |window->parent()|'s coordinates. 203 // Location at start of the drag in |window->parent()|'s coordinates.
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 EXPECT_EQ(window->GetRootWindow()->bounds().x(), 236 EXPECT_EQ(window->GetRootWindow()->bounds().x(),
237 window->GetBoundsInScreen().x()); 237 window->GetBoundsInScreen().x());
238 EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id()); 238 EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id());
239 239
240 DockedWindowLayoutManager* manager = static_cast<DockedWindowLayoutManager*>( 240 DockedWindowLayoutManager* manager = static_cast<DockedWindowLayoutManager*>(
241 window->parent()->layout_manager()); 241 window->parent()->layout_manager());
242 242
243 // Create two additional windows and test their auto-placement 243 // Create two additional windows and test their auto-placement
244 scoped_ptr<aura::Window> window1(CreateTestWindowInShellWithId(1)); 244 scoped_ptr<aura::Window> window1(CreateTestWindowInShellWithId(1));
245 gfx::Rect desktop_area = window1->parent()->bounds(); 245 gfx::Rect desktop_area = window1->parent()->bounds();
246 wm::GetWindowSettings(window1.get())->set_window_position_managed(true); 246 wm::GetWindowState(window1.get())->set_window_position_managed(true);
247 window1->Hide(); 247 window1->Hide();
248 window1->SetBounds(gfx::Rect(250, 32, 231, 320)); 248 window1->SetBounds(gfx::Rect(250, 32, 231, 320));
249 window1->Show(); 249 window1->Show();
250 // |window1| should be centered in work area. 250 // |window1| should be centered in work area.
251 EXPECT_EQ(base::IntToString( 251 EXPECT_EQ(base::IntToString(
252 manager->docked_width_ + DockedWindowLayoutManager::kMinDockGap + 252 manager->docked_width_ + DockedWindowLayoutManager::kMinDockGap +
253 (desktop_area.width() - manager->docked_width_ - 253 (desktop_area.width() - manager->docked_width_ -
254 DockedWindowLayoutManager::kMinDockGap - window1->bounds().width()) / 2)+ 254 DockedWindowLayoutManager::kMinDockGap - window1->bounds().width()) / 2)+
255 ",32 231x320", window1->bounds().ToString()); 255 ",32 231x320", window1->bounds().ToString());
256 256
257 scoped_ptr<aura::Window> window2(CreateTestWindowInShellWithId(2)); 257 scoped_ptr<aura::Window> window2(CreateTestWindowInShellWithId(2));
258 wm::GetWindowSettings(window2.get())->set_window_position_managed(true); 258 wm::GetWindowState(window2.get())->set_window_position_managed(true);
259 // To avoid any auto window manager changes due to SetBounds, the window 259 // To avoid any auto window manager changes due to SetBounds, the window
260 // gets first hidden and then shown again. 260 // gets first hidden and then shown again.
261 window2->Hide(); 261 window2->Hide();
262 window2->SetBounds(gfx::Rect(250, 48, 150, 300)); 262 window2->SetBounds(gfx::Rect(250, 48, 150, 300));
263 window2->Show(); 263 window2->Show();
264 264
265 // |window1| should be flush left and |window2| flush right. 265 // |window1| should be flush left and |window2| flush right.
266 EXPECT_EQ( 266 EXPECT_EQ(
267 base::IntToString( 267 base::IntToString(
268 manager->docked_width_ + DockedWindowLayoutManager::kMinDockGap) + 268 manager->docked_width_ + DockedWindowLayoutManager::kMinDockGap) +
(...skipping 18 matching lines...) Expand all
287 EXPECT_EQ(window->GetRootWindow()->bounds().right(), 287 EXPECT_EQ(window->GetRootWindow()->bounds().right(),
288 window->GetBoundsInScreen().right()); 288 window->GetBoundsInScreen().right());
289 EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id()); 289 EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id());
290 290
291 DockedWindowLayoutManager* manager = static_cast<DockedWindowLayoutManager*>( 291 DockedWindowLayoutManager* manager = static_cast<DockedWindowLayoutManager*>(
292 window->parent()->layout_manager()); 292 window->parent()->layout_manager());
293 293
294 // Create two additional windows and test their auto-placement 294 // Create two additional windows and test their auto-placement
295 scoped_ptr<aura::Window> window1(CreateTestWindowInShellWithId(1)); 295 scoped_ptr<aura::Window> window1(CreateTestWindowInShellWithId(1));
296 gfx::Rect desktop_area = window1->parent()->bounds(); 296 gfx::Rect desktop_area = window1->parent()->bounds();
297 wm::GetWindowSettings(window1.get())->set_window_position_managed(true); 297 wm::GetWindowState(window1.get())->set_window_position_managed(true);
298 window1->Hide(); 298 window1->Hide();
299 window1->SetBounds(gfx::Rect(16, 32, 231, 320)); 299 window1->SetBounds(gfx::Rect(16, 32, 231, 320));
300 window1->Show(); 300 window1->Show();
301 301
302 // |window1| should be centered in work area. 302 // |window1| should be centered in work area.
303 EXPECT_EQ(base::IntToString( 303 EXPECT_EQ(base::IntToString(
304 (desktop_area.width() - manager->docked_width_ - 304 (desktop_area.width() - manager->docked_width_ -
305 DockedWindowLayoutManager::kMinDockGap - window1->bounds().width()) / 2)+ 305 DockedWindowLayoutManager::kMinDockGap - window1->bounds().width()) / 2)+
306 ",32 231x320", window1->bounds().ToString()); 306 ",32 231x320", window1->bounds().ToString());
307 307
308 scoped_ptr<aura::Window> window2(CreateTestWindowInShellWithId(2)); 308 scoped_ptr<aura::Window> window2(CreateTestWindowInShellWithId(2));
309 wm::GetWindowSettings(window2.get())->set_window_position_managed(true); 309 wm::GetWindowState(window2.get())->set_window_position_managed(true);
310 // To avoid any auto window manager changes due to SetBounds, the window 310 // To avoid any auto window manager changes due to SetBounds, the window
311 // gets first hidden and then shown again. 311 // gets first hidden and then shown again.
312 window2->Hide(); 312 window2->Hide();
313 window2->SetBounds(gfx::Rect(32, 48, 256, 512)); 313 window2->SetBounds(gfx::Rect(32, 48, 256, 512));
314 window2->Show(); 314 window2->Show();
315 315
316 // |window1| should be flush left and |window2| flush right. 316 // |window1| should be flush left and |window2| flush right.
317 EXPECT_EQ("0,32 231x320", window1->bounds().ToString()); 317 EXPECT_EQ("0,32 231x320", window1->bounds().ToString());
318 EXPECT_EQ( 318 EXPECT_EQ(
319 base::IntToString( 319 base::IntToString(
(...skipping 23 matching lines...) Expand all
343 EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id()); 343 EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id());
344 344
345 DockedWindowLayoutManager* manager = static_cast<DockedWindowLayoutManager*>( 345 DockedWindowLayoutManager* manager = static_cast<DockedWindowLayoutManager*>(
346 window->parent()->layout_manager()); 346 window->parent()->layout_manager());
347 347
348 // Create two additional windows and test their auto-placement 348 // Create two additional windows and test their auto-placement
349 bounds = gfx::Rect(616, 32, 231, 320); 349 bounds = gfx::Rect(616, 32, 231, 320);
350 scoped_ptr<aura::Window> window1( 350 scoped_ptr<aura::Window> window1(
351 CreateTestWindowInShellWithDelegate(NULL, 1, bounds)); 351 CreateTestWindowInShellWithDelegate(NULL, 1, bounds));
352 gfx::Rect desktop_area = window1->parent()->bounds(); 352 gfx::Rect desktop_area = window1->parent()->bounds();
353 wm::GetWindowSettings(window1.get())->set_window_position_managed(true); 353 wm::GetWindowState(window1.get())->set_window_position_managed(true);
354 window1->Hide(); 354 window1->Hide();
355 window1->Show(); 355 window1->Show();
356 356
357 // |window1| should be centered in work area. 357 // |window1| should be centered in work area.
358 EXPECT_EQ(base::IntToString( 358 EXPECT_EQ(base::IntToString(
359 600 + (desktop_area.width() - manager->docked_width_ - 359 600 + (desktop_area.width() - manager->docked_width_ -
360 DockedWindowLayoutManager::kMinDockGap - window1->bounds().width()) / 2)+ 360 DockedWindowLayoutManager::kMinDockGap - window1->bounds().width()) / 2)+
361 ",32 231x320", window1->GetBoundsInScreen().ToString()); 361 ",32 231x320", window1->GetBoundsInScreen().ToString());
362 362
363 bounds = gfx::Rect(632, 48, 256, 512); 363 bounds = gfx::Rect(632, 48, 256, 512);
364 scoped_ptr<aura::Window> window2( 364 scoped_ptr<aura::Window> window2(
365 CreateTestWindowInShellWithDelegate(NULL, 2, bounds)); 365 CreateTestWindowInShellWithDelegate(NULL, 2, bounds));
366 wm::GetWindowSettings(window2.get())->set_window_position_managed(true); 366 wm::GetWindowState(window2.get())->set_window_position_managed(true);
367 // To avoid any auto window manager changes due to SetBounds, the window 367 // To avoid any auto window manager changes due to SetBounds, the window
368 // gets first hidden and then shown again. 368 // gets first hidden and then shown again.
369 window2->Hide(); 369 window2->Hide();
370 window2->Show(); 370 window2->Show();
371 371
372 // |window1| should be flush left and |window2| flush right. 372 // |window1| should be flush left and |window2| flush right.
373 EXPECT_EQ("600,32 231x320", window1->GetBoundsInScreen().ToString()); 373 EXPECT_EQ("600,32 231x320", window1->GetBoundsInScreen().ToString());
374 EXPECT_EQ( 374 EXPECT_EQ(
375 base::IntToString( 375 base::IntToString(
376 600 + desktop_area.width() - window2->bounds().width() - 376 600 + desktop_area.width() - window2->bounds().width() -
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
563 EXPECT_EQ(0, overlap4); 563 EXPECT_EQ(0, overlap4);
564 } 564 }
565 565
566 // Tests run twice - on both panels and normal windows 566 // Tests run twice - on both panels and normal windows
567 INSTANTIATE_TEST_CASE_P(NormalOrPanel, 567 INSTANTIATE_TEST_CASE_P(NormalOrPanel,
568 DockedWindowLayoutManagerTest, 568 DockedWindowLayoutManagerTest,
569 testing::Values(aura::client::WINDOW_TYPE_NORMAL, 569 testing::Values(aura::client::WINDOW_TYPE_NORMAL,
570 aura::client::WINDOW_TYPE_PANEL)); 570 aura::client::WINDOW_TYPE_PANEL));
571 } // namespace internal 571 } // namespace internal
572 } // namespace ash 572 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698