Kaydet (Commit) 27861421 authored tarafından Matúš Kukan's avatar Matúš Kukan

tubes: do not include tubes' object files in unit test library

Instead link against the library again.
Unit test is now closer to what the real app looks like.
Only 4 more functions exported because of unit test.

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