Merge lp:~kaijanmaki/dbus-cpp/read-only-properties-changed-fix into lp:dbus-cpp

Proposed by Antti Kaijanmäki
Status: Merged
Approved by: Thomas Voß
Approved revision: 57
Merged at revision: 60
Proposed branch: lp:~kaijanmaki/dbus-cpp/read-only-properties-changed-fix
Merge into: lp:dbus-cpp
Diff against target: 97 lines (+42/-2)
3 files modified
include/core/dbus/impl/property.h (+5/-1)
tests/service_test.cpp (+25/-1)
tests/test_service.h (+12/-0)
To merge this branch: bzr merge lp:~kaijanmaki/dbus-cpp/read-only-properties-changed-fix
Reviewer Review Type Date Requested Status
Thomas Voß (community) Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+221839@code.launchpad.net

Commit message

Fix read-only property PropertiesChanged updates.

Description of the change

When we have a read-only property which receives a PropertiesChanged signal, we must use the Super::set() as plain set() will fail on the read-only check.

To post a comment you must log in.
Revision history for this message
Antti Kaijanmäki (kaijanmaki) wrote :

The test-case passes after making the change, but now that the possible exceptions are not silently discarded I'm seeing this during the test run:
[ RUN ] Service.AddingServiceAndObjectAndCallingIntoItSucceeds
void core::dbus::Property<T>::handle_changed(const core::dbus::types::Variant&) [with PropertyType = test::Service::Properties::ReadOnly]: Mismatch between expected and actual type reported by iterator:
         Expected: uint32
         Actual: invalid
void core::dbus::Property<T>::handle_changed(const core::dbus::types::Variant&) [with PropertyType = test::Service::Properties::ReadOnly]: Mismatch between expected and actual type reported by iterator:
         Expected: uint32
         Actual: invalid

That must be because of the fact that the Variant is consumed by the first caller of Variant::as<>().

But to emphasize: The test passes and everything seems to work properly even though we now get that exception caught.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:56
No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want a jenkins rebuild you need to trigger it yourself):
https://code.launchpad.net/~kaijanmaki/dbus-cpp/read-only-properties-changed-fix/+merge/221839/+edit-commit-message

http://jenkins.qa.ubuntu.com/job/dbus-cpp-ci/162/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/dbus-cpp-utopic-amd64-ci/2
    SUCCESS: http://jenkins.qa.ubuntu.com/job/dbus-cpp-utopic-armhf-ci/2
        deb: http://jenkins.qa.ubuntu.com/job/dbus-cpp-utopic-armhf-ci/2/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/dbus-cpp-utopic-i386-ci/2

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/dbus-cpp-ci/162/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Thomas Voß (thomas-voss) :
review: Needs Fixing
57. By Antti Kaijanmäki

review fixes.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Thomas Voß (thomas-voss) wrote :

