summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Laner <laner@itestra.de>2014-03-07 19:41:32 +0100
committerStefan Laner <laner@itestra.de>2014-03-07 19:41:32 +0100
commit38ef38e4ac3afef2563eac3eff684419ac97f476 (patch)
tree5199867864422d14bee22c2ee798b488f32cd0cc
parent3cc632bdf160300ac5bc300931ff53f1e11a1c1b (diff)
downloadgenivi-common-api-dbus-runtime-38ef38e4ac3afef2563eac3eff684419ac97f476.tar.gz
fix for GENIVI bug 164 "Interface names starting with org.freedesktop.*
are ignored"
-rw-r--r--src/CommonAPI/DBus/DBusServiceRegistry.cpp2
-rw-r--r--src/CommonAPI/DBus/DBusServiceRegistry.h2
-rw-r--r--src/test/DBusProxyTest.cpp39
3 files changed, 37 insertions, 6 deletions
diff --git a/src/CommonAPI/DBus/DBusServiceRegistry.cpp b/src/CommonAPI/DBus/DBusServiceRegistry.cpp
index ba74f50..8178bca 100644
--- a/src/CommonAPI/DBus/DBusServiceRegistry.cpp
+++ b/src/CommonAPI/DBus/DBusServiceRegistry.cpp
@@ -730,7 +730,7 @@ bool DBusServiceRegistry::introspectDBusObjectPath(const std::string& dbusServic
*
* This is the other end of checking if a dbus object path is available.
* On success it'll extract all interface names from the xml data response.
- * Special interfaces that start with org.freedesktop will be ignored.
+ * Special interfaces that start with "org.freedesktop.DBus." will be ignored.
*
* @param status
* @param xmlData
diff --git a/src/CommonAPI/DBus/DBusServiceRegistry.h b/src/CommonAPI/DBus/DBusServiceRegistry.h
index 09f020a..6fdbc3c 100644
--- a/src/CommonAPI/DBus/DBusServiceRegistry.h
+++ b/src/CommonAPI/DBus/DBusServiceRegistry.h
@@ -328,7 +328,7 @@ class DBusServiceRegistry: public std::enable_shared_from_this<DBusServiceRegist
inline const bool isOrgFreedesktopDBusInterface(const std::string& dbusInterfaceName) {
- return dbusInterfaceName.find("org.freedesktop.") == 0;
+ return dbusInterfaceName.find("org.freedesktop.DBus.") == 0;
}
std::thread::id notificationThread_;
diff --git a/src/test/DBusProxyTest.cpp b/src/test/DBusProxyTest.cpp
index 1893a70..fd398c2 100644
--- a/src/test/DBusProxyTest.cpp
+++ b/src/test/DBusProxyTest.cpp
@@ -53,6 +53,7 @@ static const std::string interfaceName = "CommonAPI.DBus.tests.DBusProxyTestInte
static const std::string busName = "CommonAPI.DBus.tests.DBusProxyTestService";
static const std::string objectPath = "/CommonAPI/DBus/tests/DBusProxyTestService";
static const std::string objectPathExtended = "/CommonAPI/DBus/tests/DBusProxyTestService2";
+static const std::string commonApiAddressFreedesktop = "local:org.freedesktop.XYZ:CommonAPI.DBus.tests.DBusProxyTestInterface";
class ProxyTest: public ::testing::Test {
@@ -460,7 +461,7 @@ protected:
std::this_thread::sleep_for(std::chrono::milliseconds(300));
}
- void registerTestStub() {
+ void registerTestStub(const std::string commonApiAddress) {
stubDefault_ = std::make_shared<commonapi::tests::TestInterfaceStubDefault>();
bool isTestStubAdapterRegistered_ = runtime_->getServicePublisher()->registerService<
commonapi::tests::TestInterfaceStub>(stubDefault_, commonApiAddress, serviceFactory_);
@@ -469,7 +470,7 @@ protected:
usleep(100000);
}
- void deregisterTestStub() {
+ void deregisterTestStub(const std::string commonApiAddress) {
const bool isStubAdapterUnregistered = CommonAPI::DBus::DBusServicePublisher::getInstance()->unregisterService(
commonApiAddress);
ASSERT_TRUE(isStubAdapterUnregistered);
@@ -515,7 +516,7 @@ protected:
};
TEST_F(ProxyTest2, DBusProxyStatusEventAfterServiceIsRegistered) {
- registerTestStub();
+ registerTestStub(commonApiAddress);
proxyDBusConnection_ = CommonAPI::DBus::DBusConnection::getSessionBus();
ASSERT_TRUE(proxyDBusConnection_->connect());
@@ -533,7 +534,7 @@ TEST_F(ProxyTest2, DBusProxyStatusEventAfterServiceIsRegistered) {
EXPECT_TRUE(proxyWaitForAvailabilityStatus(CommonAPI::AvailabilityStatus::AVAILABLE));
- deregisterTestStub();
+ deregisterTestStub(commonApiAddress);
usleep(100000);
EXPECT_TRUE(proxyWaitForAvailabilityStatus(CommonAPI::AvailabilityStatus::NOT_AVAILABLE));
@@ -541,6 +542,36 @@ TEST_F(ProxyTest2, DBusProxyStatusEventAfterServiceIsRegistered) {
proxyDeregisterForAvailabilityStatus();
}
+TEST_F(ProxyTest2, DBusProxyCanUseOrgFreedesktopAddress) {
+ registerTestStub(commonApiAddressFreedesktop);
+
+ std::shared_ptr<commonapi::tests::TestInterfaceProxyDefault> proxy =
+ serviceFactory_->buildProxy<commonapi::tests::TestInterfaceProxy>(commonApiAddressFreedesktop);
+
+ for (int i = 0; i < 100; i++) {
+ if (proxy->isAvailable())
+ break;
+ std::this_thread::sleep_for(std::chrono::milliseconds(100));
+ }
+
+ const bool proxyIsAvailable = proxy->isAvailable();
+
+ EXPECT_TRUE(proxyIsAvailable);
+
+ if(proxyIsAvailable) { // if we are not available, we failed the test and do not check a method call
+ bool wasCalled = false;
+ proxy->testEmptyMethodAsync(
+ [&](const CommonAPI::CallStatus& callStatus) {
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ wasCalled = true;
+ });
+ usleep(100000);
+ EXPECT_TRUE(wasCalled);
+ }
+
+ deregisterTestStub(commonApiAddressFreedesktop);
+}
+
#ifndef WIN32
int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv);