Mir

Merge lp:~andreas-pokorny/mir/load-all-supported-input-platforms into lp:mir

Proposed by Andreas Pokorny
Status: Merged
Approved by: Andreas Pokorny
Approved revision: no longer in the source branch.
Merged at revision: 3126
Proposed branch: lp:~andreas-pokorny/mir/load-all-supported-input-platforms
Merge into: lp:mir
Prerequisite: lp:~andreas-pokorny/mir/combine-modifier-state-accross-devices
Diff against target: 774 lines (+366/-77)
22 files modified
benchmarks/frame-uniformity/touch_producing_server.cpp (+0/-1)
include/platform/mir/input/platform.h (+2/-2)
include/test/mir_test_framework/executable_path.h (+1/-0)
src/include/server/mir/default_server_configuration.h (+1/-11)
src/include/server/mir/input/input_probe.h (+48/-0)
src/platform/graphics/platform_probe.cpp (+5/-1)
src/platforms/evdev/platform_factory.cpp (+1/-1)
src/platforms/mesa/server/x11/input/input.cpp (+1/-1)
src/server/input/CMakeLists.txt (+1/-0)
src/server/input/default_configuration.cpp (+16/-39)
src/server/input/input_probe.cpp (+104/-0)
src/server/symbols.map (+1/-1)
tests/mir_test_framework/CMakeLists.txt (+1/-0)
tests/mir_test_framework/executable_path.cpp (+10/-0)
tests/mir_test_framework/fake_input_device_impl.cpp (+1/-1)
tests/mir_test_framework/fake_input_server_configuration.cpp (+0/-1)
tests/mir_test_framework/input_testing_server_options.cpp (+0/-1)
tests/mir_test_framework/stub_input.cpp (+2/-2)
tests/mir_test_framework/stub_input_platform.cpp (+1/-1)
tests/umock-acceptance-tests/test_libinput.cpp (+8/-14)
tests/unit-tests/input/CMakeLists.txt (+1/-0)
tests/unit-tests/input/test_input_platform_probing.cpp (+161/-0)
To merge this branch: bzr merge lp:~andreas-pokorny/mir/load-all-supported-input-platforms
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Cemil Azizoglu (community) Approve
Alan Griffiths Abstain
Daniel van Vugt Needs Fixing
Chris Halse Rogers Approve
Review via email: mp+274421@code.launchpad.net

This proposal supersedes a proposal from 2015-10-05.

Commit message

Add automatic searching and probing for input platforms

With this specifying the input platform via --platform-input-lib is no longer necessary, unless the stub input platform that supports attaching fake devices is required

Description of the change

The most notable change of this MP will make the libinput and x11 platform work without additional command line parameter.

This MP adds probing for input platforms. mirserver will now search inside the default platform-path for loadable modules that fulfil the input platform ABI. Then only those modules that claim to be better than 'dummy' will be used. Hence input-stub.so will not be loaded by default, but requires loading through the platform-input-lib parameter.

Next step: remove input reader and event hub..

WRT to testing this MP - or the evdev input platform in general: pick silo-56 for phone images. This will still have problems with the clock (which is fixed by lp:~andreas-pokorny/mir/use-realtime-clock-for-input-events). Xenial already has the right libinput package.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
Chris Halse Rogers (raof) wrote : Posted in a previous version of this proposal

+ mir::log_info("Found input driver: %s", desc->name);

Could you also log driver version please?

+ return std::move(platforms);

Pessimisation: this breaks return value optimisation. When the Wily clang builds work again this will be an error.

+ EXPECT_THAT(platforms.size(), Eq(2)); // we cannot disable the default evdev platform with only umock dev is in place
+ EXPECT_THAT(platforms[0].get(), AnyOf(OfType<mi::evdev::Platform>(), OfType<mi::X::XInputPlatform>()));
+ EXPECT_THAT(platforms[1].get(), AnyOf(OfType<mi::evdev::Platform>(), OfType<mi::X::XInputPlatform>()));

Seems like you could replace OfType with OfPointerType and then use

EXPECT_THAT(platforms, UnorderedElementsAre(OfPointerType<mi::evdev::Platform>(), OfPointerType<mi::X::XInputPlatform>());

Which I think is both more natural and also is a slightly stronger test.

========================
Non-review comment:
+ mtf::UdevEnvironment env; // TODO replace with mock_libevdev und mock_libudev when the new input reading stack is the only in use.

Heads up: I think that doing this will provide negative value. Also, und→and :)

review: Needs Fixing
Revision history for this message
Andreas Pokorny (andreas-pokorny) wrote : Posted in a previous version of this proposal

Fixed all of the above.

> ========================
> Non-review comment:
> + mtf::UdevEnvironment env; // TODO replace with mock_libevdev und
> mock_libudev when the new input reading stack is the only in use.
>
> Heads up: I think that doing this will provide negative value. Also, und→and
> :)

I want to simulate the cases no devices found, devices found and some or all can be opened, devices found and none can be opened. I cannot do that with umockdev...

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
Chris Halse Rogers (raof) wrote : Posted in a previous version of this proposal

On Thu, Oct 8, 2015 at 5:56 PM, Andreas Pokorny
<email address hidden> wrote:
> Fixed all of the above.
>
>> ========================
>> Non-review comment:
>> + mtf::UdevEnvironment env; // TODO replace with mock_libevdev
>> und
>> mock_libudev when the new input reading stack is the only in use.
>>
>> Heads up: I think that doing this will provide negative value.
>> Also, und→and
>> :)
>
> I want to simulate the cases no devices found, devices found and some
> or all can be opened, devices found and none can be opened. I cannot
> do that with umockdev...

You can do all except the last, and the last would be a simple patch to
umockdev.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
Chris Halse Rogers (raof) wrote : Posted in a previous version of this proposal

LGTM

review: Approve
Revision history for this message
Alan Griffiths (alan-griffiths) wrote : Posted in a previous version of this proposal

Looks like infrastructure glitch:

  inflating: package_archive/archive/work/output/libmirclient-debug-extension1_0.17.0bzr2998pkg0wily4303+autopilot0_armhf.deb
error: closed
[timestamp] Start PPAs and local Archive : 2015-10-08T10:09:40+0000
rm: cannot remove 'ppa_sources': No such file or directory

~~~~

(Non blocking) looks like we need to bump the server ABI

Revision history for this message
Alan Griffiths (alan-griffiths) wrote : Posted in a previous version of this proposal

"The most notable change of this MP will make the libinput and x11 platform work without additional command line parameter."

Am I expecting too much?

$ sudo DISPLAY= bin/mir_demo_server --vt 1 --arw-file&
$ bin/mir_demo_server --file mir-socket --host-socket /tmp/mir_socket
[Switch to vt 1]
[Switch to vt 7]

ERROR: /home/alan/display_server/mir/src/platforms/mesa/server/common/display_helpers.cpp(256): Throw in function int mir::graphics::mesa::helpers::DRMHelper::open_drm_device(const std::shared_ptr<mir::udev::Context>&)
Dynamic exception type: boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<std::runtime_error> >
std::exception::what: Error opening DRM device
13, "Permission denied"

It looks as though the nested server is selecting the wrong drivers. (It should "agree" with the host.)

NB I can workaround like this:

$ DISPLAY= bin/mir_demo_server --file mir-socket --host-socket /tmp/mir_socket --launch bin/mir_demo_client_animated_cursor

