cellular/sssettings/xqbindings/sssettingswrapper/tsrc/ut_sssettingswrapper/ut_sssettingswrapper.cpp
branchRCL_3
changeset 20 987c9837762f
parent 19 7d48bed6ce0c
child 21 0a6dd2dc9970
equal deleted inserted replaced
19:7d48bed6ce0c 20:987c9837762f
     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_sssettingswrapper.h"
       
    19 #include "qtestmains60.h"
       
    20 #define private public
       
    21 #include "sssettingswrapper.h"
       
    22 #include "sssettingswrapper_p.h"
       
    23 
       
    24 /*!
       
    25   UT_SsSettingsWrapper::UT_SsSettingsWrapper
       
    26  */
       
    27 UT_SsSettingsWrapper::UT_SsSettingsWrapper() 
       
    28     : mWrapper(NULL)
       
    29 {
       
    30 }
       
    31 
       
    32 /*!
       
    33   UT_SsSettingsWrapper::~UT_SsSettingsWrapper
       
    34  */
       
    35 UT_SsSettingsWrapper::~UT_SsSettingsWrapper()
       
    36 {
       
    37     delete mWrapper;
       
    38 }
       
    39 
       
    40 /*!
       
    41   UT_SsSettingsWrapper::init
       
    42  */
       
    43 void UT_SsSettingsWrapper::init()
       
    44 {
       
    45     initialize();
       
    46 
       
    47     mWrapper = new SsSettingsWrapper();
       
    48 }
       
    49 
       
    50 /*!
       
    51   UT_SsSettingsWrapper::cleanup
       
    52  */
       
    53 void UT_SsSettingsWrapper::cleanup()
       
    54 {
       
    55     reset();
       
    56     
       
    57     delete mWrapper;
       
    58     mWrapper = NULL;
       
    59 }
       
    60 
       
    61 /*!
       
    62   UT_SsSettingsWrapper::t_memleak
       
    63  */
       
    64 void UT_SsSettingsWrapper::t_memleak()
       
    65 {
       
    66     
       
    67 }
       
    68 
       
    69 /*!
       
    70   UT_SsSettingsWrapper::t_get
       
    71  */
       
    72 void UT_SsSettingsWrapper::t_get()
       
    73 {
       
    74     int value = 0;
       
    75     expect("RSSSettings::Get").with(ESSSettingsCug, 0);
       
    76     QVERIFY( !mWrapper->get(Cug, value) );
       
    77     expect("RSSSettings::Get").with(ESSSettingsClir, 0);
       
    78     QVERIFY( !mWrapper->get(Clir, value) );
       
    79     expect("RSSSettings::Get").with(ESSSettingsAls, 0);
       
    80     QVERIFY( !mWrapper->get(Als, value) );
       
    81     expect("RSSSettings::Get").with(ESSSettingsAlsBlocking, 0);
       
    82     QVERIFY( !mWrapper->get(AlsBlocking, value) );
       
    83     expect("RSSSettings::Get").with(ESSSettingsDefaultCug, 0);
       
    84     QVERIFY( !mWrapper->get(DefaultCug, value) );
       
    85     QVERIFY(true == verify());
       
    86 }
       
    87 
       
    88 /*!
       
    89   UT_SsSettingsWrapper::t_set
       
    90  */
       
    91 void UT_SsSettingsWrapper::t_set()
       
    92 {
       
    93     int value = 0;
       
    94     expect("RSSSettings::Set").with(ESSSettingsCug, 0);
       
    95     QVERIFY( !mWrapper->set(Cug, value) );
       
    96     expect("RSSSettings::Set").with(ESSSettingsClir, 0);
       
    97     QVERIFY( !mWrapper->set(Clir, value) );
       
    98     expect("RSSSettings::Set").with(ESSSettingsAls, 0);
       
    99     QVERIFY( !mWrapper->set(Als, value) );
       
   100     expect("RSSSettings::Set").with(ESSSettingsAlsBlocking, 0);
       
   101     QVERIFY( !mWrapper->set(AlsBlocking, value) );
       
   102     expect("RSSSettings::Set").with(ESSSettingsDefaultCug, 0);
       
   103     QVERIFY( !mWrapper->set(DefaultCug, value) );
       
   104     QVERIFY(true == verify());
       
   105 }
       
   106 
       
   107 /*!
       
   108   UT_SsSettingsWrapper::t_PhoneSettingChanged
       
   109  */
       
   110 Q_DECLARE_METATYPE(SsSettingsWrapperSettings)
       
   111 void UT_SsSettingsWrapper::t_PhoneSettingChanged()
       
   112 {
       
   113     qRegisterMetaType<SsSettingsWrapperSettings> ("SsSettingsWrapperSettings");
       
   114     QSignalSpy spy(mWrapper, 
       
   115             SIGNAL(phoneSettingChanged(SsSettingsWrapperSettings, int )));
       
   116     
       
   117     mWrapper->m_Priv->PhoneSettingChanged(ESSSettingsCug, 0);
       
   118     
       
   119     QCOMPARE(spy.count(), 1);
       
   120     const QList<QVariant> &arguments = spy.at(0);
       
   121     QVERIFY(Cug == arguments.at(0).value<SsSettingsWrapperSettings>());
       
   122     QVERIFY(0 == arguments.at(1).value<int>());
       
   123 }
       
   124 
       
   125 QTEST_MAIN_S60(UT_SsSettingsWrapper)