Mir

Merge lp://qastaging/~andreas-pokorny/mir/add-key-repeat-utility into lp://qastaging/mir

Proposed by Andreas Pokorny
Status: Work in progress
Proposed branch: lp://qastaging/~andreas-pokorny/mir/add-key-repeat-utility
Merge into: lp://qastaging/mir
Prerequisite: lp://qastaging/~andreas-pokorny/mir/add-dispatchable-alarm-factory
Diff against target: 407 lines (+340/-11)
6 files modified
include/test/mir/test/doubles/mock_alarm_factory.h (+18/-11)
src/platforms/evdev/CMakeLists.txt (+1/-0)
src/platforms/evdev/key_repeater.cpp (+97/-0)
src/platforms/evdev/key_repeater.h (+64/-0)
tests/unit-tests/input/CMakeLists.txt (+1/-0)
tests/unit-tests/input/test_key_repeater.cpp (+159/-0)
To merge this branch: bzr merge lp://qastaging/~andreas-pokorny/mir/add-key-repeat-utility
Reviewer Review Type Date Requested Status
Mir CI Bot continuous-integration Needs Fixing
Kevin DuBois (community) Approve
Review via email: mp+289961@code.qastaging.launchpad.net

Commit message

Add Key repeat utility

Similar to the key press tracking in KeyRepeatDispatcher, this class will support the evdev platform and fake input devices in implementing repeat handling.

Description of the change

A split out of an upcoming branch that moves repeat handling into the input platforms and makes it configureable. In this MP an implementation of the necessary key code tracking is added.

To post a comment you must log in.
Revision history for this message
Kevin DuBois (kdub) wrote :

+ // destructor cancels the alarm
+ ~MockAlarm()
+ {
+ cancel();
+ }
Seems specific to a test

+ if (existing_timer == repeat_alarms_by_scancode.end())
+ existing_timer = repeat_alarms_by_scancode.emplace(
+ std::make_pair(
+ code,
+ alarm_factory->create_alarm(
+ [this, code]()
+ {
+ this->handle_timeout(code);
+ })
+ )
+ ).first;

braces around multi-line if statement

+ mtd::MockAlarm * alarm = new mtd::MockAlarm;
needs delete/unique_ptr?

review: Needs Fixing
Revision history for this message
Kevin DuBois (kdub) wrote :

> + mtd::MockAlarm * alarm = new mtd::MockAlarm;
> needs delete/unique_ptr?
Ah, reading through the mock factory, it seems this gets wrapped with a unique_ptr on invocation.... Still not threadsafe, and will leak if the test fails to call the function.

mir/test/gmock_fixes.h and .WillOnce(Invoke([]{ return std::make_unique<T>(); })) is the best way I've found to work around gmock's difficulty with move-only types.

Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3417
https://mir-jenkins.ubuntu.com/job/mir-ci/642/
Executed test runs:
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-mir/578
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-0-fetch/614
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/606
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial/606
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=vivid+overlay/588
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=vivid+overlay/588/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial/588
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial/588/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/588
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/588/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/588
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/588/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial/588
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial/588/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/642/rebuild

review: Approve (continuous-integration)
Revision history for this message
Andreas Pokorny (andreas-pokorny) wrote :

> > + mtd::MockAlarm * alarm = new mtd::MockAlarm;
> > needs delete/unique_ptr?
> Ah, reading through the mock factory, it seems this gets wrapped with a
> unique_ptr on invocation.... Still not threadsafe, and will leak if the test
> fails to call the function.

In some of the tests I want to define call expectations.. but when the unique_ptr is created inside the method I dont get access to the object. But I guess in those cases I could still create the Alarm object in advance with make_unique.

> mir/test/gmock_fixes.h and .WillOnce(Invoke([]{ return std::make_unique<T>();
> })) is the best way I've found to work around gmock's difficulty with move-
> only types.

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

> + // destructor cancels the alarm
> + ~MockAlarm()
> + {
> + cancel();
> + }
> Seems specific to a test

But thats the behavior of Alarm objects..

