2
* Copyright © 2015 Canonical Ltd.
4
* This program is free software: you can redistribute it and/or modify it
5
* under the terms of the GNU General Public License version 3,
6
* as published by the Free Software Foundation.
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details.
13
* You should have received a copy of the GNU General Public License
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16
* Authored by: Kevin DuBois <kevin.dubois@canonical.com>
19
#include "../buffer_stream_arrangement.h"
20
#include "mir_toolkit/mir_presentation_chain.h"
21
#include <gmock/gmock.h>
23
namespace mt = mir::test;
24
namespace geom = mir::geometry;
25
using namespace std::literals::chrono_literals;
26
using namespace testing;
28
typedef mt::BufferStreamArrangementBase BufferStreamArrangementStaging;
29
TEST_F(BufferStreamArrangementStaging, can_set_stream_logical_and_physical_size)
31
geom::Size logical_size { 233, 111 };
32
geom::Size physical_size { 133, 222 };
33
mt::Stream stream(connection, physical_size, { {0, 0}, logical_size } );
35
auto change_spec = mir_connection_create_spec_for_changes(connection);
36
mir_surface_spec_add_buffer_stream(change_spec, 0, 0, logical_size.width.as_int(), logical_size.height.as_int(), stream.handle());
37
mir_surface_apply_spec(surface, change_spec);
38
mir_surface_spec_release(change_spec);
40
std::vector<mt::RelativeRectangle> positions { { {0,0}, logical_size, physical_size } };
41
EXPECT_TRUE(ordering->wait_for_positions_within(positions, 5s))
42
<< "timed out waiting to see the compositor post the streams in the right arrangement";
45
TEST_F(BufferStreamArrangementStaging, can_setting_stream_physical_size_doesnt_affect_logical)
47
geom::Size logical_size { 233, 111 };
48
geom::Size original_physical_size { 133, 222 };
49
geom::Size changed_physical_size { 133, 222 };
50
mt::Stream stream(connection, original_physical_size, { {0, 0}, logical_size } );
52
auto change_spec = mir_connection_create_spec_for_changes(connection);
53
mir_surface_spec_add_buffer_stream(change_spec, 0, 0, logical_size.width.as_int(), logical_size.height.as_int(), stream.handle());
54
mir_surface_apply_spec(surface, change_spec);
55
mir_surface_spec_release(change_spec);
57
stream.set_size(changed_physical_size);
58
//submits the original_buffer_size buffer, getting changed_physical_size buffer as current
59
stream.swap_buffers();
60
//submits the changed_buffer_size buffer so server can see
61
stream.swap_buffers();
63
std::vector<mt::RelativeRectangle> positions { { {0,0}, logical_size, changed_physical_size } };
64
EXPECT_TRUE(ordering->wait_for_positions_within(positions, 5s))
65
<< "timed out waiting to see the compositor post the streams in the right arrangement";
68
TEST_F(BufferStreamArrangementStaging, stream_size_reflects_current_buffer_physical_size)
70
geom::Size logical_size { 233, 111 };
71
geom::Size original_physical_size { 133, 222 };
72
geom::Size changed_physical_size { 133, 222 };
73
mt::Stream stream(connection, original_physical_size, { {0, 0}, logical_size } );
75
auto change_spec = mir_connection_create_spec_for_changes(connection);
76
mir_surface_spec_add_buffer_stream(change_spec, 0, 0, logical_size.width.as_int(), logical_size.height.as_int(), stream.handle());
77
mir_surface_apply_spec(surface, change_spec);
78
mir_surface_spec_release(change_spec);
80
EXPECT_THAT(stream.physical_size(), Eq(original_physical_size));
81
streams.back()->set_size(changed_physical_size);
82
EXPECT_THAT(stream.physical_size(), Eq(changed_physical_size));
83
streams.back()->swap_buffers();
84
EXPECT_THAT(stream.physical_size(), Eq(changed_physical_size));