calendarui/views/dayview/tsrc/unittests/unittest_calendayutils/unittest_calendayutils.cpp
changeset 45 b6db4fd4947b
child 55 2c54b51f39c4
child 58 ef813d54df51
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: Test class for CalenDayContentWidget
       
    15  *
       
    16  */
       
    17 #include <QGraphicsItem>
       
    18 #include <QtTest/QtTest>
       
    19 
       
    20 #include "calendayutils.h"
       
    21 #include "calendaycommonheaders.h"
       
    22 
       
    23 // Test variables
       
    24 QRectF gTestWindowRect = QRectF(0, 0, 10, 20);
       
    25 Qt::Orientation gTestOrientation = Qt::Horizontal;
       
    26 
       
    27 class TestCalenDayUtils : public QObject
       
    28 {
       
    29 Q_OBJECT
       
    30 
       
    31 public:
       
    32     TestCalenDayUtils();
       
    33     virtual ~TestCalenDayUtils();
       
    34 
       
    35 private slots:
       
    36     void initTestCase();
       
    37     void cleanupTestCase();
       
    38     void init();
       
    39     void cleanup();
       
    40 
       
    41     void testConstructors();
       
    42     void testHorizontalSwipe();
       
    43     void testOrientation();
       
    44 
       
    45 private:
       
    46     CalenDayUtils *mUtils;
       
    47 };
       
    48 
       
    49 /*!
       
    50  Constructor
       
    51  */
       
    52 TestCalenDayUtils::TestCalenDayUtils() :
       
    53    mUtils(NULL)
       
    54 {
       
    55 
       
    56 }
       
    57 
       
    58 /*!
       
    59  Destructor
       
    60  */
       
    61 TestCalenDayUtils::~TestCalenDayUtils()
       
    62 {
       
    63 
       
    64 }
       
    65 
       
    66 /*!
       
    67  Called before testcase
       
    68  */
       
    69 void TestCalenDayUtils::initTestCase()
       
    70 {
       
    71 }
       
    72 
       
    73 /*!
       
    74  Called after testcase
       
    75  */
       
    76 void TestCalenDayUtils::cleanupTestCase()
       
    77 {
       
    78 
       
    79 }
       
    80 
       
    81 /*!
       
    82  Called before every function
       
    83  */
       
    84 void TestCalenDayUtils::init()
       
    85 {
       
    86 }
       
    87 
       
    88 /*!
       
    89  Called after everyfunction
       
    90  */
       
    91 void TestCalenDayUtils::cleanup()
       
    92 {
       
    93 }
       
    94 
       
    95 /*!
       
    96  Test function for constructors
       
    97  1. Test if content widget is not initialized
       
    98  2. Test if content widget is correcty created
       
    99  */
       
   100 void TestCalenDayUtils::testConstructors()
       
   101 {
       
   102     //1)
       
   103     CalenDayUtils *testUtils = 0;
       
   104     QVERIFY(!testUtils);
       
   105     
       
   106     //2)
       
   107     testUtils = CalenDayUtils::instance();
       
   108     QVERIFY(testUtils);
       
   109 }
       
   110 
       
   111 /*!
       
   112    Test function for checking if swipe is horizontal or not
       
   113    1)test Horizontal swipe
       
   114    2)test no horizontal swipe
       
   115  */
       
   116 void TestCalenDayUtils::testHorizontalSwipe()
       
   117 {
       
   118     //1)
       
   119     QCOMPARE(CalenDayUtils::instance()->isHorizontalSwipe(KCalenSwipeAngle-5), 
       
   120         true);
       
   121     
       
   122     //2)
       
   123     QCOMPARE(CalenDayUtils::instance()->isHorizontalSwipe(KCalenSwipeAngle+5),
       
   124         false);
       
   125 }
       
   126 
       
   127 /*!
       
   128    Test function for getting main window's orientation
       
   129    1)test if horizontal orientation is returned
       
   130    2)test if vertical orientation is returned
       
   131  */
       
   132 void TestCalenDayUtils::testOrientation()
       
   133 {
       
   134     //1)
       
   135     gTestOrientation = Qt::Horizontal;
       
   136     QCOMPARE(CalenDayUtils::instance()->orientation(), Qt::Horizontal);
       
   137     
       
   138     //2)
       
   139     gTestOrientation = Qt::Vertical;
       
   140     QCOMPARE(CalenDayUtils::instance()->orientation(), Qt::Vertical);
       
   141 }
       
   142 
       
   143 QTEST_MAIN(TestCalenDayUtils);
       
   144 #include "unittest_calendayutils.moc"