|
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 |
|
21 #include <hbapplication.h> |
|
22 #include <hbmainwindow.h> |
|
23 #include <hbaction.h> |
|
24 #include <hbmainwindow.h> |
|
25 #include <hbinstance.h> |
|
26 #include <hbstyle.h> |
|
27 |
|
28 #include "bubbletest.h" |
|
29 #include "bubbleimagewidget.h" |
|
30 #include "bubbleimagemanager.h" |
|
31 |
|
32 class ut_BubbleImageWidget : public QObject |
|
33 { |
|
34 Q_OBJECT |
|
35 |
|
36 private slots: |
|
37 void initTestCase(); |
|
38 void cleanupTestCase(); |
|
39 |
|
40 void testPixmap(); |
|
41 void testWidePixmap(); |
|
42 void testDefaultAvatar(); |
|
43 |
|
44 private: |
|
45 QString fileNameWithPath(const QString& fileName); |
|
46 |
|
47 private: |
|
48 BubbleImageWidget* mImage; |
|
49 HbMainWindow* mMainWindow; |
|
50 BubbleImageManager* mImageManager; |
|
51 }; |
|
52 |
|
53 QString ut_BubbleImageWidget::fileNameWithPath(const QString& fileName) |
|
54 { |
|
55 #ifdef __WINS__ |
|
56 return "c:/data/images/" + fileName; |
|
57 #else |
|
58 return ":/data/" + fileName; |
|
59 #endif |
|
60 } |
|
61 |
|
62 void ut_BubbleImageWidget::initTestCase() |
|
63 { |
|
64 mMainWindow = new HbMainWindow(); |
|
65 mImageManager = new BubbleImageManager(); |
|
66 mImage = new BubbleImageWidget(*mImageManager); |
|
67 mMainWindow->addView(mImage); |
|
68 mMainWindow->show(); |
|
69 } |
|
70 |
|
71 void ut_BubbleImageWidget::cleanupTestCase() |
|
72 { |
|
73 delete mMainWindow; |
|
74 delete mImageManager; |
|
75 } |
|
76 |
|
77 void ut_BubbleImageWidget::testPixmap() |
|
78 { |
|
79 mImage->hide(); |
|
80 mImage->setImage(fileNameWithPath("pixmap.png")); |
|
81 mImage->show(); |
|
82 // set same image again |
|
83 QTest::qWait(500); |
|
84 // there is now way to verify using public API |
|
85 } |
|
86 |
|
87 void ut_BubbleImageWidget::testWidePixmap() |
|
88 { |
|
89 mImage->hide(); |
|
90 mImage->setImage(fileNameWithPath("pixmap_wide.png")); |
|
91 mImage->show(); |
|
92 QTest::qWait(500); |
|
93 // there is now way to verify using public API |
|
94 } |
|
95 |
|
96 void ut_BubbleImageWidget::testDefaultAvatar() |
|
97 { |
|
98 mImage->hide(); |
|
99 mImage->setImage(""); |
|
100 mImage->show(); |
|
101 QTest::qWait(500); |
|
102 // there is now way to verify using public API |
|
103 } |
|
104 |
|
105 BUBBLE_TEST_MAIN(ut_BubbleImageWidget) |
|
106 #include "ut_bubbleimagewidget.moc" |