Mir

Merge lp:~alan-griffiths/mir/second-test-for-cursors-in-nested into lp:mir

Proposed by Alan Griffiths
Status: Merged
Approved by: Daniel van Vugt
Approved revision: no longer in the source branch.
Merged at revision: 2995
Proposed branch: lp:~alan-griffiths/mir/second-test-for-cursors-in-nested
Merge into: lp:mir
Prerequisite: lp:~alan-griffiths/mir/first-test-for-cursors-in-nested
Diff against target: 128 lines (+102/-2)
1 file modified
tests/acceptance-tests/test_nested_mir.cpp (+102/-2)
To merge this branch: bzr merge lp:~alan-griffiths/mir/second-test-for-cursors-in-nested
Reviewer Review Type Date Requested Status
Daniel van Vugt Approve
Alexandros Frantzis (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Alan Griffiths Abstain
Review via email: mp+273064@code.launchpad.net

Commit message

test: add a test for clients of nested servers setting the cursor image

Description of the change

test: add a test for clients of nested servers setting the cursor image

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

Mmm. No cursors on mako?

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

OK, so the wily builder prodstack-worker-med-0 doesn't have X cursors either.

I need a new plan.

review: Needs Fixing
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Alan Griffiths (alan-griffiths) :
review: Abstain
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

[ 69%] Building CXX object tests/integration-tests/CMakeFiles/mir_integration_tests.dir/test_focus_selection.cpp.o
/mir/tests/acceptance-tests/test_nested_mir.cpp:560:14: error: suggest braces around initialization of subobject [-Werror,-Wmissing-braces]
        data{uint8_t(id)}

Rats! I want to be able to just run clang builds without hacking a vivid environment.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

Looks good.

review: Approve
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Cool.

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-10-05 09:07:11 +0000
3+++ tests/acceptance-tests/test_nested_mir.cpp 2015-10-05 09:07:12 +0000
4@@ -19,6 +19,7 @@
5 #include "mir/frontend/session_mediator_report.h"
6 #include "mir/graphics/platform.h"
7 #include "mir/graphics/cursor_image.h"
8+#include "mir/input/cursor_images.h"
9 #include "mir/graphics/display.h"
10 #include "mir/graphics/display_configuration.h"
11 #include "mir/graphics/display_configuration_report.h"
12@@ -480,11 +481,10 @@
13 mir_connection_release(connection);
14 }
15
16-TEST_F(NestedServer, cursor_image_changes_are_forwarded_to_host)
17+TEST_F(NestedServer, animated_cursor_image_changes_are_forwarded_to_host)
18 {
19 int const frames = 10;
20 NestedMirRunner nested_mir{new_connection()};
21- ignore_rebuild_of_egl_context();
22
23 auto const connection = mir_connect_sync(nested_mir.new_connection().c_str(), __PRETTY_FUNCTION__);
24 auto const surface = make_and_paint_surface(connection);
25@@ -531,3 +531,103 @@
26 mir_surface_release_sync(surface);
27 mir_connection_release(connection);
28 }
29+
30+// We can't rely on the test environment to have X cursors, so we provide some of our own
31+namespace
32+{
33+static auto const cursor_names = {
34+// mir_disabled_cursor_name,
35+ mir_arrow_cursor_name,
36+ mir_busy_cursor_name,
37+ mir_caret_cursor_name,
38+ mir_default_cursor_name,
39+ mir_pointing_hand_cursor_name,
40+ mir_open_hand_cursor_name,
41+ mir_closed_hand_cursor_name,
42+ mir_horizontal_resize_cursor_name,
43+ mir_vertical_resize_cursor_name,
44+ mir_diagonal_resize_bottom_to_top_cursor_name,
45+ mir_diagonal_resize_top_to_bottom_cursor_name,
46+ mir_omnidirectional_resize_cursor_name,
47+ mir_vsplit_resize_cursor_name,
48+ mir_hsplit_resize_cursor_name,
49+ mir_crosshair_cursor_name };
50+
51+struct CursorImage : public mg::CursorImage
52+{
53+ CursorImage(char const* name) :
54+ id{std::find(begin(cursor_names), end(cursor_names), name) - begin(cursor_names)},
55+ data{{uint8_t(id)}}
56+ {
57+ }
58+
59+ void const* as_argb_8888() const { return data.data(); }
60+
61+ geom::Size size() const { return { 24, 24 }; }
62+
63+ geom::Displacement hotspot() const { return {0, 0}; }
64+
65+ ptrdiff_t id;
66+ std::array<uint8_t, 4*8*24*24> data;
67+};
68+
69+struct CursorImages : mir::input::CursorImages
70+{
71+public:
72+
73+ std::shared_ptr<mg::CursorImage> image(std::string const& cursor_name, geom::Size const& /*size*/)
74+ {
75+ return std::make_shared<CursorImage>(cursor_name.c_str());
76+ }
77+};
78+
79+class NestedMirRunnerWithCursorImages : public mtf::HeadlessNestedServerRunner
80+{
81+public:
82+ NestedMirRunnerWithCursorImages(std::string const& connection_string)
83+ : mtf::HeadlessNestedServerRunner(connection_string)
84+ {
85+ server.override_the_cursor_images([] { return std::make_shared<CursorImages>(); });
86+ start_server();
87+ }
88+
89+ ~NestedMirRunnerWithCursorImages()
90+ {
91+ stop_server();
92+ }
93+};
94+}
95+
96+TEST_F(NestedServer, named_cursor_image_changes_are_forwarded_to_host)
97+{
98+ NestedMirRunnerWithCursorImages nested_mir{new_connection()};
99+
100+ auto const connection = mir_connect_sync(nested_mir.new_connection().c_str(), __PRETTY_FUNCTION__);
101+ auto const surface = make_and_paint_surface(connection);
102+ auto const mock_cursor = the_mock_cursor();
103+
104+ auto const spec = mir_connection_create_spec_for_changes(connection);
105+ mir_surface_spec_set_fullscreen_on_output(spec, 1);
106+ mir_surface_apply_spec(surface, spec);
107+ mir_surface_spec_release(spec);
108+
109+ server.the_cursor_listener()->cursor_moved_to(489, 9);
110+
111+ for (auto const name : cursor_names)
112+ {
113+ mt::WaitCondition condition;
114+
115+ EXPECT_CALL(*mock_cursor, show(_)).Times(1)
116+ .WillOnce(InvokeWithoutArgs([&] { condition.wake_up_everyone(); }));
117+
118+ auto const cursor = mir_cursor_configuration_from_name(name);
119+ mir_wait_for(mir_surface_configure_cursor(surface, cursor));
120+ mir_cursor_configuration_destroy(cursor);
121+
122+ condition.wait_for_at_most_seconds(1);
123+ Mock::VerifyAndClearExpectations(mock_cursor.get());
124+ }
125+
126+ mir_surface_release_sync(surface);
127+ mir_connection_release(connection);
128+}

Subscribers

People subscribed via source and target branches