45
|
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: Test class for CalenDayModel
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
#include <QtTest/QtTest>
|
|
18 |
|
|
19 |
#include "calendaymodel.h"
|
|
20 |
#include "calenservices.h"
|
|
21 |
|
|
22 |
class TestCalenDayModel : public QObject
|
|
23 |
{
|
|
24 |
Q_OBJECT
|
|
25 |
|
|
26 |
public:
|
|
27 |
TestCalenDayModel();
|
|
28 |
virtual ~TestCalenDayModel();
|
|
29 |
|
|
30 |
private slots:
|
|
31 |
void initTestCase();
|
|
32 |
void cleanupTestCase();
|
|
33 |
void init();
|
|
34 |
void cleanup();
|
|
35 |
|
|
36 |
void testConstructors();
|
|
37 |
|
|
38 |
private:
|
|
39 |
QDateTime mDateTime;
|
|
40 |
MCalenServices *mServices;
|
|
41 |
CalenDayModel *mModel;
|
|
42 |
};
|
|
43 |
|
|
44 |
/*!
|
|
45 |
Constructor
|
|
46 |
*/
|
|
47 |
TestCalenDayModel::TestCalenDayModel() :
|
|
48 |
mServices(NULL), mModel(NULL)
|
|
49 |
{
|
|
50 |
|
|
51 |
}
|
|
52 |
|
|
53 |
/*!
|
|
54 |
Destructor
|
|
55 |
*/
|
|
56 |
TestCalenDayModel::~TestCalenDayModel()
|
|
57 |
{
|
|
58 |
|
|
59 |
}
|
|
60 |
|
|
61 |
/*!
|
|
62 |
Called before testcase
|
|
63 |
*/
|
|
64 |
void TestCalenDayModel::initTestCase()
|
|
65 |
{
|
|
66 |
mDateTime = QDateTime::currentDateTime();
|
|
67 |
mServices = new MCalenServices();
|
|
68 |
}
|
|
69 |
|
|
70 |
/*!
|
|
71 |
Called after testcase
|
|
72 |
*/
|
|
73 |
void TestCalenDayModel::cleanupTestCase()
|
|
74 |
{
|
|
75 |
if (mServices) {
|
|
76 |
delete mServices;
|
|
77 |
}
|
|
78 |
}
|
|
79 |
|
|
80 |
/*!
|
|
81 |
Called before every function
|
|
82 |
*/
|
|
83 |
void TestCalenDayModel::init()
|
|
84 |
{
|
|
85 |
mModel = new CalenDayModel(mDateTime, *mServices);
|
|
86 |
}
|
|
87 |
|
|
88 |
/*!
|
|
89 |
Called after everyfunction
|
|
90 |
*/
|
|
91 |
void TestCalenDayModel::cleanup()
|
|
92 |
{
|
|
93 |
if (mModel) {
|
|
94 |
delete mModel;
|
|
95 |
mModel = NULL;
|
|
96 |
}
|
|
97 |
}
|
|
98 |
|
|
99 |
/*!
|
|
100 |
Test function for constructors
|
|
101 |
1. Test if model is not initialized
|
|
102 |
2. Test if model is correcty created
|
|
103 |
*/
|
|
104 |
void TestCalenDayModel::testConstructors()
|
|
105 |
{
|
|
106 |
//1)
|
|
107 |
CalenDayModel *testModel = 0;
|
|
108 |
QVERIFY(!testModel);
|
|
109 |
|
|
110 |
//2)
|
|
111 |
testModel = new CalenDayModel(mDateTime, *mServices);
|
|
112 |
QVERIFY(testModel);
|
|
113 |
|
|
114 |
delete testModel;
|
|
115 |
}
|
|
116 |
|
|
117 |
QTEST_MAIN(TestCalenDayModel);
|
|
118 |
#include "unittest_calendaymodel.moc"
|