~ubuntu-branches/ubuntu/vivid/mir/vivid

« back to all changes in this revision

Viewing changes to tests/include/mir_test_framework/testing_process_manager.h

  • Committer: Package Import Robot
  • Author(s): Ubuntu daily release
  • Date: 2014-10-10 14:01:26 UTC
  • mto: This revision was merged to the branch mainline in revision 84.
  • Revision ID: package-import@ubuntu.com-20141010140126-n1czko8na1kuz4ll
Tags: upstream-0.8.0+14.10.20141010
Import upstream version 0.8.0+14.10.20141010

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright © 2012 Canonical Ltd.
 
3
 *
 
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.
 
7
 *
 
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.
 
12
 *
 
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/>.
 
15
 *
 
16
 * Authored by: Thomas Guest <thomas.guest@canonical.com>
 
17
 */
 
18
 
 
19
#ifndef MIR_TESTING_PROCESS_MANAGER
 
20
#define MIR_TESTING_PROCESS_MANAGER
 
21
 
 
22
#include "mir/server_configuration.h"
 
23
 
 
24
#include "mir_test_framework/process.h"
 
25
 
 
26
#include "mir_test_framework/testing_server_configuration.h"
 
27
#include "mir_test_framework/testing_client_configuration.h"
 
28
 
 
29
#include <memory>
 
30
#include <vector>
 
31
#include <functional>
 
32
 
 
33
namespace mir
 
34
{
 
35
class DisplayServer;
 
36
namespace options
 
37
{
 
38
class Option;
 
39
}
 
40
}
 
41
 
 
42
namespace mir_test_framework
 
43
{
 
44
using namespace mir;
 
45
 
 
46
 
 
47
class TestingProcessManager
 
48
{
 
49
public:
 
50
    TestingProcessManager();
 
51
    ~TestingProcessManager();
 
52
 
 
53
    void launch_server_process(TestingServerConfiguration& config);
 
54
    pid_t launch_client_process(TestingClientConfiguration& config,
 
55
                               mir::options::Option const& test_options);
 
56
 
 
57
    void tear_down_clients();
 
58
    void tear_down_server();
 
59
    void tear_down_all();
 
60
    Result shutdown_server_process();
 
61
    Result kill_server_process();
 
62
    Result wait_for_shutdown_server_process();
 
63
    std::vector<Result> wait_for_shutdown_client_processes();
 
64
    void terminate_client_processes();
 
65
    void run_in_test_process(std::function<void()> const& run_code);
 
66
 
 
67
private:
 
68
    std::shared_ptr<Process> server_process;
 
69
    std::vector<std::shared_ptr<Process>> clients;
 
70
 
 
71
    bool is_test_process;
 
72
    bool server_process_was_started;
 
73
};
 
74
 
 
75
std::string const& test_socket_file();
 
76
 
 
77
}
 
78
 
 
79
#endif // MIR_TESTING_PROCESS_MANAGER