summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJürgen Gehring <Juergen.Gehring@bmw.de>2014-04-14 11:41:50 +0200
committerGerrit Code Review <qqmthk1@lpmodthk02.bmwgroup.net>2014-04-14 11:41:50 +0200
commit88755ec3a7fb13c17e0e53fe49dc7cf0d69b72c5 (patch)
tree04c60051023c1c58fce61c3bbe859f490cb55c05
parent31531e88ab2358934e7f5dcdd14e1d5dd662627c (diff)
parentcfa691dead04acffe08155733689f1932054f425 (diff)
downloadgenivi-common-api-dbus-runtime-88755ec3a7fb13c17e0e53fe49dc7cf0d69b72c5.tar.gz
Merge "improved DBusBroadcastTest and DBusLoadTest"
-rw-r--r--.gitignore3
-rw-r--r--src/test/DBusBroadcastTest.cpp43
-rw-r--r--src/test/DBusLoadTest.cpp10
3 files changed, 50 insertions, 6 deletions
diff --git a/.gitignore b/.gitignore
index 23ee12a..746b757 100644
--- a/.gitignore
+++ b/.gitignore
@@ -56,3 +56,6 @@
/DBusSelectiveBroadcastTest
/DBusManagedTest
/DBusPolymorphicTest
+/DBusBroadcastTest
+/DBusFreedesktopPropertiesTest
+/DBusLoadTest
diff --git a/src/test/DBusBroadcastTest.cpp b/src/test/DBusBroadcastTest.cpp
index 9905155..646e663 100644
--- a/src/test/DBusBroadcastTest.cpp
+++ b/src/test/DBusBroadcastTest.cpp
@@ -170,7 +170,8 @@ TEST_F(DBusBroadcastTest, ProxysCanHandleBroadcast) {
bool callbackArrived = false;
broadcastEvent.subscribeCancellableListener([&](uint32_t intParam, std::string stringParam) -> CommonAPI::SubscriptionStatus {
- callbackArrived = true; return CommonAPI::SubscriptionStatus::RETAIN;
+ callbackArrived = true;
+ return CommonAPI::SubscriptionStatus::RETAIN;
});
stub->fireTestPredefinedTypeBroadcastEvent(2, "xyz");
@@ -235,6 +236,43 @@ TEST_F(DBusBroadcastTest, ProxysCanUnsubscribeFromBroadcastAndSubscribeAgain) {
broadcastEvent.unsubscribe(broadcastSubscription2);
}
+TEST_F(DBusBroadcastTest, ProxysCanUnsubscribeFromBroadcastAndSubscribeAgainInALoop) {
+ auto stub = std::make_shared<SelectiveBroadcastSender>();
+
+ bool serviceRegistered = servicePublisher_->registerService(stub, serviceAddress_, stubFactory_);
+ for (unsigned int i = 0; !serviceRegistered && i < 100; ++i) {
+ serviceRegistered = servicePublisher_->registerService(stub, serviceAddress_, stubFactory_);
+ usleep(10000);
+ }
+ ASSERT_TRUE(serviceRegistered);
+
+
+ auto proxy = proxyFactory_->buildProxy<commonapi::tests::TestInterfaceProxy>(serviceAddress_);
+
+ commonapi::tests::TestInterfaceProxyDefault::TestPredefinedTypeBroadcastEvent& broadcastEvent =
+ proxy->getTestPredefinedTypeBroadcastEvent();
+
+ for(unsigned int i=0; i<10; i++) {
+ bool callbackArrived = false;
+
+ auto broadcastSubscription = broadcastEvent.subscribe([&,i](uint32_t intParam, std::string stringParam) -> CommonAPI::SubscriptionStatus {
+ EXPECT_EQ(intParam, i);
+ callbackArrived = true;
+ return CommonAPI::SubscriptionStatus::RETAIN;
+ });
+
+ stub->fireTestPredefinedTypeBroadcastEvent(i, "xyz");
+
+ for(unsigned int j=0; j<100 && !callbackArrived; j++) {
+ usleep(10000);
+ }
+
+ ASSERT_TRUE(callbackArrived);
+
+ broadcastEvent.unsubscribe(broadcastSubscription);
+ }
+}
+
TEST_F(DBusBroadcastTest, ProxysCanUnsubscribeFromBroadcastAndSubscribeAgainWithOtherProxy) {
auto stub = std::make_shared<SelectiveBroadcastSender>();
@@ -346,7 +384,8 @@ TEST_F(DBusBroadcastTest, ProxysCanCancelSubscriptionAndSubscribeAgainWithOtherP
ASSERT_TRUE(callbackArrived);
- broadcastEvent.unsubscribe(broadcastSubscription2);
+ broadcastEvent.unsubscribe(broadcastSubscription);
+ broadcastEvent2.unsubscribe(broadcastSubscription2);
}
diff --git a/src/test/DBusLoadTest.cpp b/src/test/DBusLoadTest.cpp
index 94090d3..e5e26bc 100644
--- a/src/test/DBusLoadTest.cpp
+++ b/src/test/DBusLoadTest.cpp
@@ -42,6 +42,7 @@ public:
std::string stringInValue,
uint32_t& uint32OutValue,
std::string& stringOutValue) {
+
uint32OutValue = uint32InValue;
stringOutValue = stringInValue;
}
@@ -82,10 +83,10 @@ public:
EXPECT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
EXPECT_EQ(out1, in1);
EXPECT_EQ(out2, in2);
- if (callStatus == CommonAPI::CallStatus::SUCCESS) {
- ASSERT_FALSE(callSucceeded_[callId]);
- callSucceeded_[callId] = true;
- }
+ mutexCallSucceeded_.lock();
+ ASSERT_FALSE(callSucceeded_[callId]);
+ callSucceeded_[callId] = true;
+ mutexCallSucceeded_.unlock();
}
std::shared_ptr<CommonAPI::Runtime> runtime_;
@@ -93,6 +94,7 @@ public:
std::shared_ptr<CommonAPI::Factory> stubFactory_;
std::shared_ptr<CommonAPI::ServicePublisher> servicePublisher_;
std::vector<bool> callSucceeded_;
+ std::mutex mutexCallSucceeded_;
static const std::string serviceAddress_;
static const uint32_t numCallsPerProxy_;