calendarui/views/dayview/tsrc/unittests/unittest_calendayview/unittest_calendayview.cpp
changeset 75 7ac58b2aae6f
parent 57 bb2d3e476f29
child 81 ce92091cbd61
equal deleted inserted replaced
72:27feeedec790 75:7ac58b2aae6f
    17 #include <QtTest/QtTest>
    17 #include <QtTest/QtTest>
    18 
    18 
    19 #include "calenservices.h"
    19 #include "calenservices.h"
    20 #include "calendateutils.h"
    20 #include "calendateutils.h"
    21 #include "calendaymodelmanager.h"
    21 #include "calendaymodelmanager.h"
       
    22 
       
    23 #define private public
       
    24 
    22 #include "calendayview.h"
    25 #include "calendayview.h"
    23 
    26 
    24 class TestCalenDayView : public QObject
    27 class TestCalenDayView : public QObject
    25 {
    28 {
    26 Q_OBJECT
    29 Q_OBJECT
    34     void cleanupTestCase();
    37     void cleanupTestCase();
    35     void init();
    38     void init();
    36     void cleanup();
    39     void cleanup();
    37 
    40 
    38     void testConstructors();
    41     void testConstructors();
    39 
    42     void testPopulationComplete();
       
    43     void testDoPopulation();
       
    44     void testOnBack();
       
    45     void testDayChangeStarted();
       
    46     void testRunChangeToAgendaView();
       
    47     void testRunLunarData();
       
    48     void testRunNewMeeting();
       
    49     void testRunGoToToday();
       
    50     void testChangeView();
       
    51     
       
    52     
    40 private:
    53 private:
    41     CalenDayView *mView;
    54     CalenDayView *mView;
       
    55     MCalenServices mServices;
    42 };
    56 };
    43 
    57 
    44 /*!
    58 /*!
    45  Constructor
    59  Constructor
    46  */
    60  */
    76 /*!
    90 /*!
    77  Called before every function
    91  Called before every function
    78  */
    92  */
    79 void TestCalenDayView::init()
    93 void TestCalenDayView::init()
    80 {
    94 {
    81 
    95     mServices.IssueCommandL(0);
       
    96     mView = new CalenDayView(mServices);
    82 }
    97 }
    83 
    98 
    84 /*!
    99 /*!
    85  Called after everyfunction
   100  Called after everyfunction
    86  */
   101  */
    87 void TestCalenDayView::cleanup()
   102 void TestCalenDayView::cleanup()
    88 {
   103 {
    89 
   104 
    90 }
   105 }
    91 
   106 
       
   107 /*!
       
   108  Test function for constructors
       
   109  1. Test if content widget is not initialized
       
   110  2. Test if content widget is correcty created
       
   111  */
    92 void TestCalenDayView::testConstructors()
   112 void TestCalenDayView::testConstructors()
    93 {
   113 {
    94 	MCalenServices services;
   114 	MCalenServices services;
    95     //1)
   115     //1)
    96     CalenDayView *testView = 0;
   116     CalenDayView *testView = 0;
   101     QVERIFY(testView);
   121     QVERIFY(testView);
   102     
   122     
   103     delete testView;
   123     delete testView;
   104 }
   124 }
   105 
   125 
       
   126 /*!
       
   127    Test if population was done.
       
   128    1)Check if there is no command before
       
   129    2)Check if command population complete is send
       
   130  */
       
   131 void TestCalenDayView::testPopulationComplete()
       
   132 {
       
   133     //1)
       
   134     QVERIFY(mServices.lastCommand() == 0);
       
   135     
       
   136     //2)
       
   137     mView->doPopulation();
       
   138     
       
   139     QVERIFY(mServices.lastCommand() == ECalenNotifyViewPopulationComplete);
       
   140 }
       
   141 
       
   142 /*!
       
   143    Test if population was done.
       
   144    1)Check if there is no command before
       
   145    2)Check if command population complete is send
       
   146  */
       
   147 void TestCalenDayView::testDoPopulation()
       
   148 {
       
   149     QVERIFY(mServices.lastCommand() == 0);
       
   150     
       
   151     mView->populationComplete();
       
   152     
       
   153     QVERIFY(mServices.lastCommand() == ECalenNotifyViewPopulationComplete);
       
   154 }
       
   155 
       
   156 /*!
       
   157    Test if population was done.
       
   158    1)Check if there is no command before
       
   159    2)Check if command  month view is send
       
   160  */
       
   161 void TestCalenDayView::testOnBack()
       
   162 {
       
   163 #ifndef __WINSCW__
       
   164     QVERIFY(mServices.lastCommand() == 0);
       
   165     
       
   166     mView->onBack();
       
   167     
       
   168     QVERIFY(mServices.lastCommand() == ECalenMonthView);
       
   169 #endif /*__WINSCW__*/
       
   170 }
       
   171 
       
   172 /*!
       
   173    Test if population was done.
       
   174    1)Check if next date is set
       
   175    2)Check if priovor date is set
       
   176  */
       
   177 void TestCalenDayView::testDayChangeStarted()
       
   178 {
       
   179 #ifndef __WINSCW__
       
   180     mView->mDate = QDateTime(QDate(2010,9,8),QTime(10,10,10));
       
   181     mView->dayChangeStarted(ECalenScrollToNext);
       
   182     
       
   183     QVERIFY(mView->mDate == QDateTime(QDate(2010,9,9),QTime(10,10,10)));
       
   184     
       
   185     mView->dayChangeStarted(ECalenScrollToPrev);
       
   186         
       
   187     QVERIFY(mView->mDate == QDateTime(QDate(2010,9,8),QTime(10,10,10)));
       
   188 #endif /*__WINSCW__*/
       
   189 }
       
   190 
       
   191 /*!
       
   192    Test if population was done.
       
   193    1)Check if there is no command before
       
   194    2)Check if command go to agenda view is send
       
   195  */
       
   196 void TestCalenDayView::testRunChangeToAgendaView()
       
   197 {
       
   198 #ifndef __WINSCW__
       
   199     QVERIFY(mServices.lastCommand() == 0);
       
   200     
       
   201     mView->runChangeToAgendaView();
       
   202     
       
   203     QVERIFY(mServices.lastCommand() == ECalenAgendaView);
       
   204 #endif /*__WINSCW__*/
       
   205 }
       
   206 
       
   207 /*!
       
   208    Test if population was done.
       
   209    1)Check if there is no command before
       
   210    2)Check if command regional info taped is send
       
   211  */
       
   212 void TestCalenDayView::testRunLunarData()
       
   213 {
       
   214 #ifndef __WINSCW__
       
   215     QVERIFY(mServices.lastCommand() == 0);
       
   216     
       
   217     mView->runLunarData();
       
   218     
       
   219     QVERIFY(mServices.lastCommand() == ECalenRegionalPluginTapEvent); 
       
   220 #endif /*__WINSCW__*/  
       
   221 }
       
   222 
       
   223 /*!
       
   224    Test if population was done.
       
   225    1)Check if there is no command before
       
   226    2)Check if command new meeting is send
       
   227  */
       
   228 void TestCalenDayView::testRunNewMeeting()
       
   229 {
       
   230 #ifndef __WINSCW__
       
   231     QVERIFY(mServices.lastCommand() == 0);
       
   232     
       
   233     mView->runNewMeeting();
       
   234     
       
   235     QVERIFY(mServices.lastCommand() == ECalenNewMeeting);   
       
   236 #endif /*__WINSCW__*/
       
   237 }
       
   238 
       
   239 /*!
       
   240    Test if population was done.
       
   241    1)Check if there is no command before
       
   242    2)Check if command go to today is send
       
   243  */
       
   244 void TestCalenDayView::testRunGoToToday()
       
   245 {
       
   246 #ifndef __WINSCW__
       
   247     QVERIFY(mServices.lastCommand() == 0);
       
   248     
       
   249     mView->runGoToToday();
       
   250     
       
   251     QVERIFY(mServices.lastCommand() == ECalenGotoToday); 
       
   252 #endif /*__WINSCW__*/
       
   253 }
       
   254 
       
   255 /*!
       
   256    Test if population was done.
       
   257    1)Check if there is no command before
       
   258    2)Check if command givenn command is send
       
   259  */
       
   260 void TestCalenDayView::testChangeView()
       
   261 {
       
   262     QVERIFY(mServices.lastCommand() == 0);
       
   263     
       
   264     mView->changeView(ECalenAgendaView);
       
   265     
       
   266     QVERIFY(mServices.lastCommand() == ECalenAgendaView); 
       
   267 }
       
   268 
   106 QTEST_MAIN(TestCalenDayView);
   269 QTEST_MAIN(TestCalenDayView);
   107 
   270 
   108 #include "unittest_calendayview.moc"
   271 #include "unittest_calendayview.moc"