Merge lp:~mir-team/qtmir/server-client-acceptance into lp:qtmir

Proposed by Robert Carr
Status: Work in progress
Proposed branch: lp:~mir-team/qtmir/server-client-acceptance
Merge into: lp:qtmir
Diff against target: 730 lines (+629/-14)
13 files modified
tests/common/common.pri (+11/-11)
tests/modules/ApplicationManager/ApplicationManager.pro (+1/-1)
tests/modules/TaskController/TaskController.pro (+1/-1)
tests/qpa/acceptance-tests/acceptance-tests.pro (+20/-0)
tests/qpa/acceptance-tests/acceptance_tests.cpp (+147/-0)
tests/qpa/acceptance-tests/mir_test_framework/deferred_in_process_server.h (+39/-0)
tests/qpa/acceptance-tests/mir_test_framework/in_process_server.h (+47/-0)
tests/qpa/acceptance-tests/mir_test_framework/server_runner.cpp (+103/-0)
tests/qpa/acceptance-tests/mir_test_framework/server_runner.h (+61/-0)
tests/qpa/acceptance-tests/stub_graphics_platform.cpp (+150/-0)
tests/qpa/acceptance-tests/stub_graphics_platform.h (+46/-0)
tests/qpa/qpa.pro (+2/-0)
tests/tests.pro (+1/-1)
To merge this branch: bzr merge lp:~mir-team/qtmir/server-client-acceptance
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Needs Fixing
Gerry Boland (community) Needs Information
Review via email: mp+230018@code.launchpad.net

Commit message

Add a small framework for creating tests which exercise the QPA MirServerConfiguration from an external client.

Description of the change

Add a small framework for creating tests which exercise the QPA MirServerConfiguration from an external client. Add 2 simple tests as proof of concept...more to come!

To post a comment you must log in.
Revision history for this message
Gerry Boland (gerboland) wrote :

Could we have Mir exporting the Mir test frameworks & stubs somehow, instead of copypasting them here? The worry is if qtmir's copy goes out of date.

review: Needs Information
Revision history for this message
Robert Carr (robertcarr) wrote :

The stub platform may dissapear (some talk of Mir exporting a stub platform, or otherwise once mesa software + simple DRM is set up no reason to stub it out could just do real software in rendering in the acceptance tests).

I'm not sure about the test framework...I doubt exporting another library is going to go over happy on the Mir team so I thought just copying the code here was best, mostly just dependent on STL and pretty simple...

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Daniel d'Andrada (dandrader) wrote :

I've just skimmed through it (so I might very well be wrong), but It all looks as a way to test mir itself and not the interaction between mir and qt, which is what qtmir is all about.

I think the directory structure should match (or at least resemble) what we see in /src. It's "platforms/mirserver" over there, not "qpa". Not saying that "platforms/mirserver" is a good one but I do think src and test should match, so that you can easily find where are the tests for some piece of code and vice-versa.

Unmerged revisions

229. By Robert Carr

Merge lp:qtmir

228. By Robert Carr

Add some tests

227. By Robert Carr

Work on mir acceptance

226. By Robert Carr

Stubbiest acceptance test

225. By Robert Carr

Begin mir test fixture

224. By Robert Carr

Add acceptance skeleton

223. By Robert Carr