Could you please file a bug for the wrong behavior with variants. Other than that: LGTM.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'include/core/dbus/impl/property.h'
--- include/core/dbus/impl/property.h 2014-01-20 22:04:16 +0000
+++ include/core/dbus/impl/property.h 2014-06-10 08:44:31 +0000
@@ -161,10 +161,14 @@
161 try161 try
162 {162 {
163 auto value = arg.as<typename PropertyType::ValueType>();163 auto value = arg.as<typename PropertyType::ValueType>();
164 set(value);164 Super::set(value);
165 }
166 catch (const std::exception &e){
167 std::cout << __PRETTY_FUNCTION__ << ": " << e.what() << std::endl;
165 }168 }
166 catch (...)169 catch (...)
167 {170 {
171 std::cout << __PRETTY_FUNCTION__ << ": " << "Unknown exception." << std::endl;
168 }172 }
169}173}
170}174}
171175
=== modified file 'tests/service_test.cpp'
--- tests/service_test.cpp 2014-02-18 06:43:55 +0000
+++ tests/service_test.cpp 2014-06-10 08:44:31 +0000
@@ -82,11 +82,25 @@
82 auto writable_property = skeleton->get_property<test::Service::Properties::Dummy>();82 auto writable_property = skeleton->get_property<test::Service::Properties::Dummy>();
83 writable_property->set(expected_value);83 writable_property->set(expected_value);
8484
85 skeleton->install_method_handler<test::Service::Method>([bus, skeleton, expected_value](const dbus::Message::Ptr& msg)85 auto readonly_property = skeleton->get_property<test::Service::Properties::ReadOnly>();
86 readonly_property->set(7);
87
88 skeleton->install_method_handler<test::Service::Method>([bus, skeleton, &readonly_property, expected_value](const dbus::Message::Ptr& msg)
86 {89 {
87 auto reply = dbus::Message::make_method_return(msg);90 auto reply = dbus::Message::make_method_return(msg);
88 reply->writer() << expected_value;91 reply->writer() << expected_value;
89 bus->send(reply);92 bus->send(reply);
93
94 readonly_property->set(expected_value);
95 auto changed_signal = skeleton->get_signal<core::dbus::interfaces::Properties::Signals::PropertiesChanged>();
96 core::dbus::interfaces::Properties::Signals::PropertiesChanged::ArgumentType
97 args("this.is.unlikely.to.exist.Service",
98 {{test::Service::Properties::ReadOnly::name(),
99 core::dbus::types::TypedVariant<test::Service::Properties::ReadOnly::ValueType>(expected_value)}},
100 {});
101 skeleton->emit_signal<core::dbus::interfaces::Properties::Signals::PropertiesChanged, core::dbus::interfaces::Properties::Signals::PropertiesChanged::ArgumentType>(args);
102 changed_signal->emit(args);
103
90 skeleton->emit_signal<test::Service::Signals::Dummy, int64_t>(expected_value);104 skeleton->emit_signal<test::Service::Signals::Dummy, int64_t>(expected_value);
91 });105 });
92106
@@ -118,6 +132,14 @@
118 {132 {
119 std::cout << "Dummy property changed: " << d << std::endl;133 std::cout << "Dummy property changed: " << d << std::endl;
120 });134 });
135
136 auto readonly_property = stub->get_property<test::Service::Properties::ReadOnly>();
137 EXPECT_EQ(readonly_property->get(), 7);
138 std::uint32_t changed_value = 0;
139 readonly_property->changed().connect([&changed_value](std::uint32_t value){
140 changed_value = value;
141 });
142
121 auto signal = stub->get_signal<test::Service::Signals::Dummy>();143 auto signal = stub->get_signal<test::Service::Signals::Dummy>();
122 int64_t received_signal_value = -1;144 int64_t received_signal_value = -1;
123 signal->connect([bus, &received_signal_value](const int32_t& value)145 signal->connect([bus, &received_signal_value](const int32_t& value)
@@ -144,6 +166,8 @@
144 t.join();166 t.join();
145167
146 EXPECT_EQ(expected_value, received_signal_value);168 EXPECT_EQ(expected_value, received_signal_value);
169 EXPECT_EQ(expected_value, readonly_property->get());
170 EXPECT_EQ(changed_value, expected_value);
147171
148 return ::testing::Test::HasFailure() ? core::posix::exit::Status::failure : core::posix::exit::Status::success;172 return ::testing::Test::HasFailure() ? core::posix::exit::Status::failure : core::posix::exit::Status::success;
149 };173 };
150174
=== modified file 'tests/test_service.h'
--- tests/test_service.h 2014-03-05 06:58:15 +0000
+++ tests/test_service.h 2014-06-10 08:44:31 +0000
@@ -68,6 +68,18 @@
68 static const bool readable = true;68 static const bool readable = true;
69 static const bool writable = true;69 static const bool writable = true;
70 };70 };
71
72 struct ReadOnly
73 {
74 inline static std::string name()
75 {
76 return "ReadOnly";
77 };
78 typedef Service Interface;
79 typedef std::uint32_t ValueType;
80 static const bool readable = true;
81 static const bool writable = false;
82 };
71 };83 };
7284
73 struct Interfaces85 struct Interfaces

Subscribers

People subscribed via source and target branches