|
1 /*! |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <QtGui> |
|
19 #include <QtTest/QtTest> |
|
20 #include <hbapplication.h> |
|
21 #include <hbtextitem.h> |
|
22 #include <hbiconitem.h> |
|
23 |
|
24 #include "bubbletest.h" |
|
25 #include "bubbleparticipantlistmodel.h" |
|
26 |
|
27 class ut_BubbleParticipantListModel : public QObject |
|
28 { |
|
29 Q_OBJECT |
|
30 |
|
31 private slots: |
|
32 void initTestCase(); |
|
33 void cleanupTestCase(); |
|
34 |
|
35 void test_addParticipant(); |
|
36 void test_bubbleId(); |
|
37 void test_dataModel(); |
|
38 void test_reset(); |
|
39 |
|
40 private: |
|
41 BubbleParticipantListModel *mModel; |
|
42 }; |
|
43 |
|
44 void ut_BubbleParticipantListModel::initTestCase() |
|
45 { |
|
46 mModel = new BubbleParticipantListModel(); |
|
47 } |
|
48 |
|
49 void ut_BubbleParticipantListModel::cleanupTestCase() |
|
50 { |
|
51 delete mModel; |
|
52 } |
|
53 |
|
54 void ut_BubbleParticipantListModel::test_addParticipant() |
|
55 { |
|
56 mModel->addParticipant(1,"Bubble-1",8); |
|
57 mModel->addParticipant(2,"Bubble-2",9); |
|
58 mModel->addParticipant(3,"Bubble-3",10); |
|
59 |
|
60 QVERIFY(mModel->rowCount()==3); |
|
61 } |
|
62 |
|
63 void ut_BubbleParticipantListModel::test_bubbleId() |
|
64 { |
|
65 QVERIFY(mModel->bubbleId(1)==2); |
|
66 QVERIFY(mModel->bubbleId(4)==-1); |
|
67 } |
|
68 |
|
69 void ut_BubbleParticipantListModel::test_dataModel() |
|
70 { |
|
71 QModelIndex index = mModel->index(1,0); |
|
72 |
|
73 QVERIFY(index.data(Qt::DecorationRole).toInt()==9); |
|
74 QVERIFY(index.data(Qt::DisplayRole).toString()=="Bubble-2"); |
|
75 QVERIFY(index.data(Qt::UserRole).isNull()); |
|
76 |
|
77 index = mModel->index(4,0); |
|
78 QVERIFY(index.data(Qt::DisplayRole).isNull()); |
|
79 } |
|
80 |
|
81 void ut_BubbleParticipantListModel::test_reset() |
|
82 { |
|
83 mModel->reset(); |
|
84 QVERIFY(mModel->rowCount()==0); |
|
85 } |
|
86 |
|
87 BUBBLE_TEST_MAIN(ut_BubbleParticipantListModel) |
|
88 #include "ut_bubblepartlistmodel.moc" |