Mir

Merge lp:~robertcarr/mir/power-control-swap-buffer-acceptance-test into lp:mir

Proposed by Robert Carr
Status: Superseded
Proposed branch: lp:~robertcarr/mir/power-control-swap-buffer-acceptance-test
Merge into: lp:mir
Diff against target: 131 lines (+116/-0)
2 files modified
tests/acceptance-tests/CMakeLists.txt (+1/-0)
tests/acceptance-tests/test_client_power_control.cpp (+115/-0)
To merge this branch: bzr merge lp:~robertcarr/mir/power-control-swap-buffer-acceptance-test
Reviewer Review Type Date Requested Status
Alan Griffiths Needs Information
Kevin DuBois (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+209535@code.launchpad.net

This proposal has been superseded by a proposal from 2014-03-06.

Commit message

Add acceptance test for behavior of client power control and buffer advancing.

Description of the change

While discussing this feature today with mterry I noticed we have no acceptance test for it!

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Kevin DuBois (kdub) wrote :

looks okay to me

review: Approve
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

80 +// when the client makes a swap buffers request, swap buffers will block until the screen is reenabled. However even if on the
81 +// client side, swap buffers is called asynchronously, the server side RPC thread will not process another request from this client
82 +// until swap buffers completes

As swap_buffers is non-blocking I don't think this has been true since -r 1398. Am I missing something?

review: Needs Information

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/acceptance-tests/CMakeLists.txt'
2--- tests/acceptance-tests/CMakeLists.txt 2014-02-10 09:07:48 +0000
3+++ tests/acceptance-tests/CMakeLists.txt 2014-03-05 20:28:14 +0000
4@@ -20,6 +20,7 @@
5 test_server_shutdown.cpp
6 test_client_focus_notification.cpp
7 test_client_authorization.cpp
8+ test_client_power_control.cpp
9 test_shell_control_of_surface_configuration.cpp
10 test_nested_mir.cpp
11 test_display_configuration.cpp
12
13=== added file 'tests/acceptance-tests/test_client_power_control.cpp'
14--- tests/acceptance-tests/test_client_power_control.cpp 1970-01-01 00:00:00 +0000
15+++ tests/acceptance-tests/test_client_power_control.cpp 2014-03-05 20:28:14 +0000
16@@ -0,0 +1,115 @@
17+/*
18+ * Copyright © 2014 Canonical Ltd.
19+ *
20+ * This program is free software: you can redistribute it and/or modify
21+ * it under the terms of the GNU General Public License version 3 as
22+ * published by the Free Software Foundation.
23+ *
24+ * This program is distributed in the hope that it will be useful,
25+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
26+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27+ * GNU General Public License for more details.
28+ *
29+ * You should have received a copy of the GNU General Public License
30+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
31+ *
32+ * Authored by: Robert Carr <robert.carr@canonical.com>
33+ */
34+
35+#include "mir_test_framework/display_server_test_fixture.h"
36+
37+#include "mir_toolkit/mir_client_library.h"
38+
39+#include <gtest/gtest.h>
40+#include <gmock/gmock.h>
41+
42+namespace mtf = mir_test_framework;
43+
44+namespace
45+{
46+char const* const mir_test_socket = mtf::test_socket_file().c_str();
47+
48+static void set_power_modes_to_off(MirDisplayConfiguration *conf)
49+{
50+ for (unsigned i = 0; i < conf->num_outputs; i++)
51+ {
52+ auto &output = conf->outputs[i];
53+
54+ output.power_mode = mir_power_mode_off;
55+ }
56+}
57+
58+static void expect_power_modes_are_on(MirDisplayConfiguration *conf)
59+{
60+ for (unsigned i = 0; i < conf->num_outputs; i++)
61+ {
62+ auto &output = conf->outputs[i];
63+
64+ EXPECT_EQ(mir_power_mode_on, output.power_mode);
65+ }
66+}
67+
68+static void with_configuration(MirConnection *connection, std::function<void(MirDisplayConfiguration*)> const& exec)
69+{
70+ auto conf = mir_connection_create_display_config(connection);
71+ exec(conf);
72+ mir_display_config_destroy(conf);
73+}
74+}
75+
76+using ClientPowerControl = BespokeDisplayServerTestFixture;
77+
78+// When a client has requested to turn the display off, we re-enable it when the client makes a buffer swapping request.
79+// This behavior is required due to the serial manner in which we process requests on the server side. If the display is off
80+// when the client makes a swap buffers request, swap buffers will block until the screen is reenabled. However even if on the
81+// client side, swap buffers is called asynchronously, the server side RPC thread will not process another request from this client
82+// until swap buffers completes. Thus its unfortunately not possible for the client to turn the screen back on!
83+TEST_F(ClientPowerControl, client_advancing_buffer_will_override_power_request_made_by_same_client)
84+{
85+ TestingServerConfiguration server_config;
86+ launch_server_process(server_config);
87+
88+ struct Client : TestingClientConfiguration
89+ {
90+ void exec()
91+ {
92+ auto connection = mir_connect_sync(mir_test_socket, __PRETTY_FUNCTION__);
93+
94+ with_configuration(connection,
95+ [&](MirDisplayConfiguration *c)
96+ {
97+ set_power_modes_to_off(c);
98+ mir_connection_apply_display_config(connection, c);
99+ });
100+
101+ MirSurfaceParameters const params =
102+ {
103+ __PRETTY_FUNCTION__,
104+ 1, 1,
105+ mir_pixel_format_abgr_8888,
106+ mir_buffer_usage_hardware,
107+ mir_display_output_id_invalid
108+ };
109+ auto s = mir_connection_create_surface_sync(connection, &params);
110+
111+ // Creating a surface advances buffers and thus should flip the power request back to on.
112+ with_configuration(connection, expect_power_modes_are_on);
113+
114+ // Flip them back off.
115+ with_configuration(connection,
116+ [&](MirDisplayConfiguration *c)
117+ {
118+ set_power_modes_to_off(c);
119+ mir_connection_apply_display_config(connection, c);
120+ });
121+
122+ mir_surface_swap_buffers_sync(s);
123+ with_configuration(connection, expect_power_modes_are_on);
124+
125+ mir_surface_release_sync(s);
126+ mir_connection_release(connection);
127+ }
128+ } client_config;
129+
130+ launch_client_process(client_config);
131+}

Subscribers

People subscribed via source and target branches