diff --git a/test/functional/Test1/TestApp.cpp b/test/functional/Test1/TestApp.cpp index 76e3cd3..69cb3c6 100644 --- a/test/functional/Test1/TestApp.cpp +++ b/test/functional/Test1/TestApp.cpp @@ -15,12 +15,16 @@ DBus::BusDispatcher dispatcher; TestAppIntro *g_testComIntro; DBus::Pipe *mTestToDBusPipe; bool testResult = false; +std::list 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"); + cout << "initialize DBus..." << endl; initDBus (); } @@ -55,25 +59,29 @@ void TestApp::initDBus () } void *TestApp::testThreadRunner (void *arg) -{ - char idstr[16]; - - snprintf (idstr, sizeof(idstr), "%lu", pthread_self()); - - mTestToDBusPipe->write (idstr, strlen (idstr) + 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) +{ + for (std::list ::const_iterator tl_it = testList.begin (); + tl_it != testList.end (); + ++tl_it) { - cout << "client timeout!" << endl; - testResult = false; - } - pthread_mutex_unlock (&clientMutex); + const string &testString = *tl_it; + + cout << "write to pipe" << endl; + 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) + { + cout << "client timeout!" << endl; + testResult = false; + } + pthread_mutex_unlock (&clientMutex); + } cout << "leave!" << endl; dispatcher.leave (); @@ -87,5 +95,12 @@ void TestApp::testHandler (const void *data, void *buffer, unsigned int nbyte) cout << "buffer1: " << str << ", size: " << nbyte << endl; cout << "run it!" << endl; - g_testComIntro->test1 (); + if (string (str) == "test1") + { + g_testComIntro->test1 (); + } + else if (string (str) == "testByte") + { + g_testComIntro->testByte (4); + } } diff --git a/test/functional/Test1/TestApp.h b/test/functional/Test1/TestApp.h index bb14db1..2321b8e 100644 --- a/test/functional/Test1/TestApp.h +++ b/test/functional/Test1/TestApp.h @@ -2,7 +2,9 @@ #define TEST_APP_H // STD -#include +#include +#include +#include /* DBus-cxx */ #include @@ -21,8 +23,7 @@ private: static void *testThreadRunnerProvider (void *arg); // variables - - pthread_t testThread; + pthread_t testThread; }; #endif // TEST_APP_H diff --git a/test/functional/Test1/TestAppIntro.h b/test/functional/Test1/TestAppIntro.h index 6945fdf..de6aa0b 100644 --- a/test/functional/Test1/TestAppIntro.h +++ b/test/functional/Test1/TestAppIntro.h @@ -2,8 +2,12 @@ #define TEST_APP_INTRO_H #include "TestAppIntroPrivate.h" +#include "../../../tools/generator_utils.h" #include +#include + +using namespace std; class TestAppIntro : public DBusCpp::Test::Com::Intro_proxy, @@ -19,7 +23,14 @@ public: void test1Result () { - std::cout << "Test1Result" << std::endl; + cout << "Test1Result" << endl; + mTestResult = true; + pthread_cond_signal (&mCondition); + } + + void testByteResult (const uint8_t& Byte) + { + printf ("TestByteResult: %d\n", Byte); mTestResult = true; pthread_cond_signal (&mCondition); } diff --git a/test/functional/Test1/TestAppIntro.xml b/test/functional/Test1/TestAppIntro.xml index de8d9ab..506f021 100644 --- a/test/functional/Test1/TestAppIntro.xml +++ b/test/functional/Test1/TestAppIntro.xml @@ -8,6 +8,16 @@ + + + + + + + + + + diff --git a/test/functional/Test1/TestAppIntroProvider.h b/test/functional/Test1/TestAppIntroProvider.h index 28a09a8..45b966b 100644 --- a/test/functional/Test1/TestAppIntroProvider.h +++ b/test/functional/Test1/TestAppIntroProvider.h @@ -2,11 +2,13 @@ #define TEST_APP_INTRO_PROVIDER_H #include "TestAppIntroProviderPrivate.h" - #include "TestAppIntro.h" +#include "../../../tools/generator_utils.h" #include +using namespace std; + class TestAppIntroProvider : public DBusCpp::Test::Com::Intro_adaptor, public DBus::IntrospectableAdaptor, @@ -20,10 +22,16 @@ public: void test1 () { - std::cout << "Test1" << std::endl; + cout << "Test1" << endl; mTestAppIntro->test1Result (); } + void testByte (const uint8_t& Byte) + { + printf ("TestByte: %d\n", Byte); + mTestAppIntro->testByteResult (Byte); + } + private: TestAppIntro *mTestAppIntro; };