homescreensrv_plat/hs_settings_api/tsrc/src/mt_map.cpp
branchRCL_3
changeset 28 053c6c7c14f3
equal deleted inserted replaced
27:2c7f27287390 28:053c6c7c14f3
       
     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: EUnit test for homescreen settings API, main suite
       
    15 *
       
    16 */
       
    17 
       
    18 // External includes
       
    19 #include <digia/eunit/eunitmacros.h>
       
    20 
       
    21 // Internal includes
       
    22 #include <itemmap.h>
       
    23 #include <propertymap.h>
       
    24 #include <MT_Map.h>
       
    25 
       
    26 // ======== MEMBER FUNCTIONS ========
       
    27 
       
    28 //----------------------------------------------------------------------------
       
    29 // MT_Map::NewL( )
       
    30 //----------------------------------------------------------------------------
       
    31 //
       
    32 MT_Map* MT_Map::NewL()
       
    33     {
       
    34     MT_Map* self = MT_Map::NewLC();
       
    35     CleanupStack::Pop( self );
       
    36     return self;
       
    37     }
       
    38 
       
    39 //----------------------------------------------------------------------------
       
    40 // MT_Map::NewLC( )
       
    41 //----------------------------------------------------------------------------
       
    42 //
       
    43 MT_Map* MT_Map::NewLC()
       
    44     {
       
    45     MT_Map* self = new( ELeave ) MT_Map();
       
    46     CleanupStack::PushL( self );
       
    47     self->ConstructL();
       
    48     return self;
       
    49     }
       
    50 
       
    51 //----------------------------------------------------------------------------
       
    52 // MT_Map::~MT_Map( )
       
    53 //----------------------------------------------------------------------------
       
    54 //
       
    55 MT_Map::~MT_Map()
       
    56     {
       
    57     }
       
    58 
       
    59 //----------------------------------------------------------------------------
       
    60 // MT_Map::MT_Map( )
       
    61 //----------------------------------------------------------------------------
       
    62 //
       
    63 MT_Map::MT_Map()
       
    64     {
       
    65     }
       
    66 
       
    67 //----------------------------------------------------------------------------
       
    68 // MT_Map::ConstructL( )
       
    69 //----------------------------------------------------------------------------
       
    70 //
       
    71 void MT_Map::ConstructL()
       
    72     {
       
    73     // The ConstructL from the base class CEUnitTestSuiteClass must be called.
       
    74     // It generates the test case table.
       
    75     CEUnitTestSuiteClass::ConstructL();
       
    76     }
       
    77 
       
    78 //----------------------------------------------------------------------------
       
    79 // MT_Map::SetupL( )
       
    80 //----------------------------------------------------------------------------
       
    81 //
       
    82 void MT_Map::SetupL(  )
       
    83     {
       
    84     iItemMap = HSPluginSettingsIf::CItemMap::NewL();
       
    85     iPropertyMap = HSPluginSettingsIf::CPropertyMap::NewL();
       
    86     }
       
    87 
       
    88 //----------------------------------------------------------------------------
       
    89 // MT_Map::Teardown( )
       
    90 //----------------------------------------------------------------------------
       
    91 //
       
    92 void MT_Map::Teardown(  )
       
    93     {
       
    94     if( iItemMap )
       
    95         {
       
    96         delete iItemMap;
       
    97         iItemMap = NULL;        
       
    98         }
       
    99     
       
   100     if( iPropertyMap )
       
   101         {
       
   102         delete iPropertyMap;
       
   103         iPropertyMap = NULL;
       
   104         }
       
   105     }
       
   106 
       
   107 //----------------------------------------------------------------------------
       
   108 // MT_Map::TeardownPropertyMap( )
       
   109 //----------------------------------------------------------------------------
       
   110 //
       
   111 void MT_Map::TeardownPropertyMap(  )
       
   112     {
       
   113     if( iItemMap )
       
   114         {
       
   115         delete iItemMap;
       
   116         iItemMap = NULL;        
       
   117         }
       
   118     }
       
   119 
       
   120 //----------------------------------------------------------------------------
       
   121 // MT_Map::TestItemIdL( )
       
   122 //----------------------------------------------------------------------------
       
   123 //
       
   124 void MT_Map::TestItemIdL()
       
   125     {
       
   126     iItemMap->SetItemIdL( _L8( "12" ) );
       
   127     const TDesC8& itemIdVal = iItemMap->ItemId();
       
   128     EUNIT_ASSERT( itemIdVal == _L8( "12" ) );
       
   129     }
       
   130 
       
   131 //----------------------------------------------------------------------------
       
   132 // MT_Map::TestItemNameL( )
       
   133 //----------------------------------------------------------------------------
       
   134 //
       
   135 void MT_Map::TestItemNameL()
       
   136     {
       
   137     iItemMap->SetItemNameL( _L8( "item name" ) );
       
   138     const TDesC8& itemNameVal = iItemMap->ItemName();
       
   139     EUNIT_ASSERT( itemNameVal == _L8( "item name" ) );
       
   140     }
       
   141 
       
   142 //----------------------------------------------------------------------------
       
   143 // MT_Map::TestPropertyNameL( )
       
   144 //----------------------------------------------------------------------------
       
   145 //
       
   146 void MT_Map::TestPropertyNameL()
       
   147     {
       
   148     iPropertyMap->SetNameL( _L8( "property name" ) );
       
   149     const TDesC8& propertyNameVal = iPropertyMap->Name();
       
   150     EUNIT_ASSERT( propertyNameVal == _L8( "property name" ) );
       
   151     }
       
   152 
       
   153 //----------------------------------------------------------------------------
       
   154 // MT_Map::TestPropertyValueL( )
       
   155 //----------------------------------------------------------------------------
       
   156 //
       
   157 void MT_Map::TestPropertyValueL()
       
   158     {
       
   159     iPropertyMap->SetValueL( _L8( "property value" ) );
       
   160     const TDesC8& propertyValueVal = iPropertyMap->Value();
       
   161     EUNIT_ASSERT( propertyValueVal == _L8( "property value" ) );
       
   162     }
       
   163 
       
   164 //----------------------------------------------------------------------------
       
   165 // MT_Map::TestPropertyMapL( )
       
   166 //----------------------------------------------------------------------------
       
   167 //
       
   168 void MT_Map::TestPropertyMapL()
       
   169     {
       
   170     iPropertyMap->SetNameL( _L8( "property name" ) );
       
   171     const TDesC8& propertyNameVal = iPropertyMap->Name();
       
   172     EUNIT_ASSERT( propertyNameVal == _L8( "property name" ) );
       
   173 
       
   174     iPropertyMap->SetValueL( _L8( "property value" ) );
       
   175     const TDesC8& propertyValueVal = iPropertyMap->Value();
       
   176     EUNIT_ASSERT( propertyValueVal == _L8( "property value" ) );
       
   177 
       
   178     RPointerArray< HSPluginSettingsIf::CPropertyMap >& iProperties = iItemMap->Properties();
       
   179     EUNIT_ASSERT( iProperties.Count() == 0 );
       
   180     iItemMap->AddPropertyMapL( iPropertyMap );
       
   181     EUNIT_ASSERT( iProperties.Count() == 1 );
       
   182     }
       
   183 
       
   184 //  EUnit test table
       
   185 
       
   186 EUNIT_BEGIN_TEST_TABLE(
       
   187     MT_Map,
       
   188     "Test MAiPluginTool implementation returned from AiUtility::CreatePluginToolL",
       
   189     "MODULE")
       
   190 
       
   191 EUNIT_TEST(
       
   192     "Test SetItemIdL, ItemId",
       
   193     "SetItemIdL, ItemId",
       
   194     "All",
       
   195     "FUNCTIONALITY",
       
   196     SetupL, TestItemIdL, Teardown)
       
   197 
       
   198 EUNIT_TEST(
       
   199     "Test SetItemNameL, ItemName",
       
   200     "SetItemNameL, ItemName",
       
   201     "All",
       
   202     "FUNCTIONALITY",
       
   203     SetupL, TestItemNameL, Teardown)
       
   204 
       
   205 EUNIT_TEST(
       
   206     "Test SetNameL, Name",
       
   207     "SetNameL, Name",
       
   208     "All",
       
   209     "FUNCTIONALITY",
       
   210     SetupL, TestPropertyNameL, Teardown)
       
   211 
       
   212 EUNIT_TEST(
       
   213     "Test SetValueL, Value",
       
   214     "SetValueL, Value",
       
   215     "All",
       
   216     "FUNCTIONALITY",
       
   217     SetupL, TestPropertyValueL, Teardown)
       
   218     
       
   219 EUNIT_TEST(
       
   220     "Test AddPropertyMapL, Properties",
       
   221     "AddPropertyMapL, Properties",
       
   222     "All",
       
   223     "FUNCTIONALITY",
       
   224     SetupL, TestPropertyMapL, TeardownPropertyMap)
       
   225 
       
   226 EUNIT_END_TEST_TABLE