OLD | NEW |
---|---|
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/root_window_controller.h" | |
7 #include "ash/screen_ash.h" | 8 #include "ash/screen_ash.h" |
9 #include "ash/shelf/shelf_layout_manager.h" | |
8 #include "ash/test/ash_test_base.h" | 10 #include "ash/test/ash_test_base.h" |
9 #include "ui/aura/window.h" | 11 #include "ui/aura/window.h" |
10 | 12 |
11 namespace ash { | 13 namespace ash { |
12 | 14 |
13 typedef test::AshTestBase WindowUtilTest; | 15 typedef test::AshTestBase WindowUtilTest; |
14 | 16 |
17 // Test the behavior of SnapWindowToEdge(). | |
18 TEST_F(WindowUtilTest, SnapWindowToEdge) { | |
19 if (!SupportsMultipleDisplays()) | |
20 return; | |
21 | |
22 UpdateDisplay("0+0-500x400, 0+500-600x400"); | |
23 scoped_ptr<aura::Window> window( | |
24 CreateTestWindowInShellWithBounds(gfx::Rect(12, 20, 100, 100))); | |
25 | |
26 internal::RootWindowController* root_window_controller = | |
27 internal::RootWindowController::ForWindow(window.get()); | |
28 internal::ShelfLayoutManager* shelf_layout_manager = | |
29 root_window_controller->GetShelfLayoutManager(); | |
30 EXPECT_EQ(SHELF_ALIGNMENT_BOTTOM, shelf_layout_manager->GetAlignment()); | |
31 shelf_layout_manager->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); | |
32 EXPECT_EQ(SHELF_VISIBLE, shelf_layout_manager->visibility_state()); | |
33 const int kSnappedHeight = 400 - | |
34 internal::ShelfLayoutManager::GetPreferredShelfSize(); | |
35 | |
36 wm::SnapWindowToEdge(window.get(), wm::SNAP_LEFT_EDGE); | |
37 EXPECT_EQ(gfx::Rect(0,0,250,kSnappedHeight).ToString(), | |
Mr4D (OOO till 08-26)
2013/08/29 01:03:15
0, 0, 250, kSna..
(Spaces are missing)
| |
38 window->GetBoundsInScreen().ToString()); | |
39 wm::SnapWindowToEdge(window.get(), wm::SNAP_RIGHT_EDGE); | |
40 EXPECT_EQ(gfx::Rect(250,0,250,kSnappedHeight).ToString(), | |
Mr4D (OOO till 08-26)
2013/08/29 01:03:15
Same here and more below.
| |
41 window->GetBoundsInScreen().ToString()); | |
42 window->SetBoundsInScreen(gfx::Rect(600, 0, 100, 100), | |
43 ScreenAsh::GetSecondaryDisplay()); | |
44 wm::SnapWindowToEdge(window.get(), wm::SNAP_LEFT_EDGE); | |
45 EXPECT_EQ(gfx::Rect(500,0,300,kSnappedHeight).ToString(), | |
46 window->GetBoundsInScreen().ToString()); | |
47 wm::SnapWindowToEdge(window.get(), wm::SNAP_RIGHT_EDGE); | |
48 EXPECT_EQ(gfx::Rect(800,0,300,kSnappedHeight).ToString(), | |
49 window->GetBoundsInScreen().ToString()); | |
50 } | |
51 | |
52 // Test the behavior of CenterWindow(). | |
15 TEST_F(WindowUtilTest, CenterWindow) { | 53 TEST_F(WindowUtilTest, CenterWindow) { |
16 if (!SupportsMultipleDisplays()) | 54 if (!SupportsMultipleDisplays()) |
17 return; | 55 return; |
18 | 56 |
19 UpdateDisplay("500x400, 600x400"); | 57 UpdateDisplay("0+0-500x400, 0+500-600x400"); |
20 scoped_ptr<aura::Window> window( | 58 scoped_ptr<aura::Window> window( |
21 CreateTestWindowInShellWithBounds(gfx::Rect(12, 20, 100, 100))); | 59 CreateTestWindowInShellWithBounds(gfx::Rect(12, 20, 100, 100))); |
60 | |
61 internal::RootWindowController* root_window_controller = | |
62 internal::RootWindowController::ForWindow(window.get()); | |
63 internal::ShelfLayoutManager* shelf_layout_manager = | |
64 root_window_controller->GetShelfLayoutManager(); | |
65 EXPECT_EQ(SHELF_ALIGNMENT_BOTTOM, shelf_layout_manager->GetAlignment()); | |
66 shelf_layout_manager->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); | |
67 EXPECT_EQ(SHELF_VISIBLE, shelf_layout_manager->visibility_state()); | |
68 const int kCenteredY = | |
69 (400 - internal::ShelfLayoutManager::GetPreferredShelfSize() - 100) / 2; | |
70 | |
22 wm::CenterWindow(window.get()); | 71 wm::CenterWindow(window.get()); |
23 EXPECT_EQ("200,126 100x100", window->bounds().ToString()); | 72 EXPECT_EQ(gfx::Rect(200,kCenteredY,100,100).ToString(), |
24 EXPECT_EQ("200,126 100x100", window->GetBoundsInScreen().ToString()); | 73 window->GetBoundsInScreen().ToString()); |
25 window->SetBoundsInScreen(gfx::Rect(600, 0, 100, 100), | 74 window->SetBoundsInScreen(gfx::Rect(600, 0, 100, 100), |
26 ScreenAsh::GetSecondaryDisplay()); | 75 ScreenAsh::GetSecondaryDisplay()); |
27 wm::CenterWindow(window.get()); | 76 wm::CenterWindow(window.get()); |
28 EXPECT_EQ("250,126 100x100", window->bounds().ToString()); | 77 EXPECT_EQ(gfx::Rect(750,kCenteredY,100,100).ToString(), |
Mr4D (OOO till 08-26)
2013/08/29 01:03:15
And more spaces are missing.
| |
29 EXPECT_EQ("750,126 100x100", window->GetBoundsInScreen().ToString()); | 78 window->GetBoundsInScreen().ToString()); |
30 } | 79 } |
31 | 80 |
32 } // namespace ash | 81 } // namespace ash |
OLD | NEW |