taskswitcher/server/tsrc/t_tsmodelitem/t_tsmodelitem.cpp
author Jaakko Haukipuro (Nokia-MS/Oulu) <Jaakko.Haukipuro@nokia.com>
Thu, 16 Sep 2010 12:11:40 +0100
changeset 117 c63ee96dbe5f
permissions -rw-r--r--
Missing activityfw and taskswitcher components - fix for Bug 3670

/*
* 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 <QtTest/QtTest>

#include "t_tsmodelitem.h"
#include "t_tsmodel.h"

void T_TsModelItem::testItem()
{
    T_TsModel model;
    int errNo(KErrNone);
    const int invalidOffset(model.count());
    const int validOffset(model.count() - 1);
    QVERIFY(0 <= validOffset);
    
    TRAP(errNo, model.itemL(invalidOffset).displayNameL());
    QVERIFY(KErrNone != errNo);
    TRAP(errNo, model.itemL(validOffset).displayNameL());
    QVERIFY(KErrNone == errNo);
    QVERIFY(0 == T_TsModel::expectedDesCValue().Compare(model.itemL(validOffset).displayNameL()));
    
    TRAP(errNo, model.itemL(invalidOffset).iconHandleL());
    QVERIFY(KErrNone != errNo);
    TRAP(errNo, model.itemL(validOffset).iconHandleL());
    QVERIFY(KErrNone == errNo);
    QVERIFY(T_TsModel::expectedIntValue() == model.itemL(validOffset).iconHandleL());
    
    TRAP(errNo, model.itemL(invalidOffset).timestampL());
    QVERIFY(KErrNone != errNo);
    TRAP(errNo, model.itemL(validOffset).timestampL());
    QVERIFY(KErrNone == errNo);
    QVERIFY(T_TsModel::expectedTimeValue() == model.itemL(validOffset).timestampL());
    
    TRAP(errNo, model.itemL(invalidOffset).keyL());
    QVERIFY(KErrNone != errNo);
    TRAP(errNo, model.itemL(validOffset).keyL());
    QVERIFY(KErrNone == errNo);
    QVERIFY(T_TsModel::expectedIntValue() == model.itemL(validOffset).keyL().key());
    
    TRAP(errNo, model.itemL(invalidOffset).isActiveL());
    QVERIFY(KErrNone != errNo);
    TRAP(errNo, model.itemL(validOffset).isActiveL());
    QVERIFY(KErrNone == errNo);
    QVERIFY(T_TsModel::expectedBoolValue() == model.itemL(validOffset).isActiveL());
    
    TRAP(errNo, model.itemL(invalidOffset).isClosableL());
    QVERIFY(KErrNone != errNo);
    TRAP(errNo, model.itemL(validOffset).isClosableL());
    QVERIFY(KErrNone == errNo);
    QVERIFY(T_TsModel::expectedBoolValue() == model.itemL(validOffset).isClosableL());
    
    TRAP(errNo, model.itemL(invalidOffset).closeL());
    QVERIFY(KErrNone != errNo);
    TRAP(errNo, model.itemL(validOffset).closeL());
    QVERIFY(KErrNone == errNo);
    QVERIFY(T_TsModel::expectedBoolValue() == model.itemL(validOffset).closeL());
    
    TRAP(errNo, model.itemL(invalidOffset).launchL());
    QVERIFY(KErrNone != errNo);
    TRAP(errNo, model.itemL(validOffset).launchL());
    QVERIFY(KErrNone == errNo);
    QVERIFY(T_TsModel::expectedBoolValue() == model.itemL(validOffset).launchL());

}

QTEST_MAIN(T_TsModelItem)