aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnna Gadomska <ext-anna.2.gadomska@nokia.com>2010-08-26 15:03:53 +0300
committerDominik Kapusta <dominik.kapusta@teleca.com>2010-08-27 11:57:46 +0200
commitf56245fa9635ef8ccf52af9642ec60bf69fef597 (patch)
tree3b7f1d0c3fdbdd130d4c78bc972289551ed20825
parent321787b10948e6be1c71f6418e1f7c63ed6d28ad (diff)
Changes: unit tests improvements
RevBy: John, Dominik
-rw-r--r--src/corelib/widgets/mabstractitemmodel.h5
-rw-r--r--src/corelib/widgets/mlabel.h6
-rw-r--r--tests/ut_madvancedlistitem/ut_madvancedlistitem.cpp7
-rw-r--r--tests/ut_mbubbleitem/ut_mbubbleitem.cpp5
-rw-r--r--tests/ut_mlabel/ut_mlabel.cpp19
-rw-r--r--tests/ut_mlist/ut_mlist.cpp17
-rw-r--r--tests/ut_mlist/ut_mlist.h1
7 files changed, 52 insertions, 8 deletions
diff --git a/src/corelib/widgets/mabstractitemmodel.h b/src/corelib/widgets/mabstractitemmodel.h
index c2f117c4..b3928f6b 100644
--- a/src/corelib/widgets/mabstractitemmodel.h
+++ b/src/corelib/widgets/mabstractitemmodel.h
@@ -136,6 +136,11 @@ private:
//! \internal
MAbstractItemModelPrivate *const d_ptr;
//! \internal_end
+
+#ifdef UNIT_TEST
+ // Test unit is defined as a friend of production code to access private members
+ friend class Ut_MList;
+#endif
};
#endif // MABSTRACTITEMMODEL_H
diff --git a/src/corelib/widgets/mlabel.h b/src/corelib/widgets/mlabel.h
index 9338f228..19a1466f 100644
--- a/src/corelib/widgets/mlabel.h
+++ b/src/corelib/widgets/mlabel.h
@@ -351,6 +351,12 @@ protected:
private:
Q_DISABLE_COPY(MLabel)
Q_DECLARE_PRIVATE(MLabel)
+
+#ifdef UNIT_TEST
+ // Test unit is defined as a friend of production code to access private members
+ friend class Ut_MLabel;
+#endif
+
};
#endif
diff --git a/tests/ut_madvancedlistitem/ut_madvancedlistitem.cpp b/tests/ut_madvancedlistitem/ut_madvancedlistitem.cpp
index aa838b05..803a7243 100644
--- a/tests/ut_madvancedlistitem/ut_madvancedlistitem.cpp
+++ b/tests/ut_madvancedlistitem/ut_madvancedlistitem.cpp
@@ -75,10 +75,10 @@ void Ut_MAdvancedListItem::testTitle()
void Ut_MAdvancedListItem::testImageWidget()
{
- //this part is commented out because setImageWidget() is crashing - bug reported: #185535
- /*MImageWidget *myImageWidget = new MImageWidget();
+ QSKIP("Wait for issue in bug #185535 to be resolved", SkipSingle);
+ MImageWidget *myImageWidget = new MImageWidget();
m_subject->setImageWidget( myImageWidget );
- QCOMPARE( m_subject->imageWidget(), myImageWidget );*/
+ QCOMPARE( m_subject->imageWidget(), myImageWidget );
}
void Ut_MAdvancedListItem::testSideTopImage()
@@ -99,6 +99,7 @@ void Ut_MAdvancedListItem::testProgressIndicator()
void Ut_MAdvancedListItem::testItemStyle()
{
+ QSKIP("Wait for issue in bug #187235 to be resolved", SkipSingle);
QCOMPARE( m_subject->itemStyle(), MAdvancedListItem::IconWithTitleProgressIndicatorAndTwoSideIcons );
m_subject->setItemStyle(MAdvancedListItem::IconWithTitleProgressIndicatorAndTopSideIcon);
QCOMPARE( m_subject->itemStyle(), MAdvancedListItem::IconWithTitleProgressIndicatorAndTopSideIcon );
diff --git a/tests/ut_mbubbleitem/ut_mbubbleitem.cpp b/tests/ut_mbubbleitem/ut_mbubbleitem.cpp
index 88bb28fd..25557c57 100644
--- a/tests/ut_mbubbleitem/ut_mbubbleitem.cpp
+++ b/tests/ut_mbubbleitem/ut_mbubbleitem.cpp
@@ -153,6 +153,7 @@ void Ut_MBubbleItem::testAvatar()
QSizeF size = m_bubble->preferredSize();
QPointer<MImageWidget> avatar1 = new MImageWidget;
QPointer<MImageWidget> avatar2 = new MImageWidget;
+ QPixmap pixmap("icon-m-home");
QVERIFY(!m_bubble->avatar());
m_bubble->setAvatar(avatar1);
QVERIFY(m_bubble->avatar() == avatar1);
@@ -175,6 +176,10 @@ void Ut_MBubbleItem::testAvatar()
QVERIFY(avatar2->parent() == m_bubble);
m_bubble->setAvatar(NULL);
QVERIFY(!m_bubble->avatar());
+ m_bubble->setAvatar( pixmap );
+ QCOMPARE(m_bubble->avatar()->pixmap()->toImage(), pixmap.toImage());
+ m_bubble->setAvatar(NULL);
+ QVERIFY(!m_bubble->avatar());
//Both should be deleted now
QVERIFY(!avatar1);
QVERIFY(!avatar2);
diff --git a/tests/ut_mlabel/ut_mlabel.cpp b/tests/ut_mlabel/ut_mlabel.cpp
index c6adf7cf..79e47625 100644
--- a/tests/ut_mlabel/ut_mlabel.cpp
+++ b/tests/ut_mlabel/ut_mlabel.cpp
@@ -35,6 +35,7 @@
#include <QFile>
#include <QGraphicsScene>
#include <QGraphicsView>
+#include <QGesture>
#define SAVE_IMAGE(fileName, image) \
do{ \
@@ -311,6 +312,7 @@ void Ut_MLabel::testRichTextElide()
void Ut_MLabel::testHighlighting()
{
+ QSKIP("Wait for issue in bug #164207 to be resolved", SkipSingle);
label->setText("Label <b>rich</b>");
QImage nonhighlighted = captureImage(label);
@@ -321,10 +323,19 @@ void Ut_MLabel::testHighlighting()
QVERIFY(nonhighlighted != highlighted);
- QSignalSpy spy(h, SIGNAL(clicked(QString)));
- //QSignalSpy spy(h, SIGNAL(longPress(QString)));
+ QSignalSpy spyClick(h, SIGNAL(clicked(QString)));
label->simulateClick(QPoint(15, 5));
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spyClick.count(), 1);
+
+ QSignalSpy spyLongPress(h, SIGNAL(longPressed(QString)));
+
+ QList<QGesture *> list;
+ QTapAndHoldGesture gesture;
+ list.append( &gesture );
+ QGestureEvent gestureEvent(list);
+ label->tapAndHoldGestureEvent (&gestureEvent, &gesture );
+
+ QCOMPARE(spyLongPress.count(), 1);
label->removeHighlighter(NULL);
label->removeHighlighter(h);
@@ -345,8 +356,6 @@ void Ut_MLabel::anchorHitTest(const QPointF &point, int expectedHits)
QCOMPARE(spy.count(), expectedHits);
}
-
-
QImage Ut_MLabel::captureImage(MLabel *label)
{
QPixmap pixmap(label->size().toSize());
diff --git a/tests/ut_mlist/ut_mlist.cpp b/tests/ut_mlist/ut_mlist.cpp
index cdf6b90e..42314898 100644
--- a/tests/ut_mlist/ut_mlist.cpp
+++ b/tests/ut_mlist/ut_mlist.cpp
@@ -173,6 +173,7 @@ void Ut_mlist::testColums()
void Ut_mlist::testSelectItem()
{
+
indexedModel = new MyIndexedModel;
m_subject->setItemModel(indexedModel);
@@ -191,6 +192,22 @@ void Ut_mlist::testSelectItem()
delete indexedModel;
}
+void Ut_mlist::testAbstractModel()
+{
+
+ indexedModel = new MyIndexedModel;
+ m_subject->setItemModel(indexedModel);
+
+ QAbstractItemModel *model = (QAbstractItemModel*) m_subject->itemModel();
+ QModelIndex index = model->index(1, 0);
+ m_subject->selectItem(index);
+
+ QVERIFY( model->columnCount() == 1);
+ QCOMPARE( model, indexedModel );
+
+ delete indexedModel;
+}
+
void Ut_mlist::testVisibleItem()
{
indexedModel = new MyIndexedModel;
diff --git a/tests/ut_mlist/ut_mlist.h b/tests/ut_mlist/ut_mlist.h
index 165458bd..9e59afaa 100644
--- a/tests/ut_mlist/ut_mlist.h
+++ b/tests/ut_mlist/ut_mlist.h
@@ -101,6 +101,7 @@ private slots:
void testIndexVisible();
void testColums();
void testSelectItem();
+ void testAbstractModel();
void testVisibleItem();
void testLongTap();
void testModelScrollTo();