convergedcallengine/spsettings/tsrc/public/basic/spsettingsUT/src/ut_spsbufferedpublisher.cpp
changeset 46 2fa1fa551b0b
parent 42 35488577e233
child 48 78df25012fda
equal deleted inserted replaced
42:35488577e233 46:2fa1fa551b0b
     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_spsbufferedpublisher.h"
       
    19 #include <EUnitMacros.h>
       
    20 #include <EUnitDecorators.h>
       
    21 
       
    22 #include <e32property.h>
       
    23 
       
    24 #include "spsbufferedpublisher.h"
       
    25 #include "spdefaultvalues.h"
       
    26 
       
    27 // - Construction -----------------------------------------------------------
       
    28 
       
    29 Ut_CSpsBufferedPublisher* Ut_CSpsBufferedPublisher::NewL()
       
    30     {
       
    31     
       
    32     Ut_CSpsBufferedPublisher* self = new (ELeave) Ut_CSpsBufferedPublisher;
       
    33     CleanupStack::PushL(self);
       
    34     self->ConstructL();
       
    35     CleanupStack::Pop(self);
       
    36     return self;
       
    37     }
       
    38 
       
    39 Ut_CSpsBufferedPublisher::~Ut_CSpsBufferedPublisher()
       
    40     {
       
    41     }
       
    42 
       
    43 Ut_CSpsBufferedPublisher::Ut_CSpsBufferedPublisher()
       
    44     {
       
    45     }
       
    46 
       
    47 void Ut_CSpsBufferedPublisher::ConstructL()
       
    48     {
       
    49     CEUnitTestSuiteClass::ConstructL();
       
    50     }
       
    51 
       
    52 // - Test methods -----------------------------------------------------------
       
    53 
       
    54 
       
    55 
       
    56 void Ut_CSpsBufferedPublisher::SetupL(  )
       
    57     {
       
    58     iPublisher = CSpsBufferedPublisher::NewL( KUidSystemCategory, KSPNotifyChangeKey );
       
    59     iPublisher->Start();
       
    60     }
       
    61     
       
    62 
       
    63 void Ut_CSpsBufferedPublisher::Teardown(  )
       
    64     {
       
    65     delete iPublisher;
       
    66     iPublisher = NULL;
       
    67     }
       
    68 
       
    69 void Ut_CSpsBufferedPublisher::Ut_ConstructL()
       
    70     {
       
    71     // Do nothing
       
    72     }
       
    73 
       
    74 void Ut_CSpsBufferedPublisher::Ut_CSpsBufferedPublisher_DataSizeL()
       
    75     {
       
    76     const TUint32 data( 0xFFFFFFFF );
       
    77     CSpsBufferedPublisher::SetL( KUidSystemCategory, KSPNotifyChangeKey, data );
       
    78     RArray<TUint32> array;
       
    79     iPublisher->GetL( array );
       
    80     EUNIT_ASSERT_EQUALS( 1, array.Count() );
       
    81     EUNIT_ASSERT_EQUALS( data, array[0] );
       
    82     array.Close();
       
    83     }
       
    84     
       
    85 void Ut_CSpsBufferedPublisher::Ut_CSpsBufferedPublisher_BufferSizeL()
       
    86     {
       
    87     TInt testedBuffer = 100000;
       
    88     
       
    89     for( TInt i(0); i < testedBuffer; i++ )
       
    90         {
       
    91         CSpsBufferedPublisher::SetL( KUidSystemCategory, KSPNotifyChangeKey, i );
       
    92         }
       
    93     
       
    94     RArray<TUint32> array;
       
    95     iPublisher->GetL( array );
       
    96     EUNIT_ASSERT_EQUALS( 127, array.Count() );
       
    97 
       
    98     for( TInt i(127); i > 0; i-- )
       
    99         {
       
   100         EUNIT_ASSERT_EQUALS( testedBuffer - i, array[array.Count()-i] );
       
   101         }
       
   102         
       
   103         
       
   104     array.Close();
       
   105     }
       
   106 
       
   107 void Ut_CSpsBufferedPublisher::Ut_CSpsBufferedPublisher_DataValidyL()
       
   108     {
       
   109     
       
   110     for( TInt i(0); i < 100000; i++ )
       
   111         {
       
   112         CSpsBufferedPublisher::SetL( KUidSystemCategory, KSPNotifyChangeKey, i );
       
   113         
       
   114         RArray<TUint32> array;
       
   115         iPublisher->GetL( array );
       
   116         EUNIT_ASSERT_EQUALS( 1, array.Count() );
       
   117         EUNIT_ASSERT_EQUALS( i, array[0] );
       
   118         array.Close();
       
   119         }
       
   120     
       
   121     RArray<TUint32> array;
       
   122     iPublisher->GetL( array );
       
   123     EUNIT_ASSERT_EQUALS( 0, array.Count() );
       
   124     array.Close();
       
   125     }
       
   126 
       
   127 // - EUnit test table -------------------------------------------------------
       
   128 
       
   129 EUNIT_BEGIN_TEST_TABLE(
       
   130     Ut_CSpsBufferedPublisher,
       
   131     "Add test suite description here.",
       
   132     "UNIT" )
       
   133     
       
   134 EUNIT_TEST(
       
   135     "Construct - destruct",
       
   136     "CSpsBufferedPublisher",
       
   137     "Construct - destruct",
       
   138     "FUNCTIONALITY",
       
   139     SetupL, Ut_ConstructL, Teardown)
       
   140 
       
   141 EUNIT_TEST(
       
   142     "Test DataSize",
       
   143     "CSpsBufferedPublisher",
       
   144     "Test DataSize",
       
   145     "FUNCTIONALITY",
       
   146     SetupL, Ut_CSpsBufferedPublisher_DataSizeL, Teardown)
       
   147     
       
   148 EUNIT_TEST(
       
   149     "Test BufferSize",
       
   150     "CSpsBufferedPublisher",
       
   151     "Test BufferSize",
       
   152     "FUNCTIONALITY",
       
   153     SetupL, Ut_CSpsBufferedPublisher_BufferSizeL, Teardown)
       
   154     
       
   155 EUNIT_TEST(
       
   156     "Test DataValidy",
       
   157     "CSpsBufferedPublisher",
       
   158     "Test DataValidy",
       
   159     "FUNCTIONALITY",
       
   160     SetupL, Ut_CSpsBufferedPublisher_DataValidyL, Teardown)
       
   161 
       
   162 EUNIT_END_TEST_TABLE