tests: fix blocking semantic in DBusProxyTest
[profile/ivi/common-api-dbus-runtime.git] / src / test / DBusNameCacheTest.cpp
1 /* Copyright (C) 2013 BMW Group
2  * Author: Manfred Bathelt (manfred.bathelt@bmw.de)
3  * Author: Juergen Gehring (juergen.gehring@bmw.de)
4  * This Source Code Form is subject to the terms of the Mozilla Public
5  * License, v. 2.0. If a copy of the MPL was not distributed with this
6  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include <common-api-dbus/dbus-connection.h>
8 #include <common-api-dbus/dbus-name-cache.h>
9
10
11
12 int main(void) {
13         auto dbusConnection = common::api::dbus::DBusConnection::getSessionBus();
14
15         dbusConnection->connect();
16
17         common::api::dbus::DBusNameCache dbusNameCache(dbusConnection);
18
19         dbusConnection->requestServiceNameAndBlock("common.api.dbus.test.DBusNameCache");
20
21         for (int i = 0; i < 5; i++)
22                 dbusConnection->readWriteDispatch(100);
23
24         dbusConnection->releaseServiceName("common.api.dbus.test.DBusNameCache");
25
26         for (int i = 0; i < 5; i++)
27                 dbusConnection->readWriteDispatch(100);
28
29         return 0;
30 }