idlefw/tsrc/framework/ut_aifw/ut_aicpscommandbuffer/src/ut_aicpscommandbuffer.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 CAiStateProvider
       
    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 #include <liwservicehandler.h>
       
    24 
       
    25 // User includes
       
    26 #include "ut_aicpscommandbuffer.h"
       
    27 
       
    28 #include "caicpscommandbuffer.h"
       
    29             
       
    30 
       
    31 // Constants
       
    32 _LIT8( KPublisherId, "publisher" );
       
    33 _LIT8( KContentType,   "content_type" );
       
    34 _LIT8( KContentId,   "content_id" );
       
    35 _LIT( KWRTPublisher, "wrt_publisher");
       
    36 _LIT( KTemplateWidget,"ai3templatedwidget");
       
    37 _LIT( KContentIdValue,   "com.accuweather.widget.touchNG" );
       
    38 _LIT8( KAction,   "active" );
       
    39 _LIT( KPubData,        "publisher" );
       
    40 
       
    41 // ======== LOCAL FUNCTIONS ========
       
    42     
       
    43 // ======== MEMBER FUNCTIONS =======
       
    44 // ----------------------------------------------------------------------------
       
    45 // UT_AiCpsCommandBuffer::NewL()
       
    46 //
       
    47 // ----------------------------------------------------------------------------
       
    48 //
       
    49 UT_AiCpsCommandBuffer* UT_AiCpsCommandBuffer::NewL()
       
    50     {
       
    51     UT_AiCpsCommandBuffer* self = UT_AiCpsCommandBuffer::NewLC();
       
    52     CleanupStack::Pop( self );
       
    53     return self;
       
    54     }
       
    55 
       
    56 // ----------------------------------------------------------------------------
       
    57 // UT_AiCpsCommandBuffer::NewLC()
       
    58 //
       
    59 // ----------------------------------------------------------------------------
       
    60 //
       
    61 UT_AiCpsCommandBuffer* UT_AiCpsCommandBuffer::NewLC()
       
    62     {
       
    63     UT_AiCpsCommandBuffer* self = new ( ELeave ) UT_AiCpsCommandBuffer();
       
    64     CleanupStack::PushL( self );
       
    65     self->ConstructL();
       
    66     return self;
       
    67     }
       
    68 
       
    69 // ----------------------------------------------------------------------------
       
    70 // UT_AiCpsCommandBuffer::~UT_AiCpsCommandBuffer()
       
    71 //
       
    72 // ----------------------------------------------------------------------------
       
    73 //
       
    74 UT_AiCpsCommandBuffer::~UT_AiCpsCommandBuffer()
       
    75     {    
       
    76     }
       
    77 
       
    78 // ----------------------------------------------------------------------------
       
    79 // UT_AiCpsCommandBuffer::UT_AiCpsCommandBuffer()
       
    80 //
       
    81 // ----------------------------------------------------------------------------
       
    82 //
       
    83 UT_AiCpsCommandBuffer::UT_AiCpsCommandBuffer()
       
    84     {
       
    85     }
       
    86 
       
    87 // ----------------------------------------------------------------------------
       
    88 // UT_AiCpsCommandBuffer::ConstructL()
       
    89 //
       
    90 // ----------------------------------------------------------------------------
       
    91 //
       
    92 void UT_AiCpsCommandBuffer::ConstructL()
       
    93     {
       
    94     // The ConstructL from the base class CEUnitTestSuiteClass must be called.
       
    95     // It generates the test case table.
       
    96     CEUnitTestSuiteClass::ConstructL();
       
    97     }
       
    98 
       
    99 // ----------------------------------------------------------------------------
       
   100 // UT_AiCpsCommandBuffer::SetupL()
       
   101 //
       
   102 // ----------------------------------------------------------------------------
       
   103 //
       
   104 void UT_AiCpsCommandBuffer::SetupL()
       
   105     {
       
   106     iCommandBuffer = CAiCpsCommandBuffer::NewL();
       
   107     }
       
   108 
       
   109 // ----------------------------------------------------------------------------
       
   110 // UT_AiCpsCommandBuffer::Teardown()
       
   111 //
       
   112 // ----------------------------------------------------------------------------
       
   113 //
       
   114 void UT_AiCpsCommandBuffer::Teardown()
       
   115     {
       
   116     delete iCommandBuffer;
       
   117     iCommandBuffer = NULL;
       
   118     }
       
   119 
       
   120 // ----------------------------------------------------------------------------
       
   121 // UT_AiCpsCommandBuffer::CreateAndDeleteL()
       
   122 //
       
   123 // ----------------------------------------------------------------------------
       
   124 //
       
   125 void UT_AiCpsCommandBuffer::CreateAndDelete()
       
   126     {
       
   127     //nothing here
       
   128     }
       
   129 
       
   130 // ----------------------------------------------------------------------------
       
   131 // UT_AiCpsCommandBuffer::GetCPsServiceInsterfaceL()
       
   132 //
       
   133 // ----------------------------------------------------------------------------
       
   134 //
       
   135 void UT_AiCpsCommandBuffer::GetCPsServiceInsterfaceL()
       
   136     {
       
   137     iCommandBuffer->GetCPSInterfaceL();
       
   138     iCommandBuffer->GetCPSInterfaceL();
       
   139     MLiwInterface* cpsInterface = iCommandBuffer->CpsInterface();
       
   140     CLiwServiceHandler* handler = iCommandBuffer->ServiceHandler();
       
   141     if ( !cpsInterface || !handler )
       
   142         {
       
   143         User::Leave( KErrArgument );
       
   144         }
       
   145     }
       
   146 
       
   147 // ----------------------------------------------------------------------------
       
   148 // UT_AiCpsCommandBuffer::GetCPsServiceInsterfaceL()
       
   149 //
       
   150 // ----------------------------------------------------------------------------
       
   151 //
       
   152 void UT_AiCpsCommandBuffer::AddCommandAndFlushL()
       
   153     {
       
   154     CLiwDefaultMap* filter = CLiwDefaultMap::NewLC();
       
   155     filter->InsertL( KPublisherId, TLiwVariant( KWRTPublisher ));
       
   156     filter->InsertL( KContentType, TLiwVariant( KTemplateWidget ));
       
   157     filter->InsertL( KContentId, TLiwVariant( KContentIdValue ));
       
   158     
       
   159     iCommandBuffer->AddCommand( _L("1"), KPubData, filter, KAction );
       
   160     iCommandBuffer->AddCommand( _L("1"), KPubData, filter, KAction );
       
   161     iCommandBuffer->Flush();
       
   162     
       
   163     // let destructor do flush
       
   164     iCommandBuffer->AddCommand( _L("1"), KPubData, filter, KAction );
       
   165     iCommandBuffer->AddCommand( _L("2"), KPubData, filter, KAction );
       
   166         
       
   167     CleanupStack::PopAndDestroy( filter );
       
   168     }
       
   169 
       
   170 //------------------------------------------------------------------------------
       
   171 // Test case table
       
   172 //
       
   173 //------------------------------------------------------------------------------
       
   174 //
       
   175 EUNIT_BEGIN_TEST_TABLE(
       
   176     UT_AiCpsCommandBuffer,
       
   177     "Unit test suite for AiCpsCommandBuffer",
       
   178     "UNIT" )
       
   179 
       
   180     EUNIT_TEST(
       
   181         "Create And Delete",
       
   182         "AiCpsCommandBuffer",
       
   183         "",
       
   184         "FUNCTIONALITY",
       
   185         SetupL, CreateAndDelete, Teardown )
       
   186 
       
   187     EUNIT_TEST(
       
   188         "Get CPS service interface",
       
   189         "AiCpsCommandBuffer",
       
   190         "",
       
   191         "FUNCTIONALITY",
       
   192         SetupL, GetCPsServiceInsterfaceL, Teardown )
       
   193 
       
   194     EUNIT_TEST(
       
   195         "Add command and flush",
       
   196         "AddCommandL",
       
   197         "",
       
   198         "FUNCTIONALITY",
       
   199         SetupL, AddCommandAndFlushL, Teardown )
       
   200     
       
   201 EUNIT_END_TEST_TABLE
       
   202 
       
   203 // End of file