review: Needs Information
Revision history for this message
Alan Griffiths (alan-griffiths) wrote : Posted in a previous version of this proposal

OK, I don't think the auto-configuration is quite there yet. But this is a step forwards.

I guess there will be an ABI break needed for 0.18.

review: Approve
Revision history for this message
Andreas Pokorny (andreas-pokorny) wrote : Posted in a previous version of this proposal

Oh .. I wasnt aware there is a mismatch between the x11 graphics and input probing.
Soooo.. a host-socket setting should win over a DISPLAY env, shouidnt it?

That should be a simple fix in graphics.cpp.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
Andreas Pokorny (andreas-pokorny) wrote : Posted in a previous version of this proposal

> Oh .. I wasnt aware there is a mismatch between the x11 graphics and input
> probing.
> Soooo.. a host-socket setting should win over a DISPLAY env, shouidnt it?
>
> That should be a simple fix in graphics.cpp.

Nested.. not as simple as I thought..

Revision history for this message
Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

Landed and then reverted:
* Modifiers don't work any more (can't move/resize windows using Alt)
* Default mouse speed too high
* A little too many log messages come from this.

Only the first issue is a blocker.

review: Needs Fixing
Revision history for this message
Andreas Pokorny (andreas-pokorny) wrote : Posted in a previous version of this proposal

> Landed and then reverted:
> * Modifiers don't work any more (can't move/resize windows using Alt)

Yes modifiers are per device right now .. which isnt what we want within the dispatcher. Working on a proper abstraction/fix for that.

> * Default mouse speed too high

Yay! So mouse acceleration is working. Configuration branches are on the way..

> * A little too many log messages come from this.
>
> Only the first issue is a blocker.

Revision history for this message
Andreas Pokorny (andreas-pokorny) wrote : Posted in a previous version of this proposal

> Landed and then reverted:
> * Modifiers don't work any more (can't move/resize windows using Alt)
> * Default mouse speed too high
> * A little too many log messages come from this.
>
> Only the first issue is a blocker.

This should fix the issue..
https://code.launchpad.net/~andreas-pokorny/mir/combine-modifier-state-accross-devices/+merge/274372

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Chris Halse Rogers (raof) wrote :

I'm still happy with this.

review: Approve
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

Nits:

+#include "mir/module_deleter.h"

 #include <memory>
 #include <string>
+#include <vector>

The other changes to src/include/server/mir/default_server_configuration.h don't justify these additions.

~~~~

- virtual std::shared_ptr<input::Platform> the_input_platform();
     virtual std::shared_ptr<dispatch::MultiplexingDispatchable> the_input_reading_multiplexer();
     virtual std::shared_ptr<input::InputDeviceRegistry> the_input_device_registry();
     virtual std::shared_ptr<input::InputDeviceHub> the_input_device_hub();
@@ -384,8 +385,7 @@
     CachedPtr<input::CompositeEventFilter> composite_event_filter;
     CachedPtr<input::InputManager> input_manager;
     CachedPtr<input::SurfaceInputDispatcher> surface_input_dispatcher;
- CachedPtr<input::DefaultInputDeviceHub> default_input_device_hub; // currently not used by default
- CachedPtr<input::Platform> input_platform; // currently not used by default
+ CachedPtr<input::DefaultInputDeviceHub> default_input_device_hub;

You can also lose the declaration of Platform on line 135.

~~~~~

Probably not something to address in this MP but...

+#ifdef MIR_BUILD_PLATFORM_MESA_X11
+ ON_CALL(mock_x11, XOpenDisplay(_)).WillByDefault(Return(nullptr));
+#endif

Should the test setup really depend on the *build* platform?

review: Needs Fixing
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Andreas Pokorny (andreas-pokorny) wrote :
Revision history for this message
Andreas Pokorny (andreas-pokorny) wrote :

^ No longer blocking.. brandon made a similar MP and that landed today.

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
Andreas Pokorny (andreas-pokorny) wrote :

^
demo server and acceptances tests crash...

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

OK, I've invested time in testing and lots needs fixing unfortunately. At least three are show-stoppers...

(1) Mouse now moves too fast. Even my slowest mouse.

(2) "evdev-input" log messages on startup report nothing useful. Can we remove or change them to report actual device descriptions?

