|
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 private: |
|
44 BubbleContainerWidget* mContainer; |
|
45 HbMainWindow* mMainWindow; |
|
46 int mStyleBaseId; |
|
47 }; |
|
48 |
|
49 void ut_BubbleContainerWidget::initTestCase() |
|
50 { |
|
51 mMainWindow = new HbMainWindow(); |
|
52 mContainer = new BubbleContainerWidget(); |
|
53 mMainWindow->addView(mContainer); |
|
54 mMainWindow->show(); |
|
55 } |
|
56 |
|
57 void ut_BubbleContainerWidget::cleanupTestCase() |
|
58 { |
|
59 delete mMainWindow; |
|
60 } |
|
61 |
|
62 void ut_BubbleContainerWidget::testLeftMouseClick() |
|
63 { |
|
64 QSignalSpy spy(mContainer,SIGNAL(clicked())); |
|
65 |
|
66 QPointF clickPos = mContainer->scenePos() + |
|
67 mContainer->rect().center(); |
|
68 QPoint windowPos = mMainWindow->mapFromScene( clickPos ); |
|
69 |
|
70 QTest::mouseClick( mMainWindow->viewport(), Qt::LeftButton, 0, windowPos,100 ); |
|
71 QCOMPARE( spy.count(), 1 ); |
|
72 } |
|
73 |
|
74 void ut_BubbleContainerWidget::testRightMouseClick() |
|
75 { |
|
76 QSignalSpy spy(mContainer,SIGNAL(clicked())); |
|
77 |
|
78 QPointF clickPos = mContainer->scenePos() + |
|
79 mContainer->rect().center(); |
|
80 QPoint windowPos = mMainWindow->mapFromScene( clickPos ); |
|
81 |
|
82 QTest::mouseClick( mMainWindow->viewport(), Qt::RightButton, 0, windowPos,100 ); |
|
83 QCOMPARE( spy.count(), 0 ); |
|
84 } |
|
85 |
|
86 void ut_BubbleContainerWidget::testMouseMove() |
|
87 { |
|
88 QSignalSpy spy(mContainer,SIGNAL(clicked())); |
|
89 |
|
90 QPointF clickPos = mContainer->scenePos() + |
|
91 mContainer->rect().center(); |
|
92 QPoint windowPos = mMainWindow->mapFromScene( clickPos ); |
|
93 QPoint windowPos2 = windowPos+QPoint(10,10); |
|
94 |
|
95 // QTest::mouseMove() doesn't work |
|
96 QTest::mouseMove( mMainWindow->viewport(), windowPos2 ); |
|
97 QCOMPARE( spy.count(), 0 ); |
|
98 } |
|
99 |
|
100 BUBBLE_TEST_MAIN(ut_BubbleContainerWidget) |
|
101 #include "ut_bubblecontainerwidget.moc" |