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, \
$$(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 \
))
......
......@@ -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) \
......
......@@ -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;
......
......@@ -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;
......
......@@ -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();
}
......
......@@ -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 )
......
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