|
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 #include <QTest> |
|
18 #include <QSignalSpy> |
|
19 #include <hbmainwindow.h> |
|
20 #include "cxuitest.h" |
|
21 #include "cxeengine.h" |
|
22 #include "cxenamespace.h" |
|
23 #include "cxevideocapturecontrol.h" |
|
24 #include "cxeviewfindercontrol.h" |
|
25 #include "cxuiviewmanagertest.h" |
|
26 #include "cxuiviewmanager.h" |
|
27 #include "cxutils.h" |
|
28 #include "cxuienums.h" |
|
29 #include "cxuicapturekeyhandler.h" |
|
30 |
|
31 |
|
32 // Run before each test |
|
33 void TestCxUi::initTestCase() |
|
34 { |
|
35 mMainWindow = new HbMainWindow; |
|
36 mEngineFake = CxuiFakeEngine::createFakeEngine(); |
|
37 |
|
38 mKeyHandler = new CxuiCaptureKeyHandler(*mEngineFake); |
|
39 mViewManager = new CxuiViewManager(*mMainWindow, *mEngineFake, *mKeyHandler); |
|
40 mViewManager->prepareWindow(); |
|
41 } |
|
42 |
|
43 // Run after each test |
|
44 void TestCxUi::cleanup() |
|
45 { |
|
46 //delete mEngineFake; |
|
47 } |
|
48 |
|
49 // Run after each test |
|
50 void TestCxUi::cleanupTestCase() |
|
51 { |
|
52 //delete mEngine; |
|
53 //delete mMainWindow; |
|
54 } |
|
55 |
|
56 void TestCxUi::initVideoMode() |
|
57 { |
|
58 /*mEngineFake->initMode( Cxe::VideoMode ); |
|
59 |
|
60 QSignalSpy deviceStateSpy(&mEngineFake->videoCaptureControl(), |
|
61 SIGNAL(stateChanged(CxeVideoCaptureControl::State, int))); |
|
62 QVERIFY( deviceStateSpy.isValid() ); |
|
63 |
|
64 // Wait 500ms for signals |
|
65 QTest::qWait( 5000 ); |
|
66 |
|
67 QCOMPARE( deviceStateSpy.count(), 3 ); |
|
68 |
|
69 QList<QVariant> initModeArguments = deviceStateSpy.takeAt(0); |
|
70 QVERIFY( initModeArguments.at(0).value<CxeVideoCaptureControl::State>() == CxeVideoCaptureControl::Open ); |
|
71 QVERIFY( initModeArguments.at(1).toInt() == 0 ); |
|
72 initModeArguments = deviceStateSpy.takeAt(0); |
|
73 QVERIFY( initModeArguments.at(1).toInt() == 0 ); |
|
74 QVERIFY( initModeArguments.at(0).value<CxeVideoCaptureControl::State>() == CxeVideoCaptureControl::Preparing ); |
|
75 initModeArguments = deviceStateSpy.takeAt(0); |
|
76 QVERIFY( initModeArguments.at(0).value<CxeVideoCaptureControl::State>() == CxeVideoCaptureControl::Ready ); |
|
77 QVERIFY( initModeArguments.at(1).toInt() == 0 ); */ |
|
78 } |
|
79 |
|
80 void TestCxUi::sendCameraKeyEvent(QEvent::Type event) |
|
81 { |
|
82 CX_DEBUG_ENTER_FUNCTION(); |
|
83 QKeyEvent* captureKeyEvent; |
|
84 if (event == QEvent::None) { |
|
85 captureKeyEvent = QKeyEvent::createExtendedKeyEvent(QEvent::KeyPress, Qt::Key_unknown, 0, |
|
86 0xab, 0, 0); |
|
87 QApplication::postEvent(mMainWindow, captureKeyEvent); |
|
88 captureKeyEvent = QKeyEvent::createExtendedKeyEvent(QEvent::KeyRelease, Qt::Key_unknown, 0, |
|
89 0xab, 0, 0); |
|
90 QApplication::postEvent(mMainWindow, captureKeyEvent); |
|
91 |
|
92 } else { |
|
93 captureKeyEvent = QKeyEvent::createExtendedKeyEvent(event, Qt::Key_unknown, 0, 0xab, 0, 0); |
|
94 QApplication::postEvent(mMainWindow, captureKeyEvent); |
|
95 } |
|
96 QTest::qWait(100); |
|
97 CX_DEBUG_EXIT_FUNCTION(); |
|
98 } |
|
99 |
|
100 void TestCxUi::sendAutofocusKeyEvent(QEvent::Type event) |
|
101 { |
|
102 CX_DEBUG_ENTER_FUNCTION(); |
|
103 QKeyEvent* autofocusKeyEvent = QKeyEvent::createExtendedKeyEvent(event, Qt::Key_unknown, 0, |
|
104 0xe2, 0, 0); |
|
105 QApplication::postEvent(mMainWindow, autofocusKeyEvent); |
|
106 QTest::qWait(50); |
|
107 CX_DEBUG_EXIT_FUNCTION(); |
|
108 } |
|
109 |
|
110 // main() function non-GUI testing |
|
111 QTEST_MAIN( TestCxUi ); |