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
1=== modified file 'include/core/dbus/impl/property.h'
2--- include/core/dbus/impl/property.h 2014-01-20 22:04:16 +0000
3+++ include/core/dbus/impl/property.h 2014-06-10 08:44:31 +0000
4@@ -161,10 +161,14 @@
5 try
6 {
7 auto value = arg.as<typename PropertyType::ValueType>();
8- set(value);
9+ Super::set(value);
10+ }
11+ catch (const std::exception &e){
12+ std::cout << __PRETTY_FUNCTION__ << ": " << e.what() << std::endl;
13 }
14 catch (...)
15 {
16+ std::cout << __PRETTY_FUNCTION__ << ": " << "Unknown exception." << std::endl;
17 }
18 }
19 }
20
21=== modified file 'tests/service_test.cpp'
22--- tests/service_test.cpp 2014-02-18 06:43:55 +0000
23+++ tests/service_test.cpp 2014-06-10 08:44:31 +0000
24@@ -82,11 +82,25 @@
25 auto writable_property = skeleton->get_property<test::Service::Properties::Dummy>();
26 writable_property->set(expected_value);
27
28- skeleton->install_method_handler<test::Service::Method>([bus, skeleton, expected_value](const dbus::Message::Ptr& msg)
29+ auto readonly_property = skeleton->get_property<test::Service::Properties::ReadOnly>();
30+ readonly_property->set(7);
31+
32+ skeleton->install_method_handler<test::Service::Method>([bus, skeleton, &readonly_property, expected_value](const dbus::Message::Ptr& msg)
33 {
34 auto reply = dbus::Message::make_method_return(msg);
35 reply->writer() << expected_value;
36 bus->send(reply);
37+
38+ readonly_property->set(expected_value);
39+ auto changed_signal = skeleton->get_signal<core::dbus::interfaces::Properties::Signals::PropertiesChanged>();
40+ core::dbus::interfaces::Properties::Signals::PropertiesChanged::ArgumentType
41+ args("this.is.unlikely.to.exist.Service",
42+ {{test::Service::Properties::ReadOnly::name(),
43+ core::dbus::types::TypedVariant<test::Service::Properties::ReadOnly::ValueType>(expected_value)}},
44+ {});
45+ skeleton->emit_signal<core::dbus::interfaces::Properties::Signals::PropertiesChanged, core::dbus::interfaces::Properties::Signals::PropertiesChanged::ArgumentType>(args);
46+ changed_signal->emit(args);
47+
48 skeleton->emit_signal<test::Service::Signals::Dummy, int64_t>(expected_value);
49 });
50
51@@ -118,6 +132,14 @@
52 {
53 std::cout << "Dummy property changed: " << d << std::endl;
54 });
55+
56+ auto readonly_property = stub->get_property<test::Service::Properties::ReadOnly>();
57+ EXPECT_EQ(readonly_property->get(), 7);
58+ std::uint32_t changed_value = 0;
59+ readonly_property->changed().connect([&changed_value](std::uint32_t value){
60+ changed_value = value;
61+ });
62+
63 auto signal = stub->get_signal<test::Service::Signals::Dummy>();
64 int64_t received_signal_value = -1;
65 signal->connect([bus, &received_signal_value](const int32_t& value)
66@@ -144,6 +166,8 @@
67 t.join();
68
69 EXPECT_EQ(expected_value, received_signal_value);
70+ EXPECT_EQ(expected_value, readonly_property->get());
71+ EXPECT_EQ(changed_value, expected_value);
72
73 return ::testing::Test::HasFailure() ? core::posix::exit::Status::failure : core::posix::exit::Status::success;
74 };
75
76=== modified file 'tests/test_service.h'
77--- tests/test_service.h 2014-03-05 06:58:15 +0000
78+++ tests/test_service.h 2014-06-10 08:44:31 +0000
79@@ -68,6 +68,18 @@
80 static const bool readable = true;
81 static const bool writable = true;
82 };
83+
84+ struct ReadOnly
85+ {
86+ inline static std::string name()
87+ {
88+ return "ReadOnly";
89+ };
90+ typedef Service Interface;
91+ typedef std::uint32_t ValueType;
92+ static const bool readable = true;
93+ static const bool writable = false;
94+ };
95 };
96
97 struct Interfaces

Subscribers

People subscribed via source and target branches