~alan-griffiths/junk/composition-bypass

« back to all changes in this revision

Viewing changes to tests/mir_test_doubles/test_protobuf_client.cpp

  • Committer: Alan Griffiths
  • Date: 2013-05-31 11:14:55 UTC
  • mfrom: (693.3.19 trunk)
  • Revision ID: alan@octopull.co.uk-20130531111455-5ka3q9h9hhnffx70
mergeĀ lp:mir

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
#include "mir_test/test_protobuf_client.h"
20
20
#include "mir_test_doubles/mock_rpc_report.h"
21
21
 
 
22
#include "src/client/rpc/make_rpc_channel.h"
 
23
#include "src/client/rpc/mir_basic_rpc_channel.h"
 
24
 
22
25
#include <thread>
23
26
 
24
27
namespace mtd = mir::test::doubles;
27
30
    std::string socket_file,
28
31
    int timeout_ms) :
29
32
    rpc_report(std::make_shared<testing::NiceMock<doubles::MockRpcReport>>()),
30
 
    channel(mir::client::make_rpc_channel(socket_file, rpc_report)),
 
33
    channel(mir::client::rpc::make_rpc_channel(socket_file, rpc_report)),
31
34
    display_server(channel.get(), ::google::protobuf::Service::STUB_DOESNT_OWN_CHANNEL),
32
35
    maxwait(timeout_ms),
33
36
    connect_done_called(false),
50
53
    ON_CALL(*this, next_buffer_done()).WillByDefault(testing::Invoke(this, &TestProtobufClient::on_next_buffer_done));
51
54
    ON_CALL(*this, release_surface_done()).WillByDefault(testing::Invoke(this, &TestProtobufClient::on_release_surface_done));
52
55
    ON_CALL(*this, disconnect_done()).WillByDefault(testing::Invoke(this, &TestProtobufClient::on_disconnect_done));
 
56
    ON_CALL(*this, drm_auth_magic_done()).WillByDefault(testing::Invoke(this, &TestProtobufClient::on_drm_auth_magic_done));
53
57
}
54
58
 
55
59
void mir::test::TestProtobufClient::on_connect_done()
89
93
    while (!disconnect_done_count.compare_exchange_weak(old, old+1));
90
94
}
91
95
 
 
96
void mir::test::TestProtobufClient::on_drm_auth_magic_done()
 
97
{
 
98
    drm_auth_magic_done_called.store(true);
 
99
}
 
100
 
92
101
void mir::test::TestProtobufClient::wait_for_connect_done()
93
102
{
94
103
    for (int i = 0; !connect_done_called.load() && i < maxwait; ++i)
140
149
    disconnect_done_called.store(false);
141
150
}
142
151
 
 
152
void mir::test::TestProtobufClient::wait_for_drm_auth_magic_done()
 
153
{
 
154
    for (int i = 0; !drm_auth_magic_done_called.load() && i < maxwait; ++i)
 
155
    {
 
156
        std::this_thread::sleep_for(std::chrono::milliseconds(1));
 
157
        std::this_thread::yield();
 
158
    }
 
159
    drm_auth_magic_done_called.store(false);
 
160
}
 
161
 
143
162
void mir::test::TestProtobufClient::wait_for_surface_count(int count)
144
163
{
145
164
    for (int i = 0; count != create_surface_done_count.load() && i < 10000; ++i)