1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "ash/display/display_util.h"
7 #include "ash/root_window_controller.h"
9 #include "ash/test/ash_test_base.h"
10 #include "ash/test/display_manager_test_api.h"
14 typedef test::AshTestBase DisplayUtilTest
;
16 TEST_F(DisplayUtilTest
, RotatedDisplay
) {
17 if (!SupportsMultipleDisplays())
20 UpdateDisplay("10+10-500x400,600+10-1000x600/r");
21 aura::Window::Windows root_windows
= Shell::GetAllRootWindows();
22 AshWindowTreeHost
* host0
=
23 GetRootWindowController(root_windows
[0])->ash_host();
24 AshWindowTreeHost
* host1
=
25 GetRootWindowController(root_windows
[1])->ash_host();
26 gfx::Rect rect0
= GetNativeEdgeBounds(host0
, gfx::Rect(499, 10, 1, 300));
27 gfx::Rect rect1
= GetNativeEdgeBounds(host1
, gfx::Rect(500, 10, 1, 300));
28 EXPECT_EQ("509,20 1x300", rect0
.ToString());
29 EXPECT_EQ("1289,10 300x1", rect1
.ToString());
32 UpdateDisplay("10+10-500x400,600+10-1000x600/l");
33 aura::Window::Windows root_windows
= Shell::GetAllRootWindows();
34 AshWindowTreeHost
* host0
=
35 GetRootWindowController(root_windows
[0])->ash_host();
36 AshWindowTreeHost
* host1
=
37 GetRootWindowController(root_windows
[1])->ash_host();
38 gfx::Rect rect0
= GetNativeEdgeBounds(host0
, gfx::Rect(499, 10, 1, 300));
39 gfx::Rect rect1
= GetNativeEdgeBounds(host1
, gfx::Rect(500, 10, 1, 300));
40 EXPECT_EQ("509,20 1x300", rect0
.ToString());
41 EXPECT_EQ("610,609 300x1", rect1
.ToString());
44 UpdateDisplay("10+10-500x400,600+10-1000x600/u");
45 aura::Window::Windows root_windows
= Shell::GetAllRootWindows();
46 AshWindowTreeHost
* host0
=
47 GetRootWindowController(root_windows
[0])->ash_host();
48 AshWindowTreeHost
* host1
=
49 GetRootWindowController(root_windows
[1])->ash_host();
50 gfx::Rect rect0
= GetNativeEdgeBounds(host0
, gfx::Rect(499, 10, 1, 300));
51 gfx::Rect rect1
= GetNativeEdgeBounds(host1
, gfx::Rect(500, 10, 1, 300));
52 EXPECT_EQ("509,20 1x300", rect0
.ToString());
53 EXPECT_EQ("1599,299 1x300", rect1
.ToString());
57 UpdateDisplay("10+10-500x400/r,600+10-1000x600");
58 aura::Window::Windows root_windows
= Shell::GetAllRootWindows();
59 AshWindowTreeHost
* host0
=
60 GetRootWindowController(root_windows
[0])->ash_host();
61 AshWindowTreeHost
* host1
=
62 GetRootWindowController(root_windows
[1])->ash_host();
63 gfx::Rect rect0
= GetNativeEdgeBounds(host0
, gfx::Rect(399, 10, 1, 300));
64 gfx::Rect rect1
= GetNativeEdgeBounds(host1
, gfx::Rect(400, 10, 1, 300));
65 EXPECT_EQ("199,409 300x1", rect0
.ToString());
66 EXPECT_EQ("600,20 1x300", rect1
.ToString());
69 UpdateDisplay("10+10-500x400/l,600+10-1000x600");
70 aura::Window::Windows root_windows
= Shell::GetAllRootWindows();
71 AshWindowTreeHost
* host0
=
72 GetRootWindowController(root_windows
[0])->ash_host();
73 AshWindowTreeHost
* host1
=
74 GetRootWindowController(root_windows
[1])->ash_host();
75 gfx::Rect rect0
= GetNativeEdgeBounds(host0
, gfx::Rect(499, 10, 1, 300));
76 gfx::Rect rect1
= GetNativeEdgeBounds(host1
, gfx::Rect(500, 10, 1, 300));
77 EXPECT_EQ("20,10 300x1", rect0
.ToString());
78 EXPECT_EQ("600,20 1x300", rect1
.ToString());
81 UpdateDisplay("10+10-500x400/u,600+10-1000x600");
82 aura::Window::Windows root_windows
= Shell::GetAllRootWindows();
83 AshWindowTreeHost
* host0
=
84 GetRootWindowController(root_windows
[0])->ash_host();
85 AshWindowTreeHost
* host1
=
86 GetRootWindowController(root_windows
[1])->ash_host();
87 gfx::Rect rect0
= GetNativeEdgeBounds(host0
, gfx::Rect(499, 10, 1, 300));
88 gfx::Rect rect1
= GetNativeEdgeBounds(host1
, gfx::Rect(500, 10, 1, 300));
89 EXPECT_EQ("10,99 1x300", rect0
.ToString());
90 EXPECT_EQ("600,20 1x300", rect1
.ToString());
94 TEST_F(DisplayUtilTest
, CreateDisplayIdPair
) {
95 DisplayIdPair pair
= CreateDisplayIdPair(10, 1);
96 EXPECT_EQ(1, pair
.first
);
97 EXPECT_EQ(10, pair
.second
);
98 pair
= CreateDisplayIdPair(10, 100);
99 EXPECT_EQ(10, pair
.first
);
100 EXPECT_EQ(100, pair
.second
);
102 test::ScopedSetInternalDisplayId
set_internal(100);
103 pair
= CreateDisplayIdPair(10, 100);
104 EXPECT_EQ(100, pair
.first
);
105 EXPECT_EQ(10, pair
.second
);
107 pair
= CreateDisplayIdPair(100, 10);
108 EXPECT_EQ(100, pair
.first
);
109 EXPECT_EQ(10, pair
.second
);
113 test::ScopedSetInternalDisplayId
set_internal(10);
114 pair
= CreateDisplayIdPair(10, 100);
115 EXPECT_EQ(10, pair
.first
);
116 EXPECT_EQ(100, pair
.second
);
118 pair
= CreateDisplayIdPair(100, 10);
119 EXPECT_EQ(10, pair
.first
);
120 EXPECT_EQ(100, pair
.second
);