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 <QDate> |
|
19 #include <QTest> |
|
20 #include <QDebug> |
|
21 #include <QSignalSpy> |
|
22 #include <QThread> |
|
23 |
|
24 #include <coecntrl.h> |
|
25 |
|
26 #include "cxeerror.h" |
|
27 #include "cxutils.h" |
|
28 #include "cxetestutils.h" |
|
29 #include "cxefakecontainer.h" |
|
30 #include "cxefakecameradevicecontrol.h" |
|
31 #include "cxefakecameradevice.h" |
|
32 #include "cxeviewfindercontrolsymbian.h" |
|
33 #include "unittest_cxeviewfindercontrolsymbian.h" |
|
34 |
|
35 |
|
36 |
|
37 /** |
|
38 * UnitTestCxeViewfinderControlSymbian::UnitTestCxeViewfinderControlSymbian() |
|
39 */ |
|
40 UnitTestCxeViewfinderControlSymbian::UnitTestCxeViewfinderControlSymbian() |
|
41 : mViewfinderControl(0), mCameraDeviceControl(0), mContainer(0), mCameraDevice(0) |
|
42 { |
|
43 } |
|
44 |
|
45 /** |
|
46 * UnitTestCxeViewfinderControlSymbian::~UnitTestCxeViewfinderControlSymbian() |
|
47 */ |
|
48 UnitTestCxeViewfinderControlSymbian::~UnitTestCxeViewfinderControlSymbian() |
|
49 { |
|
50 cleanup(); |
|
51 } |
|
52 |
|
53 /** |
|
54 * UnitTestCxeViewfinderControlSymbian::init() |
|
55 */ |
|
56 void UnitTestCxeViewfinderControlSymbian::init() |
|
57 { |
|
58 mContainer = CxeFakeContainer::create(); |
|
59 |
|
60 mCameraDeviceControl = new CxeFakeCameraDeviceControl(); |
|
61 mCameraDevice = new CxeFakeCameraDevice(); |
|
62 mCameraDevice->newCamera(Cxe::PrimaryCameraIndex, mCameraDeviceControl); |
|
63 |
|
64 mViewfinderControl = |
|
65 new CxeViewfinderControlSymbian( |
|
66 *mCameraDevice, |
|
67 *mCameraDeviceControl); |
|
68 } |
|
69 |
|
70 /** |
|
71 * UnitTestCxeViewfinderControlSymbian::cleanup() |
|
72 */ |
|
73 void UnitTestCxeViewfinderControlSymbian::cleanup() |
|
74 { |
|
75 delete mViewfinderControl; |
|
76 mViewfinderControl = 0; |
|
77 |
|
78 delete mCameraDeviceControl; |
|
79 mCameraDeviceControl = 0; |
|
80 |
|
81 delete mContainer; |
|
82 mContainer = 0; |
|
83 |
|
84 delete mCameraDevice; |
|
85 mCameraDevice = 0; |
|
86 } |
|
87 |
|
88 /** |
|
89 * UnitTestCxeViewfinderControlSymbian::testSetWindow() |
|
90 */ |
|
91 void UnitTestCxeViewfinderControlSymbian::testSetWindow() |
|
92 { |
|
93 mViewfinderControl->setWindow(mContainer); |
|
94 } |
|
95 |
|
96 /** |
|
97 * UnitTestCxeViewfinderControlSymbian::testStart() |
|
98 */ |
|
99 void UnitTestCxeViewfinderControlSymbian::testStart() |
|
100 { |
|
101 mViewfinderControl->setWindow(mContainer); |
|
102 |
|
103 QVERIFY(mViewfinderControl->start() == CxeError::None); |
|
104 QVERIFY(mViewfinderControl->state() == CxeViewfinderControl::Running); |
|
105 } |
|
106 |
|
107 /** |
|
108 * UnitTestCxeViewfinderControlSymbian::testStop() |
|
109 */ |
|
110 void UnitTestCxeViewfinderControlSymbian::testStop() |
|
111 { |
|
112 mViewfinderControl->setWindow(mContainer); |
|
113 QVERIFY(mViewfinderControl->start() == CxeError::None); |
|
114 |
|
115 mViewfinderControl->stop(); |
|
116 QVERIFY(mViewfinderControl->state() == CxeViewfinderControl::Ready); |
|
117 } |
|
118 |
|
119 /** |
|
120 * UnitTestCxeViewfinderControlSymbian::testState() |
|
121 */ |
|
122 void UnitTestCxeViewfinderControlSymbian::testState() |
|
123 { |
|
124 QVERIFY(mViewfinderControl->state() == CxeViewfinderControl::Uninitialized); |
|
125 } |
|
126 |
|
127 |
|
128 /** |
|
129 * UnitTestCxeViewfinderControlSymbian::testDisplayResolution() |
|
130 */ |
|
131 void UnitTestCxeViewfinderControlSymbian::testDisplayResolution() |
|
132 { |
|
133 mViewfinderControl->setWindow(mContainer); |
|
134 QVERIFY(mViewfinderControl->start() == CxeError::None); |
|
135 |
|
136 QSize displaySize = mViewfinderControl->deviceDisplayResolution(); |
|
137 QCOMPARE(displaySize.width(), mContainer->Size().iWidth); |
|
138 QCOMPARE(displaySize.height(), mContainer->Size().iHeight); |
|
139 } |
|
140 |
|
141 // main() function - Need event loop for waiting signals, |
|
142 // so can't use QTEST_APPLESS_MAIN. |
|
143 QTEST_MAIN(UnitTestCxeViewfinderControlSymbian); |
|
144 |
|
145 // end of file |
|