tubes: use only one test method; and also setUp and tearDown
Change-Id: I48ae990a870dc6e5c56e901485cb142b51426637
This commit is contained in:
@@ -49,20 +49,15 @@ class TestTeleTubes: public CppUnit::TestFixture
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
TestTeleTubes();
|
virtual void setUp();
|
||||||
~TestTeleTubes();
|
virtual void tearDown();
|
||||||
// This could happen in costructor wasn't there TestTeleTubes instance for each test:
|
|
||||||
void testContactList();
|
|
||||||
void testSession();
|
|
||||||
void testFailAlways();
|
|
||||||
|
|
||||||
// Order is significant.
|
void testSession();
|
||||||
|
|
||||||
|
// There is only one method because the code in setUp
|
||||||
|
// and tearDown is expected to be executed only once.
|
||||||
CPPUNIT_TEST_SUITE( TestTeleTubes );
|
CPPUNIT_TEST_SUITE( TestTeleTubes );
|
||||||
CPPUNIT_TEST( testContactList );
|
|
||||||
CPPUNIT_TEST( testSession );
|
CPPUNIT_TEST( testSession );
|
||||||
#if 0
|
|
||||||
CPPUNIT_TEST( testFailAlways ); // test failure displays SAL_LOG, uncomment for debugging
|
|
||||||
#endif
|
|
||||||
CPPUNIT_TEST_SUITE_END();
|
CPPUNIT_TEST_SUITE_END();
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -70,8 +65,6 @@ class TestCollaboration;
|
|||||||
// static, not members, so they actually survive cppunit test iteration
|
// static, not members, so they actually survive cppunit test iteration
|
||||||
static TestCollaboration* mpCollaboration1 = NULL;
|
static TestCollaboration* mpCollaboration1 = NULL;
|
||||||
static TestCollaboration* mpCollaboration2 = 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 bool mbPacketReceived = false;
|
||||||
static OUString maTestConfigIniURL;
|
static OUString maTestConfigIniURL;
|
||||||
@@ -97,7 +90,7 @@ static gboolean timed_out( void * )
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
TestTeleTubes::TestTeleTubes()
|
void TestTeleTubes::setUp()
|
||||||
{
|
{
|
||||||
g_timeout_add_seconds (10, timed_out, NULL);
|
g_timeout_add_seconds (10, timed_out, NULL);
|
||||||
maTestConfigIniURL = OUString( "file://" +
|
maTestConfigIniURL = OUString( "file://" +
|
||||||
@@ -122,8 +115,16 @@ TestTeleTubes::TestTeleTubes()
|
|||||||
CPPUNIT_ASSERT( TeleManager::init( true));
|
CPPUNIT_ASSERT( TeleManager::init( true));
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestTeleTubes::testContactList()
|
/* FIXME: do we need the possibility to pass function to Collaboration::SendFile() ?
|
||||||
|
static void lcl_FileSent( bool success, void * )
|
||||||
{
|
{
|
||||||
|
mbFileSentSuccess = success;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
void TestTeleTubes::testSession()
|
||||||
|
{
|
||||||
|
// First try to get account and contact
|
||||||
AccountContactPairV pairs = TeleManager::getContacts();
|
AccountContactPairV pairs = TeleManager::getContacts();
|
||||||
/* Both our accounts are meant to be signed in, and they both should be
|
/* Both our accounts are meant to be signed in, and they both should be
|
||||||
* capable of LibreOffice tubes because this test runs after we register
|
* capable of LibreOffice tubes because this test runs after we register
|
||||||
@@ -132,7 +133,9 @@ void TestTeleTubes::testContactList()
|
|||||||
"Make sure both your test accounts are signed in "
|
"Make sure both your test accounts are signed in "
|
||||||
"and are on each other's contact lists",
|
"and are on each other's contact lists",
|
||||||
pairs.size() > 0 );
|
pairs.size() > 0 );
|
||||||
CPPUNIT_ASSERT(!mpAccepterContact);
|
|
||||||
|
TpAccount* mpOffererAccount = NULL;
|
||||||
|
TpContact* mpAccepterContact = NULL;
|
||||||
|
|
||||||
for (guint i = 0; i < pairs.size(); i++)
|
for (guint i = 0; i < pairs.size(); i++)
|
||||||
{
|
{
|
||||||
@@ -160,25 +163,19 @@ void TestTeleTubes::testContactList()
|
|||||||
"Make sure both your test accounts are signed in "
|
"Make sure both your test accounts are signed in "
|
||||||
"and are on each other's contact lists",
|
"and are on each other's contact lists",
|
||||||
mpAccepterContact);
|
mpAccepterContact);
|
||||||
}
|
|
||||||
|
|
||||||
/* FIXME: do we need the possibility to pass function to Collaboration::SendFile() ?
|
// Now we can start session
|
||||||
static void lcl_FileSent( bool success, void * )
|
|
||||||
{
|
|
||||||
mbFileSentSuccess = success;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
void TestTeleTubes::testSession()
|
|
||||||
{
|
|
||||||
TeleConference* pConference = NULL;
|
TeleConference* pConference = NULL;
|
||||||
CPPUNIT_ASSERT( mpOffererAccount != 0);
|
|
||||||
CPPUNIT_ASSERT( mpAccepterContact != 0);
|
|
||||||
pConference = TeleManager::startBuddySession( mpOffererAccount, mpAccepterContact);
|
pConference = TeleManager::startBuddySession( mpOffererAccount, mpAccepterContact);
|
||||||
CPPUNIT_ASSERT( pConference != NULL);
|
CPPUNIT_ASSERT( pConference != NULL);
|
||||||
mpCollaboration1->SetConference( pConference );
|
mpCollaboration1->SetConference( pConference );
|
||||||
mpCollaboration1->SendFile( mpAccepterContact, maTestConfigIniURL );
|
mpCollaboration1->SendFile( mpAccepterContact, maTestConfigIniURL );
|
||||||
|
|
||||||
|
g_object_unref(mpOffererAccount);
|
||||||
|
mpOffererAccount = NULL;
|
||||||
|
g_object_unref(mpAccepterContact);
|
||||||
|
mpAccepterContact = NULL;
|
||||||
|
|
||||||
//while (!mbFileSentSuccess)
|
//while (!mbFileSentSuccess)
|
||||||
// g_main_context_iteration( NULL, TRUE);
|
// g_main_context_iteration( NULL, TRUE);
|
||||||
|
|
||||||
@@ -196,16 +193,8 @@ void TestTeleTubes::testSession()
|
|||||||
g_main_context_iteration( NULL, TRUE);
|
g_main_context_iteration( NULL, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
TestTeleTubes::~TestTeleTubes()
|
void TestTeleTubes::tearDown()
|
||||||
{
|
{
|
||||||
if (mpOffererAccount) {
|
|
||||||
g_object_unref(mpOffererAccount);
|
|
||||||
mpOffererAccount = NULL;
|
|
||||||
}
|
|
||||||
if (mpAccepterContact) {
|
|
||||||
g_object_unref(mpAccepterContact);
|
|
||||||
mpAccepterContact = NULL;
|
|
||||||
}
|
|
||||||
// Closes the TeleConference in destructor:
|
// Closes the TeleConference in destructor:
|
||||||
delete mpCollaboration1;
|
delete mpCollaboration1;
|
||||||
delete mpCollaboration2;
|
delete mpCollaboration2;
|
||||||
@@ -213,11 +202,6 @@ TestTeleTubes::~TestTeleTubes()
|
|||||||
TeleManager::finalize();
|
TeleManager::finalize();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestTeleTubes::testFailAlways()
|
|
||||||
{
|
|
||||||
CPPUNIT_ASSERT( false);
|
|
||||||
}
|
|
||||||
|
|
||||||
CPPUNIT_TEST_SUITE_REGISTRATION( TestTeleTubes);
|
CPPUNIT_TEST_SUITE_REGISTRATION( TestTeleTubes);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user