45
glm::mat2 const rotate_none;
46
glm::mat2 const rotate_left( 0, 1, // transposed
48
glm::mat2 const rotate_right( 0,-1, // transposed
50
glm::mat2 const rotate_inverted(-1, 0,
45
53
struct DisplayBuffer : public ::testing::Test
47
55
testing::NiceMock<mtd::MockEGL> mock_egl;
69
77
geom::Size const display_size{433,232};
70
78
double const refresh_rate{60.0};
71
79
geom::Displacement top_left{0,0};
80
geom::Rectangle const area{{0,0}, display_size};
72
81
std::unique_ptr<mga::LayerList> list{
73
82
new mga::LayerList(std::make_shared<mga::IntegerSourceCrop>(), {}, top_left)};
74
83
std::shared_ptr<mtd::MockFBBundle> mock_fb_bundle{
75
84
std::make_shared<testing::NiceMock<mtd::MockFBBundle>>(display_size)};
76
MirOrientation orientation{mir_orientation_normal};
85
glm::mat2 const transformation;
77
86
mga::DisplayBuffer db{
78
87
mga::DisplayName::primary,
79
88
std::unique_ptr<mga::LayerList>(
109
118
EXPECT_FALSE(db.overlay(renderlist));
112
TEST_F(DisplayBuffer, defaults_to_normal_orientation)
121
TEST_F(DisplayBuffer, defaults_to_no_transformation)
114
EXPECT_EQ(mir_orientation_normal, db.orientation());
123
EXPECT_EQ(glm::mat2(), db.transformation());
117
126
TEST_F(DisplayBuffer, rotation_transposes_dimensions_and_reports_correctly)
119
geom::Size const transposed{display_size.height.as_int(), display_size.width.as_int()};
120
EXPECT_EQ(display_size, db.view_area().size);
121
EXPECT_EQ(db.orientation(), mir_orientation_normal);
122
db.configure(mir_power_mode_on, mir_orientation_inverted, top_left);
124
EXPECT_EQ(display_size, db.view_area().size);
125
EXPECT_EQ(db.orientation(), mir_orientation_inverted);
126
db.configure(mir_power_mode_on, mir_orientation_left, top_left);
128
EXPECT_EQ(transposed, db.view_area().size);
129
EXPECT_EQ(db.orientation(), mir_orientation_left);
130
db.configure(mir_power_mode_on, mir_orientation_right, top_left);
132
EXPECT_EQ(transposed, db.view_area().size);
133
EXPECT_EQ(db.orientation(), mir_orientation_right);
128
geom::Rectangle const transposed{area.top_left, {area.size.height.as_int(),
129
area.size.width.as_int()}};
130
EXPECT_EQ(display_size, db.view_area().size);
131
EXPECT_EQ(db.transformation(), rotate_none);
132
db.configure(mir_power_mode_on, rotate_inverted, area);
135
* Note that it's the output that transposes its extents() dimensions
136
* now (which is consistent with all other platforms), and not the
137
* DisplayBuffer class that calculates the transformation. So this test
138
* has lost some of its strength, but it's also now testing a function
139
* which contains no logic (only returns what it's given). So there's not
140
* much to test anyway...
143
EXPECT_EQ(display_size, db.view_area().size);
144
EXPECT_EQ(db.transformation(), rotate_inverted);
145
db.configure(mir_power_mode_on, rotate_left, transposed);
147
EXPECT_EQ(transposed, db.view_area());
148
EXPECT_EQ(db.transformation(), rotate_left);
149
db.configure(mir_power_mode_on, rotate_right, transposed);
151
EXPECT_EQ(transposed, db.view_area());
152
EXPECT_EQ(db.transformation(), rotate_right);
136
155
TEST_F(DisplayBuffer, reports_correct_size)
262
281
EXPECT_CALL(*mock_display_device, content_cleared())
264
db.configure(mir_power_mode_off, mir_orientation_normal, top_left);
265
db.configure(mir_power_mode_suspend, mir_orientation_normal, top_left);
266
db.configure(mir_power_mode_standby, mir_orientation_normal, top_left);
267
db.configure(mir_power_mode_on, mir_orientation_normal, top_left);
283
db.configure(mir_power_mode_off, {}, area);
284
db.configure(mir_power_mode_suspend, {}, area);
285
db.configure(mir_power_mode_standby, {}, area);
286
db.configure(mir_power_mode_on, {}, area);
270
289
TEST_F(DisplayBuffer, reject_list_if_option_disabled)
331
350
TEST_F(DisplayBuffer, reports_position_correctly)
333
352
using namespace testing;
335
geom::Displacement offset{100, 100};
353
geom::Displacement const offset{100, 100};
354
geom::Point const top_left_point = area.top_left;
355
geom::Point const offset_top_left_point = top_left_point + offset;
337
EXPECT_THAT(db.view_area().top_left, Eq(origin));
338
db.configure(mir_power_mode_on, orientation, offset);
339
EXPECT_THAT(db.view_area().top_left, Eq(geom::Point{origin + offset}));
357
EXPECT_THAT(db.view_area().top_left, Eq(top_left_point));
358
db.configure(mir_power_mode_on, transformation,
359
{offset_top_left_point, area.size});
360
EXPECT_THAT(db.view_area().top_left, Eq(offset_top_left_point));
342
363
//lp: #1485070. Could alternitvely rotate all the renderables, once rotation is supported
350
371
std::make_shared<mtd::StubRenderable>(
351
372
std::make_shared<mtd::StubBuffer>(std::make_shared<mtd::StubAndroidNativeBuffer>()))};
353
db.configure(mir_power_mode_on, mir_orientation_inverted, geom::Displacement{0,0});
374
db.configure(mir_power_mode_on, rotate_inverted, area);
354
375
EXPECT_FALSE(db.overlay(renderlist));
355
db.configure(mir_power_mode_on, mir_orientation_normal, geom::Displacement{0,0});
376
db.configure(mir_power_mode_on, rotate_none, area);
356
377
EXPECT_TRUE(db.overlay(renderlist));