OLD | NEW |
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/screen_ash.h" | 5 #include "ash/screen_ash.h" |
6 | 6 |
7 #include "ash/display/display_controller.h" | 7 #include "ash/display/display_controller.h" |
8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
9 #include "ash/test/ash_test_base.h" | 9 #include "ash/test/ash_test_base.h" |
10 #include "ash/wm/window_util.h" | 10 #include "ash/wm/window_util.h" |
11 #include "ui/aura/env.h" | 11 #include "ui/aura/env.h" |
12 #include "ui/aura/root_window.h" | 12 #include "ui/aura/root_window.h" |
13 #include "ui/aura/window.h" | 13 #include "ui/aura/window.h" |
14 #include "ui/views/widget/widget.h" | 14 #include "ui/views/widget/widget.h" |
15 #include "ui/views/widget/widget_delegate.h" | 15 #include "ui/views/widget/widget_delegate.h" |
16 | 16 |
17 namespace ash { | 17 namespace ash { |
18 namespace test { | 18 namespace test { |
19 | 19 |
20 typedef test::AshTestBase ScreenAshTest; | 20 typedef test::AshTestBase ScreenAshTest; |
21 | 21 |
22 #if !defined(OS_WIN) | 22 #if !defined(OS_WIN) |
23 TEST_F(ScreenAshTest, Bounds) { | 23 TEST_F(ScreenAshTest, Bounds) { |
24 UpdateDisplay("600x600,500x500"); | 24 UpdateDisplay("600x600,500x500"); |
25 Shell::GetInstance()->SetShelfAutoHideBehavior( | |
26 ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | |
27 | 25 |
28 views::Widget* primary = | 26 views::Widget* primary = |
29 views::Widget::CreateWindowWithBounds(NULL, gfx::Rect(10, 10, 100, 100)); | 27 views::Widget::CreateWindowWithBounds(NULL, gfx::Rect(10, 10, 100, 100)); |
30 primary->Show(); | 28 primary->Show(); |
31 views::Widget* secondary = | 29 views::Widget* secondary = |
32 views::Widget::CreateWindowWithBounds(NULL, gfx::Rect(610, 10, 100, 100)); | 30 views::Widget::CreateWindowWithBounds(NULL, gfx::Rect(610, 10, 100, 100)); |
33 secondary->Show(); | 31 secondary->Show(); |
34 | 32 |
35 // Maximized bounds | 33 // Maximized bounds |
36 EXPECT_EQ("0,0 600x597", | 34 EXPECT_EQ("0,0 600x597", |
37 ScreenAsh::GetMaximizedWindowBoundsInParent( | 35 ScreenAsh::GetMaximizedWindowBoundsInParent( |
38 primary->GetNativeView()).ToString()); | 36 primary->GetNativeView()).ToString()); |
39 EXPECT_EQ("0,0 500x500", | 37 EXPECT_EQ("0,0 500x500", |
40 ScreenAsh::GetMaximizedWindowBoundsInParent( | 38 ScreenAsh::GetMaximizedWindowBoundsInParent( |
41 secondary->GetNativeView()).ToString()); | 39 secondary->GetNativeView()).ToString()); |
42 | 40 |
43 // Unmaximized work area bounds | 41 // Unmaximized work area bounds |
44 EXPECT_EQ("0,0 600x597", | 42 EXPECT_EQ("0,0 600x552", |
45 ScreenAsh::GetUnmaximizedWorkAreaBoundsInParent( | 43 ScreenAsh::GetUnmaximizedWorkAreaBoundsInParent( |
46 primary->GetNativeView()).ToString()); | 44 primary->GetNativeView()).ToString()); |
47 EXPECT_EQ("0,0 500x500", | 45 EXPECT_EQ("0,0 500x500", |
48 ScreenAsh::GetUnmaximizedWorkAreaBoundsInParent( | 46 ScreenAsh::GetUnmaximizedWorkAreaBoundsInParent( |
49 secondary->GetNativeView()).ToString()); | 47 secondary->GetNativeView()).ToString()); |
50 | 48 |
51 // Display bounds | 49 // Display bounds |
52 EXPECT_EQ("0,0 600x600", | 50 EXPECT_EQ("0,0 600x600", |
53 ScreenAsh::GetDisplayBoundsInParent( | 51 ScreenAsh::GetDisplayBoundsInParent( |
54 primary->GetNativeView()).ToString()); | 52 primary->GetNativeView()).ToString()); |
55 EXPECT_EQ("0,0 500x500", | 53 EXPECT_EQ("0,0 500x500", |
56 ScreenAsh::GetDisplayBoundsInParent( | 54 ScreenAsh::GetDisplayBoundsInParent( |
57 secondary->GetNativeView()).ToString()); | 55 secondary->GetNativeView()).ToString()); |
58 | 56 |
59 // Work area bounds | 57 // Work area bounds |
60 EXPECT_EQ("0,0 600x597", | 58 EXPECT_EQ("0,0 600x552", |
61 ScreenAsh::GetDisplayWorkAreaBoundsInParent( | 59 ScreenAsh::GetDisplayWorkAreaBoundsInParent( |
62 primary->GetNativeView()).ToString()); | 60 primary->GetNativeView()).ToString()); |
63 EXPECT_EQ("0,0 500x500", | 61 EXPECT_EQ("0,0 500x500", |
64 ScreenAsh::GetDisplayWorkAreaBoundsInParent( | 62 ScreenAsh::GetDisplayWorkAreaBoundsInParent( |
65 secondary->GetNativeView()).ToString()); | 63 secondary->GetNativeView()).ToString()); |
66 } | 64 } |
67 #endif | 65 #endif |
68 | 66 |
69 TEST_F(ScreenAshTest, ConvertRect) { | 67 TEST_F(ScreenAshTest, ConvertRect) { |
70 UpdateDisplay("600x600,500x500"); | 68 UpdateDisplay("600x600,500x500"); |
(...skipping 19 matching lines...) Expand all Loading... |
90 ScreenAsh::ConvertRectToScreen( | 88 ScreenAsh::ConvertRectToScreen( |
91 primary->GetNativeView(), gfx::Rect(30, 30, 100, 100)).ToString()); | 89 primary->GetNativeView(), gfx::Rect(30, 30, 100, 100)).ToString()); |
92 EXPECT_EQ( | 90 EXPECT_EQ( |
93 "650,50 100x100", | 91 "650,50 100x100", |
94 ScreenAsh::ConvertRectToScreen( | 92 ScreenAsh::ConvertRectToScreen( |
95 secondary->GetNativeView(), gfx::Rect(40, 40, 100, 100)).ToString()); | 93 secondary->GetNativeView(), gfx::Rect(40, 40, 100, 100)).ToString()); |
96 } | 94 } |
97 | 95 |
98 } // namespace test | 96 } // namespace test |
99 } // namespace ash | 97 } // namespace ash |
OLD | NEW |