idlefw/tsrc/framework/ut_aifw/ut_hspublisherinfo/src/ut_hspublisherinfo.cpp
branchRCL_3
changeset 27 2c7f27287390
equal deleted inserted replaced
25:9e077f9a342c 27:2c7f27287390
       
     1 /*
       
     2 * Copyright (c) 2004 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 unit test class for THsPublisherInfo
       
    15 *
       
    16 */
       
    17 
       
    18 // System includes
       
    19 #include <e32base.h>
       
    20 #include <e32cmn.h> 
       
    21 #include <digia/eunit/eunitmacros.h>
       
    22 #include <digia/eunit/teunitassertioninfo.h>
       
    23 
       
    24 // User includes
       
    25 #include <hspublisherinfo.h>
       
    26 
       
    27 #include "ut_hspublisherinfo.h"
       
    28 
       
    29 // Constants
       
    30 _LIT( KName, "testname" );
       
    31 _LIT8( KNamespace, "testnamespace" );
       
    32 
       
    33 const TInt KUid( 0xBABE2BED );
       
    34     
       
    35 
       
    36 // ======== LOCAL FUNCTIONS ========
       
    37 
       
    38 // ======== MEMBER FUNCTIONS =======
       
    39 // ----------------------------------------------------------------------------
       
    40 // UT_HsPublisherInfo::NewL()
       
    41 //
       
    42 // ----------------------------------------------------------------------------
       
    43 //
       
    44 UT_HsPublisherInfo* UT_HsPublisherInfo::NewL()
       
    45     {
       
    46     UT_HsPublisherInfo* self = UT_HsPublisherInfo::NewLC();
       
    47     CleanupStack::Pop( self );
       
    48     return self;
       
    49     }
       
    50 
       
    51 // ----------------------------------------------------------------------------
       
    52 // UT_HsPublisherInfo::NewLC()
       
    53 //
       
    54 // ----------------------------------------------------------------------------
       
    55 //
       
    56 UT_HsPublisherInfo* UT_HsPublisherInfo::NewLC()
       
    57     {
       
    58     UT_HsPublisherInfo* self = new ( ELeave ) UT_HsPublisherInfo();
       
    59     CleanupStack::PushL( self );
       
    60     self->ConstructL();
       
    61     return self;
       
    62     }
       
    63 
       
    64 // ----------------------------------------------------------------------------
       
    65 // UT_HsPublisherInfo::~UT_HsPublisherInfo()
       
    66 //
       
    67 // ----------------------------------------------------------------------------
       
    68 //
       
    69 UT_HsPublisherInfo::~UT_HsPublisherInfo()
       
    70     {    
       
    71     }
       
    72 
       
    73 // ----------------------------------------------------------------------------
       
    74 // UT_HsPublisherInfo::UT_HsPublisherInfo()
       
    75 //
       
    76 // ----------------------------------------------------------------------------
       
    77 //
       
    78 UT_HsPublisherInfo::UT_HsPublisherInfo()
       
    79     {
       
    80     }
       
    81 
       
    82 // ----------------------------------------------------------------------------
       
    83 // UT_HsPublisherInfo::ConstructL()
       
    84 //
       
    85 // ----------------------------------------------------------------------------
       
    86 //
       
    87 void UT_HsPublisherInfo::ConstructL()
       
    88     {
       
    89     // The ConstructL from the base class CEUnitTestSuiteClass must be called.
       
    90     // It generates the test case table.
       
    91     CEUnitTestSuiteClass::ConstructL();
       
    92     }
       
    93 
       
    94 // ----------------------------------------------------------------------------
       
    95 // UT_HsPublisherInfo::SetupL()
       
    96 //
       
    97 // ----------------------------------------------------------------------------
       
    98 //
       
    99 void UT_HsPublisherInfo::SetupL()
       
   100     {
       
   101     }
       
   102 
       
   103 // ----------------------------------------------------------------------------
       
   104 // UT_HsPublisherInfo::Teardown()
       
   105 //
       
   106 // ----------------------------------------------------------------------------
       
   107 //
       
   108 void UT_HsPublisherInfo::Teardown()
       
   109     {
       
   110     }
       
   111 
       
   112 // ----------------------------------------------------------------------------
       
   113 // UT_HsPublisherInfo::TestConstructionL()
       
   114 //
       
   115 // ----------------------------------------------------------------------------
       
   116 //
       
   117 void UT_HsPublisherInfo::TestConstructionL()
       
   118     {
       
   119     TUid uid( TUid::Uid( KUid ) );
       
   120     
       
   121     THsPublisherInfo info;
       
   122     
       
   123     EUNIT_ASSERT_EQUALS( info.iUid == TUid::KNullUid, ETrue );
       
   124     EUNIT_ASSERT_EQUALS( info.iName == KNullDesC, ETrue );
       
   125     EUNIT_ASSERT_EQUALS( info.iNamespace == KNullDesC8, ETrue );
       
   126         
       
   127     THsPublisherInfo info2( uid, KName, KNamespace );
       
   128 
       
   129     EUNIT_ASSERT_EQUALS( info2.iUid == uid, ETrue );
       
   130     EUNIT_ASSERT_EQUALS( info2.iName == KName, ETrue );
       
   131     EUNIT_ASSERT_EQUALS( info2.iNamespace == KNamespace, ETrue );    
       
   132     }
       
   133 
       
   134 // ----------------------------------------------------------------------------
       
   135 // UT_HsPublisherInfo::TestAssigmentOperatorL()
       
   136 //
       
   137 // ----------------------------------------------------------------------------
       
   138 //
       
   139 void UT_HsPublisherInfo::TestAssigmentOperatorL()
       
   140     {
       
   141     TUid uid( TUid::Uid( KUid ) );
       
   142     
       
   143     THsPublisherInfo info;
       
   144     
       
   145     THsPublisherInfo info2( uid, KName, KNamespace );
       
   146 
       
   147     info = info2;
       
   148 
       
   149     EUNIT_ASSERT_EQUALS( info.iUid == uid, ETrue );
       
   150     EUNIT_ASSERT_EQUALS( info.iName == KName, ETrue );
       
   151     EUNIT_ASSERT_EQUALS( info.iNamespace == KNamespace, ETrue );          
       
   152     }
       
   153 
       
   154 // ----------------------------------------------------------------------------
       
   155 // UT_HsPublisherInfo::TestEqualsOperatorL()
       
   156 //
       
   157 // ----------------------------------------------------------------------------
       
   158 //
       
   159 void UT_HsPublisherInfo::TestEqualsOperatorL()
       
   160     {
       
   161     TUid uid( TUid::Uid( KUid ) );
       
   162     
       
   163     THsPublisherInfo info( uid, KName, KNamespace ); 
       
   164     THsPublisherInfo info2 = info;
       
   165              
       
   166     EUNIT_ASSERT_EQUALS( info == info2, ETrue );
       
   167     
       
   168     THsPublisherInfo info3;
       
   169         
       
   170     EUNIT_ASSERT_EQUALS( !( info == info3 ), ETrue );
       
   171     }
       
   172 
       
   173 // ----------------------------------------------------------------------------
       
   174 // UT_HsPublisherInfo::TestGetUidL()
       
   175 //
       
   176 // ----------------------------------------------------------------------------
       
   177 //
       
   178 void UT_HsPublisherInfo::TestGetUidL()
       
   179     {
       
   180     TUid uid( TUid::Uid( KUid ) );
       
   181     
       
   182     THsPublisherInfo info( uid, KName, KNamespace );
       
   183     
       
   184     EUNIT_ASSERT_EQUALS( info.Uid() == uid, ETrue );
       
   185     }
       
   186 
       
   187 // ----------------------------------------------------------------------------
       
   188 // UT_HsPublisherInfo::TestGetNameL()
       
   189 //
       
   190 // ----------------------------------------------------------------------------
       
   191 //
       
   192 void UT_HsPublisherInfo::TestGetNameL()
       
   193     {
       
   194     TUid uid( TUid::Uid( KUid ) );
       
   195     
       
   196     THsPublisherInfo info( uid, KName, KNamespace );
       
   197 
       
   198     EUNIT_ASSERT_EQUALS( info.Name() == KName, ETrue );    
       
   199     }
       
   200 
       
   201 // ----------------------------------------------------------------------------
       
   202 // UT_HsPublisherInfo::TestGetNamespaceL()
       
   203 //
       
   204 // ----------------------------------------------------------------------------
       
   205 //
       
   206 void UT_HsPublisherInfo::TestGetNamespaceL()
       
   207     {
       
   208     TUid uid( TUid::Uid( KUid ) );
       
   209     
       
   210     THsPublisherInfo info( uid, KName, KNamespace );
       
   211 
       
   212     EUNIT_ASSERT_EQUALS( info.Namespace() == KNamespace, ETrue );        
       
   213     }
       
   214 
       
   215 //------------------------------------------------------------------------------
       
   216 // Test case table
       
   217 //
       
   218 //------------------------------------------------------------------------------
       
   219 //
       
   220 EUNIT_BEGIN_TEST_TABLE(
       
   221     UT_HsPublisherInfo,
       
   222     "Unit test suite for THsPublisherInfo",
       
   223     "UNIT" )
       
   224 
       
   225     EUNIT_TEST(
       
   226         "Construction",
       
   227         "THsPublisherInfo",
       
   228         "",
       
   229         "FUNCTIONALITY",
       
   230         SetupL, TestConstructionL, Teardown )
       
   231 
       
   232     EUNIT_TEST(
       
   233         "AssigmentOperator",
       
   234         "THsPublisherInfo",
       
   235         "",
       
   236         "FUNCTIONALITY",
       
   237         SetupL, TestAssigmentOperatorL, Teardown )
       
   238 
       
   239     EUNIT_TEST(
       
   240         "EqualsOperator",
       
   241         "THsPublisherInfo",
       
   242         "",
       
   243         "FUNCTIONALITY",
       
   244         SetupL, TestEqualsOperatorL, Teardown )
       
   245     
       
   246     EUNIT_TEST(
       
   247         "GetUid",
       
   248         "THsPublisherInfo",
       
   249         "",
       
   250         "FUNCTIONALITY",
       
   251         SetupL, TestGetUidL, Teardown )
       
   252 
       
   253     EUNIT_TEST(
       
   254         "GetName",
       
   255         "THsPublisherInfo",
       
   256         "",
       
   257         "FUNCTIONALITY",
       
   258         SetupL, TestGetNameL, Teardown )
       
   259 
       
   260     EUNIT_TEST(
       
   261         "GetNamespace",
       
   262         "THsPublisherInfo",
       
   263         "",
       
   264         "FUNCTIONALITY",
       
   265         SetupL, TestGetNamespaceL, Teardown )
       
   266         
       
   267 EUNIT_END_TEST_TABLE
       
   268 
       
   269 // End of file