|
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: Item decorator of the message list view. |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "unittest_msgaudiofetchermodel.h" |
|
19 #include <QtTest/QtTest> |
|
20 #include <HbMainWindow> |
|
21 #include <HbListView> |
|
22 #include "msguitest.h" |
|
23 |
|
24 TestMsgAudioFetcherModel::TestMsgAudioFetcherModel():mTestMainWindow(NULL),mListView(NULL),mMsgAudioFetcherModel(NULL) |
|
25 { |
|
26 |
|
27 } |
|
28 |
|
29 TestMsgAudioFetcherModel::~TestMsgAudioFetcherModel() |
|
30 { |
|
31 |
|
32 } |
|
33 |
|
34 void TestMsgAudioFetcherModel::initTestCase() |
|
35 { |
|
36 mTestMainWindow = new HbMainWindow(); |
|
37 mListView = new HbListView(); |
|
38 mMsgAudioFetcherModel = new MsgAudioFetcherModel(this); |
|
39 mListView->setModel(mMsgAudioFetcherModel); |
|
40 mTestMainWindow->addView(mListView); |
|
41 } |
|
42 void TestMsgAudioFetcherModel::test_Constructor() |
|
43 { |
|
44 QVERIFY(mMsgAudioFetcherModel->mSelectionEngine != NULL); |
|
45 } |
|
46 |
|
47 void TestMsgAudioFetcherModel::test_init() |
|
48 { |
|
49 QVERIFY(mMsgAudioFetcherModel->mSelectionEngine != NULL); |
|
50 } |
|
51 |
|
52 void TestMsgAudioFetcherModel::test_addToneFiles() |
|
53 { |
|
54 QDir dir("c:\\data\\testAudioFetcher"); |
|
55 mMsgAudioFetcherModel->addToneFiles(dir); |
|
56 int rowCount = mMsgAudioFetcherModel->rowCount(); |
|
57 QVERIFY(mMsgAudioFetcherModel->rowCount() != 0); |
|
58 } |
|
59 |
|
60 void TestMsgAudioFetcherModel::test_insertIndex() |
|
61 { |
|
62 QDir dir("c:\\data\\testAudioFetcher"); |
|
63 mMsgAudioFetcherModel->addToneFiles(dir); |
|
64 /*As already 4 file are present int the list, So index for file AAA should be 0 and ZZZ should be 4*/ |
|
65 int index = mMsgAudioFetcherModel->insertIndex(0,mMsgAudioFetcherModel->rowCount(),"AAA"); |
|
66 QVERIFY(index == 0); |
|
67 index = mMsgAudioFetcherModel->insertIndex(0,mMsgAudioFetcherModel->rowCount(),"zzz"); |
|
68 QVERIFY(index == 4); |
|
69 } |
|
70 |
|
71 void TestMsgAudioFetcherModel::test_clearAll() |
|
72 { |
|
73 |
|
74 QVERIFY(mMsgAudioFetcherModel->rowCount() != 0); |
|
75 /*test_addToneFiles is already called so this count should not be 0*/ |
|
76 mMsgAudioFetcherModel->clearAll(); |
|
77 |
|
78 QVERIFY(mMsgAudioFetcherModel->rowCount() == 0) ; |
|
79 QVERIFY(mMsgAudioFetcherModel->columnCount() == 0); |
|
80 } |
|
81 |
|
82 void TestMsgAudioFetcherModel::test_queryComplete() |
|
83 { |
|
84 QStringList nameList; |
|
85 QStringList uriList; |
|
86 nameList.append("drm.amr"); |
|
87 nameList.append("nondrm.amr"); |
|
88 |
|
89 uriList.append("c:\\data\\testAudioFetcher\\drm.amr"); |
|
90 uriList.append("c:\\data\\testAudioFetcher\\nondrm.amr"); |
|
91 mMsgAudioFetcherModel->queryComplete(nameList,uriList); |
|
92 QVERIFY(mMsgAudioFetcherModel->rowCount() == 2); |
|
93 } |
|
94 |
|
95 void TestMsgAudioFetcherModel::test_isDRM() |
|
96 { |
|
97 QFETCH(QString, fileName); |
|
98 QFETCH(bool, expectedResult); |
|
99 bool result = mMsgAudioFetcherModel->isDRM(fileName); |
|
100 QVERIFY(result == expectedResult); |
|
101 } |
|
102 void TestMsgAudioFetcherModel::test_isDRM_data() |
|
103 { |
|
104 QTest::addColumn<QString>("fileName"); |
|
105 QTest::addColumn<bool>("expectedResult"); |
|
106 QTest::newRow("NON DRM File")<< "c:\\data\\testAudioFetcher\\drm.amr" << false; |
|
107 QTest::newRow("NON DRM File")<< "c:\\data\\testAudioFetcher\\nondrm.amr" << false; |
|
108 QTest::newRow("DRM File")<< "c:\\data\\testAudioFetcher\\DRM_AMR.dcf" << true; |
|
109 } |
|
110 |
|
111 void TestMsgAudioFetcherModel::cleanupTestCase() |
|
112 { |
|
113 if(mMsgAudioFetcherModel) |
|
114 delete mMsgAudioFetcherModel; |
|
115 if(mListView) |
|
116 delete mListView; |
|
117 if(mTestMainWindow) |
|
118 delete mTestMainWindow; |
|
119 } |
|
120 MSGUI_TEST_MAIN(TestMsgAudioFetcherModel) |