summaryrefslogtreecommitdiff
path: root/tubes
diff options
context:
space:
mode:
authorMatúš Kukan <matus.kukan@gmail.com>2012-10-10 20:50:23 +0200
committerMatúš Kukan <matus.kukan@gmail.com>2012-10-10 20:55:25 +0200
commit5fe772a23f7de0a75849fa6d770a1ca6dd00bdea (patch)
tree7e74346832225b178b163ade12ae2cd35f276af2 /tubes
parent1ad0aef2ab81eeb96396bd0bce1203f3f6e681af (diff)
tubes: use only one test method; and also setUp and tearDown
Change-Id: I48ae990a870dc6e5c56e901485cb142b51426637
Diffstat (limited to 'tubes')
-rw-r--r--tubes/qa/test_manager.cxx66
1 files changed, 25 insertions, 41 deletions
diff --git a/tubes/qa/test_manager.cxx b/tubes/qa/test_manager.cxx
index 04ad98cfde1d..5e2ccf7fc5c8 100644
--- a/tubes/qa/test_manager.cxx
+++ b/tubes/qa/test_manager.cxx
@@ -49,20 +49,15 @@ class TestTeleTubes: public CppUnit::TestFixture
{
public:
- TestTeleTubes();
- ~TestTeleTubes();
- // This could happen in costructor wasn't there TestTeleTubes instance for each test:
- void testContactList();
+ virtual void setUp();
+ virtual void tearDown();
+
void testSession();
- void testFailAlways();
- // Order is significant.
+ // 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( testContactList );
CPPUNIT_TEST( testSession );
-#if 0
- CPPUNIT_TEST( testFailAlways ); // test failure displays SAL_LOG, uncomment for debugging
-#endif
CPPUNIT_TEST_SUITE_END();
};
@@ -70,8 +65,6 @@ class TestCollaboration;
// static, not members, so they actually survive cppunit test iteration
static TestCollaboration* mpCollaboration1 = NULL;
static TestCollaboration* mpCollaboration2 = NULL;
-static TpAccount* mpOffererAccount = NULL;
-static TpContact* mpAccepterContact = NULL;
//static bool mbFileSentSuccess = false;
static bool mbPacketReceived = false;
static OUString maTestConfigIniURL;
@@ -97,7 +90,7 @@ static gboolean timed_out( void * )
return FALSE;
}
-TestTeleTubes::TestTeleTubes()
+void TestTeleTubes::setUp()
{
g_timeout_add_seconds (10, timed_out, NULL);
maTestConfigIniURL = OUString( "file://" +
@@ -122,8 +115,16 @@ TestTeleTubes::TestTeleTubes()
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();
/* 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
@@ -132,7 +133,9 @@ void TestTeleTubes::testContactList()
"Make sure both your test accounts are signed in "
"and are on each other's contact lists",
pairs.size() > 0 );
- CPPUNIT_ASSERT(!mpAccepterContact);
+
+ TpAccount* mpOffererAccount = NULL;
+ TpContact* mpAccepterContact = NULL;
for (guint i = 0; i < pairs.size(); i++)
{
@@ -160,25 +163,19 @@ void TestTeleTubes::testContactList()
"Make sure both your test accounts are signed in "
"and are on each other's contact lists",
mpAccepterContact);
-}
-
-/* FIXME: do we need the possibility to pass function to Collaboration::SendFile() ?
-static void lcl_FileSent( bool success, void * )
-{
- mbFileSentSuccess = success;
-}
-*/
-void TestTeleTubes::testSession()
-{
+ // Now we can start session
TeleConference* pConference = NULL;
- CPPUNIT_ASSERT( mpOffererAccount != 0);
- CPPUNIT_ASSERT( mpAccepterContact != 0);
pConference = TeleManager::startBuddySession( mpOffererAccount, mpAccepterContact);
CPPUNIT_ASSERT( pConference != NULL);
mpCollaboration1->SetConference( pConference );
mpCollaboration1->SendFile( mpAccepterContact, maTestConfigIniURL );
+ g_object_unref(mpOffererAccount);
+ mpOffererAccount = NULL;
+ g_object_unref(mpAccepterContact);
+ mpAccepterContact = NULL;
+
//while (!mbFileSentSuccess)
// g_main_context_iteration( NULL, TRUE);
@@ -196,16 +193,8 @@ void TestTeleTubes::testSession()
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:
delete mpCollaboration1;
delete mpCollaboration2;
@@ -213,11 +202,6 @@ TestTeleTubes::~TestTeleTubes()
TeleManager::finalize();
}
-void TestTeleTubes::testFailAlways()
-{
- CPPUNIT_ASSERT( false);
-}
-
CPPUNIT_TEST_SUITE_REGISTRATION( TestTeleTubes);
}