Mir

Merge lp:~alan-griffiths/mir/NestedServer.posts_when_scene_has_visible_changes into lp:mir

Proposed by Alan Griffiths on 2015-06-04
Status: Merged
Approved by: Alan Griffiths on 2015-06-09
Approved revision: 2626
Merged at revision: 2639
Proposed branch: lp:~alan-griffiths/mir/NestedServer.posts_when_scene_has_visible_changes
Merge into: lp:mir
Diff against target: 77 lines (+50/-4)
1 file modified
tests/acceptance-tests/test_nested_mir.cpp (+50/-4)
To merge this branch: bzr merge lp:~alan-griffiths/mir/NestedServer.posts_when_scene_has_visible_changes
Reviewer Review Type Date Requested Status
Alexandros Frantzis (community) 2015-06-04 Approve on 2015-06-09
PS Jenkins bot continuous-integration Approve on 2015-06-08
Review via email: mp+261103@code.launchpad.net

Commit Message

tests: Test we get exactly the expected posts from a nested server

Description of the Change

tests: Test we get exactly the expected posts from a nested server

To post a comment you must log in.
Alan Griffiths (alan-griffiths) wrote :

7: [ RUN ] NestedInput.nested_event_filter_receives_keyboard_from_host
7: [1433432727.674278] mirserver: Starting
7: [1433432727.675137] mirserver: Selected driver: dummy (version 0.14.0)
7: [1433432727.679338] mirserver: Using software cursor
7: [1433432727.681407] mirserver: Mir version 0.14.0
7: [1433432727.732641] mirserver: Starting
7: [1433432727.733449] mirserver: Selected driver: dummy (version 0.14.0)
7: [1433432727.894537] mirserver: Mir version 0.14.0
7: [1433432738.076193] mirserver: Stopping
7: /tmp/buildd/mir-0.14.0bzr2624pkg0wily166/tests/acceptance-tests/test_nested_input.cpp:149: Failure
7: Actual function call count doesn't match EXPECT_CALL(*nested_mir.mock_event_filter, handle(_))...
7: Expected: to be called at least once
7: Actual: never called - unsatisfied and active
7: [1433432738.154764] mirserver: Stopping
7: [ FAILED ] NestedInput.nested_event_filter_receives_keyboard_from_host (10518 ms)

Unrelated

2624. By Alan Griffiths on 2015-06-05

merge lp:mir

Alexandros Frantzis (afrantzis) wrote :

33+ // No post on surface creation
37+ auto const surface = mtf::make_any_surface(connection);
38+ Mock::VerifyAndClearExpectations(mock_session_mediator_report.get());

Due to the asynchronous nature of our communications (mainly from nested to host in this case) and processing, the absence of an exchange buffer call at this point doesn't provide the guarantee we want, since the exchange may occur at some later time. Introducing a delay would improve our chances of catching a regression at this checkpoint.

A redeeming feature of this particular test is that if we regress (i.e., post a buffer to the host when the client surface is created) and we don't catch the problem at the first checkpoint, the test will probably fail at a subsequent checkpoint because we will see one more buffer exchange than expected.

It would be good to document that the first checkpoint does not provide a strong guarantee of correctness, or perhaps remove it completely, and let the other checkpoints do the work.

A weak needs fixing.

review: Needs Fixing
2625. By Alan Griffiths on 2015-06-08

Helpful message

2626. By Alan Griffiths on 2015-06-08

merge lp:mir

Alexandros Frantzis (afrantzis) wrote :

Looks good.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/acceptance-tests/test_nested_mir.cpp'
2--- tests/acceptance-tests/test_nested_mir.cpp 2015-05-19 21:34:34 +0000
3+++ tests/acceptance-tests/test_nested_mir.cpp 2015-06-08 15:15:01 +0000
4@@ -1,5 +1,5 @@
5 /*
6- * Copyright © 2013-2014 Canonical Ltd.
7+ * Copyright © 2013-2015 Canonical Ltd.
8 *
9 * This program is free software: you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License version 3,
11@@ -37,13 +37,11 @@
12 #include <gtest/gtest.h>
13 #include <gmock/gmock.h>
14
15-#include <mutex>
16-#include <condition_variable>
17-
18 namespace geom = mir::geometry;
19 namespace mf = mir::frontend;
20 namespace mg = mir::graphics;
21 namespace msh = mir::shell;
22+namespace mt = mir::test;
23 namespace mtd = mir::test::doubles;
24 namespace mtf = mir_test_framework;
25
26@@ -246,3 +244,51 @@
27 mir_surface_release_sync(surface);
28 mir_connection_release(c);
29 }
30+
31+TEST_F(NestedServer, posts_when_scene_has_visible_changes)
32+{
33+ // No post on surface creation
34+ EXPECT_CALL(*mock_session_mediator_report, session_exchange_buffer_called(_)).Times(0);
35+ NestedMirRunner nested_mir{new_connection()};
36+ auto const connection = mir_connect_sync(nested_mir.new_connection().c_str(), __PRETTY_FUNCTION__);
37+ auto const surface = mtf::make_any_surface(connection);
38+
39+ // NB there is no synchronization to guarantee that a spurious post on surface creation will have
40+ // been seen by this point (although in testing it was invariably the case). However, any missed post
41+ // would be included in one of the later counts and cause a test failure.
42+ Mock::VerifyAndClearExpectations(mock_session_mediator_report.get());
43+
44+ // One post when surface drawn
45+ {
46+ mt::WaitCondition wait;
47+
48+ EXPECT_CALL(*mock_session_mediator_report, session_exchange_buffer_called(_)).Times(1)
49+ .WillOnce(InvokeWithoutArgs([&] { wait.wake_up_everyone(); }));
50+
51+ mir_buffer_stream_swap_buffers_sync(mir_surface_get_buffer_stream(surface));
52+
53+ wait.wait_for_at_most_seconds(1);
54+ Mock::VerifyAndClearExpectations(mock_session_mediator_report.get());
55+ }
56+
57+ // One post when surface released
58+ {
59+ mt::WaitCondition wait;
60+
61+ EXPECT_CALL(*mock_session_mediator_report, session_exchange_buffer_called(_)).Times(1)
62+ .WillOnce(InvokeWithoutArgs([&] { wait.wake_up_everyone(); }));
63+
64+ mir_surface_release_sync(surface);
65+ mir_connection_release(connection);
66+
67+ wait.wait_for_at_most_seconds(1);
68+ Mock::VerifyAndClearExpectations(mock_session_mediator_report.get());
69+ }
70+
71+ // No post during shutdown
72+ EXPECT_CALL(*mock_session_mediator_report, session_exchange_buffer_called(_)).Times(0);
73+
74+ // Ignore other shutdown events
75+ EXPECT_CALL(*mock_session_mediator_report, session_release_surface_called(_)).Times(AnyNumber());
76+ EXPECT_CALL(*mock_session_mediator_report, session_disconnect_called(_)).Times(AnyNumber());
77+}

Subscribers

People subscribed via source and target branches