summaryrefslogtreecommitdiff
path: root/test/functional/Test1/TestApp.cpp
diff options
context:
space:
mode:
authorAndreas Volz <andreas.volz@tux-style.com>2011-11-28 12:44:11 +0100
committerAndreas Volz <andreas.volz@tux-style.com>2011-11-28 12:44:11 +0100
commit1c8e43e6d60205b427c2c7540254c6d6fb9c2682 (patch)
treec0cb9512c6b607c5885c637b9630fb9f5e570c8e /test/functional/Test1/TestApp.cpp
parentb100e9d32a45b6173a8c9b1963f60bccc793afbe (diff)
downloaddbus-c++-1c8e43e6d60205b427c2c7540254c6d6fb9c2682.tar.gz
- NO FUNCTIONAL CODE CHANGES!!!!
- changed code formating from tabs to spaces and others - used astyle with this option: --style=ansi --indent=spaces=2 -M --pad-oper --unpad-paren --pad-header --align-pointer=name --lineend=linux
Diffstat (limited to 'test/functional/Test1/TestApp.cpp')
-rw-r--r--test/functional/Test1/TestApp.cpp70
1 files changed, 35 insertions, 35 deletions
diff --git a/test/functional/Test1/TestApp.cpp b/test/functional/Test1/TestApp.cpp
index 69cb3c6..0dcaac5 100644
--- a/test/functional/Test1/TestApp.cpp
+++ b/test/functional/Test1/TestApp.cpp
@@ -20,16 +20,16 @@ std::list <std::string> testList;
pthread_mutex_t clientMutex = PTHREAD_MUTEX_INITIALIZER;
pthread_cond_t clientCondition = PTHREAD_COND_INITIALIZER;
-TestApp::TestApp ()
-{
- testList.push_back ("test1");
- testList.push_back ("testByte");
-
+TestApp::TestApp()
+{
+ testList.push_back("test1");
+ testList.push_back("testByte");
+
cout << "initialize DBus..." << endl;
- initDBus ();
+ initDBus();
}
-void TestApp::initDBus ()
+void TestApp::initDBus()
{
DBus::_init_threading();
@@ -39,68 +39,68 @@ void TestApp::initDBus ()
DBus::Connection conn = DBus::Connection::SessionBus();
- TestAppIntro testComIntro (conn, clientCondition, testResult);
+ TestAppIntro testComIntro(conn, clientCondition, testResult);
g_testComIntro = &testComIntro;
cout << "Start server..." << endl;
- TestAppIntroProvider testComProviderIntro (conn, &testComIntro);
- conn.request_name ("DBusCpp.Test.Com.Intro");
-
- mTestToDBusPipe = dispatcher.add_pipe (TestApp::testHandler, NULL);
+ TestAppIntroProvider testComProviderIntro(conn, &testComIntro);
+ conn.request_name("DBusCpp.Test.Com.Intro");
+
+ mTestToDBusPipe = dispatcher.add_pipe(TestApp::testHandler, NULL);
cout << "Start client thread..." << endl;
- pthread_create (&testThread, NULL, TestApp::testThreadRunner, &conn);
+ pthread_create(&testThread, NULL, TestApp::testThreadRunner, &conn);
dispatcher.enter();
- pthread_join (testThread, NULL);
+ pthread_join(testThread, NULL);
- cout << "Testresult = " << string (testResult ? "OK" : "NOK") << endl;
+ cout << "Testresult = " << string(testResult ? "OK" : "NOK") << endl;
}
-void *TestApp::testThreadRunner (void *arg)
-{
- for (std::list <std::string>::const_iterator tl_it = testList.begin ();
- tl_it != testList.end ();
+void *TestApp::testThreadRunner(void *arg)
+{
+ for (std::list <std::string>::const_iterator tl_it = testList.begin();
+ tl_it != testList.end();
++tl_it)
{
const string &testString = *tl_it;
cout << "write to pipe" << endl;
- mTestToDBusPipe->write (testString.c_str (), testString.length () + 1);
+ mTestToDBusPipe->write(testString.c_str(), testString.length() + 1);
struct timespec abstime;
-
+
clock_gettime(CLOCK_REALTIME, &abstime);
abstime.tv_sec += 1;
-
- pthread_mutex_lock (&clientMutex);
- if (pthread_cond_timedwait (&clientCondition, &clientMutex, &abstime) == ETIMEDOUT)
+
+ pthread_mutex_lock(&clientMutex);
+ if (pthread_cond_timedwait(&clientCondition, &clientMutex, &abstime) == ETIMEDOUT)
{
cout << "client timeout!" << endl;
testResult = false;
- }
- pthread_mutex_unlock (&clientMutex);
+ }
+ pthread_mutex_unlock(&clientMutex);
}
cout << "leave!" << endl;
- dispatcher.leave ();
-
+ dispatcher.leave();
+
return NULL;
}
-void TestApp::testHandler (const void *data, void *buffer, unsigned int nbyte)
+void TestApp::testHandler(const void *data, void *buffer, unsigned int nbyte)
{
- char *str = (char*) buffer;
+ char *str = (char *) buffer;
cout << "buffer1: " << str << ", size: " << nbyte << endl;
-
+
cout << "run it!" << endl;
- if (string (str) == "test1")
+ if (string(str) == "test1")
{
- g_testComIntro->test1 ();
+ g_testComIntro->test1();
}
- else if (string (str) == "testByte")
+ else if (string(str) == "testByte")
{
- g_testComIntro->testByte (4);
+ g_testComIntro->testByte(4);
}
}