1 #include <QtTest/QtTest>
2 #include "MeetingRoomCombo.h"
4 #include "TestMeetingRoomCombo.h"
5 #include <QApplication>
7 void TestMeetingRoomCombo::initTestCase()
9 iRooms.append( new Room( "Hercules", "meetingroom.hercules@ixonos.com" ) );
10 iRooms.append( new Room( "Pegasus", "meetingroom.pegasus_jyv@ixonos.com" ) );
11 iRooms.append( new Room( "Taurus", "meetingroom.taurus_jyv@ixonos.com" ) );
13 iCombo = new MeetingRoomCombo( iRooms );
14 QVERIFY( iCombo != 0 );
17 void TestMeetingRoomCombo::cleanupTestCase()
23 void TestMeetingRoomCombo::init()
27 void TestMeetingRoomCombo::cleanup()
31 void TestMeetingRoomCombo::testCount()
33 QCOMPARE( iCombo->count(), iRooms.count() );
36 void TestMeetingRoomCombo::testCurrentIndex()
38 iCombo->setCurrentIndex( 0 );
39 QCOMPARE( iCombo->currentIndex(), 0 );
41 iCombo->setCurrentIndex( -10 );
42 QCOMPARE( iCombo->currentIndex(), -1 );
44 iCombo->setCurrentIndex( 10 );
45 QCOMPARE( iCombo->currentIndex(), -1 );
47 iCombo->setCurrentRoom( iRooms.at( 1 ) );
48 QCOMPARE( iCombo->currentIndex(), 1 );
51 void TestMeetingRoomCombo::testCurrentRoom()
53 iCombo->setCurrentRoom( iRooms.at( 1 ) );
54 QCOMPARE( iCombo->currentRoom()->equals( iRooms.at( 1 ) ), true );
55 QCOMPARE( iCombo->currentRoom()->equals( iRooms.at( 0 ) ), false );
58 void TestMeetingRoomCombo::testSetCurrentIndex()
60 for ( int i = 0; i < iRooms.count(); i++ )
62 iCombo->setCurrentIndex( i );
63 QCOMPARE( iCombo->currentIndex(), i );
67 void TestMeetingRoomCombo::testSetCurrentRoom()
69 for ( int i = 0; i < iRooms.count(); i++ )
71 iCombo->setCurrentRoom( iRooms[i] );
72 QCOMPARE( iCombo->currentRoom(), iRooms[i] );
76 void TestMeetingRoomCombo::testSetCurrentRoomBy()
78 iCombo->setCurrentRoomBy( iRooms.at( 0 )->name() );
79 QCOMPARE( iCombo->currentIndex(), 0 );
81 iCombo->setCurrentRoomBy( iRooms.at( 2 )->name() );
82 QCOMPARE( iCombo->currentIndex(), 2 );
84 iCombo->setCurrentRoomBy( "WRONG NAME" );
85 QCOMPARE( iCombo->currentIndex(), -1 );
88 void TestMeetingRoomCombo::testFindRoom()
90 for ( int i = 0; i < iRooms.count(); i++ )
92 QCOMPARE( iCombo->findRoom( iRooms[i] ), i );
96 void TestMeetingRoomCombo::testFindRoomBy()
98 QCOMPARE( iCombo->findRoomBy( iRooms.at( 0 )->name() ), 0 );
99 QCOMPARE( iCombo->findRoomBy( iRooms.at( 1 )->name() ), 1 );
100 QCOMPARE( iCombo->findRoomBy( "WRONG NAME" ), -1 );