~ubuntu-branches/ubuntu/wily/mir/wily-proposed

« back to all changes in this revision

Viewing changes to tests/acceptance-tests/test_client_focus_notification.cpp

  • Committer: Package Import Robot
  • Author(s): CI Train Bot
  • Date: 2015-05-12 13:12:55 UTC
  • mto: This revision was merged to the branch mainline in revision 96.
  • Revision ID: package-import@ubuntu.com-20150512131255-y7z12i8n4pbvo70x
Tags: upstream-0.13.0+15.10.20150512
ImportĀ upstreamĀ versionĀ 0.13.0+15.10.20150512

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 * Authored by: Robert Carr <robert.carr@canonical.com>
17
17
 */
18
18
 
19
 
#define MIR_INCLUDE_DEPRECATED_EVENT_HEADER
20
 
 
21
19
#include "mir_toolkit/mir_client_library.h"
22
20
 
23
21
#include "mir_test/wait_condition.h"
24
22
#include "mir_test/event_matchers.h"
25
23
 
26
24
#include "mir_test_framework/interprocess_client_server_test.h"
27
 
#include "mir_test_framework/cross_process_sync.h"
 
25
#include "mir_test/cross_process_sync.h"
28
26
 
29
27
#include <gtest/gtest.h>
30
28
#include <gmock/gmock.h>
61
59
 
62
60
        mir_wait_for(mir_surface_create(spec, surface_created, this));
63
61
        mir_surface_spec_release(spec);
 
62
        mir_buffer_stream_swap_buffers_sync(mir_surface_get_buffer_stream(surface));
64
63
 
65
64
        all_events_received.wait_for_at_most_seconds(60);
66
65
        mir_surface_release_sync(surface);
85
84
        // We need to set the event delegate from the surface_created
86
85
        // callback so we can block the reading of new events
87
86
        // until we are ready
88
 
        MirEventDelegate const event_delegate =
89
 
            {
90
 
                handle_event,
91
 
                self
92
 
            };
93
 
        mir_surface_set_event_handler(surface_, &event_delegate);
 
87
        mir_surface_set_event_handler(surface_, handle_event, self);
94
88
    }
95
89
};
96
90
}
100
94
    run_in_client([&]
101
95
        {
102
96
            InSequence s;
103
 
            EXPECT_CALL(observer, see(Pointee(mt::SurfaceEvent(mir_surface_attrib_focus, mir_surface_focused)))).Times(1)
 
97
            EXPECT_CALL(observer, see(mt::SurfaceEvent(mir_surface_attrib_focus, mir_surface_focused))).Times(1)
104
98
                .WillOnce(mt::WakeUp(&all_events_received));
105
99
            // We may not see mir_surface_unfocused before connection closes
106
 
            EXPECT_CALL(observer, see(Pointee(mt::SurfaceEvent(mir_surface_attrib_focus, mir_surface_unfocused)))).Times(AtMost(1));
 
100
            EXPECT_CALL(observer, see(mt::SurfaceEvent(mir_surface_attrib_focus, mir_surface_unfocused))).Times(AtMost(1));
107
101
 
108
102
            connect_and_create_surface();
109
103
        });
123
117
{
124
118
    // We use this for synchronization to ensure the two clients
125
119
    // are launched in a defined order.
126
 
    mtf::CrossProcessSync ready_for_second_client;
 
120
    mt::CrossProcessSync ready_for_second_client;
127
121
 
128
122
    auto const client_one = new_client_process([&]
129
123
        {
130
124
            InSequence seq;
131
125
            // We should receive focus as we are created
132
 
            EXPECT_CALL(observer, see(Pointee(mt::SurfaceEvent(mir_surface_attrib_focus,
133
 
                mir_surface_focused)))).Times(1)
 
126
            EXPECT_CALL(observer, see(mt::SurfaceEvent(mir_surface_attrib_focus,
 
127
                mir_surface_focused))).Times(1)
134
128
                    .WillOnce(SignalFence(&ready_for_second_client));
135
129
 
136
130
            // And lose it as the second surface is created
137
 
            EXPECT_CALL(observer, see(Pointee(mt::SurfaceEvent(mir_surface_attrib_focus,
138
 
                mir_surface_unfocused)))).Times(1);
 
131
            EXPECT_CALL(observer, see(mt::SurfaceEvent(mir_surface_attrib_focus,
 
132
                mir_surface_unfocused))).Times(1);
139
133
            // And regain it when the second surface is closed
140
 
            EXPECT_CALL(observer, see(Pointee(mt::SurfaceEvent(mir_surface_attrib_focus,
141
 
                mir_surface_focused)))).Times(1).WillOnce(mt::WakeUp(&all_events_received));
 
134
            EXPECT_CALL(observer, see(mt::SurfaceEvent(mir_surface_attrib_focus,
 
135
                mir_surface_focused))).Times(1).WillOnce(mt::WakeUp(&all_events_received));
142
136
            // And then lose it as we are closed (but we may not see confirmation before connection closes)
143
 
            EXPECT_CALL(observer, see(Pointee(mt::SurfaceEvent(mir_surface_attrib_focus,
144
 
                mir_surface_unfocused)))).Times(AtMost(1));
 
137
            EXPECT_CALL(observer, see(mt::SurfaceEvent(mir_surface_attrib_focus,
 
138
                mir_surface_unfocused))).Times(AtMost(1));
145
139
 
146
140
            connect_and_create_surface();
147
141
        });
150
144
        {
151
145
            ready_for_second_client.wait_for_signal_ready_for();
152
146
 
153
 
            EXPECT_CALL(observer, see(Pointee(
154
 
                mt::SurfaceEvent(mir_surface_attrib_focus, mir_surface_focused))))
 
147
            EXPECT_CALL(observer, see(
 
148
                mt::SurfaceEvent(mir_surface_attrib_focus, mir_surface_focused)))
155
149
                    .Times(1).WillOnce(mt::WakeUp(&all_events_received));
156
150
            // We may not see mir_surface_unfocused before connection closes
157
 
            EXPECT_CALL(observer, see(Pointee(
158
 
                mt::SurfaceEvent(mir_surface_attrib_focus, mir_surface_unfocused))))
 
151
            EXPECT_CALL(observer, see(
 
152
                mt::SurfaceEvent(mir_surface_attrib_focus, mir_surface_unfocused)))
159
153
                    .Times(AtMost(1));
160
154
 
161
155
            connect_and_create_surface();