phoneplugins/infowidgetprovider/tsrc/ut_infowidgetengine/src/ut_infowidgetengine.cpp
changeset 22 6bb1b21d2484
parent 21 92ab7f8d0eab
child 27 2f8f8080a020
equal deleted inserted replaced
21:92ab7f8d0eab 22:6bb1b21d2484
     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:
       
    15 *
       
    16 */
       
    17 #include "ut_infowidgetengine.h"
       
    18 #include "infowidgetengine.h"
       
    19 #include "qtestmains60.h"
       
    20 // mocked dependencies of the class under test
       
    21 #include "infowidgetnetworkhandler.h"
       
    22 
       
    23 const QString KHomeZoneTextTag("HomeZoneText0");    // max length 13
       
    24 const TNWViagIndicatorType 
       
    25     KHomeZoneIndicatorType = ENWViagIndicatorTypeHomeZone;
       
    26 
       
    27 const QString KMcnName("McnNameMcnNameMcnNam");     // max length 20 
       
    28 const TNWMCNIndicatorType 
       
    29     KMcnIndicatorType = ENWMCNIndicatorTypeActive;
       
    30 
       
    31 /*!
       
    32   UT_InfoWidgetEngine::UT_InfoWidgetEngine
       
    33  */
       
    34 UT_InfoWidgetEngine::UT_InfoWidgetEngine() 
       
    35     : 
       
    36     m_infoWidgetEngine(0)
       
    37 {
       
    38     
       
    39 }
       
    40 
       
    41 
       
    42 /*!
       
    43   UT_InfoWidgetEngine::~UT_InfoWidgetEngine
       
    44  */
       
    45 UT_InfoWidgetEngine::~UT_InfoWidgetEngine()
       
    46 {
       
    47     delete m_infoWidgetEngine;
       
    48 }
       
    49 
       
    50 
       
    51 /*!
       
    52   UT_InfoWidgetEngine::init
       
    53  */
       
    54 void UT_InfoWidgetEngine::init()
       
    55 {
       
    56     initialize();
       
    57     
       
    58     EXPECT(InfoWidgetNetworkHandler::logCurrentInfo);
       
    59     EXPECT(InfoWidgetNetworkHandler::homeZoneTextTag)
       
    60         .returns(KHomeZoneTextTag);
       
    61     EXPECT(InfoWidgetNetworkHandler::homeZoneIndicatorType)
       
    62         .returns(KHomeZoneIndicatorType);
       
    63     EXPECT(InfoWidgetNetworkHandler::mcnName).returns(KMcnName);
       
    64     EXPECT(InfoWidgetNetworkHandler::mcnIndicatorType)
       
    65         .returns(KMcnIndicatorType);
       
    66     
       
    67     m_infoWidgetEngine = new InfoWidgetEngine();
       
    68     
       
    69     QVERIFY(verify());
       
    70 }
       
    71 
       
    72 
       
    73 /*!
       
    74   UT_InfoWidgetEngine::cleanup
       
    75  */
       
    76 void UT_InfoWidgetEngine::cleanup()
       
    77 {
       
    78     reset();
       
    79     
       
    80     delete m_infoWidgetEngine;
       
    81     m_infoWidgetEngine = 0;
       
    82 }
       
    83 
       
    84 
       
    85 /*!
       
    86   UT_InfoWidgetEngine::t_modelData
       
    87  */
       
    88 void UT_InfoWidgetEngine::t_modelData()
       
    89 {
       
    90     const InfoWidgetEngine::ModelData& data = m_infoWidgetEngine->modelData();
       
    91     QVERIFY(data.homeZoneTextTag() == KHomeZoneTextTag);
       
    92     QVERIFY(data.homeZoneIndicatorType() == KHomeZoneIndicatorType);
       
    93     QVERIFY(data.mcnName() == KMcnName);
       
    94     QVERIFY(data.mcnIndicatorType() == KMcnIndicatorType);
       
    95 }
       
    96 
       
    97 
       
    98 /*!
       
    99   UT_InfoWidgetEngine::t_updateNetworkDataToModel
       
   100  */
       
   101 void UT_InfoWidgetEngine::t_updateNetworkDataToModel()
       
   102 {
       
   103     EXPECT(InfoWidgetNetworkHandler::logCurrentInfo);
       
   104     EXPECT(InfoWidgetNetworkHandler::homeZoneTextTag)
       
   105         .returns(KHomeZoneTextTag);
       
   106     EXPECT(InfoWidgetNetworkHandler::homeZoneIndicatorType)
       
   107         .returns(KHomeZoneIndicatorType);
       
   108     EXPECT(InfoWidgetNetworkHandler::mcnName).returns(KMcnName);
       
   109     EXPECT(InfoWidgetNetworkHandler::mcnIndicatorType)
       
   110         .returns(KMcnIndicatorType);
       
   111     QSignalSpy spy(m_infoWidgetEngine, SIGNAL(modelChanged()));
       
   112     
       
   113     m_infoWidgetEngine->updateNetworkDataToModel();
       
   114     
       
   115     const int KExpectedNumOfSignalEmissions = 1;
       
   116     QCOMPARE(spy.count(), KExpectedNumOfSignalEmissions);
       
   117     const QList<QVariant> &arguments = spy.at(0);
       
   118     QCOMPARE(arguments.count(), 0);
       
   119     
       
   120     QVERIFY(verify());
       
   121 }
       
   122 
       
   123 
       
   124 /*!
       
   125   UT_InfoWidgetEngine::t_updateSatDataToModel
       
   126  */
       
   127 void UT_InfoWidgetEngine::t_updateSatDataToModel()
       
   128 {
       
   129     m_infoWidgetEngine->updateSatDataToModel();
       
   130 }
       
   131 
       
   132 
       
   133 /*!
       
   134   UT_InfoWidgetEngine::t_updateLineDataToModel
       
   135  */
       
   136 void UT_InfoWidgetEngine::t_updateLineDataToModel()
       
   137 {
       
   138     m_infoWidgetEngine->updateLineDataToModel();
       
   139 }
       
   140 
       
   141 
       
   142 /*!
       
   143   UT_InfoWidgetEngine::t_handleNetworkError
       
   144  */
       
   145 void UT_InfoWidgetEngine::t_handleNetworkError()
       
   146 {
       
   147     m_infoWidgetEngine->handleNetworkError(0, 0);
       
   148 }
       
   149 
       
   150 
       
   151 /*!
       
   152   UT_InfoWidgetEngine::t_handleSatError
       
   153  */
       
   154 void UT_InfoWidgetEngine:: t_handleSatError()
       
   155 {
       
   156     m_infoWidgetEngine->handleSatError(0, 0);
       
   157 }
       
   158 
       
   159 
       
   160 /*!
       
   161   UT_InfoWidgetEngine::t_handleLineError
       
   162  */
       
   163 void UT_InfoWidgetEngine:: t_handleLineError()
       
   164 {
       
   165     m_infoWidgetEngine->handleLineError(0, 0);    
       
   166 }
       
   167 
       
   168 QTEST_MAIN_S60(UT_InfoWidgetEngine)