Mir

Merge lp:~robertcarr/mir/client-input-report into lp:mir

Proposed by Robert Carr
Status: Merged
Approved by: Alan Griffiths
Approved revision: no longer in the source branch.
Merged at revision: 1204
Proposed branch: lp:~robertcarr/mir/client-input-report
Merge into: lp:mir
Diff against target: 654 lines (+351/-18)
15 files modified
doc/component_reports.md (+1/-0)
include/shared/mir/input/input_platform.h (+3/-1)
include/shared/mir/input/input_receiver_report.h (+48/-0)
include/shared/mir/input/null_input_receiver_report.h (+46/-0)
src/client/CMakeLists.txt (+1/-0)
src/client/default_connection_configuration.cpp (+20/-2)
src/client/default_connection_configuration.h (+9/-0)
src/client/logging/input_receiver_report.cpp (+125/-0)
src/client/logging/input_receiver_report.h (+54/-0)
src/shared/input/android/android_input_platform.cpp (+11/-3)
src/shared/input/android/android_input_platform.h (+4/-1)
src/shared/input/android/android_input_receiver.cpp (+9/-2)
src/shared/input/android/android_input_receiver.h (+7/-2)
tests/unit-tests/client/input/test_android_input_receiver.cpp (+8/-5)
tests/unit-tests/client/input/test_android_input_receiver_thread.cpp (+5/-2)
To merge this branch: bzr merge lp:~robertcarr/mir/client-input-report
Reviewer Review Type Date Requested Status
Alan Griffiths Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+194028@code.launchpad.net

Commit message

Add a client input receiver report.

Description of the change

Useful for debugging. You can try it out by running the input acceptance tests with MIR_CLIENT_INPUT_RECEIVER_REPORT=log

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

I'm not entirely convinced by the log formatting. But I've not tried using this and you probably have.

