diff options
-rw-r--r-- | tubes/CppunitTest_tubes_test.mk | 12 | ||||
-rw-r--r-- | tubes/Library_tubes.mk | 2 | ||||
-rw-r--r-- | tubes/inc/tubes/contact-list.hxx | 5 | ||||
-rw-r--r-- | tubes/inc/tubes/manager.hxx | 9 | ||||
-rw-r--r-- | tubes/qa/test_manager.cxx | 71 | ||||
-rw-r--r-- | tubes/source/collaboration.cxx | 6 |
6 files changed, 44 insertions, 61 deletions
diff --git a/tubes/CppunitTest_tubes_test.mk b/tubes/CppunitTest_tubes_test.mk index 7c9f08a338ee..f40f0f41ce98 100644 --- a/tubes/CppunitTest_tubes_test.mk +++ b/tubes/CppunitTest_tubes_test.mk @@ -35,24 +35,14 @@ $(eval $(call gb_CppunitTest_set_include,tubes_test, \ $$(INCLUDE) \ )) -$(eval $(call gb_CppunitTest_use_packages,tubes_test,tubes_inc)) - -$(eval $(call gb_CppunitTest_use_library_objects,tubes_test,tubes)) - $(eval $(call gb_CppunitTest_use_libraries,tubes_test, \ - comphelper \ - cppu \ sal \ - svt \ - svxcore \ - tl \ + tubes \ utl \ - vcl \ $(gb_STDLIBS) \ )) $(eval $(call gb_CppunitTest_use_externals,tubes_test,\ - gtk \ telepathy \ )) diff --git a/tubes/Library_tubes.mk b/tubes/Library_tubes.mk index 2cdac5f9dd97..1c20e2b29b74 100644 --- a/tubes/Library_tubes.mk +++ b/tubes/Library_tubes.mk @@ -27,6 +27,8 @@ $(eval $(call gb_Library_Library,tubes)) +$(eval $(call gb_Library_use_packages,tubes,tubes_inc)) + $(eval $(call gb_Library_set_include,tubes,\ -I$(SRCDIR)/tubes/inc \ $$(INCLUDE) \ diff --git a/tubes/inc/tubes/contact-list.hxx b/tubes/inc/tubes/contact-list.hxx index 6dc4f3212483..cc4ba29bc28f 100644 --- a/tubes/inc/tubes/contact-list.hxx +++ b/tubes/inc/tubes/contact-list.hxx @@ -29,6 +29,8 @@ #ifndef INCLUDED_TUBES_CONTACT_LIST_HXX #define INCLUDED_TUBES_CONTACT_LIST_HXX +#include <tubes/tubesdllapi.h> + #include <set> #include <utility> #include <vector> @@ -46,7 +48,8 @@ public: ContactList(TpAccountManager *pAccountManager); ~ContactList(); - AccountContactPairV getContacts(); + // exported for unit test + TUBES_DLLPUBLIC AccountContactPairV getContacts(); private: TpAccountManager* mpAccountManager; diff --git a/tubes/inc/tubes/manager.hxx b/tubes/inc/tubes/manager.hxx index 22a3daefada6..ce17fd929491 100644 --- a/tubes/inc/tubes/manager.hxx +++ b/tubes/inc/tubes/manager.hxx @@ -81,7 +81,8 @@ public: /** Fetches the contact list. Returns 0 before connect() is called successfully. Is non-functional until prepareAccountManager(). */ - static ContactList* getContactList(); + // exported for unit test + TUBES_DLLPUBLIC static ContactList* getContactList(); /** Start a demo session where all local documents are shared to each other */ static TeleConference* startDemoSession(); @@ -112,7 +113,8 @@ public: @param pBuddy The buddy to be connected. Must be a contact of pAccount. */ - static TeleConference* startBuddySession( TpAccount *pAccount, TpContact *pBuddy ); + // exported for unit test + TUBES_DLLPUBLIC static TeleConference* startBuddySession( TpAccount *pAccount, TpContact *pBuddy ); static void registerCollaboration( Collaboration* pCollaboration ); static void unregisterCollaboration( Collaboration* pCollaboration ); @@ -154,7 +156,8 @@ public: used it must be called before the first TeleManager is instanciated and connects. */ - static void addSuffixToNames( const char* pName ); + // exported for unit test + TUBES_DLLPUBLIC static void addSuffixToNames( const char* pName ); private: static TeleManagerImpl* pImpl; diff --git a/tubes/qa/test_manager.cxx b/tubes/qa/test_manager.cxx index a531265b8cc2..2e5543ee81d9 100644 --- a/tubes/qa/test_manager.cxx +++ b/tubes/qa/test_manager.cxx @@ -36,13 +36,14 @@ #include <rtl/string.hxx> #include <rtl/ustring.hxx> #include <tubes/collaboration.hxx> -#include <tubes/conference.hxx> #include <tubes/contact-list.hxx> #include <tubes/manager.hxx> #include <unotools/localfilehelper.hxx> #include <telepathy-glib/telepathy-glib.h> +class TeleConference; + namespace { class TestTeleTubes: public CppUnit::TestFixture @@ -53,24 +54,20 @@ public: ~TestTeleTubes() {} // This could happen in costructor wasn't there TestTeleTubes instance for each test: void testInitialize(); - void testCreateAccountManager(); - void testRegisterClients(); + void testInitTeleManager(); void testContactList(); void testStartBuddySession(); void testSendPacket(); - void testReceivePacket(); void testDestroyTeleTubes(); void testFailAlways(); // Order is significant. CPPUNIT_TEST_SUITE( TestTeleTubes ); CPPUNIT_TEST( testInitialize ); - CPPUNIT_TEST( testCreateAccountManager ); - CPPUNIT_TEST( testRegisterClients ); + CPPUNIT_TEST( testInitTeleManager ); CPPUNIT_TEST( testContactList ); CPPUNIT_TEST( testStartBuddySession ); CPPUNIT_TEST( testSendPacket ); - CPPUNIT_TEST( testReceivePacket ); CPPUNIT_TEST( testDestroyTeleTubes ); #if 0 CPPUNIT_TEST( testFailAlways ); // test failure displays SAL_LOG, uncomment for debugging @@ -80,12 +77,11 @@ public: class TestCollaboration; // static, not members, so they actually survive cppunit test iteration -static TestCollaboration* mpCollaboration = NULL; -static TeleConference* mpConference1 = NULL; -static TeleConference* mpConference2 = NULL; +static TestCollaboration* mpCollaboration1 = NULL; +static TestCollaboration* mpCollaboration2 = NULL; static TpAccount* mpOffererAccount = NULL; static TpContact* mpAccepterContact = NULL; -static bool mbFileSentSuccess = false; +//static bool mbFileSentSuccess = false; static bool mbPacketReceived = false; static OUString maTestConfigIniURL; static OString maOffererIdentifier; @@ -130,19 +126,13 @@ void TestTeleTubes::testInitialize() maAccepterIdentifier = OUStringToOString( aAccepterIdentifier, RTL_TEXTENCODING_UTF8); g_timeout_add_seconds (10, timed_out, NULL); - mpCollaboration = new TestCollaboration(); + mpCollaboration1 = new TestCollaboration(); + mpCollaboration2 = new TestCollaboration(); } -void TestTeleTubes::testCreateAccountManager() +void TestTeleTubes::testInitTeleManager() { - bool bConnected = TeleManager::createAccountManager(); - CPPUNIT_ASSERT( bConnected == true); -} - -void TestTeleTubes::testRegisterClients() -{ - bool bRegistered = TeleManager::registerClients(); - CPPUNIT_ASSERT( bRegistered == true); + CPPUNIT_ASSERT( TeleManager::init( true)); } void TestTeleTubes::testContactList() @@ -185,41 +175,39 @@ void TestTeleTubes::testContactList() mpAccepterContact); } +/* FIXME: do we need the possibility to pass function to Collaboration::SendFile() ? static void lcl_FileSent( bool success, void * ) { mbFileSentSuccess = success; } +*/ void TestTeleTubes::testStartBuddySession() { + TeleConference* pConference = NULL; CPPUNIT_ASSERT( mpOffererAccount != 0); CPPUNIT_ASSERT( mpAccepterContact != 0); - mpConference1 = TeleManager::startBuddySession( mpOffererAccount, mpAccepterContact); - CPPUNIT_ASSERT( mpConference1 != NULL); - mpConference1->sendFile( mpAccepterContact, maTestConfigIniURL, lcl_FileSent, NULL); + pConference = TeleManager::startBuddySession( mpOffererAccount, mpAccepterContact); + CPPUNIT_ASSERT( pConference != NULL); + mpCollaboration1->SetConference( pConference ); + mpCollaboration1->SendFile( mpAccepterContact, maTestConfigIniURL ); - while (!mbFileSentSuccess) - g_main_context_iteration( NULL, TRUE); + //while (!mbFileSentSuccess) + // g_main_context_iteration( NULL, TRUE); // This checks that the file was received and msCurrentUUID set (see manager.cxx) while (!TeleManager::hasWaitingConference()) g_main_context_iteration( NULL, TRUE); - mpConference2 = TeleManager::getConference(); - CPPUNIT_ASSERT( mpConference2 != NULL); - mpCollaboration->SetConference( mpConference2 ); + pConference = TeleManager::getConference(); + CPPUNIT_ASSERT( pConference != NULL); + mpCollaboration2->SetConference( pConference ); } void TestTeleTubes::testSendPacket() { - bool bSentPacket = false; - if (mpConference1) - bSentPacket = mpConference1->sendPacket( "from 1 to 2"); - CPPUNIT_ASSERT( bSentPacket); -} + mpCollaboration1->SendPacket( "from 1 to 2"); -void TestTeleTubes::testReceivePacket() -{ while (!mbPacketReceived) g_main_context_iteration( NULL, TRUE); } @@ -234,14 +222,9 @@ void TestTeleTubes::testDestroyTeleTubes() g_object_unref(mpAccepterContact); mpAccepterContact = NULL; } - - if (mpConference1) - mpConference1->close(); - delete mpConference1; - - if (mpConference2) - mpConference2->close(); - delete mpConference2; + // Closes the TeleConference in destructor: + delete mpCollaboration1; + delete mpCollaboration2; TeleManager::finalize(); } diff --git a/tubes/source/collaboration.cxx b/tubes/source/collaboration.cxx index c957091cf042..a6e5ec09b760 100644 --- a/tubes/source/collaboration.cxx +++ b/tubes/source/collaboration.cxx @@ -42,12 +42,14 @@ void Collaboration::Invite( TpContact* pContact ) const void Collaboration::SendFile( TpContact* pContact, const OUString& rURL ) const { - mpConference->sendFile( pContact, rURL, NULL, NULL ); + if (mpConference) + mpConference->sendFile( pContact, rURL, NULL, NULL ); } void Collaboration::SendPacket( const OString& rPacket ) const { - mpConference->sendPacket( rPacket ); + if (mpConference) + mpConference->sendPacket( rPacket ); } void Collaboration::SetConference( TeleConference* pConference ) |