diff -r 8bda91a87a00 -r 8ee96d21d9bf controlpanel/tsrc/unit/ut_profileengwrapper/src/ut_profileengwrapper.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/controlpanel/tsrc/unit/ut_profileengwrapper/src/ut_profileengwrapper.cpp Tue Aug 31 15:29:50 2010 +0300 @@ -0,0 +1,91 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0"" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +#include "ut_profileengwrapper.h" +#include "cpprofileengine.h" +#include "cpprofile.h" +#include "cpprofiledef.h" +#include +#include +#include + + +void TestProfileEngWrapper::initTestCase() +{ + mProfileEng = new CpProfileEngine(); + QVERIFY(mProfileEng != 0); +} + +void TestProfileEngWrapper::testProfileList() +{ + QStringList profileList = mProfileEng->profileList(); + + QVERIFY(profileList.size() > 0); + + qDebug() << "read all profiles:\r\n"; + foreach(const QString &name,profileList) { + qDebug() << name << "\t"; + } + qDebug() << "\r\n"; +} + +void TestProfileEngWrapper::testModifyProfile() +{ + CpProfile *generalProfile = mProfileEng->profile(CpProfileGeneralId); + + int prevolume = generalProfile->ringingVolume(CpProfileKnownCaller); + qDebug() << "before modifying volume:" << prevolume << "\r\n"; + + int newvolume = prevolume + 1; + generalProfile->setRingingVolume(CpProfileKnownCaller, newvolume); + mProfileEng->saveProfile(generalProfile); + + qDebug() << "after modifying volume:" << generalProfile->ringingVolume(CpProfileKnownCaller) << "\r\n"; + + generalProfile->setRingingVolume(CpProfileKnownCaller, prevolume); + mProfileEng->saveProfile(generalProfile); + + QVERIFY(prevolume == generalProfile->ringingVolume(CpProfileKnownCaller)); +} + +void TestProfileEngWrapper::testCreateAndDeleteProfile() +{ + QStringList profileList = mProfileEng->profileList(); + qDebug() << "origion size:" << profileList.size() << "\r\n"; + + //create a profile + CpProfile *newProfile = mProfileEng->createProfile(); + mProfileEng->saveProfile(newProfile); + + QStringList newProfileList = mProfileEng->profileList(); + + qDebug() << "size after creating new:" << newProfileList.size() << "\r\n"; + QVERIFY(profileList.size() + 1 == newProfileList.size()); + + mProfileEng->deleteProfile(newProfile->id()); + newProfileList = mProfileEng->profileList(); + qDebug() << "size after deleting new:" << newProfileList.size() << "\r\n"; + QVERIFY(profileList.size() == newProfileList.size()); + +} + +void TestProfileEngWrapper::cleanupTestCase() +{ + delete mProfileEng; + mProfileEng = 0; +} + +QTEST_MAIN(TestProfileEngWrapper)