(3) Input resampling has been lost (can only verify on desktop due to #5). It was introduced on 2014-08-29 but we only just fixed Unity8 this week to utilize it and achieve halved latency. It's taken 14 months to come to fruition this week, so please try to avoid regressing on it.
 Test: env MIR_CLIENT_INPUT_RATE=59 mir_demo_client_fingerpaint
           Verify only one square painted per frame.

(4) Input events are strangely erratic and no longer smooth (even when not resampled), compared to lp:mir. Compare 'mir_demo_client_fingerpaint' using this branch with lp:mir and you will see a lot of jitter when using this branch. Weirdly, MIR_CLIENT_INPUT_RATE=59 does affect the result but only in that it makes things even more erratic, and not limited to 59Hz either (#3).

(5) Servers crash on startup on mako (vivid rc-proposed):
[1446022093.989552] <WARNING> mircommon: Failed to load module: bin/../lib/server-modules/input-evdev.so.4 (error was:libinput.so.10: cannot open shared object file: No such file or directory)
[1446022093.989948] mircommon: Loading module: bin/../lib/server-modules/graphics-dummy.so
[1446022094.000600] mircommon: Loading module: bin/../lib/server-modules/input-stub.so
ERROR: /home/dan/bzr/mir/tmp.all/src/server/input/default_configuration.cpp(328): Throw in function mir::DefaultServerConfiguration::the_input_manager()::<lambda()>
Dynamic exception type: N5boost16exception_detail10clone_implINS0_19error_info_injectorISt13runtime_errorEEEE
std::exception::what: No input platforms found

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

(5) Fixed by installing package 'libinput10' but ...

(6) mir_demo_client_fingerpaint on mako paints very small, indicating the touch_major/touch_minor values are wrong using this branch.

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

(7) Multi-touch gestures no longer work (on mako). Try moving a window in mir_proving_server using three fingers and it mostly does nothing, or has a mind of its own. If you run 'mir_demo_client_target' you can see what the problem is with multiple touches: some go missing mid-gesture (flickering targets).

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

Although (1) sounds unimportant and not like a blocker, if you fix (1) and remove the default acceleration that libinput introduces, then that might actually fix (4) as well.

Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

My issue above fixed. Looks like enough issues remain to be dealt with for me to wait before looking again.

review: Abstain
Revision history for this message
Andreas Pokorny (andreas-pokorny) wrote :

(1) This is the default setting of libinput - 1.1.0 will change that i.e use differnt profiles depending on the mouse or device type. I found the default setting just good..

(2)

(3) There is a known problem with libinput-0.21 in the overlay ppas. Patches are w

(4)

(5) better than hanging the system

(6) they are reported like that from the kernel.. in general to small.. but d

Revision history for this message
Andreas Pokorny (andreas-pokorny) wrote :

oops hit reply to soon..

(3) (4) require a libinput patch that has not yet landed in archive or those ppas. This might be the reason for (7) too.

(6) proper touch screen drivers should report resolution values to allow scaling values to actual units. All touch screen drives that we use only report a resolution of zero. That invalid setting is handled inside libinput and it returns the plain value reported by the kernel. Those values as you have noticed are too small. To come up with proper values we need to have a device dependent scaling. I dont see

Revision history for this message
Andreas Pokorny (andreas-pokorny) wrote :

.. any other client than finger paint use those values at the moment. I do hope that since they are now exposed via libinput that the other display servers and toolkits start to use those. Within the Qt event feeder they are mapped to a rectangular region.. which isnt really accurate either.

Revision history for this message
Andreas Pokorny (andreas-pokorny) wrote :

just checked mako again: (3) (4) and (7) is the same cause - and needs the current libinput patch-set as in:

https://bugs.launchpad.net/ubuntu/+source/libinput/+bug/1504168

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

(3) and (4) were discovered with a mouse on desktop. So any touchscreen fixes will not help (3) and (4). It appears likely that fixing (1), while not a major issue itself, will probably fix (3) and (4). Because (1) is the only reason I can think of for libinput to tinker with the mouse event stream.

Revision history for this message
Andreas Pokorny (andreas-pokorny) wrote :

(2) I just improved logs with lp:~andreas-pokorny/mir/better-input-device-related-logs
We should really consider having something like a severity filter..

Ok I misunderstood (3) and (4) so what I just tried on lp:mir was:

A: Resampling with input-evdev:
export MIR_CLIENT_INPUT_RATE=59
mir_demo_server --platform-input-lib ../lib/server-modules/input-evdev.so.4 --launch-client=./mir_demo_client_fingerpaint

B: Resampling with android input
export MIR_CLIENT_INPUT_RATE=59
mir_demo_server --launch-client=./mir_demo_client_fingerpaint

C: No resampling with input-evdev
export MIR_CLIENT_INPUT_RATE=0
mir_demo_server --platform-input-lib ../lib/server-modules/input-evdev.so.4 --launch-client=./mir_demo_client_fingerpaint

D: No resampling with android input
export MIR_CLIENT_INPUT_RATE=0
mir_demo_server --launch-client=./mir_demo_client_fingerpaint

using a cheap USB MS mouse on top of libinput-1.1.0 with my patches

A and B look nearly identical - mouse moves slightly faster than with android input but there are ugly gaps/jumps .. in both cases every 5 or 10 seconds in the trace drawn by fingerpaint.

C and D look nearly identical - mouse moves slightly faster than with android input but there in both cases the trace displayed is smooth and sticks close to the cursor. Additionally there is no odd jump in both the data sets. As opposed to the resampled cases the plotted squares have a similar distance and give a good indication of mouse movement.

I repeated A and B a few times and I was able to reproduce the odd jumps for A and B sometimes. It seems that the resampling is very sensitive to scheduling. My conclusion from that:
we should make sure that we only use resampling when we have a horrible input device (driver) or when the client is unable to process the user input fast enough. Additionally we should spend the next 14 month with verifying that the algorithm yields proper results.

PS: I did mess with android input in the past and found the bug that disabled the pointer acceleration:
https://code.launchpad.net/~andreas-pokorny/mir/activate-pointer-acceleration
Not sure if it still works..

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

AFAIK, resampling uses the original event timestamps which in android-input are accurate because they come directly from the kernel. So if those timestamps are being faked in libinput then that might explain the irregularity and sensitivity to scheduling. Better check that libinput (and Mir itself) is not inserting new timestamps. Our input reports also rely on those timestamps being the original event time from the kernel.

It's also worth noting my mouse setting is 1000Hz (kernel param usbhid.mousepoll=1). You might need that to notice some issues.

Revision history for this message
Andreas Pokorny (andreas-pokorny) wrote :

> AFAIK, resampling uses the original event timestamps which in android-input
> are accurate because they come directly from the kernel. So if those
> timestamps are being faked in libinput then that might explain the
> irregularity and sensitivity to scheduling. Better check that libinput (and
> Mir itself) is not inserting new timestamps. Our input reports also rely on
> those timestamps being the original event time from the kernel.
>
> It's also worth noting my mouse setting is 1000Hz (kernel param
> usbhid.mousepoll=1). You might need that to notice some issues.

Well whatever you observe I cannot observe that. I see negative effects of resampling with and without libinput involved.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Andreas Pokorny (andreas-pokorny) wrote :

There is now a silo for vivid overlay and this newer libinput package is about to land in xenial:
https://launchpad.net/~ci-train-ppa-service/+archive/ubuntu/landing-056/+packages

With that the known touchscreen troubles are gone - mouse is still fast though (as actually requested by many people)

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: Approve (continuous-integration)
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

-if(MIR_TEST_PLATFORM STREQUAL "mesa-kms" OR MIR_TEST_PLATFORM STREQUAL "mesa-x11")
+if(MIR_BUILD_PLATFORM_MESA_KMS OR MIR_BUILD_PLATFORM_MESA_X11)
...
+#ifdef MIR_BUILD_PLATFORM_MESA_X11
+ ON_CALL(mock_x11, XOpenDisplay(_)).WillByDefault(Return(nullptr));
+#endif

Should the test setup really depend on the *build* platform? (Or is this poor naming - should MIR_BUILD_PLATFORM_* really be MIR_TARGET_PLATFORM_*)

review: Needs Information
Revision history for this message
Andreas Pokorny (andreas-pokorny) wrote :

> -if(MIR_TEST_PLATFORM STREQUAL "mesa-kms" OR MIR_TEST_PLATFORM STREQUAL
> "mesa-x11")
> +if(MIR_BUILD_PLATFORM_MESA_KMS OR MIR_BUILD_PLATFORM_MESA_X11)
> ...
> +#ifdef MIR_BUILD_PLATFORM_MESA_X11
> + ON_CALL(mock_x11, XOpenDisplay(_)).WillByDefault(Return(nullptr));
> +#endif
>
> Should the test setup really depend on the *build* platform? (Or is this poor
> naming - should MIR_BUILD_PLATFORM_* really be MIR_TARGET_PLATFORM_*)

Yeah rather poor naming. MIR_BUILD_PLATFORM indicates that we build for platform X11 .. to be honest the way autoconf names target, host and build still confuses me regularly.

Good that you mention this. This is one of the things I wanted to have another look.

Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

Right. I'll consider it preexisting.

review: Approve
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

Nit:

+struct StubEmergencyCleanupRegistry : mir::EmergencyCleanupRegistry
+{
+ void add(mir::EmergencyCleanupHandler const&) override {}
+};

This needs to implement the other overload.

review: Needs Fixing
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

Also, in the following scenario:

$ sudo bin/mir_demo_server --window-manager system-compositor --display-config sidebyside --vt 1 --arw-file
$ bin/mir_demo_server --host /tmp/mir_socket --display-config clone --window-manager tiling
$ bin/mir_demo_client_egltriangle

I find that Alt+middle-button+drag seems intermittently to not work (neither resizing nor moving the cursor).

review: Needs Fixing
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 :

A bit more detail on the problems I see:

I'm using a lenovo with a trackpoint.

The trackpoint controls the cursor unless the middle "mouse" button is pressed. E.g. Alt+left button drags the triangle, With Alt on its own or with Alt+right it just move the cursor.

Just pressing the middle button (with or without Alt) and the cursor no longer responds to the trackpoint.

It might be diagnostic that the left and right buttons do work, but the middle button doesn't - is something misidentifying it as a two button mouse?

Plugging in a spare 3-button mouse does work.

Revision history for this message
Cemil Azizoglu (cemil-azizoglu) wrote :

613 -if(MIR_TEST_PLATFORM STREQUAL "mesa-kms" OR MIR_TEST_PLATFORM STREQUAL "mesa-x11")
614 +if(MIR_BUILD_PLATFORM_MESA_KMS OR MIR_BUILD_PLATFORM_MESA_X11)

Why is this needed? If the test is being built for Android only why should mesa related stuff be linked in?

review: Needs Information
Revision history for this message
Andreas Pokorny (andreas-pokorny) wrote :

> A bit more detail on the problems I see:
>
> I'm using a lenovo with a trackpoint.
>
> The trackpoint controls the cursor unless the middle "mouse" button is
> pressed. E.g. Alt+left button drags the triangle, With Alt on its own or with
> Alt+right it just move the cursor.
>
> Just pressing the middle button (with or without Alt) and the cursor no longer
> responds to the trackpoint.
>
> It might be diagnostic that the left and right buttons do work, but the middle
> button doesn't - is something misidentifying it as a two button mouse?
>
> Plugging in a spare 3-button mouse does work.

Not quite. I diagnosed that with your evemu record and libinput-debug-events - which is a tool provided by libinput but is not part of the ubuntu libinput package so far.

So by default - it configures your device to use the middle button as scroll-button - so trackpoint motion is converted to scroll axis events while middle button is pressed. You should be able to deactivate that behaviour with the lp:~andreas-pokorny/mir/example-configure-input-devices MP - since it overwrite those settings.

Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

> So by default - it configures your device to use the middle button as scroll-
> button - so trackpoint motion is converted to scroll axis events while middle
> button is pressed. You should be able to deactivate that behaviour with the lp
> :~andreas-pokorny/mir/example-configure-input-devices MP - since it overwrite
> those settings.

I tried adding that, but (after a few merge conflicts - I'm a little way off trunk because of the landings backlog) the server exited because if couldn't find an input platform.

I'll try again later. Meanwhile I won't block on a problem that's being worked on elsewhere.

review: Abstain
Revision history for this message
Andreas Pokorny (andreas-pokorny) wrote :

I thought we do not build the unit tests for

> 613 -if(MIR_TEST_PLATFORM STREQUAL "mesa-kms" OR MIR_TEST_PLATFORM
> STREQUAL "mesa-x11")
> 614 +if(MIR_BUILD_PLATFORM_MESA_KMS OR MIR_BUILD_PLATFORM_MESA_X11)
>
> Why is this needed? If the test is being built for Android only why should
> mesa related stuff be linked in?

Back then I got linker errors whithout that depending on the ordering of the MIR_PLATFORM variable. This is no longer the case..

In general we should find a way to avoid the machinery of MIR_TEST_PLATFORM as far as possible.

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
Cemil Azizoglu (cemil-azizoglu) wrote :

ok

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (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
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'benchmarks/frame-uniformity/touch_producing_server.cpp'
2--- benchmarks/frame-uniformity/touch_producing_server.cpp 2015-10-05 02:18:18 +0000
3+++ benchmarks/frame-uniformity/touch_producing_server.cpp 2015-11-20 15:25:54 +0000
4@@ -26,7 +26,6 @@
5 #include <functional>
6
7 namespace mi = mir::input;
8-namespace mia = mi::android;
9 namespace mg = mir::graphics;
10 namespace mis = mi::synthesis;
11 namespace geom = mir::geometry;
12
13=== modified file 'include/platform/mir/input/platform.h'
14--- include/platform/mir/input/platform.h 2015-10-12 08:08:58 +0000
15+++ include/platform/mir/input/platform.h 2015-11-20 15:25:54 +0000
16@@ -91,7 +91,7 @@
17 };
18
19 typedef mir::UniqueModulePtr<Platform>(*CreatePlatform)(
20- std::shared_ptr<options::Option> const& options,
21+ options::Option const& options,
22 std::shared_ptr<EmergencyCleanupRegistry> const& emergency_cleanup_registry,
23 std::shared_ptr<InputDeviceRegistry> const& input_device_registry,
24 std::shared_ptr<InputReport> const& report);
25@@ -123,7 +123,7 @@
26 * \ingroup platform_enablement
27 */
28 mir::UniqueModulePtr<mir::input::Platform> create_input_platform(
29- std::shared_ptr<mir::options::Option> const& options,
30+ mir::options::Option const& options,
31 std::shared_ptr<mir::EmergencyCleanupRegistry> const& emergency_cleanup_registry,
32 std::shared_ptr<mir::input::InputDeviceRegistry> const& input_device_registry,
33 std::shared_ptr<mir::input::InputReport> const& report);
34
35=== modified file 'include/test/mir_test_framework/executable_path.h'
36--- include/test/mir_test_framework/executable_path.h 2015-10-20 12:46:15 +0000
37+++ include/test/mir_test_framework/executable_path.h 2015-11-20 15:25:54 +0000
38@@ -26,6 +26,7 @@
39 std::string executable_path();
40
41 std::string library_path();
42+std::string server_platform_path();
43 std::string udev_recordings_path();
44 std::string server_platform(std::string const& name);
45 std::string server_input_platform(std::string const& name);
46
47=== modified file 'src/include/server/mir/default_server_configuration.h'
48--- src/include/server/mir/default_server_configuration.h 2015-11-19 04:54:42 +0000
49+++ src/include/server/mir/default_server_configuration.h 2015-11-20 15:25:54 +0000
50@@ -132,7 +132,6 @@
51 class Scene;
52 class InputManager;
53 class SurfaceInputDispatcher;
54-class Platform;
55 class InputDeviceRegistry;
56 class InputDeviceHub;
57 class DefaultInputDeviceHub;
58@@ -144,15 +143,8 @@
59 class InputRegion;
60 class InputSender;
61 class InputSendObserver;
62-class NestedInputRelay;
63-class EventHandler;
64 class CursorImages;
65 class LegacyInputDispatchable;
66-namespace android
67-{
68-class InputRegistrar;
69-class InputThread;
70-}
71 }
72
73 namespace logging
74@@ -331,7 +323,6 @@
75 virtual std::shared_ptr<droidinput::InputListenerInterface> the_input_translator();
76
77 // new input reading related parts:
78- virtual std::shared_ptr<input::Platform> the_input_platform();
79 virtual std::shared_ptr<dispatch::MultiplexingDispatchable> the_input_reading_multiplexer();
80 virtual std::shared_ptr<input::InputDeviceRegistry> the_input_device_registry();
81 virtual std::shared_ptr<input::InputDeviceHub> the_input_device_hub();
82@@ -390,8 +381,7 @@
83 CachedPtr<input::CompositeEventFilter> composite_event_filter;
84 CachedPtr<input::InputManager> input_manager;
85 CachedPtr<input::SurfaceInputDispatcher> surface_input_dispatcher;
86- CachedPtr<input::DefaultInputDeviceHub> default_input_device_hub; // currently not used by default
87- CachedPtr<input::Platform> input_platform; // currently not used by default
88+ CachedPtr<input::DefaultInputDeviceHub> default_input_device_hub;
89 CachedPtr<dispatch::MultiplexingDispatchable> input_reading_multiplexer;
90 CachedPtr<input::InputDispatcher> input_dispatcher;
91 CachedPtr<input::InputSender> input_sender;
92
93=== added file 'src/include/server/mir/input/input_probe.h'
94--- src/include/server/mir/input/input_probe.h 1970-01-01 00:00:00 +0000
95+++ src/include/server/mir/input/input_probe.h 2015-11-20 15:25:54 +0000
96@@ -0,0 +1,48 @@
97+/*
98+ * Copyright © 2015 Canonical Ltd.
99+ *
100+ * This program is free software: you can redistribute it and/or modify it
101+ * under the terms of the GNU General Public License version 3,
102+ * as published by the Free Software Foundation.
103+ *
104+ * This program is distributed in the hope that it will be useful,
105+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
106+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
107+ * GNU General Public License for more details.
108+ *
109+ * You should have received a copy of the GNU General Public License
110+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
111+ *
112+ * Authored by: Andreas Pokorny <andreas.pokorny@canonical.com>
113+ */
114+
115+#ifndef MIR_INPUT_PROBE_H_
116+#define MIR_INPUT_PROBE_H_
117+
118+#include <vector>
119+#include "mir/module_deleter.h"
120+
121+namespace mir
122+{
123+namespace options
124+{
125+class Option;
126+}
127+class EmergencyCleanupRegistry;
128+class SharedLibraryProberReport;
129+
130+namespace input
131+{
132+class InputReport;
133+class Platform;
134+class InputDeviceRegistry;
135+
136+std::vector<mir::UniqueModulePtr<Platform>> probe_input_platforms(
137+ options::Option const& options, std::shared_ptr<EmergencyCleanupRegistry> const& emergency_cleanup,
138+ std::shared_ptr<InputDeviceRegistry> const& device_registry, std::shared_ptr<InputReport> const& input_report,
139+ SharedLibraryProberReport & prober_report);
140+
141+}
142+}
143+
144+#endif
145
146=== modified file 'src/platform/graphics/platform_probe.cpp'
147--- src/platform/graphics/platform_probe.cpp 2015-10-12 08:08:58 +0000
148+++ src/platform/graphics/platform_probe.cpp 2015-11-20 15:25:54 +0000
149@@ -46,7 +46,11 @@
150 "describe_graphics_module",
151 MIR_SERVER_GRAPHICS_PLATFORM_VERSION);
152 auto desc = describe();
153- mir::log_info("Found graphics driver: %s", desc->name);
154+ mir::log_info("Found graphics driver: %s, (version: %d.%d.%d)",
155+ desc->name,
156+ desc->major_version,
157+ desc->minor_version,
158+ desc->micro_version);
159 }
160 catch (std::runtime_error const&)
161 {
162
163=== modified file 'src/platforms/evdev/platform_factory.cpp'
164--- src/platforms/evdev/platform_factory.cpp 2015-10-20 12:46:15 +0000
165+++ src/platforms/evdev/platform_factory.cpp 2015-11-20 15:25:54 +0000
166@@ -67,7 +67,7 @@
167 }
168
169 mir::UniqueModulePtr<mi::Platform> create_input_platform(
170- std::shared_ptr<mo::Option> const& /*options*/,
171+ mo::Option const& /*options*/,
172 std::shared_ptr<mir::EmergencyCleanupRegistry> const& /*emergency_cleanup_registry*/,
173 std::shared_ptr<mi::InputDeviceRegistry> const& input_device_registry,
174 std::shared_ptr<mi::InputReport> const& report)
175
176=== modified file 'src/platforms/mesa/server/x11/input/input.cpp'
177--- src/platforms/mesa/server/x11/input/input.cpp 2015-10-12 08:08:58 +0000
178+++ src/platforms/mesa/server/x11/input/input.cpp 2015-11-20 15:25:54 +0000
179@@ -28,7 +28,7 @@
180 extern mx::X11Resources x11_resources;
181
182 mir::UniqueModulePtr<mi::Platform> create_input_platform(
183- std::shared_ptr<mo::Option> const& /*options*/,
184+ mo::Option const& /*options*/,
185 std::shared_ptr<mir::EmergencyCleanupRegistry> const& /*emergency_cleanup_registry*/,
186 std::shared_ptr<mi::InputDeviceRegistry> const& input_device_registry,
187 std::shared_ptr<mi::InputReport> const& /*report*/)
188
189=== modified file 'src/server/input/CMakeLists.txt'
190--- src/server/input/CMakeLists.txt 2015-11-04 16:30:42 +0000
191+++ src/server/input/CMakeLists.txt 2015-11-20 15:25:54 +0000
192@@ -14,6 +14,7 @@
193 display_input_region.cpp
194 event_filter_chain_dispatcher.cpp
195 input_modifier_utils.cpp
196+ input_probe.cpp
197 key_repeat_dispatcher.cpp
198 null_input_channel_factory.cpp
199 null_input_dispatcher.cpp
200
201=== modified file 'src/server/input/default_configuration.cpp'
202--- src/server/input/default_configuration.cpp 2015-10-13 17:42:07 +0000
203+++ src/server/input/default_configuration.cpp 2015-11-20 15:25:54 +0000
204@@ -39,16 +39,16 @@
205 #include "surface_input_dispatcher.h"
206
207 #include "mir/input/touch_visualizer.h"
208+#include "mir/input/input_probe.h"
209 #include "mir/input/platform.h"
210 #include "mir/options/configuration.h"
211 #include "mir/options/option.h"
212 #include "mir/dispatch/multiplexing_dispatchable.h"
213 #include "mir/compositor/scene.h"
214 #include "mir/emergency_cleanup.h"
215-#include "mir/report/legacy_input_report.h"
216 #include "mir/main_loop.h"
217-#include "mir/shared_library.h"
218 #include "mir/glib_main_loop.h"
219+#include "mir/log.h"
220 #include "mir/dispatch/action_queue.h"
221
222 #include "mir_toolkit/cursors.h"
223@@ -290,26 +290,6 @@
224 });
225 }
226
227-std::shared_ptr<mi::Platform>
228-mir::DefaultServerConfiguration::the_input_platform()
229-{
230- return input_platform(
231- [this]() -> std::shared_ptr<mi::Platform>
232- {
233- auto options = the_options();
234-
235- if (!options->is_set(options::platform_input_lib))
236- return nullptr;
237-
238- auto lib = std::make_shared<mir::SharedLibrary>(
239- options->get<std::string>(options::platform_input_lib));
240- auto create = lib->load_function<mi::CreatePlatform>(
241- "create_input_platform",
242- MIR_SERVER_INPUT_PLATFORM_VERSION);
243- return create(the_options(), the_emergency_cleanup(), the_input_device_registry(), the_input_report());
244- });
245-}
246-
247 namespace
248 {
249 class NullLegacyInputDispatchable : public mi::LegacyInputDispatchable
250@@ -341,23 +321,20 @@
251 }
252 else
253 {
254- if (options->get<std::string>(options::legacy_input_report_opt) == options::log_opt_value)
255- mr::legacy_input::initialize(the_logger());
256-
257- if (auto platform = the_input_platform())
258- {
259- auto const ret = std::make_shared<mi::DefaultInputManager>(
260- the_input_reading_multiplexer(),
261- std::make_shared<NullLegacyInputDispatchable>());
262-
263- ret->add_platform(platform);
264- return ret;
265- }
266- else
267- {
268- return std::make_shared<mi::DefaultInputManager>(
269- the_input_reading_multiplexer(), the_legacy_input_dispatchable());
270- }
271+ auto platforms = probe_input_platforms(*options, the_emergency_cleanup(), the_input_device_registry(),
272+ the_input_report(), *the_shared_library_prober_report());
273+
274+ if (platforms.empty())
275+ BOOST_THROW_EXCEPTION(std::runtime_error("No input platforms found"));
276+
277+ auto const ret = std::make_shared<mi::DefaultInputManager>(
278+ the_input_reading_multiplexer(),
279+ std::make_shared<NullLegacyInputDispatchable>());
280+
281+ for (auto & platform : platforms)
282+ ret->add_platform(std::move(platform));
283+
284+ return ret;
285 }
286 }
287 );
288
289=== added file 'src/server/input/input_probe.cpp'
290--- src/server/input/input_probe.cpp 1970-01-01 00:00:00 +0000
291+++ src/server/input/input_probe.cpp 2015-11-20 15:25:54 +0000
292@@ -0,0 +1,104 @@
293+/*
294+ * Copyright © 2015 Canonical Ltd.
295+ *
296+ * This program is free software: you can redistribute it and/or modify it
297+ * under the terms of the GNU General Public License version 3,
298+ * as published by the Free Software Foundation.
299+ *
300+ * This program is distributed in the hope that it will be useful,
301+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
302+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
303+ * GNU General Public License for more details.
304+ *
305+ * You should have received a copy of the GNU General Public License
306+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
307+ *
308+ * Authored by: Andreas Pokorny <andreas.pokorny@canonical.com>
309+ */
310+
311+#include "mir/input/input_probe.h"
312+#include "mir/input/platform.h"
313+
314+#include "mir/options/configuration.h"
315+#include "mir/options/option.h"
316+
317+#include "mir/shared_library_prober.h"
318+#include "mir/shared_library.h"
319+#include "mir/log.h"
320+#include "mir/module_deleter.h"
321+
322+#include <stdexcept>
323+
324+namespace mi = mir::input;
325+namespace mo = mir::options;
326+
327+namespace
328+{
329+auto probe_input_platform(mir::SharedLibrary const& lib, mir::options::Option const& options)
330+{
331+ auto probe = lib.load_function<mi::ProbePlatform>("probe_input_platform", MIR_SERVER_INPUT_PLATFORM_VERSION);
332+
333+ return probe(options);
334+}
335+
336+void describe_input_platform(mir::SharedLibrary const& lib)
337+{
338+ auto describe =
339+ lib.load_function<mi::DescribeModule>("describe_input_module", MIR_SERVER_INPUT_PLATFORM_VERSION);
340+ auto desc = describe();
341+ mir::log_info("Selected input driver: %s (version: %d.%d.%d)", desc->name, desc->major_version, desc->minor_version,
342+ desc->micro_version);
343+}
344+
345+mir::UniqueModulePtr<mi::Platform> create_input_platform(
346+ mir::SharedLibrary const& lib, mir::options::Option const& options,
347+ std::shared_ptr<mir::EmergencyCleanupRegistry> const& cleanup_registry,
348+ std::shared_ptr<mi::InputDeviceRegistry> const& registry, std::shared_ptr<mi::InputReport> const& report)
349+{
350+
351+ auto create = lib.load_function<mi::CreatePlatform>("create_input_platform", MIR_SERVER_INPUT_PLATFORM_VERSION);
352+
353+ return create(options, cleanup_registry, registry, report);
354+}
355+}
356+
357+std::vector<mir::UniqueModulePtr<mi::Platform>> mi::probe_input_platforms(
358+ mo::Option const& options, std::shared_ptr<EmergencyCleanupRegistry> const& emergency_cleanup,
359+ std::shared_ptr<mi::InputDeviceRegistry> const& device_registry, std::shared_ptr<mi::InputReport> const& input_report,
360+ mir::SharedLibraryProberReport& prober_report)
361+{
362+ std::vector<UniqueModulePtr<Platform>> platforms;
363+
364+ if (options.is_set(mo::platform_input_lib))
365+ {
366+ mir::SharedLibrary lib(options.get<std::string>(mo::platform_input_lib));
367+
368+ platforms.emplace_back(create_input_platform(lib, options, emergency_cleanup, device_registry, input_report));
369+
370+ describe_input_platform(lib);
371+ }
372+ else
373+ {
374+ auto const& path = options.get<std::string>(mo::platform_path);
375+ auto platforms_libs = mir::libraries_for_path(path, prober_report);
376+
377+ for (auto const& platform_lib : platforms_libs)
378+ {
379+ try
380+ {
381+ if (probe_input_platform(*platform_lib, options) > mi::PlatformPriority::dummy)
382+ {
383+ platforms.emplace_back(
384+ create_input_platform(*platform_lib, options, emergency_cleanup, device_registry, input_report));
385+
386+ describe_input_platform(*platform_lib);
387+ }
388+ }
389+ catch (std::runtime_error const&)
390+ {
391+ }
392+ }
393+ }
394+
395+ return platforms;
396+}
397
398=== modified file 'src/server/symbols.map'
399--- src/server/symbols.map 2015-11-19 06:43:10 +0000
400+++ src/server/symbols.map 2015-11-20 15:25:54 +0000
401@@ -83,6 +83,7 @@
402 mir::input::TouchVisualizer::operator*;
403 mir::input::TouchVisualizer::?TouchVisualizer*;
404 mir::input::TouchVisualizer::TouchVisualizer*;
405+ mir::input::probe_input_platforms*;
406 mir::LockableCallback::?LockableCallback*;
407 mir::LockableCallback::LockableCallback*;
408 mir::LockableCallback::operator*;
409@@ -687,7 +688,6 @@
410 mir::DefaultServerConfiguration::the_input_dispatcher*;
411 mir::DefaultServerConfiguration::the_new_input_dispatcher*;
412 mir::DefaultServerConfiguration::the_input_manager*;
413- mir::DefaultServerConfiguration::the_input_platform*;
414 mir::DefaultServerConfiguration::the_input_reader*;
415 mir::DefaultServerConfiguration::the_input_reader_policy*;
416 mir::DefaultServerConfiguration::the_input_reading_multiplexer*;
417
418=== renamed file 'tests/mir_test_framework/stub_input_platform.h' => 'tests/include/mir_test_framework/stub_input_platform.h'
419=== modified file 'tests/mir_test_framework/CMakeLists.txt'
420--- tests/mir_test_framework/CMakeLists.txt 2015-11-04 15:42:43 +0000
421+++ tests/mir_test_framework/CMakeLists.txt 2015-11-20 15:25:54 +0000
422@@ -38,6 +38,7 @@
423 process.cpp
424 server_runner.cpp
425 socket_detect_server.cpp
426+ stub_input_platform.cpp
427 stub_client_platform_factory.cpp
428 stub_server_platform_factory.cpp
429 stub_session.cpp
430
431=== modified file 'tests/mir_test_framework/executable_path.cpp'
432--- tests/mir_test_framework/executable_path.cpp 2015-10-20 12:46:15 +0000
433+++ tests/mir_test_framework/executable_path.cpp 2015-11-20 15:25:54 +0000
434@@ -45,6 +45,16 @@
435 return executable_path() + "/../lib";
436 }
437
438+std::string mir_test_framework::server_platform_path()
439+{
440+ for (auto const& option : {library_path() + "/server-modules/",
441+ library_path() + "/server-platform/",
442+ std::string(MIR_SERVER_PLATFORM_PATH) + '/'})
443+ if (boost::filesystem::exists(option))
444+ return option;
445+ BOOST_THROW_EXCEPTION(std::runtime_error("Failed to find server platform in standard search locations"));
446+}
447+
448 std::string mir_test_framework::udev_recordings_path()
449 {
450 std::string run_path = executable_path() + "/udev_recordings";
451
452=== modified file 'tests/mir_test_framework/fake_input_device_impl.cpp'
453--- tests/mir_test_framework/fake_input_device_impl.cpp 2015-11-19 04:54:42 +0000
454+++ tests/mir_test_framework/fake_input_device_impl.cpp 2015-11-20 15:25:54 +0000
455@@ -17,7 +17,7 @@
456 */
457
458 #include "fake_input_device_impl.h"
459-#include "stub_input_platform.h"
460+#include "mir_test_framework/stub_input_platform.h"
461
462 #include "mir/input/input_device.h"
463 #include "mir/input/input_device_info.h"
464
465=== modified file 'tests/mir_test_framework/fake_input_server_configuration.cpp'
466--- tests/mir_test_framework/fake_input_server_configuration.cpp 2015-08-26 08:44:24 +0000
467+++ tests/mir_test_framework/fake_input_server_configuration.cpp 2015-11-20 15:25:54 +0000
468@@ -23,7 +23,6 @@
469 namespace mi = mir::input;
470 namespace ms = mir::scene;
471 namespace msh = mir::shell;
472-namespace mia = mir::input::android;
473
474 mtf::FakeInputServerConfiguration::FakeInputServerConfiguration()
475 {
476
477=== modified file 'tests/mir_test_framework/input_testing_server_options.cpp'
478--- tests/mir_test_framework/input_testing_server_options.cpp 2015-06-25 03:00:08 +0000
479+++ tests/mir_test_framework/input_testing_server_options.cpp 2015-11-20 15:25:54 +0000
480@@ -38,7 +38,6 @@
481 namespace mg = mir::graphics;
482 namespace mi = mir::input;
483 namespace ms = mir::shell;
484-namespace mia = mi::android;
485 namespace geom = mir::geometry;
486
487 mtf::InputTestingServerConfiguration::InputTestingServerConfiguration()
488
489=== modified file 'tests/mir_test_framework/stub_input.cpp'
490--- tests/mir_test_framework/stub_input.cpp 2015-10-12 08:08:58 +0000
491+++ tests/mir_test_framework/stub_input.cpp 2015-11-20 15:25:54 +0000
492@@ -16,7 +16,7 @@
493 * Authored by: Andreas Pokorny <andreas.pokorny@canonical.com>
494 */
495
496-#include "stub_input_platform.h"
497+#include "mir_test_framework/stub_input_platform.h"
498 #include "fake_input_device_impl.h"
499 #include "mir/module_properties.h"
500
501@@ -25,7 +25,7 @@
502 namespace mi = mir::input;
503
504 mir::UniqueModulePtr<mi::Platform> create_input_platform(
505- std::shared_ptr<mo::Option> const& /*options*/,
506+ mo::Option const& /*options*/,
507 std::shared_ptr<mir::EmergencyCleanupRegistry> const& /*emergency_cleanup_registry*/,
508 std::shared_ptr<mi::InputDeviceRegistry> const& input_device_registry,
509 std::shared_ptr<mi::InputReport> const& /*report*/)
510
511=== modified file 'tests/mir_test_framework/stub_input_platform.cpp'
512--- tests/mir_test_framework/stub_input_platform.cpp 2015-10-12 08:08:58 +0000
513+++ tests/mir_test_framework/stub_input_platform.cpp 2015-11-20 15:25:54 +0000
514@@ -16,7 +16,7 @@
515 * Authored by: Andreas Pokorny <andreas.pokorny@canonical.com>
516 */
517
518-#include "stub_input_platform.h"
519+#include "mir_test_framework/stub_input_platform.h"
520
521 #include "mir/input/input_device_registry.h"
522 #include "mir/dispatch/action_queue.h"
523
524=== modified file 'tests/umock-acceptance-tests/test_libinput.cpp'
525--- tests/umock-acceptance-tests/test_libinput.cpp 2015-10-12 08:08:58 +0000
526+++ tests/umock-acceptance-tests/test_libinput.cpp 2015-11-20 15:25:54 +0000
527@@ -17,8 +17,8 @@
528 */
529
530 #include "mir/input/platform.h"
531+#include "mir/test/doubles/mock_option.h"
532 #include "mir/shared_library.h"
533-#include "mir/options/option.h"
534
535 #include "mir_test_framework/udev_environment.h"
536 #include "mir_test_framework/executable_path.h"
537@@ -27,20 +27,13 @@
538 #include <gtest/gtest.h>
539
540 namespace mtf = mir_test_framework;
541+namespace mtd = mir::test::doubles;
542 namespace mo = mir::options;
543+
544 using namespace ::testing;
545 namespace
546 {
547
548-struct MockOption : mo::Option
549-{
550- MOCK_CONST_METHOD1(is_set, bool(char const*));
551- MOCK_CONST_METHOD2(get, bool(char const*, bool));
552- MOCK_CONST_METHOD2(get, int(char const*, int));
553- MOCK_CONST_METHOD2(get, std::string(char const* name, char const*));
554- MOCK_CONST_METHOD1(get, boost::any const&(char const*));
555-};
556-
557 auto get_libinput_platform()
558 {
559 auto path = mtf::server_input_platform("input-evdev");
560@@ -54,7 +47,7 @@
561
562 TEST(LibInput, DISABLED_probes_as_unsupported_without_device_access)
563 {
564- NiceMock<MockOption> options;
565+ NiceMock<mtd::MockOption> options;
566
567 // dumb assumption - nobody runs this test cases as root..
568 // or allows accessing evdev input devices from non privileged users.
569@@ -67,7 +60,7 @@
570 {
571 mtf::UdevEnvironment env;
572 env.add_standard_device("laptop-keyboard");
573- NiceMock<MockOption> options;
574+ NiceMock<mtd::MockOption> options;
575
576 auto library = get_libinput_platform();
577 auto probe_fun = library->load_function<mir::input::ProbePlatform>(probe_input_platform_symbol);
578@@ -78,7 +71,8 @@
579 {
580 mtf::UdevEnvironment env;
581 env.add_standard_device("laptop-keyboard");
582- NiceMock<MockOption> options;
583+ NiceMock<mtd::MockOption> options;
584+
585 ON_CALL(options,is_set(StrEq(host_socket_opt)))
586 .WillByDefault(Return(true));
587 ON_CALL(options,get(StrEq(host_socket_opt), Matcher<char const*>(_)))
588@@ -92,7 +86,7 @@
589 TEST(LibInput, probes_as_supported_when_umock_dev_available_or_before_input_devices_are_available)
590 {
591 mtf::UdevEnvironment env;
592- NiceMock<MockOption> options;
593+ NiceMock<mtd::MockOption> options;
594
595 auto library = get_libinput_platform();
596 auto probe_fun = library->load_function<mir::input::ProbePlatform>(probe_input_platform_symbol);
597
598=== modified file 'tests/unit-tests/input/CMakeLists.txt'
599--- tests/unit-tests/input/CMakeLists.txt 2015-11-04 19:47:19 +0000
600+++ tests/unit-tests/input/CMakeLists.txt 2015-11-20 15:25:54 +0000
601@@ -8,6 +8,7 @@
602 ${CMAKE_CURRENT_SOURCE_DIR}/test_xcursor_loader.cpp
603 ${CMAKE_CURRENT_SOURCE_DIR}/test_touchspot_controller.cpp
604 ${CMAKE_CURRENT_SOURCE_DIR}/test_input_event.cpp
605+ ${CMAKE_CURRENT_SOURCE_DIR}/test_input_platform_probing.cpp
606 ${CMAKE_CURRENT_SOURCE_DIR}/test_event_builders.cpp
607 ${CMAKE_CURRENT_SOURCE_DIR}/test_default_device.cpp
608 ${CMAKE_CURRENT_SOURCE_DIR}/test_default_input_device_hub.cpp
609
610=== added file 'tests/unit-tests/input/test_input_platform_probing.cpp'
611--- tests/unit-tests/input/test_input_platform_probing.cpp 1970-01-01 00:00:00 +0000
612+++ tests/unit-tests/input/test_input_platform_probing.cpp 2015-11-20 15:25:54 +0000
613@@ -0,0 +1,161 @@
614+/*
615+ * Copyright © 2015 Canonical Ltd.
616+ *
617+ * This program is free software: you can redistribute it and/or modify
618+ * it under the terms of the GNU General Public License version 3 as
619+ * published by the Free Software Foundation.
620+ *
621+ * This program is distributed in the hope that it will be useful,
622+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
623+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
624+ * GNU General Public License for more details.
625+ *
626+ * You should have received a copy of the GNU General Public License
627+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
628+ *
629+ * Authored by: Andreas Pokorny <andreas.pokorny@canonical.com>
630+ */
631+
632+#include <gtest/gtest.h>
633+
634+#include "mir/input/input_probe.h"
635+
636+#include "mir/input/platform.h"
637+#include "src/server/report/null_report_factory.h"
638+
639+#include "mir/options/option.h"
640+#include "mir/emergency_cleanup_registry.h"
641+
642+#include "mir_test_framework/udev_environment.h"
643+#include "mir_test_framework/executable_path.h"
644+#include "mir_test_framework/stub_input_platform.h"
645+#include "mir/test/doubles/mock_x11.h"
646+#include "mir/test/doubles/mock_libinput.h"
647+#include "mir/test/doubles/mock_option.h"
648+#include "mir/test/doubles/mock_input_device_registry.h"
649+#include "src/platforms/evdev/platform.h"
650+#include "src/platforms/mesa/server/x11/input/input_platform.h"
651+#include "mir/test/fake_shared.h"
652+
653+namespace mt = mir::test;
654+namespace mtd = mt::doubles;
655+namespace mi = mir::input;
656+namespace mr = mir::report;
657+namespace mtf = mir_test_framework;
658+
659+using namespace ::testing;
660+
661+namespace
662+{
663+struct StubEmergencyCleanupRegistry : mir::EmergencyCleanupRegistry
664+{
665+ void add(mir::EmergencyCleanupHandler const&) override {}
666+ void add(mir::ModuleEmergencyCleanupHandler) override {}
667+};
668+char const platform_input_lib[] = "platform-input-lib";
669+char const platform_path[] = "platform-path";
670+
671+struct InputPlatformProbe : ::testing::Test
672+{
673+ InputPlatformProbe()
674+ {
675+ ON_CALL(mock_options, is_set(StrEq(platform_input_lib))).WillByDefault(Return(false));
676+ ON_CALL(mock_options, is_set(StrEq(platform_path))).WillByDefault(Return(true));
677+ ON_CALL(mock_options, get(StrEq(platform_path),Matcher<char const*>(_)))
678+ .WillByDefault(Return(platform_path_value));
679+ ON_CALL(mock_options, get(StrEq(platform_path)))
680+ .WillByDefault(Invoke(
681+ [this](char const*) -> boost::any const&
682+ {
683+ return platform_path_value_as_any;
684+ }));
685+ ON_CALL(mock_options, get(StrEq(platform_input_lib)))
686+ .WillByDefault(Invoke(
687+ [this](char const*) -> boost::any const&
688+ {
689+ return platform_input_lib_value_as_any;
690+ }));
691+ }
692+
693+ void disable_x11()
694+ {
695+#ifdef MIR_BUILD_PLATFORM_MESA_X11
696+ ON_CALL(mock_x11, XOpenDisplay(_)).WillByDefault(Return(nullptr));
697+#endif
698+ }
699+
700+ // replace with with mocks for udev and evdev to simulate root or non-root
701+ // access on evdev devices, and enable the disabled test case(s) below.
702+ mtf::UdevEnvironment env;
703+
704+#ifdef MIR_BUILD_PLATFORM_MESA_X11
705+ NiceMock<mtd::MockX11> mock_x11;
706+#endif
707+ NiceMock<mtd::MockLibInput> mock_libinput;
708+ NiceMock<mtd::MockOption> mock_options;
709+ mtd::MockInputDeviceRegistry mock_registry;
710+ StubEmergencyCleanupRegistry stub_emergency;
711+ std::shared_ptr<mir::SharedLibraryProberReport> stub_prober_report{mr::null_shared_library_prober_report()};
712+ std::string platform_path_value{mtf::server_platform_path()};
713+ boost::any platform_path_value_as_any{platform_path_value};
714+ std::string platform_input_lib_value;
715+ boost::any platform_input_lib_value_as_any;
716+};
717+
718+template <typename Expected>
719+struct OfPtrTypeMatcher
720+{
721+ template <typename T>
722+ bool MatchAndExplain(T&& p, MatchResultListener* /* listener */) const
723+ {
724+ return dynamic_cast<Expected*>(&*p) != nullptr;
725+ }
726+ void DescribeTo(::std::ostream* os) const
727+ {
728+ *os << "is a or derived from a " << typeid(Expected).name();
729+ }
730+ void DescribeNegationTo(::std::ostream* os) const
731+ {
732+ *os << "is not or not derived from " << typeid(Expected).name();
733+ }
734+};
735+
736+template<typename Dest>
737+inline auto OfPtrType()
738+{
739+ return MakePolymorphicMatcher(OfPtrTypeMatcher<Dest>());
740+}
741+}
742+
743+
744+TEST_F(InputPlatformProbe, stub_platform_not_picked_up_by_default)
745+{
746+ disable_x11();
747+ auto platforms =
748+ mi::probe_input_platforms(mock_options, mt::fake_shared(stub_emergency), mt::fake_shared(mock_registry),
749+ mr::null_input_report(), *stub_prober_report);
750+
751+ EXPECT_THAT(platforms, ElementsAre(OfPtrType<mi::evdev::Platform>()));
752+}
753+
754+#ifdef MIR_BUILD_PLATFORM_MESA_X11
755+TEST_F(InputPlatformProbe, x11_platform_found_and_used_when_display_connection_works)
756+{
757+ auto platforms =
758+ mi::probe_input_platforms(mock_options, mt::fake_shared(stub_emergency), mt::fake_shared(mock_registry),
759+ mr::null_input_report(), *stub_prober_report);
760+
761+ EXPECT_THAT(platforms, UnorderedElementsAre(OfPtrType<mi::evdev::Platform>(), OfPtrType<mi::X::XInputPlatform>()));
762+}
763+#endif
764+
765+TEST_F(InputPlatformProbe, allows_forcing_stub_input_platform)
766+{
767+ ON_CALL(mock_options, is_set(StrEq(platform_input_lib))).WillByDefault(Return(true));
768+ platform_input_lib_value = mtf::server_input_platform("input-stub.so");
769+ platform_input_lib_value_as_any = platform_input_lib_value;
770+ auto platforms =
771+ mi::probe_input_platforms(mock_options, mt::fake_shared(stub_emergency), mt::fake_shared(mock_registry),
772+ mr::null_input_report(), *stub_prober_report);
773+ EXPECT_THAT(platforms, ElementsAre(OfPtrType<mtf::StubInputPlatform>()));
774+}

Subscribers

People subscribed via source and target branches