Move common test directory to prepare for new test dir

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== renamed directory 'tests/modules/common' => 'tests/common'
2=== modified file 'tests/common/common.pri'
3--- tests/modules/common/common.pri 2014-07-23 08:19:28 +0000
4+++ tests/common/common.pri 2014-08-07 21:45:29 +0000
5@@ -1,21 +1,21 @@
6 CONFIG += link_pkgconfig no_keywords # keywords clash with ProcessC++
7-PKGCONFIG += mirserver process-cpp ubuntu-app-launch-2
8+PKGCONFIG += mirserver mirclient process-cpp ubuntu-app-launch-2
9
10 QT += quick testlib
11 QMAKE_CXXFLAGS = -std=c++11
12
13-HEADERS += ../common/mock_application_controller.h \
14- ../common/mock_desktop_file_reader.h \
15- ../common/mock_focus_controller.h \
16- ../common/mock_oom_controller.h \
17- ../common/mock_process_controller.h \
18- ../common/mock_proc_info.h \
19- ../common/mock_prompt_session.h
20- ../common/mock_prompt_session_manager.h
21- ../common/mock_session.h
22+HEADERS += ../../common/mock_application_controller.h \
23+ ../../common/mock_desktop_file_reader.h \
24+ ../../common/mock_focus_controller.h \
25+ ../../common/mock_oom_controller.h \
26+ ../../common/mock_process_controller.h \
27+ ../../common/mock_proc_info.h \
28+ ../../common/mock_prompt_session.h
29+ ../../common/mock_prompt_session_manager.h
30+ ../../common/mock_session.h
31
32 INCLUDEPATH += ../../../src/modules \
33- ../common
34+ ../../common
35
36
37 GMOCK_SOURCES = /usr/src/gmock/src/gmock-all.cc \
38
39=== modified file 'tests/modules/ApplicationManager/ApplicationManager.pro'
40--- tests/modules/ApplicationManager/ApplicationManager.pro 2014-07-07 19:33:56 +0000
41+++ tests/modules/ApplicationManager/ApplicationManager.pro 2014-08-07 21:45:29 +0000
42@@ -1,5 +1,5 @@
43 include(../../test-includes.pri)
44-include(../common/common.pri)
45+include(../../common/common.pri)
46
47 TARGET = application_manager_test
48
49
50=== modified file 'tests/modules/TaskController/TaskController.pro'
51--- tests/modules/TaskController/TaskController.pro 2014-07-07 19:33:56 +0000
52+++ tests/modules/TaskController/TaskController.pro 2014-08-07 21:45:29 +0000
53@@ -1,5 +1,5 @@
54 include(../../test-includes.pri)
55-include(../common/common.pri)
56+include(../../common/common.pri)
57
58 TARGET = taskcontroller_test
59
60
61=== added directory 'tests/qpa'
62=== added directory 'tests/qpa/acceptance-tests'
63=== added file 'tests/qpa/acceptance-tests/acceptance-tests.pro'
64--- tests/qpa/acceptance-tests/acceptance-tests.pro 1970-01-01 00:00:00 +0000
65+++ tests/qpa/acceptance-tests/acceptance-tests.pro 2014-08-07 21:45:29 +0000
66@@ -0,0 +1,20 @@
67+include(../../test-includes.pri)
68+include(../../common/common.pri)
69+
70+TARGET = qpa_mir_server_and_client_acceptance_tests
71+
72+INCLUDEPATH += \
73+ ../../../src/platforms/mirserver
74+
75+SOURCES += \
76+ acceptance_tests.cpp \
77+ stub_graphics_platform.cpp \
78+ mir_test_framework/server_runner.cpp
79+
80+#CONFIG += link_pkgconfig
81+#PKG_CONFIG += mirclient
82+
83+# need to link in the QPA plugin too for access to MirServerConfiguration
84+LIBS += -Wl,-rpath,$${PWD}/../../../src/platforms/mirserver \
85+ -L../../../src/platforms/mirserver -lqpa-mirserver
86+
87
88=== added file 'tests/qpa/acceptance-tests/acceptance_tests.cpp'
89--- tests/qpa/acceptance-tests/acceptance_tests.cpp 1970-01-01 00:00:00 +0000
90+++ tests/qpa/acceptance-tests/acceptance_tests.cpp 2014-08-07 21:45:29 +0000
91@@ -0,0 +1,147 @@
92+/*
93+ * Copyright (C) 2014 Canonical, Ltd.
94+ *
95+ * This program is free software: you can redistribute it and/or modify it under
96+ * the terms of the GNU Lesser General Public License version 3, as published by
97+ * the Free Software Foundation.
98+ *
99+ * This program is distributed in the hope that it will be useful, but WITHOUT
100+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
101+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
102+ * Lesser General Public License for more details.
103+ *
104+ * You should have received a copy of the GNU Lesser General Public License
105+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
106+ *
107+ */
108+#include <Unity/Application/application_manager.h>
109+
110+#include <Unity/Application/applicationcontroller.h>
111+#include <Unity/Application/taskcontroller.h>
112+#include <Unity/Application/proc_info.h>
113+#include <mirserverconfiguration.h>
114+#include <sessionauthorizer.h>
115+#include <qmirserver.h>
116+
117+#include <mir_toolkit/mir_client_library.h>
118+
119+#include <gmock/gmock.h>
120+#include <gtest/gtest.h>
121+
122+#include "stub_graphics_platform.h"
123+#include "mir_test_framework/deferred_in_process_server.h"
124+
125+namespace mg = mir::graphics;
126+namespace mtf = mir_test_framework;
127+
128+namespace
129+{
130+
131+static char const* argv[] = {
132+ "acceptance-tests",
133+};
134+
135+struct TestingServerConfiguration : public MirServerConfiguration
136+{
137+ TestingServerConfiguration()
138+ : MirServerConfiguration(1, argv)
139+ {
140+ }
141+ std::shared_ptr<mg::Platform> the_graphics_platform() override
142+ {
143+ return std::make_shared<StubPlatform>();
144+ }
145+};
146+
147+struct TestQPAServer : public mtf::DeferredInProcessServer
148+{
149+ TestingServerConfiguration conf;
150+ mir::DefaultServerConfiguration& server_config() override
151+ {
152+ return conf;
153+ }
154+
155+ void launch_client(std::function<void(std::string)> const& client_exec)
156+ {
157+ auto thread = std::thread(client_exec, new_connection());
158+ client_threads.push_back(std::move(thread));
159+ }
160+
161+ void TearDown() override
162+ {
163+ for (auto &thread : client_threads)
164+ {
165+ if (thread.joinable())
166+ thread.join();
167+ }
168+ DeferredInProcessServer::TearDown();
169+ }
170+
171+ std::vector<std::thread> client_threads;
172+};
173+
174+}
175+
176+TEST_F(TestQPAServer, client_may_connect_and_exit)
177+{
178+ using namespace testing;
179+
180+ start_server();
181+
182+ launch_client([&](std::string const& connect_string) -> void
183+ {
184+ MirConnection *connection = mir_connect_sync(connect_string.c_str(),
185+ __PRETTY_FUNCTION__);
186+ ASSERT_TRUE(mir_connection_is_valid(connection));
187+ mir_connection_release(connection);
188+ });
189+}
190+
191+namespace
192+{
193+
194+class AuthorizationDenier : public QObject
195+{
196+ Q_OBJECT
197+public:
198+ AuthorizationDenier(QObject *parent = 0)
199+ : QObject(parent)
200+ {
201+ }
202+ ~AuthorizationDenier() = default;
203+
204+ void authorizeSession(quint64 const pid, bool& authorized)
205+ {
206+ (void) pid;
207+ // Observe fail and toggle
208+ authorized = false;
209+ }
210+};
211+
212+}
213+
214+TEST_F(TestQPAServer, session_authorizer_may_prevent_client_from_connecting)
215+{
216+ using namespace testing;
217+
218+ start_server();
219+
220+ AuthorizationDenier d(nullptr);
221+ QObject::connect(conf.sessionAuthorizer(), &SessionAuthorizer::requestAuthorizationForSession,
222+ &d, &AuthorizationDenier::authorizeSession, Qt::DirectConnection);
223+
224+ launch_client([&](std::string const& connect_string) -> void
225+ {
226+ MirConnection *connection = mir_connect_sync(connect_string.c_str(),
227+ __PRETTY_FUNCTION__);
228+ // We should fail to connect!
229+ ASSERT_FALSE(mir_connection_is_valid(connection));
230+ });
231+}
232+
233+// TODO: Could Test SessionListener and other things in server configuration
234+// TODO: Test surface creation
235+// TODO: Could add tests in a similar format with an active ApplicationManager instance
236+
237+// Must be at end
238+#include "acceptance_tests.moc"
239
240=== added directory 'tests/qpa/acceptance-tests/mir_test_framework'
241=== added file 'tests/qpa/acceptance-tests/mir_test_framework/deferred_in_process_server.h'
242--- tests/qpa/acceptance-tests/mir_test_framework/deferred_in_process_server.h 1970-01-01 00:00:00 +0000
243+++ tests/qpa/acceptance-tests/mir_test_framework/deferred_in_process_server.h 2014-08-07 21:45:29 +0000
244@@ -0,0 +1,39 @@
245+/*
246+ * Copyright © 2014 Canonical Ltd.
247+ *
248+ * This program is free software: you can redistribute it and/or modify it
249+ * under the terms of the GNU General Public License version 3,
250+ * as published by the Free Software Foundation.
251+ *
252+ * This program is distributed in the hope that it will be useful,
253+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
254+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
255+ * GNU General Public License for more details.
256+ *
257+ * You should have received a copy of the GNU General Public License
258+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
259+ *
260+ * Authored By: Alan Griffiths <alan@octopull.co.uk>
261+ */
262+
263+#ifndef MIR_TEST_FRAMEWORK_DEFERRED_IN_PROCESS_SERVER_H_
264+#define MIR_TEST_FRAMEWORK_DEFERRED_IN_PROCESS_SERVER_H_
265+
266+#include "mir_test_framework/server_runner.h"
267+
268+namespace mir_test_framework
269+{
270+/** Fixture for running Mir server in test process.
271+ * The server startup is deferred until start_server() is called, to allows the
272+ * test code to initialize the server environment with expectations or stubs.
273+ */
274+struct DeferredInProcessServer : testing::Test, private ServerRunner
275+{
276+ void TearDown() override { ServerRunner::stop_server(); }
277+
278+ using ServerRunner::start_server;
279+ using ServerRunner::new_connection;
280+};
281+}
282+
283+#endif /* MIR_TEST_FRAMEWORK_DEFERRED_IN_PROCESS_SERVER_H_ */
284
285=== added file 'tests/qpa/acceptance-tests/mir_test_framework/in_process_server.h'
286--- tests/qpa/acceptance-tests/mir_test_framework/in_process_server.h 1970-01-01 00:00:00 +0000
287+++ tests/qpa/acceptance-tests/mir_test_framework/in_process_server.h 2014-08-07 21:45:29 +0000
288@@ -0,0 +1,47 @@
289+/*
290+ * Copyright © 2013-2014 Canonical Ltd.
291+ *
292+ * This program is free software: you can redistribute it and/or modify it
293+ * under the terms of the GNU General Public License version 3,
294+ * as published by the Free Software Foundation.
295+ *
296+ * This program is distributed in the hope that it will be useful,
297+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
298+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
299+ * GNU General Public License for more details.
300+ *
301+ * You should have received a copy of the GNU General Public License
302+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
303+ *
304+ * Authored by: Alan Griffiths <alan@octopull.co.uk>
305+ */
306+
307+#ifndef MIR_TEST_FRAMEWORK_IN_PROCESS_SERVER_H_
308+#define MIR_TEST_FRAMEWORK_IN_PROCESS_SERVER_H_
309+
310+#include "mir_test_framework/server_runner.h"
311+
312+#include <gtest/gtest.h>
313+
314+namespace mir_test_framework
315+{
316+/// Fixture for running Mir server in test process
317+struct InProcessServer : testing::Test, private ServerRunner
318+{
319+ /// Starts the server
320+ /// \warning don't forget to call this if you override SetUp()
321+ void SetUp() override { ServerRunner::start_server(); }
322+
323+ /// Stops the server
324+ /// \warning don't forget to call this if you override TearDown()
325+ void TearDown() override { ServerRunner::stop_server(); }
326+
327+ /// \return a connection string for a new client to connect to the server
328+ using ServerRunner::new_connection;
329+
330+ /// \return a connection string for a new client to connect to the prompt server
331+ using ServerRunner::new_prompt_connection;
332+};
333+}
334+
335+#endif /* MIR_TEST_FRAMEWORK_IN_PROCESS_SERVER_H_ */
336
337=== added file 'tests/qpa/acceptance-tests/mir_test_framework/server_runner.cpp'
338--- tests/qpa/acceptance-tests/mir_test_framework/server_runner.cpp 1970-01-01 00:00:00 +0000
339+++ tests/qpa/acceptance-tests/mir_test_framework/server_runner.cpp 2014-08-07 21:45:29 +0000
340@@ -0,0 +1,103 @@
341+/*
342+ * Copyright © 2013-2014 Canonical Ltd.
343+ *
344+ * This program is free software: you can redistribute it and/or modify it
345+ * under the terms of the GNU General Public License version 3,
346+ * as published by the Free Software Foundation.
347+ *
348+ * This program is distributed in the hope that it will be useful,
349+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
350+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
351+ * GNU General Public License for more details.
352+ *
353+ * You should have received a copy of the GNU General Public License
354+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
355+ *
356+ * Authored by: Alan Griffiths <alan@octopull.co.uk>
357+ */
358+
359+#include "mir_test_framework/server_runner.h"
360+
361+#include <mir/default_server_configuration.h>
362+#include <mir/display_server.h>
363+#include <mir/frontend/connector.h>
364+#include <mir/run_mir.h>
365+#include <gtest/gtest.h>
366+
367+#include <condition_variable>
368+#include <mutex>
369+
370+namespace mtf = mir_test_framework;
371+
372+namespace
373+{
374+char const* const env_no_file = "MIR_SERVER_NO_FILE";
375+}
376+
377+mtf::ServerRunner::ServerRunner() :
378+ old_env(getenv(env_no_file))
379+{
380+ if (!old_env) setenv(env_no_file, "", true);
381+}
382+
383+void mtf::ServerRunner::start_server()
384+{
385+ display_server = start_mir_server();
386+ ASSERT_TRUE(display_server);
387+}
388+
389+std::string mtf::ServerRunner::new_connection()
390+{
391+ char connect_string[64] = {0};
392+ sprintf(connect_string, "fd://%d", server_config().the_connector()->client_socket_fd());
393+ return connect_string;
394+}
395+
396+std::string mtf::ServerRunner::new_prompt_connection()
397+{
398+ char connect_string[64] = {0};
399+ sprintf(connect_string, "fd://%d", server_config().the_prompt_connector()->client_socket_fd());
400+ return connect_string;
401+}
402+
403+void mtf::ServerRunner::stop_server()
404+{
405+ ASSERT_TRUE(display_server);
406+ display_server->stop();
407+}
408+
409+mtf::ServerRunner::~ServerRunner()
410+{
411+ if (server_thread.joinable()) server_thread.join();
412+
413+ if (!old_env) unsetenv(env_no_file);
414+}
415+
416+mir::DisplayServer* mtf::ServerRunner::start_mir_server()
417+{
418+ std::mutex mutex;
419+ std::condition_variable started;
420+ mir::DisplayServer* result{nullptr};
421+
422+ server_thread = std::thread([&]
423+ {
424+ try
425+ {
426+ mir::run_mir(server_config(), [&](mir::DisplayServer& ds)
427+ {
428+ std::lock_guard<std::mutex> lock(mutex);
429+ result = &ds;
430+ started.notify_one();
431+ });
432+ }
433+ catch (std::exception const& e)
434+ {
435+ FAIL() << e.what();
436+ }
437+ });
438+
439+ std::unique_lock<std::mutex> lock(mutex);
440+ started.wait_for(lock, std::chrono::seconds(2), [&]{ return !!result; });
441+
442+ return result;
443+}
444
445=== added file 'tests/qpa/acceptance-tests/mir_test_framework/server_runner.h'
446--- tests/qpa/acceptance-tests/mir_test_framework/server_runner.h 1970-01-01 00:00:00 +0000
447+++ tests/qpa/acceptance-tests/mir_test_framework/server_runner.h 2014-08-07 21:45:29 +0000
448@@ -0,0 +1,61 @@
449+/*
450+ * Copyright © 2014 Canonical Ltd.
451+ *
452+ * This program is free software: you can redistribute it and/or modify it
453+ * under the terms of the GNU General Public License version 3,
454+ * as published by the Free Software Foundation.
455+ *
456+ * This program is distributed in the hope that it will be useful,
457+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
458+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
459+ * GNU General Public License for more details.
460+ *
461+ * You should have received a copy of the GNU General Public License
462+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
463+ *
464+ * Authored By: Alan Griffiths <alan@octopull.co.uk>
465+ */
466+
467+#ifndef MIR_TEST_FRAMEWORK_SERVER_RUNNER_H_
468+#define MIR_TEST_FRAMEWORK_SERVER_RUNNER_H_
469+
470+#include <string>
471+#include <thread>
472+
473+namespace mir
474+{
475+class DisplayServer;
476+class DefaultServerConfiguration;
477+}
478+
479+namespace mir_test_framework
480+{
481+/// Utility for running Mir server in test process
482+struct ServerRunner
483+{
484+ ServerRunner();
485+ virtual ~ServerRunner();
486+
487+ /// Starts the server
488+ void start_server();
489+
490+ /// Stops the server
491+ void stop_server();
492+
493+ /// \return a connection string for a new client to connect to the server
494+ std::string new_connection();
495+
496+ /// \return a connection string for a new client to connect to the prompt server
497+ std::string new_prompt_connection();
498+
499+private:
500+ mir::DisplayServer* start_mir_server();
501+ virtual mir::DefaultServerConfiguration& server_config() = 0;
502+
503+ char const* const old_env;
504+ std::thread server_thread;
505+ mir::DisplayServer* display_server = 0;
506+};
507+}
508+
509+#endif /* MIR_TEST_FRAMEWORK_SERVER_RUNNER_H_ */
510
511=== added file 'tests/qpa/acceptance-tests/stub_graphics_platform.cpp'
512--- tests/qpa/acceptance-tests/stub_graphics_platform.cpp 1970-01-01 00:00:00 +0000
513+++ tests/qpa/acceptance-tests/stub_graphics_platform.cpp 2014-08-07 21:45:29 +0000
514@@ -0,0 +1,150 @@
515+/*
516+ * Copyright © 2014 Canonical Ltd.
517+ *
518+ * This program is free software: you can redistribute it and/or modify it
519+ * under the terms of the GNU Lesser General Public License version 3,
520+ * as published by the Free Software Foundation.
521+ *
522+ * This program is distributed in the hope that it will be useful,
523+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
524+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
525+ * GNU General Public License for more details.
526+ *
527+ * You should have received a copy of the GNU Lesser General Public License
528+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
529+ */
530+
531+#include <mir/graphics/graphic_buffer_allocator.h>
532+#include <mir/graphics/display.h>
533+#include <mir/graphics/gl_context.h>
534+#include <mir/graphics/display_configuration.h>
535+#include <mir/graphics/platform_ipc_package.h>
536+
537+#include "stub_graphics_platform.h"
538+
539+#include <thread>
540+
541+namespace mg = mir::graphics;
542+
543+namespace
544+{
545+
546+struct StubBufferAllocator : public mg::GraphicBufferAllocator
547+{
548+ std::shared_ptr<mg::Buffer> alloc_buffer(
549+ mg::BufferProperties const& properties)
550+ {
551+ (void) properties;
552+ return nullptr;
553+ }
554+
555+ std::vector<MirPixelFormat> supported_pixel_formats()
556+ {
557+ return {};
558+ }
559+};
560+
561+struct StubGLContext : public mg::GLContext
562+{
563+ void make_current() const
564+ {
565+ }
566+
567+ void release_current() const
568+ {
569+ }
570+};
571+
572+class StubDisplayConfiguration : public mg::DisplayConfiguration
573+{
574+ void for_each_card(std::function<void(mg::DisplayConfigurationCard const&)>) const override
575+ {
576+ }
577+ void for_each_output(std::function<void(mg::DisplayConfigurationOutput const&)>) const override
578+ {
579+ }
580+ void for_each_output(std::function<void(mg::UserDisplayConfigurationOutput&)>) override
581+ {
582+ }
583+};
584+
585+class StubDisplay : public mg::Display
586+{
587+ public:
588+ void for_each_display_buffer(std::function<void(mg::DisplayBuffer&)> const&)
589+ {
590+ /* yield() is needed to ensure reasonable runtime under valgrind for some tests */
591+ std::this_thread::yield();
592+ }
593+ std::unique_ptr<mg::DisplayConfiguration> configuration() const override
594+ {
595+ return std::unique_ptr<mg::DisplayConfiguration>(
596+ new StubDisplayConfiguration
597+ );
598+ }
599+ void configure(mg::DisplayConfiguration const&) {}
600+ void register_configuration_change_handler(
601+ mg::EventHandlerRegister&,
602+ mg::DisplayConfigurationChangeHandler const&) override
603+ {
604+ }
605+ void register_pause_resume_handlers(mg::EventHandlerRegister&,
606+ mg::DisplayPauseHandler const&,
607+ mg::DisplayResumeHandler const&) override
608+ {
609+ }
610+ void pause() {}
611+ void resume() {}
612+ std::shared_ptr<mg::Cursor> create_hardware_cursor(std::shared_ptr<mg::CursorImage> const& /* initial_image */)
613+ {
614+ return {};
615+ }
616+ std::unique_ptr<mg::GLContext> create_gl_context()
617+ {
618+ return std::unique_ptr<StubGLContext>{new StubGLContext()};
619+ }
620+};
621+
622+}
623+
624+std::shared_ptr<mg::GraphicBufferAllocator> StubPlatform::create_buffer_allocator(
625+ std::shared_ptr<mg::BufferInitializer> const& buffer_initializer)
626+{
627+ (void) buffer_initializer;
628+ return std::make_shared<StubBufferAllocator>();
629+}
630+
631+std::shared_ptr<mg::Display> StubPlatform::create_display(
632+ std::shared_ptr<mg::DisplayConfigurationPolicy> const& initial_conf_policy,
633+ std::shared_ptr<mg::GLProgramFactory> const& gl_program_factory,
634+ std::shared_ptr<mg::GLConfig> const& gl_config)
635+{
636+ (void) initial_conf_policy;
637+ (void) gl_program_factory;
638+ (void) gl_config;
639+ // TODO: Probably need some sizing...
640+ return std::make_shared<StubDisplay>();
641+}
642+
643+std::shared_ptr<mg::PlatformIPCPackage> StubPlatform::get_ipc_package()
644+{
645+ return std::make_shared<mg::PlatformIPCPackage>();
646+}
647+
648+void StubPlatform::fill_buffer_package(mg::BufferIPCPacker* packer, mg::Buffer const* buffer,
649+ mg::BufferIpcMsgType msg_type) const
650+{
651+ (void) packer;
652+ (void) buffer;
653+ (void) msg_type;
654+}
655+
656+std::shared_ptr<mg::InternalClient> StubPlatform::create_internal_client()
657+{
658+ return nullptr;
659+}
660+
661+EGLNativeDisplayType StubPlatform::egl_native_display() const
662+{
663+ return EGLNativeDisplayType();
664+}
665
666=== added file 'tests/qpa/acceptance-tests/stub_graphics_platform.h'
667--- tests/qpa/acceptance-tests/stub_graphics_platform.h 1970-01-01 00:00:00 +0000
668+++ tests/qpa/acceptance-tests/stub_graphics_platform.h 2014-08-07 21:45:29 +0000
669@@ -0,0 +1,46 @@
670+/*
671+ * Copyright © 2014 Canonical Ltd.
672+ *
673+ * This program is free software: you can redistribute it and/or modify it
674+ * under the terms of the GNU Lesser General Public License version 3,
675+ * as published by the Free Software Foundation.
676+ *
677+ * This program is distributed in the hope that it will be useful,
678+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
679+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
680+ * GNU General Public License for more details.
681+ *
682+ * You should have received a copy of the GNU Lesser General Public License
683+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
684+ */
685+
686+#ifndef STUB_GRAPHICS_PLATFORM_H_
687+#define STUB_GRAPHICS_PLATFORM_H_
688+
689+#include <mir/graphics/platform.h>
690+
691+struct StubPlatform : public mir::graphics::Platform
692+{
693+ StubPlatform() = default;
694+ virtual ~StubPlatform() = default;
695+
696+ std::shared_ptr<mir::graphics::GraphicBufferAllocator> create_buffer_allocator(
697+ std::shared_ptr<mir::graphics::BufferInitializer> const& buffer_initializer) override;
698+
699+ std::shared_ptr<mir::graphics::Display> create_display(
700+ std::shared_ptr<mir::graphics::DisplayConfigurationPolicy> const& initial_conf_policy,
701+ std::shared_ptr<mir::graphics::GLProgramFactory> const& gl_program_factory,
702+ std::shared_ptr<mir::graphics::GLConfig> const& gl_config) override;
703+
704+ std::shared_ptr<mir::graphics::PlatformIPCPackage> get_ipc_package() override;
705+
706+ void fill_buffer_package(mir::graphics::BufferIPCPacker* packer, mir::graphics::Buffer const* buffer,
707+ mir::graphics::BufferIpcMsgType msg_type) const override;
708+
709+ std::shared_ptr<mir::graphics::InternalClient> create_internal_client() override;
710+
711+ EGLNativeDisplayType egl_native_display() const override;
712+};
713+
714+#endif // STUB_GRAPHICS_PLATFORM_H_
715+
716
717=== added file 'tests/qpa/qpa.pro'
718--- tests/qpa/qpa.pro 1970-01-01 00:00:00 +0000
719+++ tests/qpa/qpa.pro 2014-08-07 21:45:29 +0000
720@@ -0,0 +1,2 @@
721+TEMPLATE = subdirs
722+SUBDIRS = acceptance-tests
723
724=== modified file 'tests/tests.pro'
725--- tests/tests.pro 2014-07-01 13:38:06 +0000
726+++ tests/tests.pro 2014-08-07 21:45:29 +0000
727@@ -1,2 +1,2 @@
728 TEMPLATE = subdirs
729-SUBDIRS = modules
730+SUBDIRS = modules qpa

Subscribers

People subscribed via source and target branches