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

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

Issue 106303005: Fix AdjustBoundsToEnsureWindowVisibility to work with non primary display bounds (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: update bounds without removing Created 6 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 | Annotate | Revision Log
« no previous file with comments | « ash/wm/window_util.cc ('k') | ash/wm/workspace/workspace_layout_manager.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) 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/window_util.h" 5 #include "ash/wm/window_util.h"
6 6
7 #include "ash/screen_ash.h" 7 #include "ash/screen_ash.h"
8 #include "ash/test/ash_test_base.h" 8 #include "ash/test/ash_test_base.h"
9 #include "ui/aura/window.h" 9 #include "ui/aura/window.h"
10 10
11 namespace ash { 11 namespace ash {
12 12
13 namespace {
14
15 std::string GetAdjustedBounds(const gfx::Rect& visible,
16 gfx::Rect to_be_adjusted) {
17 wm::AdjustBoundsToEnsureMinimumWindowVisibility(visible, &to_be_adjusted);
18 return to_be_adjusted.ToString();
19 }
20
21 }
22
13 typedef test::AshTestBase WindowUtilTest; 23 typedef test::AshTestBase WindowUtilTest;
14 24
15 TEST_F(WindowUtilTest, CenterWindow) { 25 TEST_F(WindowUtilTest, CenterWindow) {
16 if (!SupportsMultipleDisplays()) 26 if (!SupportsMultipleDisplays())
17 return; 27 return;
18 28
19 UpdateDisplay("500x400, 600x400"); 29 UpdateDisplay("500x400, 600x400");
20 scoped_ptr<aura::Window> window( 30 scoped_ptr<aura::Window> window(
21 CreateTestWindowInShellWithBounds(gfx::Rect(12, 20, 100, 100))); 31 CreateTestWindowInShellWithBounds(gfx::Rect(12, 20, 100, 100)));
22 wm::CenterWindow(window.get()); 32 wm::CenterWindow(window.get());
23 EXPECT_EQ("200,126 100x100", window->bounds().ToString()); 33 EXPECT_EQ("200,126 100x100", window->bounds().ToString());
24 EXPECT_EQ("200,126 100x100", window->GetBoundsInScreen().ToString()); 34 EXPECT_EQ("200,126 100x100", window->GetBoundsInScreen().ToString());
25 window->SetBoundsInScreen(gfx::Rect(600, 0, 100, 100), 35 window->SetBoundsInScreen(gfx::Rect(600, 0, 100, 100),
26 ScreenAsh::GetSecondaryDisplay()); 36 ScreenAsh::GetSecondaryDisplay());
27 wm::CenterWindow(window.get()); 37 wm::CenterWindow(window.get());
28 EXPECT_EQ("250,126 100x100", window->bounds().ToString()); 38 EXPECT_EQ("250,126 100x100", window->bounds().ToString());
29 EXPECT_EQ("750,126 100x100", window->GetBoundsInScreen().ToString()); 39 EXPECT_EQ("750,126 100x100", window->GetBoundsInScreen().ToString());
30 } 40 }
31 41
42 TEST_F(WindowUtilTest, AdjustBoundsToEnsureMinimumVisibility) {
43 const gfx::Rect visible_bounds(0, 0, 100, 100);
44
45 EXPECT_EQ("0,0 90x90",
46 GetAdjustedBounds(visible_bounds, gfx::Rect(0, 0, 90, 90)));
47 EXPECT_EQ("0,0 100x100",
48 GetAdjustedBounds(visible_bounds, gfx::Rect(0, 0, 150, 150)));
49 EXPECT_EQ("-50,0 100x100",
50 GetAdjustedBounds(visible_bounds, gfx::Rect(-50, -50, 150, 150)));
51 EXPECT_EQ("-90,10 100x100",
52 GetAdjustedBounds(visible_bounds, gfx::Rect(-100, 10, 150, 150)));
53 EXPECT_EQ("90,90 100x100",
54 GetAdjustedBounds(visible_bounds, gfx::Rect(100, 100, 150, 150)));
55
56 const gfx::Rect visible_bounds_right(200, 50, 100, 100);
57
58 EXPECT_EQ(
59 "210,60 90x90",
60 GetAdjustedBounds(visible_bounds_right, gfx::Rect(210, 60, 90, 90)));
61 EXPECT_EQ(
62 "210,60 100x100",
63 GetAdjustedBounds(visible_bounds_right, gfx::Rect(210, 60, 150, 150)));
64 EXPECT_EQ(
65 "110,50 100x100",
66 GetAdjustedBounds(visible_bounds_right, gfx::Rect(0, 0, 150, 150)));
67 EXPECT_EQ(
68 "290,50 100x100",
69 GetAdjustedBounds(visible_bounds_right, gfx::Rect(300, 20, 150, 150)));
70 EXPECT_EQ(
71 "110,140 100x100",
72 GetAdjustedBounds(visible_bounds_right, gfx::Rect(-100, 150, 150, 150)));
73
74 const gfx::Rect visible_bounds_left(-200, -50, 100, 100);
75 EXPECT_EQ(
76 "-190,-40 90x90",
77 GetAdjustedBounds(visible_bounds_left, gfx::Rect(-190, -40, 90, 90)));
78 EXPECT_EQ(
79 "-190,-40 100x100",
80 GetAdjustedBounds(visible_bounds_left, gfx::Rect(-190, -40, 150, 150)));
81 EXPECT_EQ(
82 "-250,-40 100x100",
83 GetAdjustedBounds(visible_bounds_left, gfx::Rect(-250, -40, 150, 150)));
84 EXPECT_EQ(
85 "-290,-50 100x100",
86 GetAdjustedBounds(visible_bounds_left, gfx::Rect(-400, -60, 150, 150)));
87 EXPECT_EQ(
88 "-110,0 100x100",
89 GetAdjustedBounds(visible_bounds_left, gfx::Rect(0, 0, 150, 150)));
90 }
91
32 } // namespace ash 92 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/window_util.cc ('k') | ash/wm/workspace/workspace_layout_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698