qtmeetings sources to Maemo garage
[qtmeetings] / tests / UserInterface / Components / MeetingRoomCombo / TestMeetingRoomCombo.cpp
1 #include <QtTest/QtTest>
2 #include "MeetingRoomCombo.h"
3 #include "Room.h"
4 #include "TestMeetingRoomCombo.h"
5 #include <QApplication>
6
7 void TestMeetingRoomCombo::initTestCase()
8 {
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" ) );
12
13         iCombo = new MeetingRoomCombo( iRooms );
14         QVERIFY( iCombo != 0 );
15 }
16
17 void TestMeetingRoomCombo::cleanupTestCase()
18 {
19         delete iCombo;
20         iCombo = NULL;
21 }
22
23 void TestMeetingRoomCombo::init()
24 {
25 }
26
27 void TestMeetingRoomCombo::cleanup()
28 {
29 }
30
31 void TestMeetingRoomCombo::testCount()
32 {
33         QCOMPARE( iCombo->count(), iRooms.count() );
34 }
35
36 void TestMeetingRoomCombo::testCurrentIndex()
37 {
38         iCombo->setCurrentIndex( 0 );
39         QCOMPARE( iCombo->currentIndex(), 0 );
40
41         iCombo->setCurrentIndex( -10 );
42         QCOMPARE( iCombo->currentIndex(), -1 );
43
44         iCombo->setCurrentIndex( 10 );
45         QCOMPARE( iCombo->currentIndex(), -1 );
46
47         iCombo->setCurrentRoom( iRooms.at( 1 ) );
48         QCOMPARE( iCombo->currentIndex(), 1 );
49 }
50
51 void TestMeetingRoomCombo::testCurrentRoom()
52 {
53         iCombo->setCurrentRoom( iRooms.at( 1 ) );
54         QCOMPARE( iCombo->currentRoom()->equals( iRooms.at( 1 ) ), true );
55         QCOMPARE( iCombo->currentRoom()->equals( iRooms.at( 0 ) ), false );
56 }
57
58 void TestMeetingRoomCombo::testSetCurrentIndex()
59 {
60         for ( int i = 0; i < iRooms.count(); i++ )
61         {
62                 iCombo->setCurrentIndex( i );
63                 QCOMPARE( iCombo->currentIndex(), i );
64         }
65 }
66
67 void TestMeetingRoomCombo::testSetCurrentRoom()
68 {
69         for ( int i = 0; i < iRooms.count(); i++ )
70         {
71                 iCombo->setCurrentRoom( iRooms[i] );
72                 QCOMPARE( iCombo->currentRoom(), iRooms[i] );
73         }
74 }
75
76 void TestMeetingRoomCombo::testSetCurrentRoomBy()
77 {
78         iCombo->setCurrentRoomBy( iRooms.at( 0 )->name() );
79         QCOMPARE( iCombo->currentIndex(), 0 );
80
81         iCombo->setCurrentRoomBy( iRooms.at( 2 )->name() );
82         QCOMPARE( iCombo->currentIndex(), 2 );
83
84         iCombo->setCurrentRoomBy( "WRONG NAME" );
85         QCOMPARE( iCombo->currentIndex(), -1 );
86 }
87
88 void TestMeetingRoomCombo::testFindRoom()
89 {
90         for ( int i = 0; i < iRooms.count(); i++ )
91         {
92                 QCOMPARE( iCombo->findRoom( iRooms[i] ), i );
93         }
94 }
95
96 void TestMeetingRoomCombo::testFindRoomBy()
97 {
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 );
101 }