|
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 #include "ut_profileengwrapper.h" |
|
18 #include "cpprofileengine.h" |
|
19 #include "cpprofile.h" |
|
20 #include "cpprofiledef.h" |
|
21 #include <QDebug> |
|
22 #include <qstringlist> |
|
23 #include <qttest/qttest> |
|
24 |
|
25 |
|
26 void TestProfileEngWrapper::initTestCase() |
|
27 { |
|
28 mProfileEng = new CpProfileEngine(); |
|
29 QVERIFY(mProfileEng != 0); |
|
30 } |
|
31 |
|
32 void TestProfileEngWrapper::testProfileList() |
|
33 { |
|
34 QStringList profileList = mProfileEng->profileList(); |
|
35 |
|
36 QVERIFY(profileList.size() > 0); |
|
37 |
|
38 qDebug() << "read all profiles:\r\n"; |
|
39 foreach(const QString &name,profileList) { |
|
40 qDebug() << name << "\t"; |
|
41 } |
|
42 qDebug() << "\r\n"; |
|
43 } |
|
44 |
|
45 void TestProfileEngWrapper::testModifyProfile() |
|
46 { |
|
47 CpProfile *generalProfile = mProfileEng->profile(CpProfileGeneralId); |
|
48 |
|
49 int prevolume = generalProfile->ringingVolume(CpProfileKnownCaller); |
|
50 qDebug() << "before modifying volume:" << prevolume << "\r\n"; |
|
51 |
|
52 int newvolume = prevolume + 1; |
|
53 generalProfile->setRingingVolume(CpProfileKnownCaller, newvolume); |
|
54 mProfileEng->saveProfile(generalProfile); |
|
55 |
|
56 qDebug() << "after modifying volume:" << generalProfile->ringingVolume(CpProfileKnownCaller) << "\r\n"; |
|
57 |
|
58 generalProfile->setRingingVolume(CpProfileKnownCaller, prevolume); |
|
59 mProfileEng->saveProfile(generalProfile); |
|
60 |
|
61 QVERIFY(prevolume == generalProfile->ringingVolume(CpProfileKnownCaller)); |
|
62 } |
|
63 |
|
64 void TestProfileEngWrapper::testCreateAndDeleteProfile() |
|
65 { |
|
66 QStringList profileList = mProfileEng->profileList(); |
|
67 qDebug() << "origion size:" << profileList.size() << "\r\n"; |
|
68 |
|
69 //create a profile |
|
70 CpProfile *newProfile = mProfileEng->createProfile(); |
|
71 mProfileEng->saveProfile(newProfile); |
|
72 |
|
73 QStringList newProfileList = mProfileEng->profileList(); |
|
74 |
|
75 qDebug() << "size after creating new:" << newProfileList.size() << "\r\n"; |
|
76 QVERIFY(profileList.size() + 1 == newProfileList.size()); |
|
77 |
|
78 mProfileEng->deleteProfile(newProfile->id()); |
|
79 newProfileList = mProfileEng->profileList(); |
|
80 qDebug() << "size after deleting new:" << newProfileList.size() << "\r\n"; |
|
81 QVERIFY(profileList.size() == newProfileList.size()); |
|
82 |
|
83 } |
|
84 |
|
85 void TestProfileEngWrapper::cleanupTestCase() |
|
86 { |
|
87 delete mProfileEng; |
|
88 mProfileEng = 0; |
|
89 } |
|
90 |
|
91 QTEST_MAIN(TestProfileEngWrapper) |