|
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 "bubblecontainerwidget.h" |
|
30 |
|
31 class ut_BubbleContainerWidget : public QObject |
|
32 { |
|
33 Q_OBJECT |
|
34 |
|
35 private slots: |
|
36 void initTestCase(); |
|
37 void cleanupTestCase(); |
|
38 |
|
39 void testLeftMouseClick(); |
|
40 void testRightMouseClick(); |
|
41 void testMouseMove(); |
|
42 |
|
43 //void testInvalidStylePlugin(); |
|
44 |
|
45 private: |
|
46 BubbleContainerWidget* mContainer; |
|
47 HbMainWindow* mMainWindow; |
|
48 int mStyleBaseId; |
|
49 }; |
|
50 |
|
51 void ut_BubbleContainerWidget::initTestCase() |
|
52 { |
|
53 mMainWindow = new HbMainWindow(); |
|
54 mContainer = new BubbleContainerWidget(BUBBLE_STYLE_PLUGIN); |
|
55 mMainWindow->addView(mContainer); |
|
56 mMainWindow->show(); |
|
57 } |
|
58 |
|
59 void ut_BubbleContainerWidget::cleanupTestCase() |
|
60 { |
|
61 delete mMainWindow; |
|
62 } |
|
63 |
|
64 void ut_BubbleContainerWidget::testLeftMouseClick() |
|
65 { |
|
66 QSignalSpy spy(mContainer,SIGNAL(clicked())); |
|
67 |
|
68 QPointF clickPos = mContainer->scenePos() + |
|
69 mContainer->rect().center(); |
|
70 QPoint windowPos = mMainWindow->mapFromScene( clickPos ); |
|
71 |
|
72 QTest::mouseClick( mMainWindow->viewport(), Qt::LeftButton, 0, windowPos,100 ); |
|
73 QCOMPARE( spy.count(), 1 ); |
|
74 } |
|
75 |
|
76 void ut_BubbleContainerWidget::testRightMouseClick() |
|
77 { |
|
78 QSignalSpy spy(mContainer,SIGNAL(clicked())); |
|
79 |
|
80 QPointF clickPos = mContainer->scenePos() + |
|
81 mContainer->rect().center(); |
|
82 QPoint windowPos = mMainWindow->mapFromScene( clickPos ); |
|
83 |
|
84 QTest::mouseClick( mMainWindow->viewport(), Qt::RightButton, 0, windowPos,100 ); |
|
85 QCOMPARE( spy.count(), 0 ); |
|
86 } |
|
87 |
|
88 void ut_BubbleContainerWidget::testMouseMove() |
|
89 { |
|
90 QSignalSpy spy(mContainer,SIGNAL(clicked())); |
|
91 |
|
92 QPointF clickPos = mContainer->scenePos() + |
|
93 mContainer->rect().center(); |
|
94 QPoint windowPos = mMainWindow->mapFromScene( clickPos ); |
|
95 QPoint windowPos2 = windowPos+QPoint(10,10); |
|
96 |
|
97 // QTest::mouseMove() doesn't work |
|
98 QTest::mouseMove( mMainWindow->viewport(), windowPos2 ); |
|
99 QCOMPARE( spy.count(), 0 ); |
|
100 } |
|
101 |
|
102 /*void ut_BubbleContainerWidget::testInvalidStylePlugin() |
|
103 { |
|
104 // this just shouldn't crash |
|
105 BubbleContainerWidget *cnt = |
|
106 new BubbleContainerWidget("c:\foobar.dll"); |
|
107 HbView* view = mMainWindow->addView(cnt); |
|
108 mMainWindow->setCurrentView(view); |
|
109 }*/ |
|
110 |
|
111 BUBBLE_TEST_MAIN(ut_BubbleContainerWidget) |
|
112 #include "ut_bubblecontainerwidget.moc" |