calendarui/views/dayview/tsrc/unittests/unittest_calendayitemview/hbinstance.h
changeset 45 b6db4fd4947b
child 57 bb2d3e476f29
equal deleted inserted replaced
23:fd30d51f876b 45:b6db4fd4947b
       
     1 /*
       
     2 * Copyright (c) 2010 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 CalenDayUtils class
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef  HBMAINWINDOW_H
       
    19 #define  HBMAINWINDOW_H
       
    20 
       
    21 #include <QObject>
       
    22 #include <QtGlobal>
       
    23 #include <QRectF>
       
    24 
       
    25 // Test variables
       
    26 extern QRectF gTestWindowRect;
       
    27 extern Qt::Orientation gTestOrientation;
       
    28 
       
    29 
       
    30 
       
    31 /*!
       
    32  Mocked class HbMainWindow (simulating window in unittests)
       
    33  */
       
    34 class HbMainWindow
       
    35 : public QObject
       
    36 {
       
    37     Q_OBJECT
       
    38 public:
       
    39     HbMainWindow(QObject *parent = 0) : QObject(parent){
       
    40         Q_UNUSED(parent);
       
    41     }
       
    42     
       
    43     ~HbMainWindow() {
       
    44     }
       
    45     
       
    46     QRectF layoutRect() const {
       
    47         return gTestWindowRect;
       
    48     }
       
    49     
       
    50     Qt::Orientation orientation() const {
       
    51         return gTestOrientation;
       
    52     }
       
    53 signals:
       
    54     void orientationChanged(Qt::Orientation);
       
    55 };
       
    56 
       
    57 #endif // HBMAINWINDOW_H
       
    58 
       
    59 #ifndef  HBINSTANCE_H
       
    60 #define  HBINSTANCE_H
       
    61 
       
    62 #include <QList>
       
    63 
       
    64 /*!
       
    65  Mocked class HbInstance (simulating hbinstance in unittests)
       
    66  */
       
    67 class HbInstance
       
    68 {
       
    69 public:
       
    70     
       
    71     static HbInstance *instance() {
       
    72         return new HbInstance();
       
    73     }
       
    74     
       
    75     QList<HbMainWindow *> allMainWindows() const {
       
    76         return mMainWindows;
       
    77     }
       
    78     
       
    79     HbInstance() {
       
    80         HbMainWindow* window = new HbMainWindow();
       
    81         mMainWindows.append(window);
       
    82     }
       
    83     
       
    84     ~HbInstance() {
       
    85         for (int i = 0; i < mMainWindows.count(); i++) {
       
    86             delete mMainWindows[i];
       
    87         }
       
    88         mMainWindows.clear();
       
    89     }
       
    90     
       
    91     QList<HbMainWindow *> mMainWindows;
       
    92 };
       
    93 
       
    94 #endif // HBINSTANCE_H
       
    95 
       
    96 // End of File