> + if (existing_timer == repeat_alarms_by_scancode.end())
> + existing_timer = repeat_alarms_by_scancode.emplace(
> + std::make_pair(
> + code,
> + alarm_factory->create_alarm(
> + [this, code]()
> + {
> + this->handle_timeout(code);
> + })
> + )
> + ).first;
>
> braces around multi-line if statement
>
> + mtd::MockAlarm * alarm = new mtd::MockAlarm;
> needs delete/unique_ptr?

ack

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

> > > + mtd::MockAlarm * alarm = new mtd::MockAlarm;
> > > needs delete/unique_ptr?
> > Ah, reading through the mock factory, it seems this gets wrapped with a
> > unique_ptr on invocation.... Still not threadsafe, and will leak if the test
> > fails to call the function.
>
> In some of the tests I want to define call expectations.. but when the
> unique_ptr is created inside the method I dont get access to the object. But I
> guess in those cases I could still create the Alarm object in advance with
> make_unique.
>
> > mir/test/gmock_fixes.h and .WillOnce(Invoke([]{ return
> std::make_unique<T>();
> > })) is the best way I've found to work around gmock's difficulty with move-
> > only types.

It does not work here. I had to reorder the expectations to still have a valid Alarm ptr in the test case. But to get the unique_ptr to the caller .. I cannot use Return() with a move only type, and an Invoke action with a mutable lambda.

3418. By Andreas Pokorny

fixed indenting

Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

FAILED: Continuous integration, rev:3418
https://mir-jenkins.ubuntu.com/job/mir-ci/651/
Executed test runs:
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-mir/592/console
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-0-fetch/628
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/620
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial/620
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=vivid+overlay/602
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=vivid+overlay/602/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial/602
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial/602/artifact/output/*zip*/output.zip
    ABORTED: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/602/console
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/602/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/602
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/602/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial/602
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial/602/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/651/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3418
https://mir-jenkins.ubuntu.com/job/mir-ci/667/
Executed test runs:
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-mir/614
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-0-fetch/651
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/643
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial/643
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=vivid+overlay/624
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=vivid+overlay/624/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial/624
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial/624/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/624
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/624/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/624
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/624/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial/624
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial/624/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/667/rebuild

review: Approve (continuous-integration)
Revision history for this message
Kevin DuBois (kdub) wrote :

> It does not work here. I had to reorder the expectations to still have a valid
> Alarm ptr in the test case. But to get the unique_ptr to the caller .. I
> cannot use Return() with a move only type, and an Invoke action with a mutable
> lambda.

can merge this branch in, makes things a bit more raii in the test: lp:~kdub/mir/key-repeat-gmock-fixes

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

wow.. for some reason I always tried binding the alarm object by value to lambda.
Works fine. Thanks!

3419. By Andreas Pokorny

merge prereq

3420. By Andreas Pokorny

Merge improvement from kdub..

Revision history for this message
Kevin DuBois (kdub) wrote :

lgtm

review: Approve
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
3421. By Andreas Pokorny

merge prereq to resolve conflict

Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

FAILED: Continuous integration, rev:3421
https://mir-jenkins.ubuntu.com/job/mir-ci/716/
Executed test runs:
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-mir/680/console
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-0-fetch/717
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/708
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial/708
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=vivid+overlay/689/console
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial/689
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial/689/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/689
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/689/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/689
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/689/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial/689
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial/689/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/716/rebuild

review: Needs Fixing (continuous-integration)

Unmerged revisions

3421. By Andreas Pokorny

merge prereq to resolve conflict

3420. By Andreas Pokorny

Merge improvement from kdub..

3419. By Andreas Pokorny

merge prereq

3418. By Andreas Pokorny

fixed indenting

3417. By Andreas Pokorny

merge prereq

3416. By Andreas Pokorny

Add accessors

3415. By Andreas Pokorny

Add Key repeat utility

Similar to the key press tracking in KeyRepeatDispatcher, this class will support the evdev platform and fake input devices in implementing repeat handling.

3414. By Andreas Pokorny

Add mir::dispatch::AlarmFactory

Implementation of mir::time::AlarmFactory that works with mir::dispatch::Dispatchable and supports all the state transitions required by the test suite accumulated in test_glib_main_loop.cpp.

With this change several GPL interfaces defined inside the mirserver API have been moved to mircommon and LGPL.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches