calendarui/views/dayview/tsrc/unittests/unittest_calendaycontentwidget/calendaymodelmanager.h
changeset 45 b6db4fd4947b
equal deleted inserted replaced
23:fd30d51f876b 45:b6db4fd4947b
       
     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: Mocked classes for testing CalenDayContentWidget class
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "calendaycontentwidgetheaders.h"
       
    20 
       
    21 
       
    22 #ifndef CALENDAYMODELMANAGER_H
       
    23 #define CALENDAYMODELMANAGER_H
       
    24 
       
    25 #include <QAbstractListModel>
       
    26 
       
    27 /*!
       
    28  Test class TestAbstractListModel
       
    29  */
       
    30 class TestAbstractListModel : public QAbstractListModel
       
    31 {
       
    32     Q_OBJECT
       
    33     
       
    34 public:
       
    35     TestAbstractListModel() : QAbstractListModel() {
       
    36     }
       
    37     
       
    38     ~TestAbstractListModel() {
       
    39     }
       
    40     
       
    41     int rowCount(const QModelIndex &parent) const {
       
    42         Q_UNUSED(parent);
       
    43         return 0;
       
    44     }
       
    45     
       
    46     QVariant data(const QModelIndex &index, int role) const {
       
    47         Q_UNUSED(index);
       
    48         Q_UNUSED(role);
       
    49         return QVariant(0);
       
    50     }
       
    51 };
       
    52 
       
    53 /*!
       
    54  Test class CalenDayModelManager
       
    55  */
       
    56 class CalenDayModelManager : public QObject
       
    57 {    
       
    58 public:
       
    59     enum ModelDay {
       
    60         PreviousDay = 0,
       
    61         CurrentDay = 1,
       
    62         NextDay = 2,
       
    63         NumberOfDays
       
    64     };
       
    65     
       
    66     CalenDayModelManager() : QObject() {
       
    67         mModel = new TestAbstractListModel();
       
    68         mServices = new MCalenServices();
       
    69     }
       
    70     
       
    71     ~CalenDayModelManager() {
       
    72         if (mModel) {
       
    73             delete mModel;
       
    74             mModel = NULL;
       
    75         }
       
    76         
       
    77         if (mServices) {
       
    78             delete mServices;
       
    79             mServices = NULL;
       
    80         }
       
    81     }
       
    82     
       
    83     QAbstractItemModel &getModel(CalenDayModelManager::ModelDay day) {
       
    84         Q_UNUSED(day)
       
    85         return *mModel;
       
    86     }
       
    87     
       
    88     MCalenServices &getServices() {
       
    89         return *mServices;
       
    90     }
       
    91     
       
    92 public:
       
    93     TestAbstractListModel *mModel;
       
    94     MCalenServices *mServices;
       
    95 };
       
    96 
       
    97 #endif//CALENDAYMODELMANAGER_H