author | hgs |
Fri, 15 Oct 2010 12:58:46 +0300 | |
changeset 78 | baacf668fe89 |
parent 46 | bc5a64e5bc3c |
permissions | -rw-r--r-- |
37 | 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 "ut_cptelephonypluginview.h" |
|
19 |
#include "qtestmains60ui.h" |
|
20 |
#include <cpplugininterface.h> |
|
21 |
#include <cpitemdatahelper.h> |
|
22 |
#include <cpsettingformitemdata.h> |
|
23 |
#include <smcmockclassincludes.h> |
|
24 |
#include <hbdataform.h> |
|
25 |
#include <hbdataformmodel.h> |
|
26 |
#include "cptelephonypluginview.h" |
|
78 | 27 |
#include <cppluginloader.h> |
37 | 28 |
|
29 |
||
30 |
class DummyPlugin : public CpPluginInterface |
|
31 |
{ |
|
32 |
public: |
|
33 |
DummyPlugin(){} |
|
34 |
~DummyPlugin(){} |
|
35 |
||
36 |
QList<CpSettingFormItemData*> createSettingFormItemData( |
|
37 |
CpItemDataHelper &itemDataHelper) const |
|
38 |
{ |
|
39 |
SMC_MOCK_METHOD1( QList<CpSettingFormItemData*>, CpItemDataHelper &, itemDataHelper ) |
|
40 |
} |
|
41 |
}; |
|
42 |
||
43 |
/*! |
|
44 |
UT_CpTelephonyPluginView::UT_CpTelephonyPluginView |
|
45 |
*/ |
|
46 |
UT_CpTelephonyPluginView::UT_CpTelephonyPluginView() |
|
47 |
{ |
|
48 |
} |
|
49 |
||
50 |
/*! |
|
51 |
UT_CpTelephonyPluginView::~UT_CpTelephonyPluginView |
|
52 |
*/ |
|
53 |
UT_CpTelephonyPluginView::~UT_CpTelephonyPluginView() |
|
54 |
{ |
|
55 |
} |
|
56 |
||
57 |
||
58 |
/*! |
|
59 |
UT_CpTelephonyPluginView::init |
|
60 |
*/ |
|
61 |
void UT_CpTelephonyPluginView::init() |
|
62 |
{ |
|
63 |
initialize(); |
|
78 | 64 |
} |
46
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
65 |
|
37 | 66 |
|
67 |
/*! |
|
68 |
UT_CpTelephonyPluginView::cleanup |
|
69 |
*/ |
|
70 |
void UT_CpTelephonyPluginView::cleanup() |
|
71 |
{ |
|
72 |
reset(); |
|
73 |
} |
|
74 |
||
78 | 75 |
|
37 | 76 |
/*! |
77 |
UT_CpTelephonyPluginView::t_memleak |
|
78 |
*/ |
|
79 |
void UT_CpTelephonyPluginView::t_memleak() |
|
80 |
{ |
|
81 |
QList<CpSettingFormItemData*> list; |
|
82 |
list.append(new CpSettingFormItemData); |
|
83 |
DummyPlugin *ret = new DummyPlugin; |
|
78 | 84 |
|
85 |
HbDataForm *form = new HbDataForm; |
|
86 |
EXPECT(HbView, widget).returns(form); |
|
87 |
||
88 |
EXPECT(CpPluginLoader, loadCpPluginInterface). |
|
89 |
with(QString("cpcallsplugin")).returns(ret); // Ownership change. |
|
90 |
EXPECT(DummyPlugin, createSettingFormItemData).returns(list); |
|
91 |
||
92 |
// For clarity, create a new pointer instead of using the existing one. |
|
93 |
DummyPlugin *dummy = new DummyPlugin; |
|
94 |
EXPECT(CpPluginLoader, loadCpPluginInterface). |
|
95 |
with(QString("cpdivertplugin")).returns(dummy); // Ownership change. |
|
96 |
EXPECT(DummyPlugin, createSettingFormItemData).returns(list); |
|
97 |
||
98 |
QModelIndex index; |
|
99 |
EXPECT(HbDataFormModel, indexFromItem).returns<QModelIndex>(index); |
|
100 |
||
37 | 101 |
CpTelephonyPluginView *tmp = new CpTelephonyPluginView; |
78 | 102 |
QVERIFY(verify()); |
37 | 103 |
delete tmp; |
78 | 104 |
delete form; |
105 |
||
106 |
// Test constructor that doesn't call any other functions. |
|
107 |
EXPECT(HbView, widget).returns<QGraphicsWidget *>(0); |
|
108 |
CpTelephonyPluginView *tmp2 = new CpTelephonyPluginView; |
|
109 |
QVERIFY(verify()); |
|
110 |
delete tmp2; |
|
37 | 111 |
} |
112 |
||
113 |
||
78 | 114 |
void UT_CpTelephonyPluginView::t_construct2() |
115 |
{ |
|
116 |
QVariantList list; |
|
117 |
list.append("blah"); |
|
118 |
list.append("blaah"); |
|
119 |
||
120 |
// Test constructor that doesn't call any other functions. |
|
121 |
EXPECT(HbView, widget).returns<QGraphicsWidget *>(0); |
|
122 |
CpTelephonyPluginView *tmp = new CpTelephonyPluginView(list); |
|
123 |
QVERIFY(verify()); |
|
124 |
delete tmp; |
|
125 |
||
126 |
// Do the "real" test. |
|
127 |
QModelIndex index; |
|
128 |
HbDataForm *form = new HbDataForm; |
|
129 |
EXPECT(HbView, widget).returns(form); |
|
130 |
||
131 |
DummyPlugin *dummy = new DummyPlugin; |
|
132 |
EXPECT(CpPluginLoader, loadCpPluginInterface). |
|
133 |
with(QString("blaah")).returns(dummy); // Ownership change. |
|
134 |
QList<CpSettingFormItemData*> list2; |
|
135 |
list2.append(new CpSettingFormItemData); |
|
136 |
EXPECT(DummyPlugin, createSettingFormItemData).returns(list2); |
|
137 |
||
138 |
EXPECT(HbDataFormModel, indexFromItem).returns<QModelIndex>(index); |
|
139 |
CpTelephonyPluginView *tmp2 = new CpTelephonyPluginView(list); |
|
140 |
QVERIFY(verify()); |
|
141 |
delete form; |
|
142 |
delete tmp2; |
|
143 |
} |
|
144 |
||
37 | 145 |
|
146 |
QTEST_MAIN_S60UI(UT_CpTelephonyPluginView) |