phonesettings/cpphonesettingsplugins/telephonyplugin/tsrc/ut_cptelephonypluginview/ut_cptelephonypluginview.cpp
branchRCL_3
changeset 61 41a7f70b3818
equal deleted inserted replaced
58:40a3f856b14d 61:41a7f70b3818
       
     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 
       
    18 #include "ut_cptelephonypluginview.h"
       
    19 #include "qtestmains60ui.h"
       
    20 #include <cpplugininterface.h>
       
    21 #include <cpitemdatahelper.h>
       
    22 #include <cpsettingformitemdata.h>
       
    23 #include <smcmockclassincludes.h>
       
    24 #include <hbdataform.h>
       
    25 #include <hbdataformmodel.h>
       
    26 #include "cptelephonypluginview.h"
       
    27 
       
    28 
       
    29 class DummyPlugin : public CpPluginInterface
       
    30 {
       
    31 public:
       
    32     DummyPlugin(){}
       
    33     ~DummyPlugin(){}
       
    34     
       
    35     QList<CpSettingFormItemData*> createSettingFormItemData(
       
    36             CpItemDataHelper &itemDataHelper) const
       
    37     {
       
    38         SMC_MOCK_METHOD1( QList<CpSettingFormItemData*>, CpItemDataHelper &, itemDataHelper )
       
    39     }
       
    40 };
       
    41 
       
    42 /*!
       
    43   UT_CpTelephonyPluginView::UT_CpTelephonyPluginView
       
    44  */
       
    45 UT_CpTelephonyPluginView::UT_CpTelephonyPluginView() 
       
    46     : m_callspluginview(NULL)
       
    47 {
       
    48 
       
    49 }
       
    50 
       
    51 /*!
       
    52   UT_CpTelephonyPluginView::~UT_CpTelephonyPluginView
       
    53  */
       
    54 UT_CpTelephonyPluginView::~UT_CpTelephonyPluginView()
       
    55 {
       
    56     delete m_callspluginview;
       
    57 }
       
    58 
       
    59 
       
    60 
       
    61 /*!
       
    62   UT_CpTelephonyPluginView::init
       
    63  */
       
    64 void UT_CpTelephonyPluginView::init()
       
    65 {
       
    66     initialize();
       
    67 
       
    68     CpPluginInterface *nullPlugin=0;
       
    69     DummyPlugin *ret = new DummyPlugin;
       
    70 
       
    71     QList<CpSettingFormItemData*> list;
       
    72     list.append(new CpSettingFormItemData);
       
    73     expect("CpPluginLoader::loadCpPluginInterface").
       
    74             with(QString("cpcallsplugin")).returns(ret);
       
    75     expect("DummyPlugin::createSettingFormItemData").returns(list);
       
    76     expect("CpPluginLoader::loadCpPluginInterface").
       
    77             with(QString("cpdivertplugin")).returns(nullPlugin);
       
    78     
       
    79     m_callspluginview = new CpTelephonyPluginView;
       
    80     QVERIFY( verify() );
       
    81 
       
    82 }
       
    83 
       
    84 /*!
       
    85   UT_CpTelephonyPluginView::cleanup
       
    86  */
       
    87 void UT_CpTelephonyPluginView::cleanup()
       
    88 {
       
    89     reset();
       
    90     
       
    91     delete m_callspluginview;
       
    92     m_callspluginview = NULL;
       
    93 }
       
    94 
       
    95 /*!
       
    96   UT_CpTelephonyPluginView::t_memleak
       
    97  */
       
    98 void UT_CpTelephonyPluginView::t_memleak()
       
    99 {
       
   100     QList<CpSettingFormItemData*> list;
       
   101     list.append(new CpSettingFormItemData);
       
   102     DummyPlugin *ret = new DummyPlugin;
       
   103     expect("CpPluginLoader::loadCpPluginInterface").
       
   104             with(QString("cpcallsplugin")).returns(ret);
       
   105     expect("DummyPlugin::createSettingFormItemData").returns(list);
       
   106     
       
   107     ret = new DummyPlugin;
       
   108     expect("CpPluginLoader::loadCpPluginInterface").
       
   109             with(QString("cpdivertplugin")).returns(ret);
       
   110     expect("DummyPlugin::createSettingFormItemData").returns(list);
       
   111     
       
   112     
       
   113     CpTelephonyPluginView *tmp = new CpTelephonyPluginView;
       
   114     QVERIFY( verify() );
       
   115     delete tmp;
       
   116 }
       
   117 
       
   118 
       
   119 
       
   120 QTEST_MAIN_S60UI(UT_CpTelephonyPluginView)