|
1 /* |
|
2 * Copyright (c) 2010 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: Unit test for mpsettingsaudioeffectswidget |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <QMetaType> |
|
19 #include <QtGui> |
|
20 #include <QTranslator> |
|
21 #include <QLocale> |
|
22 |
|
23 #include "unittest_mpsettingsaudioeffectswidget.h" |
|
24 #include "mpenginefactory.h" |
|
25 #include "mpengine.h" |
|
26 |
|
27 // Do this so we can access all member variables. |
|
28 #define private public |
|
29 #include "MpSettingsAudioEffectsWidget.h" |
|
30 #undef private |
|
31 |
|
32 /*! |
|
33 Make our test case a stand-alone executable that runs all the test functions. |
|
34 */ |
|
35 int main(int argc, char *argv[]) |
|
36 { |
|
37 QApplication app(argc, argv); |
|
38 TestMpSettingsAudioEffectsWidget tv; |
|
39 |
|
40 if ( argc > 1 ) { |
|
41 return QTest::qExec( &tv, argc, argv); |
|
42 } |
|
43 else { |
|
44 char *pass[3]; |
|
45 pass[0] = argv[0]; |
|
46 pass[1] = "-o"; |
|
47 pass[2] = "c:\\data\\unittest_mpsettingsaudioeffectswidget.txt"; |
|
48 |
|
49 return QTest::qExec(&tv, 3, pass); |
|
50 } |
|
51 } |
|
52 |
|
53 TestMpSettingsAudioEffectsWidget::TestMpSettingsAudioEffectsWidget() |
|
54 : mTest(0), |
|
55 mMpTranslator(0) |
|
56 { |
|
57 } |
|
58 |
|
59 TestMpSettingsAudioEffectsWidget::~TestMpSettingsAudioEffectsWidget() |
|
60 { |
|
61 delete mTest; |
|
62 delete mMpTranslator; |
|
63 } |
|
64 |
|
65 /*! |
|
66 Called before the first testfunction is executed. |
|
67 */ |
|
68 void TestMpSettingsAudioEffectsWidget::initTestCase() |
|
69 { |
|
70 QString lang = QLocale::system().name(); |
|
71 QString path = QString("z:/resource/qt/translations/"); |
|
72 bool translatorLoaded = false; |
|
73 |
|
74 mMpTranslator = new QTranslator(this); |
|
75 translatorLoaded = mMpTranslator->load(path + "musicplayer_" + lang); |
|
76 if ( translatorLoaded ) { |
|
77 qApp->installTranslator(mMpTranslator); |
|
78 } |
|
79 } |
|
80 |
|
81 /*! |
|
82 Called after the last testfunction was executed. |
|
83 */ |
|
84 void TestMpSettingsAudioEffectsWidget::cleanupTestCase() |
|
85 { |
|
86 } |
|
87 |
|
88 /*! |
|
89 Called before each testfunction is executed. |
|
90 */ |
|
91 void TestMpSettingsAudioEffectsWidget::init() |
|
92 { |
|
93 MpEngineFactory::createSharedEngine(); |
|
94 mTest = new MpSettingsAudioEffectsWidget(); |
|
95 } |
|
96 |
|
97 /*! |
|
98 Called after every testfunction. |
|
99 */ |
|
100 void TestMpSettingsAudioEffectsWidget::cleanup() |
|
101 { |
|
102 delete mTest; |
|
103 mTest = 0; |
|
104 MpEngineFactory::close(); |
|
105 } |
|
106 |
|
107 /*! |
|
108 Tests InitializeSlider. |
|
109 */ |
|
110 void TestMpSettingsAudioEffectsWidget::testInitializeSlider() |
|
111 { |
|
112 //test slider widget is set up correctly in initialize() |
|
113 mTest->initialize(); |
|
114 QVERIFY(mTest->mMpEngine != 0 ); |
|
115 |
|
116 MpEngineFactory::sharedEngine()->setLoudness( false ); |
|
117 |
|
118 QCOMPARE(mTest->mModel->rowCount(),2 ); |
|
119 QCOMPARE(mTest->mModel->columnCount(),1 ); |
|
120 |
|
121 QCOMPARE( mTest->mModel->item( 0 )->type(), HbDataFormModelItem::SliderItem ); |
|
122 QCOMPARE( mTest->mModel->item( 1 )->type(), HbDataFormModelItem::ToggleValueItem ); |
|
123 |
|
124 //slider |
|
125 QCOMPARE( mTest->mModel->item( 0 )->contentWidgetData("minimum"), QVariant(-100) ); |
|
126 QCOMPARE( mTest->mModel->item( 0 )->contentWidgetData("maximum"), QVariant(100) ); |
|
127 QCOMPARE( mTest->mModel->item( 0 )->contentWidgetData("majorTickInterval"), QVariant(100) ); |
|
128 QCOMPARE( mTest->mModel->item( 0 )->contentWidgetData("minorTickInterval"), QVariant(25) ); |
|
129 QCOMPARE( mTest->mModel->item( 0 )->contentWidgetData("singleStep"), QVariant(25) ); |
|
130 QCOMPARE( mTest->mModel->item( 0 )->contentWidgetData("toolTipVisible"), QVariant(false) ); |
|
131 int position = Hb::SliderTicksRight; |
|
132 QCOMPARE((mTest->mModel->item( 0 )->contentWidgetData("tickPosition")).toInt(), position); |
|
133 QCOMPARE( mTest->mModel->item( 0 )->contentWidgetData("sliderPosition"), QVariant(mTest->mMpEngine->balance()) ); //this needs to be checked |
|
134 QCOMPARE( mTest->mModel->item( 0 )->contentWidgetData("trackFilled"), QVariant(false) ); |
|
135 |
|
136 } |
|
137 |
|
138 /*! |
|
139 Tests InitializeLoudnessOff. |
|
140 */ |
|
141 void TestMpSettingsAudioEffectsWidget::testInitializeLoudnessOff() |
|
142 { |
|
143 //test loudness HbDataFormModelItem is set up correctly in initialize() |
|
144 MpEngineFactory::sharedEngine()->setLoudness( false ); |
|
145 mTest->initialize(); |
|
146 QVERIFY( mTest->mModel->item( 1 )->type() == HbDataFormModelItem::ToggleValueItem ); |
|
147 QCOMPARE( mTest->mModel->item( 1 )->contentWidgetData("text"), QVariant(hbTrId( "txt_mus_setlabel_loudness_val_off" )) ); |
|
148 QCOMPARE( mTest->mModel->item( 1 )->contentWidgetData("additionalText"), QVariant(hbTrId( "txt_mus_setlabel_loudness_val_on" )) ); |
|
149 } |
|
150 |
|
151 /*! |
|
152 Tests InitializeLoudnessOn. |
|
153 */ |
|
154 void TestMpSettingsAudioEffectsWidget::testInitializeLoudnessOn() |
|
155 { |
|
156 //test loudness HbDataFormModelItem is set up correctly in initialize() |
|
157 MpEngineFactory::sharedEngine()->setLoudness( true ); |
|
158 mTest->initialize(); |
|
159 QVERIFY( mTest->mModel->item( 1 )->type() == HbDataFormModelItem::ToggleValueItem ); |
|
160 QCOMPARE( mTest->mModel->item( 1 )->contentWidgetData("text"), QVariant(hbTrId( "txt_mus_setlabel_loudness_val_on" )) ); |
|
161 QCOMPARE( mTest->mModel->item( 1 )->contentWidgetData("additionalText"), QVariant(hbTrId( "txt_mus_setlabel_loudness_val_off" )) ); |
|
162 |
|
163 } |
|
164 |
|
165 /*! |
|
166 Tests FilterSignals. |
|
167 */ |
|
168 void TestMpSettingsAudioEffectsWidget::testFilterSignals() |
|
169 { |
|
170 //filtersignals should not change loudness value |
|
171 MpEngineFactory::sharedEngine()->setLoudness( false ); |
|
172 mTest->initialize(); |
|
173 QModelIndex index1 = mTest->mModel->indexFromItem((mTest->mModel->item(1))); |
|
174 mTest->filterSignals(index1,index1); |
|
175 QCOMPARE(MpEngineFactory::sharedEngine()->loudness(), false); |
|
176 |
|
177 } |
|
178 |
|
179 |
|
180 |
|
181 |
|
182 // End of file |