Mir

Merge lp:~alan-griffiths/mir/basic-test-fixture into lp:mir

Proposed by Alan Griffiths
Status: Merged
Approved by: Alexandros Frantzis
Approved revision: no longer in the source branch.
Merged at revision: 1636
Proposed branch: lp:~alan-griffiths/mir/basic-test-fixture
Merge into: lp:mir
Diff against target: 102 lines (+58/-15)
2 files modified
include/test/mir_test_framework/basic_client_server_fixture.h (+53/-0)
tests/acceptance-tests/test_trust_session_helper.cpp (+5/-15)
To merge this branch: bzr merge lp:~alan-griffiths/mir/basic-test-fixture
Reviewer Review Type Date Requested Status
Alexandros Frantzis (community) Approve
Kevin DuBois (community) Approve
Alberto Aguirre (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+219700@code.launchpad.net

Commit message

test framework: a generic fixture for setting up server and getting a connection from the client

Description of the change

test framework: a generic fixture for setting up server and getting a connection from the client

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
Alberto Aguirre (albaguirre) wrote :

Looks good.

review: Approve
Revision history for this message
Kevin DuBois (kdub) wrote :

Seems handy

review: Approve
Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

OK.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'include/test/mir_test_framework/basic_client_server_fixture.h'
2--- include/test/mir_test_framework/basic_client_server_fixture.h 1970-01-01 00:00:00 +0000
3+++ include/test/mir_test_framework/basic_client_server_fixture.h 2014-05-15 13:59:27 +0000
4@@ -0,0 +1,53 @@
5+/*
6+ * Copyright © 2014 Canonical Ltd.
7+ *
8+ * This program is free software: you can redistribute it and/or modify it
9+ * under the terms of the GNU General Public License version 3,
10+ * as published by the Free Software Foundation.
11+ *
12+ * This program is distributed in the hope that it will be useful,
13+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+ * GNU General Public License for more details.
16+ *
17+ * You should have received a copy of the GNU General Public License
18+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
19+ *
20+ * Authored By: Alan Griffiths <alan@octopull.co.uk>
21+ */
22+
23+#ifndef MIR_TEST_FRAMEWORK_BASIC_CLIENT_SERVER_FIXTURE_H_
24+#define MIR_TEST_FRAMEWORK_BASIC_CLIENT_SERVER_FIXTURE_H_
25+
26+#include "mir_toolkit/mir_client_library.h"
27+
28+#include "mir_test_framework/in_process_server.h"
29+
30+namespace mir_test_framework
31+{
32+/// Test fixture to create a server in process and allocate a client connection.
33+/// There are a lot of tests that could use this context.
34+template<class TestServerConfiguration>
35+struct BasicClientServerFixture : InProcessServer
36+{
37+ TestServerConfiguration server_configuration;
38+
39+ mir::DefaultServerConfiguration& server_config() override { return server_configuration; }
40+
41+ void SetUp()
42+ {
43+ InProcessServer::SetUp();
44+ connection = mir_connect_sync(new_connection().c_str(), __PRETTY_FUNCTION__);
45+ }
46+
47+ void TearDown()
48+ {
49+ mir_connection_release(connection);
50+ InProcessServer::TearDown();
51+ }
52+
53+ MirConnection* connection = nullptr;
54+};
55+}
56+
57+#endif /* MIR_TEST_FRAMEWORK_BASIC_CLIENT_SERVER_FIXTURE_H_ */
58
59=== modified file 'tests/acceptance-tests/test_trust_session_helper.cpp'
60--- tests/acceptance-tests/test_trust_session_helper.cpp 2014-05-14 08:31:54 +0000
61+++ tests/acceptance-tests/test_trust_session_helper.cpp 2014-05-15 13:59:27 +0000
62@@ -25,7 +25,7 @@
63 #include "mir/graphics/graphic_buffer_allocator.h"
64
65 #include "mir_test_framework/stubbed_server_configuration.h"
66-#include "mir_test_framework/in_process_server.h"
67+#include "mir_test_framework/basic_client_server_fixture.h"
68 #include "mir_test_doubles/fake_ipc_factory.h"
69
70 #include <gtest/gtest.h>
71@@ -117,27 +117,17 @@
72 }
73 };
74
75-struct TrustSessionHelper : mir_test_framework::InProcessServer
76+using MyBasicClientServerFixture = mir_test_framework::BasicClientServerFixture<MyServerConfiguration>;
77+
78+struct TrustSessionHelper : MyBasicClientServerFixture
79 {
80- MyServerConfiguration my_server_config;
81-
82- mir::DefaultServerConfiguration& server_config() override { return my_server_config; }
83-
84- void SetUp()
85- {
86- mir_test_framework::InProcessServer::SetUp();
87- connection = mir_connect_sync(new_connection().c_str(), __PRETTY_FUNCTION__);
88- }
89
90 void TearDown()
91 {
92 trusted_helper_mediator.reset();
93- mir_connection_release(connection);
94- mir_test_framework::InProcessServer::TearDown();
95+ MyBasicClientServerFixture::TearDown();
96 }
97
98- MirConnection* connection = nullptr;
99-
100 static std::size_t const arbritary_fd_request_count = 3;
101
102 std::mutex mutex;

Subscribers

People subscribed via source and target branches