It is at least a step forward

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'doc/component_reports.md'
--- doc/component_reports.md 2013-10-24 11:41:30 +0000
+++ doc/component_reports.md 2013-11-06 00:09:36 +0000
@@ -40,6 +40,7 @@
40Report | Handlers40Report | Handlers
41------------------- | --------41------------------- | --------
42rpc-report | log,lttng42rpc-report | log,lttng
43input-receiver | log
4344
44For example, to enable the logging RPC report, one should set the45For example, to enable the logging RPC report, one should set the
45`MIR_CLIENT_RPC_REPORT=log` environment variable.46`MIR_CLIENT_RPC_REPORT=log` environment variable.
4647
=== modified file 'include/shared/mir/input/input_platform.h'
--- include/shared/mir/input/input_platform.h 2013-05-13 23:20:52 +0000
+++ include/shared/mir/input/input_platform.h 2013-11-06 00:09:36 +0000
@@ -31,6 +31,7 @@
31namespace receiver31namespace receiver
32{32{
33class InputReceiverThread;33class InputReceiverThread;
34class InputReceiverReport;
3435
35// Interface for MirSurface to construct input dispatcher threads.36// Interface for MirSurface to construct input dispatcher threads.
36class InputPlatform37class InputPlatform
@@ -39,8 +40,9 @@
39 virtual ~InputPlatform() {}; 40 virtual ~InputPlatform() {};
4041
41 virtual std::shared_ptr<InputReceiverThread> create_input_thread(int fd, std::function<void(MirEvent *)> const& callback) = 0;42 virtual std::shared_ptr<InputReceiverThread> create_input_thread(int fd, std::function<void(MirEvent *)> const& callback) = 0;
42 43
43 static std::shared_ptr<InputPlatform> create();44 static std::shared_ptr<InputPlatform> create();
45 static std::shared_ptr<InputPlatform> create(std::shared_ptr<InputReceiverReport> const& report);
4446
45protected:47protected:
46 InputPlatform() = default;48 InputPlatform() = default;
4749
=== added file 'include/shared/mir/input/input_receiver_report.h'
--- include/shared/mir/input/input_receiver_report.h 1970-01-01 00:00:00 +0000
+++ include/shared/mir/input/input_receiver_report.h 2013-11-06 00:09:36 +0000
@@ -0,0 +1,48 @@
1/*
2 * Copyright © 2013 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Robert Carr <robert.carr@canonical.com>
17 */
18
19#ifndef MIR_CLIENT_INPUT_RECEIVER_REPORT_H_
20#define MIR_CLIENT_INPUT_RECEIVER_REPORT_H_
21
22#include <mir_toolkit/event.h>
23
24namespace mir
25{
26namespace input
27{
28namespace receiver
29{
30
31class InputReceiverReport
32{
33public:
34 virtual ~InputReceiverReport() = default;
35
36 virtual void received_event(MirEvent const& event) = 0;
37
38protected:
39 InputReceiverReport() = default;
40 InputReceiverReport(InputReceiverReport const&) = delete;
41 InputReceiverReport& operator=(InputReceiverReport const&) = delete;
42};
43
44}
45}
46}
47
48#endif /* MIR_CLIENT_INPUT_RECEIVER_REPORT_H_ */
049
=== added file 'include/shared/mir/input/null_input_receiver_report.h'
--- include/shared/mir/input/null_input_receiver_report.h 1970-01-01 00:00:00 +0000
+++ include/shared/mir/input/null_input_receiver_report.h 2013-11-06 00:09:36 +0000
@@ -0,0 +1,46 @@
1/*
2 * Copyright © 2013 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Robert Carr <robert.carr@canonical.com>
17 */
18
19#ifndef MIR_CLIENT_NULL_INPUT_RECEIVER_REPORT_H_
20#define MIR_CLIENT_NULL_INPUT_RECEIVER_REPORT_H_
21
22#include "mir/input/input_receiver_report.h"
23
24#include <mir_toolkit/event.h>
25
26namespace mir
27{
28namespace input
29{
30namespace receiver
31{
32
33class NullInputReceiverReport : public InputReceiverReport
34{
35public:
36 NullInputReceiverReport() = default;
37 virtual ~NullInputReceiverReport() = default;
38
39 void received_event(MirEvent const& /* event */) {}
40};
41
42}
43}
44}
45
46#endif /* MIR_CLIENT_NULL_INPUT_RECEIVER_REPORT_H_ */
047
=== modified file 'src/client/CMakeLists.txt'
--- src/client/CMakeLists.txt 2013-10-21 16:02:28 +0000
+++ src/client/CMakeLists.txt 2013-11-06 00:09:36 +0000
@@ -29,6 +29,7 @@
29 mir_wait_handle.cpp29 mir_wait_handle.cpp
30 mir_surface.cpp30 mir_surface.cpp
31 logging/rpc_report.cpp31 logging/rpc_report.cpp
32 logging/input_receiver_report.cpp
32 default_connection_configuration.cpp33 default_connection_configuration.cpp
33 surface_map.cpp34 surface_map.cpp
34 lifecycle_control.cpp35 lifecycle_control.cpp
3536
=== modified file 'src/client/default_connection_configuration.cpp'
--- src/client/default_connection_configuration.cpp 2013-08-28 03:41:48 +0000
+++ src/client/default_connection_configuration.cpp 2013-11-06 00:09:36 +0000
@@ -24,7 +24,9 @@
24#include "mir/logging/dumb_console_logger.h"24#include "mir/logging/dumb_console_logger.h"
25#include "native_client_platform_factory.h"25#include "native_client_platform_factory.h"
26#include "mir/input/input_platform.h"26#include "mir/input/input_platform.h"
27#include "mir/input/null_input_receiver_report.h"
27#include "logging/rpc_report.h"28#include "logging/rpc_report.h"
29#include "logging/input_receiver_report.h"
28#include "lttng/rpc_report.h"30#include "lttng/rpc_report.h"
29#include "connection_surface_map.h"31#include "connection_surface_map.h"
30#include "lifecycle_control.h"32#include "lifecycle_control.h"
@@ -88,9 +90,9 @@
88mcl::DefaultConnectionConfiguration::the_input_platform()90mcl::DefaultConnectionConfiguration::the_input_platform()
89{91{
90 return input_platform(92 return input_platform(
91 []93 [this]
92 {94 {
93 return mir::input::receiver::InputPlatform::create();95 return mir::input::receiver::InputPlatform::create(the_input_receiver_report());
94 });96 });
95}97}
9698
@@ -118,6 +120,22 @@
118 });120 });
119}121}
120122
123std::shared_ptr<mir::input::receiver::InputReceiverReport>
124mcl::DefaultConnectionConfiguration::the_input_receiver_report()
125{
126 return input_receiver_report(
127 [this] () -> std::shared_ptr<mir::input::receiver::InputReceiverReport>
128 {
129 auto val_raw = getenv("MIR_CLIENT_INPUT_RECEIVER_REPORT");
130 std::string const val{val_raw ? val_raw : off_opt_val};
131
132 if (val == log_opt_val)
133 return std::make_shared<mcl::logging::InputReceiverReport>(the_logger());
134 else
135 return std::make_shared<mir::input::receiver::NullInputReceiverReport>();
136 });
137}
138
121std::shared_ptr<mcl::DisplayConfiguration> mcl::DefaultConnectionConfiguration::the_display_configuration()139std::shared_ptr<mcl::DisplayConfiguration> mcl::DefaultConnectionConfiguration::the_display_configuration()
122{140{
123 return display_configuration(141 return display_configuration(
124142
=== modified file 'src/client/default_connection_configuration.h'
--- src/client/default_connection_configuration.h 2013-08-28 03:41:48 +0000
+++ src/client/default_connection_configuration.h 2013-11-06 00:09:36 +0000
@@ -27,6 +27,13 @@
2727
28namespace mir28namespace mir
29{29{
30namespace input
31{
32namespace receiver
33{
34class InputReceiverReport;
35}
36}
30namespace client37namespace client
31{38{
3239
@@ -50,6 +57,7 @@
5057
51 virtual std::string the_socket_file();58 virtual std::string the_socket_file();
52 virtual std::shared_ptr<rpc::RpcReport> the_rpc_report();59 virtual std::shared_ptr<rpc::RpcReport> the_rpc_report();
60 virtual std::shared_ptr<input::receiver::InputReceiverReport> the_input_receiver_report();
5361
54protected:62protected:
55 CachedPtr<rpc::MirBasicRpcChannel> rpc_channel;63 CachedPtr<rpc::MirBasicRpcChannel> rpc_channel;
@@ -61,6 +69,7 @@
61 CachedPtr<LifecycleControl> lifecycle_control;69 CachedPtr<LifecycleControl> lifecycle_control;
6270
63 CachedPtr<rpc::RpcReport> rpc_report;71 CachedPtr<rpc::RpcReport> rpc_report;
72 CachedPtr<input::receiver::InputReceiverReport> input_receiver_report;
6473
65private:74private:
66 std::string const socket_file;75 std::string const socket_file;
6776
=== added file 'src/client/logging/input_receiver_report.cpp'
--- src/client/logging/input_receiver_report.cpp 1970-01-01 00:00:00 +0000
+++ src/client/logging/input_receiver_report.cpp 2013-11-06 00:09:36 +0000
@@ -0,0 +1,125 @@
1/*
2 * Copyright © 2013 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Robert Carr <robert.carr@canonical.com>
17 */
18
19#include "input_receiver_report.h"
20
21#include "mir/logging/logger.h"
22
23#include <boost/throw_exception.hpp>
24
25#include <sstream>
26#include <stdexcept>
27
28namespace ml = mir::logging;
29namespace mcll = mir::client::logging;
30
31namespace
32{
33std::string const component{"input-receiver"};
34}
35
36mcll::InputReceiverReport::InputReceiverReport(std::shared_ptr<ml::Logger> const& logger)
37 : logger{logger}
38{
39}
40
41namespace
42{
43
44static void format_key_event(std::stringstream &ss, MirKeyEvent const& ev)
45{
46 ss << "MirKeyEvent {" << std::endl;
47 ss << " device_id: " << ev.device_id << std::endl;
48 ss << " source_id: " << ev.source_id << std::endl;
49 ss << " action: " << ev.action << std::endl;
50 ss << " flags: " << ev.flags << std::endl;
51 ss << " modifiers: " << ev.modifiers << std::endl;
52 ss << " key_code: " << ev.key_code << std::endl;
53 ss << " scan_code: " << ev.scan_code << std::endl;
54 ss << " repeat_count: " << ev.repeat_count << std::endl;
55 ss << " down_time: " << ev.down_time << std::endl;
56 ss << " event_time: " << ev.event_time << std::endl;
57 ss << " is_system_key: " << ev.is_system_key << std::endl;
58 ss << "}";
59}
60static void format_motion_event(std::stringstream &ss, MirMotionEvent const& ev)
61{
62 ss << "MirMotionEvent{" << std::endl;
63 ss << " type: motion" << std::endl;
64 ss << " device_id: " << ev.device_id << std::endl;
65 ss << " source_id: " << ev.source_id << std::endl;
66 ss << " action: " << ev.action << std::endl;
67 ss << " flags: " << ev.flags << std::endl;
68 ss << " modifiers: " << ev.modifiers << std::endl;
69 ss << " edge_flags: " << ev.edge_flags << std::endl;
70 ss << " button_state: " << ev.button_state << std::endl;
71 ss << " x_offset: " << ev.x_offset << std::endl;
72 ss << " y_offset: " << ev.y_offset << std::endl;
73 ss << " x_precision: " << ev.x_precision << std::endl;
74 ss << " y_precision: " << ev.y_precision << std::endl;
75 ss << " down_time: " << ev.down_time << std::endl;
76 ss << " event_time: " << ev.event_time << std::endl;
77 ss << " pointer_count: " << ev.pointer_count << std::endl;
78 for (unsigned int i = 0; i < ev.pointer_count; i++)
79 {
80 ss << " pointer[" << i << "]{" << std::endl;
81 ss << " id: " << ev.pointer_coordinates[i].id << std::endl;
82 ss << " x: " << ev.pointer_coordinates[i].x << std::endl;
83 ss << " raw_x: " << ev.pointer_coordinates[i].raw_x << std::endl;
84 ss << " y: " << ev.pointer_coordinates[i].y << std::endl;
85 ss << " raw_y: " << ev.pointer_coordinates[i].raw_y << std::endl;
86 ss << " touch_major: " << ev.pointer_coordinates[i].touch_major << std::endl;
87 ss << " touch_minor: " << ev.pointer_coordinates[i].touch_minor << std::endl;
88 ss << " size: " << ev.pointer_coordinates[i].size << std::endl;
89 ss << " pressure: " << ev.pointer_coordinates[i].pressure << std::endl;
90 ss << " orientation: " << ev.pointer_coordinates[i].orientation << std::endl;
91 ss << " vscroll: " << ev.pointer_coordinates[i].vscroll << std::endl;
92 ss << " hscroll: " << ev.pointer_coordinates[i].hscroll << std::endl;
93 ss << " }" << std::endl;
94 }
95 ss << "}";
96}
97
98static void format_event(std::stringstream &ss, MirEvent const& ev)
99{
100 switch (ev.type)
101 {
102 case mir_event_type_key:
103 format_key_event(ss, ev.key);
104 break;
105 case mir_event_type_motion:
106 format_motion_event(ss, ev.motion);
107 break;
108 default:
109 BOOST_THROW_EXCEPTION(std::runtime_error("Unexpected event type"));
110 }
111}
112
113}
114
115void mcll::InputReceiverReport::received_event(
116 MirEvent const& event)
117{
118 std::stringstream ss;
119
120 ss << "Received event:" << std::endl;
121
122 format_event(ss, event);
123
124 logger->log<ml::Logger::debug>(ss.str(), component);
125}
0126
=== added file 'src/client/logging/input_receiver_report.h'
--- src/client/logging/input_receiver_report.h 1970-01-01 00:00:00 +0000
+++ src/client/logging/input_receiver_report.h 2013-11-06 00:09:36 +0000
@@ -0,0 +1,54 @@
1/*
2 * Copyright © 2013 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Alexandros Frantzis <alexandros.frantzis@canonical.com>
17 */
18
19#ifndef MIR_CLIENT_LOGGING_INPUT_RECEIVER_REPORT_H_
20#define MIR_CLIENT_LOGGING_INPUT_RECEIVER_REPORT_H_
21
22#include "mir/input/input_receiver_report.h"
23
24#include <memory>
25
26namespace mir
27{
28
29namespace logging
30{
31class Logger;
32}
33
34namespace client
35{
36namespace logging
37{
38
39class InputReceiverReport : public input::receiver::InputReceiverReport
40{
41public:
42 InputReceiverReport(std::shared_ptr<mir::logging::Logger> const& logger);
43
44 void received_event(MirEvent const& event) override;
45
46private:
47 std::shared_ptr<mir::logging::Logger> const logger;
48};
49
50}
51}
52}
53
54#endif /* MIR_CLIENT_LOGGING_INPUT_RECEIVER_REPORT_H_ */
055
=== modified file 'src/shared/input/android/android_input_platform.cpp'
--- src/shared/input/android/android_input_platform.cpp 2013-05-13 23:20:52 +0000
+++ src/shared/input/android/android_input_platform.cpp 2013-11-06 00:09:36 +0000
@@ -20,10 +20,13 @@
20#include "android_input_receiver.h"20#include "android_input_receiver.h"
21#include "android_input_receiver_thread.h"21#include "android_input_receiver_thread.h"
2222
23#include "mir/input/null_input_receiver_report.h"
24
23namespace mircv = mir::input::receiver;25namespace mircv = mir::input::receiver;
24namespace mircva = mircv::android;26namespace mircva = mircv::android;
2527
26mircva::AndroidInputPlatform::AndroidInputPlatform()28mircva::AndroidInputPlatform::AndroidInputPlatform(std::shared_ptr<mircv::InputReceiverReport> const& report)
29 : report(report)
27{30{
28}31}
2932
@@ -34,11 +37,16 @@
34std::shared_ptr<mircv::InputReceiverThread> mircva::AndroidInputPlatform::create_input_thread(37std::shared_ptr<mircv::InputReceiverThread> mircva::AndroidInputPlatform::create_input_thread(
35 int fd, std::function<void(MirEvent*)> const& callback)38 int fd, std::function<void(MirEvent*)> const& callback)
36{39{
37 auto receiver = std::make_shared<mircva::InputReceiver>(fd);40 auto receiver = std::make_shared<mircva::InputReceiver>(fd, report);
38 return std::make_shared<mircva::InputReceiverThread>(receiver, callback);41 return std::make_shared<mircva::InputReceiverThread>(receiver, callback);
39}42}
4043
41std::shared_ptr<mircv::InputPlatform> mircv::InputPlatform::create()44std::shared_ptr<mircv::InputPlatform> mircv::InputPlatform::create()
42{45{
43 return std::make_shared<mircva::AndroidInputPlatform>();46 return create(std::make_shared<mircv::NullInputReceiverReport>());
47}
48
49std::shared_ptr<mircv::InputPlatform> mircv::InputPlatform::create(std::shared_ptr<mircv::InputReceiverReport> const& report)
50{
51 return std::make_shared<mircva::AndroidInputPlatform>(report);
44}52}
4553
=== modified file 'src/shared/input/android/android_input_platform.h'
--- src/shared/input/android/android_input_platform.h 2013-05-13 23:20:52 +0000
+++ src/shared/input/android/android_input_platform.h 2013-11-06 00:09:36 +0000
@@ -34,7 +34,7 @@
34class AndroidInputPlatform : public InputPlatform34class AndroidInputPlatform : public InputPlatform
35{35{
36public:36public:
37 AndroidInputPlatform();37 AndroidInputPlatform(std::shared_ptr<InputReceiverReport> const& report);
38 virtual ~AndroidInputPlatform(); 38 virtual ~AndroidInputPlatform();
3939
40 std::shared_ptr<InputReceiverThread> create_input_thread(int fd, std::function<void(MirEvent *)> const& callback);40 std::shared_ptr<InputReceiverThread> create_input_thread(int fd, std::function<void(MirEvent *)> const& callback);
@@ -42,6 +42,9 @@
42protected:42protected:
43 AndroidInputPlatform(const AndroidInputPlatform&) = delete;43 AndroidInputPlatform(const AndroidInputPlatform&) = delete;
44 AndroidInputPlatform& operator=(const AndroidInputPlatform&) = delete;44 AndroidInputPlatform& operator=(const AndroidInputPlatform&) = delete;
45
46private:
47 std::shared_ptr<InputReceiverReport> const report;
45};48};
4649
47}50}
4851
=== modified file 'src/shared/input/android/android_input_receiver.cpp'
--- src/shared/input/android/android_input_receiver.cpp 2013-05-24 18:20:37 +0000
+++ src/shared/input/android/android_input_receiver.cpp 2013-11-06 00:09:36 +0000
@@ -19,6 +19,7 @@
19#include "android_input_receiver.h"19#include "android_input_receiver.h"
2020
21#include "mir/input/xkb_mapper.h"21#include "mir/input/xkb_mapper.h"
22#include "mir/input/input_receiver_report.h"
22#include "mir/input/android/android_input_lexicon.h"23#include "mir/input/android/android_input_lexicon.h"
2324
24#include <androidfw/InputTransport.h>25#include <androidfw/InputTransport.h>
@@ -29,8 +30,10 @@
2930
30namespace mia = mir::input::android;31namespace mia = mir::input::android;
3132
32mircva::InputReceiver::InputReceiver(droidinput::sp<droidinput::InputChannel> const& input_channel)33mircva::InputReceiver::InputReceiver(droidinput::sp<droidinput::InputChannel> const& input_channel,
34 std::shared_ptr<mircv::InputReceiverReport> const& report)
33 : input_channel(input_channel),35 : input_channel(input_channel),
36 report(report),
34 input_consumer(std::make_shared<droidinput::InputConsumer>(input_channel)),37 input_consumer(std::make_shared<droidinput::InputConsumer>(input_channel)),
35 looper(new droidinput::Looper(true)),38 looper(new droidinput::Looper(true)),
36 fd_added(false),39 fd_added(false),
@@ -38,8 +41,10 @@
38{41{
39}42}
4043
41mircva::InputReceiver::InputReceiver(int fd)44mircva::InputReceiver::InputReceiver(int fd,
45 std::shared_ptr<mircv::InputReceiverReport> const& report)
42 : input_channel(new droidinput::InputChannel(droidinput::String8(""), fd)), 46 : input_channel(new droidinput::InputChannel(droidinput::String8(""), fd)),
47 report(report),
43 input_consumer(std::make_shared<droidinput::InputConsumer>(input_channel)),48 input_consumer(std::make_shared<droidinput::InputConsumer>(input_channel)),
44 looper(new droidinput::Looper(true)),49 looper(new droidinput::Looper(true)),
45 fd_added(false),50 fd_added(false),
@@ -84,6 +89,8 @@
84 map_key_event(xkb_mapper, ev);89 map_key_event(xkb_mapper, ev);
8590
86 input_consumer->sendFinishedSignal(event_sequence_id, true);91 input_consumer->sendFinishedSignal(event_sequence_id, true);
92
93 report->received_event(ev);
8794
88 return true;95 return true;
89 }96 }
9097
=== modified file 'src/shared/input/android/android_input_receiver.h'
--- src/shared/input/android/android_input_receiver.h 2013-05-24 18:20:37 +0000
+++ src/shared/input/android/android_input_receiver.h 2013-11-06 00:09:36 +0000
@@ -43,6 +43,7 @@
43namespace receiver43namespace receiver
44{44{
45class XKBMapper;45class XKBMapper;
46class InputReceiverReport;
4647
47namespace android48namespace android
48{49{
@@ -51,8 +52,10 @@
51class InputReceiver52class InputReceiver
52{53{
53public:54public:
54 InputReceiver(droidinput::sp<droidinput::InputChannel> const& input_channel);55 InputReceiver(droidinput::sp<droidinput::InputChannel> const& input_channel,
55 InputReceiver(int fd);56 std::shared_ptr<InputReceiverReport> const& report);
57 InputReceiver(int fd,
58 std::shared_ptr<InputReceiverReport> const& report);
5659
57 virtual ~InputReceiver();60 virtual ~InputReceiver();
58 int fd() const;61 int fd() const;
@@ -71,6 +74,8 @@
7174
72private:75private:
73 droidinput::sp<droidinput::InputChannel> input_channel;76 droidinput::sp<droidinput::InputChannel> input_channel;
77 std::shared_ptr<InputReceiverReport> const report;
78
74 std::shared_ptr<droidinput::InputConsumer> input_consumer;79 std::shared_ptr<droidinput::InputConsumer> input_consumer;
75 droidinput::PreallocatedInputEventFactory event_factory;80 droidinput::PreallocatedInputEventFactory event_factory;
76 droidinput::sp<droidinput::Looper> looper;81 droidinput::sp<droidinput::Looper> looper;
7782
=== modified file 'tests/unit-tests/client/input/test_android_input_receiver.cpp'
--- tests/unit-tests/client/input/test_android_input_receiver.cpp 2013-05-31 16:06:07 +0000
+++ tests/unit-tests/client/input/test_android_input_receiver.cpp 2013-11-06 00:09:36 +0000
@@ -17,8 +17,10 @@
17 */17 */
1818
19#include "src/shared/input/android/android_input_receiver.h"19#include "src/shared/input/android/android_input_receiver.h"
20#include "mir/input/null_input_receiver_report.h"
20#include "mir_toolkit/event.h"21#include "mir_toolkit/event.h"
2122
23
22#include <androidfw/InputTransport.h>24#include <androidfw/InputTransport.h>
2325
24#include <gmock/gmock.h>26#include <gmock/gmock.h>
@@ -27,7 +29,8 @@
27#include <unistd.h>29#include <unistd.h>
28#include <memory>30#include <memory>
2931
30namespace mircva = mir::input::receiver::android;32namespace mircv = mir::input::receiver;
33namespace mircva = mircv::android;
3134
32namespace droidinput = android;35namespace droidinput = android;
3336
@@ -142,14 +145,14 @@
142145
143TEST_F(AndroidInputReceiverSetup, receiever_takes_channel_fd)146TEST_F(AndroidInputReceiverSetup, receiever_takes_channel_fd)
144{147{
145 mircva::InputReceiver receiver(client_fd);148 mircva::InputReceiver receiver(client_fd, std::make_shared<mircv::NullInputReceiverReport>());
146 149
147 EXPECT_EQ(client_fd, receiver.fd());150 EXPECT_EQ(client_fd, receiver.fd());
148}151}
149152
150TEST_F(AndroidInputReceiverSetup, receiver_receives_key_events)153TEST_F(AndroidInputReceiverSetup, receiver_receives_key_events)
151{154{
152 mircva::InputReceiver receiver(client_fd);155 mircva::InputReceiver receiver(client_fd, std::make_shared<mircv::NullInputReceiverReport>());
153 TestingInputProducer producer(server_fd);156 TestingInputProducer producer(server_fd);
154 157
155 producer.produce_a_key_event();158 producer.produce_a_key_event();
@@ -165,7 +168,7 @@
165168
166TEST_F(AndroidInputReceiverSetup, receiver_handles_events)169TEST_F(AndroidInputReceiverSetup, receiver_handles_events)
167{170{
168 mircva::InputReceiver receiver(client_fd);171 mircva::InputReceiver receiver(client_fd, std::make_shared<mircv::NullInputReceiverReport>());
169 TestingInputProducer producer(server_fd);172 TestingInputProducer producer(server_fd);
170 173
171 producer.produce_a_key_event();174 producer.produce_a_key_event();
@@ -181,7 +184,7 @@
181184
182TEST_F(AndroidInputReceiverSetup, receiver_consumes_batched_motion_events)185TEST_F(AndroidInputReceiverSetup, receiver_consumes_batched_motion_events)
183{186{
184 mircva::InputReceiver receiver(client_fd);187 mircva::InputReceiver receiver(client_fd, std::make_shared<mircv::NullInputReceiverReport>());
185 TestingInputProducer producer(server_fd);188 TestingInputProducer producer(server_fd);
186 189
187 // Produce 3 motion events before client handles any.190 // Produce 3 motion events before client handles any.
188191
=== modified file 'tests/unit-tests/client/input/test_android_input_receiver_thread.cpp'
--- tests/unit-tests/client/input/test_android_input_receiver_thread.cpp 2013-05-13 23:20:52 +0000
+++ tests/unit-tests/client/input/test_android_input_receiver_thread.cpp 2013-11-06 00:09:36 +0000
@@ -19,6 +19,8 @@
19#include "src/shared/input/android/android_input_receiver_thread.h"19#include "src/shared/input/android/android_input_receiver_thread.h"
20#include "src/shared/input/android/android_input_receiver.h"20#include "src/shared/input/android/android_input_receiver.h"
2121
22#include "mir/input/null_input_receiver_report.h"
23
22#include "mir_toolkit/mir_client_library.h"24#include "mir_toolkit/mir_client_library.h"
2325
24#include <gtest/gtest.h>26#include <gtest/gtest.h>
@@ -30,7 +32,8 @@
3032
31#include <fcntl.h>33#include <fcntl.h>
3234
33namespace mircva = mir::input::receiver::android;35namespace mircv = mir::input::receiver;
36namespace mircva = mircv::android;
3437
35namespace38namespace
36{39{
@@ -43,7 +46,7 @@
43struct MockInputReceiver : public mircva::InputReceiver46struct MockInputReceiver : public mircva::InputReceiver
44{47{
45 MockInputReceiver(int fd)48 MockInputReceiver(int fd)
46 : InputReceiver(fd)49 : InputReceiver(fd, std::make_shared<mircv::NullInputReceiverReport>())
47 {50 {
48 }51 }
49 MOCK_METHOD1(next_event, bool(MirEvent &));52 MOCK_METHOD1(next_event, bool(MirEvent &));

Subscribers

People subscribed via source and target branches