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 class ScreenAshTest : public test::AshTestBase { | 19 class ScreenAshTest : public test::AshTestBase { |
20 public: | 20 public: |
21 ScreenAshTest() {} | 21 ScreenAshTest() {} |
22 virtual ~ScreenAshTest() {} | 22 virtual ~ScreenAshTest() {} |
23 | 23 |
24 virtual void SetUp() OVERRIDE { | 24 virtual void SetUp() OVERRIDE { |
25 internal::DisplayController::SetExtendedDesktopEnabled(true); | 25 internal::DisplayController::SetExtendedDesktopEnabled(true); |
26 internal::DisplayController::SetVirtualScreenCoordinatesEnabled(true); | |
27 AshTestBase::SetUp(); | 26 AshTestBase::SetUp(); |
28 } | 27 } |
29 | 28 |
30 virtual void TearDown() OVERRIDE { | 29 virtual void TearDown() OVERRIDE { |
31 AshTestBase::TearDown(); | 30 AshTestBase::TearDown(); |
32 internal::DisplayController::SetExtendedDesktopEnabled(false); | 31 internal::DisplayController::SetExtendedDesktopEnabled(false); |
33 internal::DisplayController::SetVirtualScreenCoordinatesEnabled(false); | |
34 } | 32 } |
35 | 33 |
36 private: | 34 private: |
37 DISALLOW_COPY_AND_ASSIGN(ScreenAshTest); | 35 DISALLOW_COPY_AND_ASSIGN(ScreenAshTest); |
38 }; | 36 }; |
39 | 37 |
40 #if !defined(OS_WIN) | 38 #if !defined(OS_WIN) |
41 TEST_F(ScreenAshTest, Bounds) { | 39 TEST_F(ScreenAshTest, Bounds) { |
42 UpdateDisplay("0+0-600x600,600+0-500x500"); | 40 UpdateDisplay("600x600,500x500"); |
43 | 41 |
44 views::Widget* primary = | 42 views::Widget* primary = |
45 views::Widget::CreateWindowWithBounds(NULL, gfx::Rect(10, 10, 100, 100)); | 43 views::Widget::CreateWindowWithBounds(NULL, gfx::Rect(10, 10, 100, 100)); |
46 primary->Show(); | 44 primary->Show(); |
47 views::Widget* secondary = | 45 views::Widget* secondary = |
48 views::Widget::CreateWindowWithBounds(NULL, gfx::Rect(610, 10, 100, 100)); | 46 views::Widget::CreateWindowWithBounds(NULL, gfx::Rect(610, 10, 100, 100)); |
49 secondary->Show(); | 47 secondary->Show(); |
50 | 48 |
51 // Maximized bounds | 49 // Maximized bounds |
52 EXPECT_EQ("0,0 600x598", | 50 EXPECT_EQ("0,0 600x598", |
(...skipping 23 matching lines...) Expand all Loading... |
76 EXPECT_EQ("0,0 600x552", | 74 EXPECT_EQ("0,0 600x552", |
77 ScreenAsh::GetDisplayWorkAreaBoundsInParent( | 75 ScreenAsh::GetDisplayWorkAreaBoundsInParent( |
78 primary->GetNativeView()).ToString()); | 76 primary->GetNativeView()).ToString()); |
79 EXPECT_EQ("0,0 500x500", | 77 EXPECT_EQ("0,0 500x500", |
80 ScreenAsh::GetDisplayWorkAreaBoundsInParent( | 78 ScreenAsh::GetDisplayWorkAreaBoundsInParent( |
81 secondary->GetNativeView()).ToString()); | 79 secondary->GetNativeView()).ToString()); |
82 } | 80 } |
83 #endif | 81 #endif |
84 | 82 |
85 TEST_F(ScreenAshTest, ConvertRect) { | 83 TEST_F(ScreenAshTest, ConvertRect) { |
86 UpdateDisplay("0+0-600x600,600+0-500x500"); | 84 UpdateDisplay("600x600,500x500"); |
87 | 85 |
88 views::Widget* primary = | 86 views::Widget* primary = |
89 views::Widget::CreateWindowWithBounds(NULL, gfx::Rect(10, 10, 100, 100)); | 87 views::Widget::CreateWindowWithBounds(NULL, gfx::Rect(10, 10, 100, 100)); |
90 primary->Show(); | 88 primary->Show(); |
91 views::Widget* secondary = | 89 views::Widget* secondary = |
92 views::Widget::CreateWindowWithBounds(NULL, gfx::Rect(610, 10, 100, 100)); | 90 views::Widget::CreateWindowWithBounds(NULL, gfx::Rect(610, 10, 100, 100)); |
93 secondary->Show(); | 91 secondary->Show(); |
94 | 92 |
95 EXPECT_EQ( | 93 EXPECT_EQ( |
96 "0,0 100x100", | 94 "0,0 100x100", |
97 ScreenAsh::ConvertRectFromScreen( | 95 ScreenAsh::ConvertRectFromScreen( |
98 primary->GetNativeView(), gfx::Rect(10, 10, 100, 100)).ToString()); | 96 primary->GetNativeView(), gfx::Rect(10, 10, 100, 100)).ToString()); |
99 EXPECT_EQ( | 97 EXPECT_EQ( |
100 "10,10 100x100", | 98 "10,10 100x100", |
101 ScreenAsh::ConvertRectFromScreen( | 99 ScreenAsh::ConvertRectFromScreen( |
102 secondary->GetNativeView(), gfx::Rect(620, 20, 100, 100)).ToString()); | 100 secondary->GetNativeView(), gfx::Rect(620, 20, 100, 100)).ToString()); |
103 | 101 |
104 EXPECT_EQ( | 102 EXPECT_EQ( |
105 "40,40 100x100", | 103 "40,40 100x100", |
106 ScreenAsh::ConvertRectToScreen( | 104 ScreenAsh::ConvertRectToScreen( |
107 primary->GetNativeView(), gfx::Rect(30, 30, 100, 100)).ToString()); | 105 primary->GetNativeView(), gfx::Rect(30, 30, 100, 100)).ToString()); |
108 EXPECT_EQ( | 106 EXPECT_EQ( |
109 "650,50 100x100", | 107 "650,50 100x100", |
110 ScreenAsh::ConvertRectToScreen( | 108 ScreenAsh::ConvertRectToScreen( |
111 secondary->GetNativeView(), gfx::Rect(40, 40, 100, 100)).ToString()); | 109 secondary->GetNativeView(), gfx::Rect(40, 40, 100, 100)).ToString()); |
112 } | 110 } |
113 | 111 |
114 } // namespace test | 112 } // namespace test |
115 } // namespace ash | 113 } // namespace ash |
OLD | NEW |