contentcontrolsrv/tsrc/src/mthsccapiclient.cpp
branchRCL_3
changeset 110 2c7f27287390
equal deleted inserted replaced
101:9e077f9a342c 110:2c7f27287390
       
     1 /*
       
     2 * Copyright (c) 2008 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 module test class for CPS Wrapper
       
    15 *
       
    16 */
       
    17 
       
    18 // System include files
       
    19 #include <hsccapiclient.h>
       
    20 #include <hscontentcontrol.h>
       
    21 #include <hscontentinfo.h>
       
    22 #include <hscontentinfoarray.h>
       
    23 #include <ccresource.h>
       
    24 
       
    25 // User include files
       
    26 #include "mthsccapiclient.h"
       
    27 
       
    28 // Local constants
       
    29 _LIT8( KInfoTypeWidget, "widget" );
       
    30 _LIT8( KInfoTypeTemplate, "template" );
       
    31 _LIT8( KInfoTypeView, "view" );
       
    32 _LIT8( KInfoTypeApp, "application" );
       
    33 _LIT8( KTemplateViewUid, "0x20026f50" );
       
    34 _LIT8( KHsViewUid, "0x2001f48b" );
       
    35 _LIT8( KDesktopWidgetUid, "0x20026f4f" );
       
    36 _LIT8( KNotFoundAppUid, "0xffffffff" );
       
    37 _LIT8( KNotFoundViewUid, "0xffffffff" );
       
    38 _LIT8( KNotFoundWidgetUid, "0xffffffff" );
       
    39 _LIT8( KNotFoundViewPluginId, "999" );
       
    40 
       
    41 // ======== MEMBER FUNCTIONS ========
       
    42 
       
    43 // -----------------------------------------------------------------------
       
    44 // CMTHsCcApiClient::NewL()
       
    45 // -----------------------------------------------------------------------
       
    46 //
       
    47 CMTHsCcApiClient* CMTHsCcApiClient::NewL()
       
    48     {
       
    49     CMTHsCcApiClient* self = new ( ELeave ) CMTHsCcApiClient();
       
    50     CleanupStack::PushL( self );
       
    51     self->ConstructL();
       
    52     CleanupStack::Pop( self );
       
    53     return self;
       
    54     }
       
    55 
       
    56 // -----------------------------------------------------------------------
       
    57 // CMTHsCcApiClient::ConstructL()
       
    58 // -----------------------------------------------------------------------
       
    59 //
       
    60 void CMTHsCcApiClient::ConstructL()
       
    61     {
       
    62     // The ConstructL from the base class CEUnitTestSuiteClass must be called.
       
    63     // It generates the test case table.
       
    64     CEUnitTestSuiteClass::ConstructL();
       
    65     }
       
    66 
       
    67 // -----------------------------------------------------------------------
       
    68 // CMTHsCcApiClient::CMTHsCcApiClient()
       
    69 // -----------------------------------------------------------------------
       
    70 //
       
    71 CMTHsCcApiClient::CMTHsCcApiClient()
       
    72     :iApiClient( NULL )
       
    73     {
       
    74     }
       
    75 
       
    76 // -----------------------------------------------------------------------
       
    77 // CMTHsCcApiClient::~CMTHsCcApiClient()
       
    78 // -----------------------------------------------------------------------
       
    79 //
       
    80 CMTHsCcApiClient::~CMTHsCcApiClient()
       
    81     {
       
    82     delete iApiClient;
       
    83     }
       
    84 
       
    85 // -----------------------------------------------------------------------
       
    86 // CMTHsCcApiClient::SetupL()
       
    87 // -----------------------------------------------------------------------
       
    88 //
       
    89 void CMTHsCcApiClient::SetupL()
       
    90     {
       
    91     iWidgetListNtfExpected = EFalse;
       
    92     iWidgetListNtfReceived = EFalse;
       
    93     iViewListNtfExpected = EFalse;
       
    94     iViewListNtfReceived = EFalse;
       
    95     iAppListNtfExpected = EFalse;
       
    96     iAppListNtfReceived = EFalse;
       
    97 
       
    98     if ( iApiClient )
       
    99         {
       
   100         delete iApiClient;
       
   101         iApiClient = NULL;
       
   102         }
       
   103     iApiClient = CHsCcApiClient::NewL( NULL );
       
   104 
       
   105     // Remove all removable views from Home screen
       
   106     CHsContentInfo* app = CHsContentInfo::NewL();
       
   107     CleanupStack::PushL( app );
       
   108     iApiClient->ActiveAppL( *app );
       
   109     
       
   110     CHsContentInfoArray* views = CHsContentInfoArray::NewL();
       
   111     CleanupStack::PushL( views );
       
   112     iApiClient->ViewListL( *app, *views );
       
   113 
       
   114     for ( TInt i = 0; i < views->Array().Count(); i++ )
       
   115         {
       
   116         CHsContentInfo* info = views->Array()[ i ];
       
   117         if ( info->CanBeRemoved() )
       
   118             {
       
   119             iApiClient->RemoveViewL( *info );
       
   120             }
       
   121         }
       
   122 
       
   123     CleanupStack::PopAndDestroy( views );
       
   124 
       
   125     // Remove all removable widgets from Home screen
       
   126     CHsContentInfoArray* widgets = CHsContentInfoArray::NewL();
       
   127     CleanupStack::PushL( widgets );
       
   128     iApiClient->WidgetListL( *app, *widgets );
       
   129 
       
   130     for ( TInt i = 0; i < widgets->Array().Count(); i++ )
       
   131         {
       
   132         CHsContentInfo* info = widgets->Array()[ i ];
       
   133         if ( info->CanBeRemoved() )
       
   134             {
       
   135             iApiClient->RemoveWidgetL( *info );
       
   136             }
       
   137         }
       
   138 
       
   139     CleanupStack::PopAndDestroy( widgets );
       
   140 
       
   141     CleanupStack::PopAndDestroy( app );
       
   142         
       
   143     delete iApiClient;
       
   144     iApiClient = NULL;
       
   145         
       
   146     }
       
   147 
       
   148 // -----------------------------------------------------------------------
       
   149 // CMTHsCcApiClient::Teardown()
       
   150 // -----------------------------------------------------------------------
       
   151 //
       
   152 void CMTHsCcApiClient::Teardown()
       
   153     {
       
   154     }
       
   155 
       
   156 // -----------------------------------------------------------------------
       
   157 // CMTHsCcApiClient::NotifyWidgetListChanged()
       
   158 // -----------------------------------------------------------------------
       
   159 //
       
   160 void CMTHsCcApiClient::NotifyWidgetListChanged()
       
   161     {
       
   162     if ( iWidgetListNtfExpected )
       
   163         {
       
   164         iWidgetListNtfReceived = ETrue;
       
   165         iWait.AsyncStop();
       
   166         }
       
   167     }
       
   168 
       
   169 // -----------------------------------------------------------------------
       
   170 // CMTHsCcApiClient::NotifyViewListChanged()
       
   171 // -----------------------------------------------------------------------
       
   172 //
       
   173 void CMTHsCcApiClient::NotifyViewListChanged()
       
   174     {
       
   175     if ( iViewListNtfExpected )
       
   176         {
       
   177         iViewListNtfReceived = ETrue;
       
   178         iWait.AsyncStop();
       
   179         }
       
   180     }
       
   181 
       
   182 // -----------------------------------------------------------------------
       
   183 // CMTHsCcApiClient::NotifyAppListChanged()
       
   184 // -----------------------------------------------------------------------
       
   185 //
       
   186 void CMTHsCcApiClient::NotifyAppListChanged()
       
   187     {
       
   188     if ( iAppListNtfExpected )
       
   189         {
       
   190         iAppListNtfReceived = ETrue;
       
   191         iWait.AsyncStop();
       
   192         }
       
   193     }
       
   194 
       
   195 // -----------------------------------------------------------------------
       
   196 // CMTHsCcApiClient::ConnectHsCcApiClientL()
       
   197 // -----------------------------------------------------------------------
       
   198 //
       
   199 void CMTHsCcApiClient::ConnectHsCcApiClientL( MHsContentControl* aObserver )
       
   200     {
       
   201     iApiClient = CHsCcApiClient::NewL( aObserver );
       
   202     }
       
   203 
       
   204 // -----------------------------------------------------------------------
       
   205 // CMTHsCcApiClient::DisconnectHsCcApiClient()
       
   206 // -----------------------------------------------------------------------
       
   207 //
       
   208 void CMTHsCcApiClient::DisconnectHsCcApiClient()
       
   209     {
       
   210     delete iApiClient;
       
   211     iApiClient = NULL;
       
   212     }
       
   213 
       
   214 // -----------------------------------------------------------------------
       
   215 // CMTHsCcApiClient::AddViewL()
       
   216 // -----------------------------------------------------------------------
       
   217 //
       
   218 CHsContentInfo* CMTHsCcApiClient::AddViewL(
       
   219     const TDesC8& aUid )
       
   220     {
       
   221     CHsContentInfo* info = GetViewL( NULL, aUid );
       
   222     CleanupStack::PushL( info );
       
   223 
       
   224     TInt err = iApiClient->AddViewL( *info );
       
   225     User::LeaveIfError( err );
       
   226     CleanupStack::PopAndDestroy( info );
       
   227     info = NULL;
       
   228 
       
   229     CHsContentInfo* app = CHsContentInfo::NewL();
       
   230     CleanupStack::PushL( app );
       
   231 
       
   232     err = iApiClient->ActiveAppL( *app );
       
   233     User::LeaveIfError( err );
       
   234 
       
   235     info = GetViewL( app, aUid );
       
   236 
       
   237     CleanupStack::PopAndDestroy( app );
       
   238 
       
   239     User::LeaveIfNull( info );
       
   240     return info;
       
   241     }
       
   242 
       
   243 // -----------------------------------------------------------------------
       
   244 // CMTHsCcApiClient::AddWidgetL()
       
   245 // -----------------------------------------------------------------------
       
   246 //
       
   247 CHsContentInfo* CMTHsCcApiClient::AddWidgetL(
       
   248     const TDesC8& aUid )
       
   249     {
       
   250 
       
   251     CHsContentInfo* info = GetWidgetL( NULL, aUid );
       
   252     CleanupStack::PushL( info );
       
   253 
       
   254     TInt err = iApiClient->AddWidgetL( *info );
       
   255     User::LeaveIfError( err );
       
   256     CleanupStack::PopAndDestroy( info );
       
   257     info = NULL;
       
   258 
       
   259     CHsContentInfo* view = CHsContentInfo::NewL();
       
   260     CleanupStack::PushL( view );
       
   261 
       
   262     err = iApiClient->ActiveViewL( *view );
       
   263     User::LeaveIfError( err );
       
   264 
       
   265     info = GetWidgetL( view, aUid );
       
   266     
       
   267     CleanupStack::PopAndDestroy( view );
       
   268 
       
   269     User::LeaveIfNull( info );
       
   270     return info;
       
   271     }
       
   272 
       
   273 // -----------------------------------------------------------------------
       
   274 // CMTHsCcApiClient::GetViewL()
       
   275 // -----------------------------------------------------------------------
       
   276 //
       
   277 CHsContentInfo* CMTHsCcApiClient::GetViewL(
       
   278     CHsContentInfo* aApp,
       
   279     const TDesC8& aUid )
       
   280     {
       
   281     CHsContentInfoArray* views = CHsContentInfoArray::NewL();
       
   282     CleanupStack::PushL( views );
       
   283     TInt err( KErrNone );
       
   284     if ( aApp )
       
   285         {
       
   286         err = iApiClient->ViewListL( *aApp, *views );
       
   287         }
       
   288     else
       
   289         {
       
   290         err = iApiClient->ViewListL( *views );
       
   291         }
       
   292     User::LeaveIfError( err );
       
   293 
       
   294     CHsContentInfo* info = NULL;
       
   295     for ( TInt i = 0; i < views->Array().Count() && !info; i++ )
       
   296         {
       
   297         if ( views->Array()[ i ]->Uid().CompareF( aUid ) == 0 )
       
   298             {
       
   299             info = views->Array()[ i ];
       
   300             views->Array().Remove( i );
       
   301             break;
       
   302             }
       
   303         }
       
   304     CleanupStack::PopAndDestroy( views );
       
   305 
       
   306     User::LeaveIfNull( info );
       
   307     return info;
       
   308     }
       
   309 
       
   310 // -----------------------------------------------------------------------
       
   311 // CMTHsCcApiClient::GetWidgetL()
       
   312 // -----------------------------------------------------------------------
       
   313 //
       
   314 CHsContentInfo* CMTHsCcApiClient::GetWidgetL(
       
   315     CHsContentInfo* aView,
       
   316     const TDesC8& aUid )
       
   317     {
       
   318     CHsContentInfoArray* widgets = CHsContentInfoArray::NewL();
       
   319     CleanupStack::PushL( widgets );
       
   320     TInt err( KErrNone );
       
   321     if ( aView )
       
   322         {
       
   323         err = iApiClient->WidgetListL( *aView, *widgets );
       
   324         }
       
   325     else
       
   326         {
       
   327         err = iApiClient->WidgetListL( *widgets );
       
   328         }
       
   329     User::LeaveIfError( err );
       
   330 
       
   331     CHsContentInfo* info = NULL;
       
   332     for ( TInt i = 0; i < widgets->Array().Count() && !info; i++ )
       
   333         {
       
   334         if ( widgets->Array()[ i ]->Uid().CompareF( aUid ) == 0 )
       
   335             {
       
   336             info = widgets->Array()[ i ];
       
   337             widgets->Array().Remove( i );
       
   338             break;
       
   339             }
       
   340         }
       
   341     CleanupStack::PopAndDestroy( widgets );
       
   342 
       
   343     User::LeaveIfNull( info );
       
   344     return info;
       
   345     }
       
   346 
       
   347 // -----------------------------------------------------------------------
       
   348 // CMTHsCcApiClient::ConnectDisconnectHsCcApiClientL()
       
   349 // 
       
   350 // Test purpose:
       
   351 // The purpose of this test case is to verify that a connection to the
       
   352 // Home screen Content Control server is successfully established and 
       
   353 // closed via Home screen Content Control API client when the api observer
       
   354 // is not defined
       
   355 //
       
   356 // Pre conditions (SetupL()):
       
   357 // Empty homescreen
       
   358 //
       
   359 // Test step 1:
       
   360 // Create CHsCcApiClient
       
   361 //
       
   362 // Expected result:
       
   363 // Connection is successfully established
       
   364 //
       
   365 // Test step 2:
       
   366 // Delete CHsCcApiClient
       
   367 //
       
   368 // Expected result:
       
   369 // Connection is successfully closed
       
   370 //
       
   371 // Post conditions (Teardown()):
       
   372 // -
       
   373 //
       
   374 // -----------------------------------------------------------------------
       
   375 //
       
   376 void CMTHsCcApiClient::ConnectDisconnectHsCcApiClientL()
       
   377     {
       
   378     // Test step 1
       
   379     ConnectHsCcApiClientL( NULL );
       
   380 
       
   381     // Test step 2
       
   382     DisconnectHsCcApiClient();
       
   383     }
       
   384 
       
   385 // -----------------------------------------------------------------------
       
   386 // CMTHsCcApiClient::RegisterUnregisterHsCcApiObserverL()
       
   387 // 
       
   388 // Test purpose:
       
   389 // The purpose of this test case is to verify that a connection to the
       
   390 // Home screen Content Control server is successfully established and 
       
   391 // closed via Home screen Content Control API client when the api observer
       
   392 // is defined
       
   393 //
       
   394 // Pre conditions (SetupL()):
       
   395 // Empty homescreen
       
   396 //
       
   397 // Test step 1:
       
   398 // Create CHsCcApiClient
       
   399 //
       
   400 // Expected result:
       
   401 // Connection is successfully established and 
       
   402 // observation is successfully started
       
   403 //
       
   404 // Test step 2:
       
   405 // Delete CHsCcApiClient
       
   406 //
       
   407 // Expected result:
       
   408 // Connection is successfully closed
       
   409 //
       
   410 // Post conditions (Teardown()):
       
   411 // -
       
   412 //
       
   413 // -----------------------------------------------------------------------
       
   414 //
       
   415 void CMTHsCcApiClient::RegisterUnregisterHsCcApiObserverL()
       
   416     {
       
   417     // Test step 1
       
   418     ConnectHsCcApiClientL( this );
       
   419 
       
   420     // Test step 2
       
   421     DisconnectHsCcApiClient();
       
   422     }
       
   423 
       
   424 // -----------------------------------------------------------------------
       
   425 // CMTHsCcApiClient::RegisterUnregisterMultipleObserversL()
       
   426 // 
       
   427 // Test purpose:
       
   428 // The purpose of this test case is to verify that multiple connections to 
       
   429 // the Home screen Content Control server are successfully established and 
       
   430 // closed via Home screen Content Control API client when the api observer
       
   431 // is defined
       
   432 //
       
   433 // Pre conditions (SetupL()):
       
   434 // Empty homescreen
       
   435 //
       
   436 // Test step 1:
       
   437 // Create CHsCcApiClient
       
   438 //
       
   439 // Expected result:
       
   440 // Connection is successfully established and 
       
   441 // observation is successfully started
       
   442 //
       
   443 // Test step 2
       
   444 // Create additional connection 1
       
   445 //
       
   446 // Expected result:
       
   447 // Connection is successfully established and 
       
   448 // observation is successfully started
       
   449 //
       
   450 // Test step 3
       
   451 // Create additional connection 2
       
   452 //
       
   453 // Expected result:
       
   454 // Connection is successfully established and 
       
   455 // observation is successfully started
       
   456 //
       
   457 // Test step 4:
       
   458 // Delete additional connection 1
       
   459 //
       
   460 // Expected result:
       
   461 // Connection is successfully closed
       
   462 //
       
   463 // Test step 5:
       
   464 // Delete additional connection 2
       
   465 //
       
   466 // Expected result:
       
   467 // Connection is successfully closed
       
   468 //
       
   469 // Test step 6:
       
   470 // Delete CHsCcApiClient
       
   471 //
       
   472 // Expected result:
       
   473 // Connection is successfully closed
       
   474 //
       
   475 // Post conditions (Teardown()):
       
   476 // -
       
   477 //
       
   478 // -----------------------------------------------------------------------
       
   479 //
       
   480 void CMTHsCcApiClient::RegisterUnregisterMultipleObserversL()
       
   481     {
       
   482     // Test step 1
       
   483     ConnectHsCcApiClientL( this );
       
   484 
       
   485     // Test step 2
       
   486     CHsCcApiClient* addClient1 = CHsCcApiClient::NewL( this );
       
   487     CleanupStack::PushL( addClient1 );
       
   488 
       
   489     // Test step 3
       
   490     CHsCcApiClient* addClient2 = CHsCcApiClient::NewL( this );
       
   491 
       
   492     // Test step 4
       
   493     CleanupStack::PopAndDestroy( addClient1 );
       
   494     
       
   495     // Test step 5
       
   496     delete addClient2;
       
   497 
       
   498     // Test step 6
       
   499     DisconnectHsCcApiClient();
       
   500     }
       
   501 
       
   502 // -----------------------------------------------------------------------
       
   503 // CMTHsCcApiClient::WidgetListL()
       
   504 // 
       
   505 // Test purpose:
       
   506 // The purpose of this test case is to verify that a correct list of
       
   507 // widgets is returned
       
   508 //
       
   509 // Pre conditions (SetupL()):
       
   510 // Empty homescreen
       
   511 //
       
   512 // Test step 1:
       
   513 // Create CHsCcApiClient
       
   514 //
       
   515 // Expected result:
       
   516 // Connection is successfully established
       
   517 //
       
   518 // Test step 2:
       
   519 // Get widget list
       
   520 //
       
   521 // Expected result:
       
   522 // Content info list with widget or template type content info
       
   523 //
       
   524 // Test step 3:
       
   525 // Delete CHsCcApiClient
       
   526 //
       
   527 // Expected result:
       
   528 // Connection is successfully closed
       
   529 //
       
   530 // Post conditions (Teardown()):
       
   531 // -
       
   532 //
       
   533 // -----------------------------------------------------------------------
       
   534 //
       
   535 void CMTHsCcApiClient::WidgetListL()
       
   536     {
       
   537     // Test step 1
       
   538     ConnectHsCcApiClientL( NULL );
       
   539 
       
   540     // Test step 2
       
   541     CHsContentInfoArray* widgets = CHsContentInfoArray::NewL();
       
   542     CleanupStack::PushL( widgets );
       
   543     TInt err = iApiClient->WidgetListL( *widgets );
       
   544     // Check widget list
       
   545     for ( TInt i = 0; i < widgets->Array().Count() && !err ; i++ )
       
   546         {
       
   547         CHsContentInfo* info = widgets->Array()[ i ];
       
   548         if ( info->Type().Compare( KInfoTypeWidget ) != 0 &&
       
   549              info->Type().Compare( KInfoTypeTemplate ) != 0 )
       
   550             {
       
   551             // Invalid widget type
       
   552             err = KErrArgument;
       
   553             }
       
   554         }
       
   555     CleanupStack::PopAndDestroy( widgets );
       
   556     User::LeaveIfError( err );
       
   557 
       
   558     // Test step 3
       
   559     DisconnectHsCcApiClient();
       
   560     }
       
   561 
       
   562 // -----------------------------------------------------------------------
       
   563 // CMTHsCcApiClient::AddRemoveWidgetL()
       
   564 // 
       
   565 // Test purpose:
       
   566 // The purpose of this test case is to verify that a widget which can be
       
   567 // added to the Home scree is successfully added
       
   568 //
       
   569 // Pre conditions (SetupL()):
       
   570 // Empty homescreen
       
   571 //
       
   572 // Test step 1:
       
   573 // Create CHsCcApiClient
       
   574 //
       
   575 // Expected result:
       
   576 // Connection is successfully established
       
   577 //
       
   578 // Test step 2:
       
   579 // Add test view
       
   580 //
       
   581 // Expected result:
       
   582 // View successfully aded
       
   583 //
       
   584 // Test step 3:
       
   585 // Activate test view
       
   586 //
       
   587 // Expected result:
       
   588 // View successfully activated
       
   589 //
       
   590 // Test step 4:
       
   591 // Add desktop widget
       
   592 //
       
   593 // Expected result:
       
   594 // Widget is successfully added
       
   595 //
       
   596 // Test step 5:
       
   597 // Remove desktop widget
       
   598 //
       
   599 // Expected result
       
   600 // Widget is removed succesfully
       
   601 //
       
   602 // Test step 6:
       
   603 // Delete CHsCcApiClient
       
   604 //
       
   605 // Expected result:
       
   606 // Connection is successfully closed
       
   607 //
       
   608 // Post conditions (Teardown()):
       
   609 // -
       
   610 //
       
   611 // -----------------------------------------------------------------------
       
   612 //
       
   613 void CMTHsCcApiClient::AddRemoveWidgetL()
       
   614     {
       
   615     // Test step 1
       
   616     ConnectHsCcApiClientL( NULL );
       
   617 
       
   618     // Test step 2
       
   619     CHsContentInfo* view = AddViewL( KTemplateViewUid );
       
   620     User::LeaveIfNull( view );
       
   621     CleanupStack::PushL( view );
       
   622 
       
   623     // Test step 3
       
   624     TInt err = iApiClient->ActivateViewL( *view );
       
   625     User::LeaveIfError( err );
       
   626     CleanupStack::PopAndDestroy( view );
       
   627 
       
   628     // Test step 4
       
   629     CHsContentInfo* widget = AddWidgetL( KDesktopWidgetUid );
       
   630     User::LeaveIfNull( widget );
       
   631     CleanupStack::PushL( widget );
       
   632 
       
   633     // Test step 5
       
   634     err = iApiClient->RemoveWidgetL( *widget );
       
   635     User::LeaveIfError( err );
       
   636     CleanupStack::PopAndDestroy( widget );
       
   637 
       
   638     // Test step 6
       
   639     DisconnectHsCcApiClient();
       
   640     }
       
   641 
       
   642 // -----------------------------------------------------------------------
       
   643 // CMTHsCcApiClient::AddWidgetFails1L()
       
   644 // 
       
   645 // Test purpose:
       
   646 // The purpose of this test case is to verify that adding of widget fails
       
   647 // if a widget which cannot be found is request to be added
       
   648 //
       
   649 // Pre conditions (SetupL()):
       
   650 // Empty homescreen
       
   651 //
       
   652 // Test step 1:
       
   653 // Create CHsCcApiClient
       
   654 //
       
   655 // Expected result:
       
   656 // Connection is successfully established
       
   657 //
       
   658 // Test step 2:
       
   659 // Add test view
       
   660 //
       
   661 // Expected result:
       
   662 // View successfully added
       
   663 //
       
   664 // Test step 3:
       
   665 // Activate test view
       
   666 //
       
   667 // Expected result:
       
   668 // View successfully activated
       
   669 //
       
   670 // Test step 4:
       
   671 // Add invalid widget
       
   672 //
       
   673 // Expected result:
       
   674 // Widget adding fails
       
   675 //
       
   676 // Test step 5:
       
   677 // Delete CHsCcApiClient
       
   678 //
       
   679 // Expected result:
       
   680 // Connection is successfully closed
       
   681 //
       
   682 // Post conditions (Teardown()):
       
   683 // -
       
   684 //
       
   685 // -----------------------------------------------------------------------
       
   686 //
       
   687 void CMTHsCcApiClient::AddWidgetFails1L()
       
   688     {
       
   689     // Test step 1
       
   690     ConnectHsCcApiClientL( NULL );
       
   691 
       
   692     // Test step 2
       
   693     CHsContentInfo* view = AddViewL( KTemplateViewUid );
       
   694     User::LeaveIfNull( view );
       
   695     CleanupStack::PushL( view );
       
   696 
       
   697     // Test step 3
       
   698     TInt err = iApiClient->ActivateViewL( *view );
       
   699     User::LeaveIfError( err );
       
   700     CleanupStack::PopAndDestroy( view );
       
   701 
       
   702     // Test step 4
       
   703     CHsContentInfo* widget = GetWidgetL( NULL, KDesktopWidgetUid );
       
   704     User::LeaveIfNull( widget );
       
   705     CleanupStack::PushL( widget );
       
   706     widget->SetUidL( KNotFoundWidgetUid );
       
   707     err = iApiClient->AddWidgetL( *widget );
       
   708     if ( err != KErrArgument )
       
   709         {
       
   710         User::Leave( KErrGeneral );
       
   711         }
       
   712     CleanupStack::PopAndDestroy( widget );
       
   713 
       
   714     // Test step 5
       
   715     DisconnectHsCcApiClient();
       
   716     }
       
   717 
       
   718 // -----------------------------------------------------------------------
       
   719 // CMTHsCcApiClient::RemoveWidgetFails1L()
       
   720 // 
       
   721 // Test purpose:
       
   722 // The purpose of this test case is to verify that removing of widget fails
       
   723 // if a widget request to be removed cannot be found
       
   724 //
       
   725 // Pre conditions (SetupL()):
       
   726 // Empty homescreen
       
   727 //
       
   728 // Test step 1:
       
   729 // Create CHsCcApiClient
       
   730 //
       
   731 // Expected result:
       
   732 // Connection is successfully established
       
   733 //
       
   734 // Test step 2:
       
   735 // Add test view
       
   736 //
       
   737 // Expected result:
       
   738 // View successfully added
       
   739 //
       
   740 // Test step 3:
       
   741 // Activate test view
       
   742 //
       
   743 // Expected result:
       
   744 // View successfully activated
       
   745 //
       
   746 // Test step 4:
       
   747 // Remove invalid widget
       
   748 //
       
   749 // Expected result:
       
   750 // Widget removing fails
       
   751 //
       
   752 // Test step 5:
       
   753 // Delete CHsCcApiClient
       
   754 //
       
   755 // Expected result:
       
   756 // Connection is successfully closed
       
   757 //
       
   758 // Post conditions (Teardown()):
       
   759 // -
       
   760 //
       
   761 // -----------------------------------------------------------------------
       
   762 //
       
   763 void CMTHsCcApiClient::RemoveWidgetFails1L()
       
   764     {
       
   765     // Test step 1
       
   766     ConnectHsCcApiClientL( NULL );
       
   767 
       
   768     // Test step 2
       
   769     CHsContentInfo* view = AddViewL( KTemplateViewUid );
       
   770     User::LeaveIfNull( view );
       
   771     CleanupStack::PushL( view );
       
   772 
       
   773     // Test step 3
       
   774     TInt err = iApiClient->ActivateViewL( *view );
       
   775     User::LeaveIfError( err );
       
   776     CleanupStack::PopAndDestroy( view );
       
   777 
       
   778     // Test step 4
       
   779     CHsContentInfo* widget = GetWidgetL( NULL, KDesktopWidgetUid );
       
   780     User::LeaveIfNull( widget );
       
   781     CleanupStack::PushL( widget );
       
   782     widget->SetUidL( KNotFoundWidgetUid );
       
   783     err = iApiClient->RemoveWidgetL( *widget );
       
   784     if ( err != KErrArgument )
       
   785         {
       
   786         User::Leave( KErrGeneral );
       
   787         }
       
   788     CleanupStack::PopAndDestroy( widget );
       
   789 
       
   790     // Test step 5
       
   791     DisconnectHsCcApiClient();
       
   792     }
       
   793 
       
   794 // -----------------------------------------------------------------------
       
   795 // CMTHsCcApiClient::WidgetListChangeNtfL()
       
   796 // 
       
   797 // Test purpose:
       
   798 // The purpose of this test case is to verify that a notification is
       
   799 // received after a widget is successfully addded to Home screen
       
   800 //
       
   801 // Pre conditions (SetupL()):
       
   802 // Empty homescreen
       
   803 //
       
   804 // Test step 1:
       
   805 // Create CHsCcApiClient
       
   806 //
       
   807 // Expected result:
       
   808 // Connection is successfully established
       
   809 //
       
   810 // Test step 2:
       
   811 // Add test view
       
   812 //
       
   813 // Expected result:
       
   814 // View successfully added
       
   815 //
       
   816 // Test step 3:
       
   817 // Activate test view
       
   818 //
       
   819 // Expected result:
       
   820 // View successfully activated
       
   821 //
       
   822 // Test step 4:
       
   823 // Delete CHsCcApiClient
       
   824 //
       
   825 // Expected result:
       
   826 // Connection is successfully closed
       
   827 //
       
   828 // Test step 5:
       
   829 // Create CHsCcApiClient and register it as Content Control server api 
       
   830 // observer
       
   831 //
       
   832 // Expected result:
       
   833 // Connection is successfully established observation registration 
       
   834 // succeeded
       
   835 //
       
   836 // Test step 6:
       
   837 // Add desktop widget
       
   838 //
       
   839 // Expected result:
       
   840 // 1) Widget added successfully
       
   841 // 2) Widget list change notification received
       
   842 //
       
   843 // Test step 7:
       
   844 // Delete CHsCcApiClient
       
   845 //
       
   846 // Expected result:
       
   847 // Connection is successfully closed
       
   848 //
       
   849 // Post conditions (Teardown()):
       
   850 // -
       
   851 //
       
   852 // -----------------------------------------------------------------------
       
   853 //
       
   854 void CMTHsCcApiClient::WidgetListChangeNtfL()
       
   855     {
       
   856     // Test step 1
       
   857     ConnectHsCcApiClientL( NULL );
       
   858 
       
   859     // Test step 2
       
   860     CHsContentInfo* view = AddViewL( KTemplateViewUid );
       
   861     User::LeaveIfNull( view );
       
   862     CleanupStack::PushL( view );
       
   863 
       
   864     // Test step 3
       
   865     TInt err = iApiClient->ActivateViewL( *view );
       
   866     User::LeaveIfError( err );
       
   867     CleanupStack::PopAndDestroy( view );
       
   868 
       
   869     // Test step 4
       
   870     DisconnectHsCcApiClient();
       
   871 
       
   872     // Test step 5
       
   873     ConnectHsCcApiClientL( this );
       
   874 
       
   875     // Test step 6
       
   876     iWidgetListNtfExpected = ETrue;
       
   877     CHsContentInfo* widget = GetWidgetL( NULL, KDesktopWidgetUid );
       
   878     User::LeaveIfNull( widget );
       
   879     CleanupStack::PushL( widget );
       
   880     err = iApiClient->AddWidgetL( *widget );
       
   881     User::LeaveIfError( err );
       
   882 
       
   883     // Wait for notification
       
   884     iWait.Start();
       
   885     if ( !iWidgetListNtfReceived )
       
   886         {
       
   887         User::Leave( KErrGeneral );
       
   888         }
       
   889     CleanupStack::PopAndDestroy( widget );
       
   890 
       
   891     // Test step 7
       
   892     DisconnectHsCcApiClient();
       
   893     }
       
   894 
       
   895 // -----------------------------------------------------------------------
       
   896 // CMTHsCcApiClient::ViewListL()
       
   897 // 
       
   898 // Test purpose:
       
   899 // The purpose of this test case is to verify that a correct list of
       
   900 // views is returned
       
   901 //
       
   902 // Pre conditions (SetupL()):
       
   903 // Empty homescreen
       
   904 //
       
   905 // Test step 1:
       
   906 // Create CHsCcApiClient
       
   907 //
       
   908 // Expected result:
       
   909 // Connection is successfully established
       
   910 //
       
   911 // Test step 2:
       
   912 // Get view list
       
   913 //
       
   914 // Expected result:
       
   915 // Content info list with view type content info
       
   916 //
       
   917 // Test step 3:
       
   918 // Delete CHsCcApiClient
       
   919 //
       
   920 // Expected result:
       
   921 // Connection is successfully closed
       
   922 //
       
   923 // Post conditions (Teardown()):
       
   924 // -
       
   925 //
       
   926 // -----------------------------------------------------------------------
       
   927 //
       
   928 void CMTHsCcApiClient::ViewListL()
       
   929     {
       
   930     // Test step 1
       
   931     ConnectHsCcApiClientL( NULL );
       
   932 
       
   933     // Test step 2
       
   934     CHsContentInfoArray* views = CHsContentInfoArray::NewL();
       
   935     CleanupStack::PushL( views );
       
   936     TInt err = iApiClient->ViewListL( *views );
       
   937     // Check widget list
       
   938     for ( TInt i = 0; i < views->Array().Count() && !err ; i++ )
       
   939         {
       
   940         CHsContentInfo* info = views->Array()[ i ];
       
   941         if ( info->Type().Compare( KInfoTypeView ) != 0 )
       
   942             {
       
   943             // Invalid widget type
       
   944             err = KErrArgument;
       
   945             }
       
   946         }
       
   947     CleanupStack::PopAndDestroy( views );
       
   948     User::LeaveIfError( err );
       
   949 
       
   950     // Test step 3
       
   951     DisconnectHsCcApiClient();
       
   952     }
       
   953 
       
   954 // -----------------------------------------------------------------------
       
   955 // CMTHsCcApiClient::AddRemoveViewL()
       
   956 // 
       
   957 // Test purpose:
       
   958 // The purpose of this test case is to verify that a widget which can be
       
   959 // added to the Home scree is successfully added
       
   960 //
       
   961 // Pre conditions (SetupL()):
       
   962 // Empty homescreen
       
   963 //
       
   964 // Test step 1:
       
   965 // Create CHsCcApiClient
       
   966 //
       
   967 // Expected result:
       
   968 // Connection is successfully established
       
   969 //
       
   970 // Test step 2:
       
   971 // Add test view
       
   972 //
       
   973 // Expected result:
       
   974 // View added successfully
       
   975 //
       
   976 // Test step 3:
       
   977 // Remove test view
       
   978 //
       
   979 // Expected result:
       
   980 // View is successfully removed
       
   981 //
       
   982 // Test step 4:
       
   983 // Delete CHsCcApiClient
       
   984 //
       
   985 // Expected result:
       
   986 // Connection is successfully closed
       
   987 //
       
   988 // Post conditions (Teardown()):
       
   989 // -
       
   990 //
       
   991 // -----------------------------------------------------------------------
       
   992 //
       
   993 void CMTHsCcApiClient::AddRemoveViewL()
       
   994     {
       
   995     // Test step 1
       
   996     ConnectHsCcApiClientL( NULL );
       
   997 
       
   998     // Test step 2
       
   999     CHsContentInfo* view = AddViewL( KTemplateViewUid );
       
  1000     User::LeaveIfNull( view );
       
  1001     CleanupStack::PushL( view );
       
  1002 
       
  1003     // Test step 3
       
  1004     TInt err = iApiClient->RemoveViewL( *view );
       
  1005     User::LeaveIfError( err );
       
  1006     CleanupStack::PopAndDestroy( view );
       
  1007 
       
  1008     // Test step 4
       
  1009     DisconnectHsCcApiClient();
       
  1010     }
       
  1011 
       
  1012 // -----------------------------------------------------------------------
       
  1013 // CMTHsCcApiClient::ActivateViewL()
       
  1014 // 
       
  1015 // Test purpose:
       
  1016 // The purpose of this test case is to verify that a view can be
       
  1017 // successfully activated
       
  1018 //
       
  1019 // Pre conditions (SetupL()):
       
  1020 // Empty homescreen
       
  1021 //
       
  1022 // Test step 1:
       
  1023 // Create CHsCcApiClient
       
  1024 //
       
  1025 // Expected result:
       
  1026 // Connection is successfully established
       
  1027 //
       
  1028 // Test step 2:
       
  1029 // Add test view
       
  1030 //
       
  1031 // Expected result:
       
  1032 // View successfully added
       
  1033 //
       
  1034 // Test step 3:
       
  1035 // Activate test view
       
  1036 //
       
  1037 // Expected result:
       
  1038 // View successfully activated
       
  1039 //
       
  1040 // Test step 4:
       
  1041 // Delete CHsCcApiClient
       
  1042 //
       
  1043 // Expected result:
       
  1044 // Connection is successfully closed
       
  1045 //
       
  1046 // Post conditions (Teardown()):
       
  1047 // -
       
  1048 //
       
  1049 // -----------------------------------------------------------------------
       
  1050 //
       
  1051 void CMTHsCcApiClient::ActivateViewL()
       
  1052     {
       
  1053     // Test step 1
       
  1054     ConnectHsCcApiClientL( NULL );
       
  1055 
       
  1056     // Test step 2
       
  1057     CHsContentInfo* view = AddViewL( KTemplateViewUid );
       
  1058     User::LeaveIfNull( view );
       
  1059     CleanupStack::PushL( view );
       
  1060 
       
  1061     // Test step 3
       
  1062     TInt err = iApiClient->ActivateViewL( *view );
       
  1063     User::LeaveIfError( err );
       
  1064     CleanupStack::PopAndDestroy( view );
       
  1065 
       
  1066     // Test step 4
       
  1067     DisconnectHsCcApiClient();
       
  1068     }
       
  1069 
       
  1070 // -----------------------------------------------------------------------
       
  1071 // CMTHsCcApiClient::AddViewFails1L()
       
  1072 // 
       
  1073 // Test purpose:
       
  1074 // The purpose of this test case is to verify that adding of view fails
       
  1075 // if an unknown view (invalid UID) is tried to add to Home screen
       
  1076 //
       
  1077 // Pre conditions (SetupL()):
       
  1078 // Empty homescreen
       
  1079 //
       
  1080 // Test step 1:
       
  1081 // Create CHsCcApiClient
       
  1082 //
       
  1083 // Expected result:
       
  1084 // Connection is successfully established
       
  1085 //
       
  1086 // Test step 2:
       
  1087 // Add view which cannot be found to the Home screen
       
  1088 //
       
  1089 // Expected result:
       
  1090 // View adding fails
       
  1091 //
       
  1092 // Test step 3:
       
  1093 // Delete CHsCcApiClient
       
  1094 //
       
  1095 // Expected result:
       
  1096 // Connection is successfully closed
       
  1097 //
       
  1098 // Post conditions (Teardown()):
       
  1099 // -
       
  1100 //
       
  1101 // -----------------------------------------------------------------------
       
  1102 //
       
  1103 void CMTHsCcApiClient::AddViewFails1L()
       
  1104     {
       
  1105     // Test step 1
       
  1106     ConnectHsCcApiClientL( NULL );
       
  1107 
       
  1108     // Test step 2
       
  1109     CHsContentInfo* view = GetViewL( NULL, KTemplateViewUid );
       
  1110     User::LeaveIfNull( view );
       
  1111     CleanupStack::PushL( view );
       
  1112     view->SetUidL( KNotFoundViewUid );
       
  1113     TInt err = iApiClient->AddViewL( *view );
       
  1114     if ( err != KErrArgument )
       
  1115         {
       
  1116         User::Leave( KErrGeneral );
       
  1117         }
       
  1118     CleanupStack::PopAndDestroy( view );
       
  1119 
       
  1120     // Test step 3
       
  1121     DisconnectHsCcApiClient();
       
  1122     }
       
  1123 
       
  1124 // -----------------------------------------------------------------------
       
  1125 // CMTHsCcApiClient::RemoveViewFails1L()
       
  1126 // 
       
  1127 // Test purpose:
       
  1128 // The purpose of this test case is to verify that removing of view fails
       
  1129 // if a view which cannot be removed (last view) is request to be removed
       
  1130 //
       
  1131 // Pre conditions (SetupL()):
       
  1132 // Empty homescreen
       
  1133 //
       
  1134 // Test step 1:
       
  1135 // Create CHsCcApiClient
       
  1136 //
       
  1137 // Expected result:
       
  1138 // Connection is successfully established
       
  1139 //
       
  1140 // Test step 2:
       
  1141 // Remove last view
       
  1142 //
       
  1143 // Expected result:
       
  1144 // Removing of last view fails
       
  1145 //
       
  1146 // Test step 3:
       
  1147 // Delete CHsCcApiClient
       
  1148 //
       
  1149 // Expected result:
       
  1150 // Connection is successfully closed
       
  1151 //
       
  1152 // Post conditions (Teardown()):
       
  1153 // -
       
  1154 //
       
  1155 // -----------------------------------------------------------------------
       
  1156 //
       
  1157 void CMTHsCcApiClient::RemoveViewFails1L()
       
  1158     {
       
  1159     // Test step 1
       
  1160     ConnectHsCcApiClientL( NULL );
       
  1161 
       
  1162     // Test step 2
       
  1163     CHsContentInfo* view = GetViewL( NULL, KHsViewUid );
       
  1164     User::LeaveIfNull( view );
       
  1165     CleanupStack::PushL( view );
       
  1166     TInt err = iApiClient->RemoveViewL( *view );
       
  1167     if ( err != KErrArgument )
       
  1168         {
       
  1169         User::Leave( KErrGeneral );
       
  1170         }
       
  1171     CleanupStack::PopAndDestroy( view );
       
  1172 
       
  1173     // Test step 3
       
  1174     DisconnectHsCcApiClient();
       
  1175     }
       
  1176 
       
  1177 // -----------------------------------------------------------------------
       
  1178 // CMTHsCcApiClient::ViewListChangeNtfL()
       
  1179 // 
       
  1180 // Test purpose:
       
  1181 // The purpose of this test case is to verify that a notification is
       
  1182 // received after a view is successfully addded to Home screen
       
  1183 //
       
  1184 // Pre conditions (SetupL()):
       
  1185 // Empty homescreen
       
  1186 //
       
  1187 // Test step 1:
       
  1188 // Create CHsCcApiClient and register it as Content Control server api 
       
  1189 // observer
       
  1190 //
       
  1191 // Expected result:
       
  1192 // Connection is successfully established observation registration 
       
  1193 // succeeded
       
  1194 //
       
  1195 // Test step 2:
       
  1196 // Add template view
       
  1197 //
       
  1198 // Expected result:
       
  1199 // 1) View added successfully
       
  1200 // 2) View list change notification received
       
  1201 //
       
  1202 // Test step 3:
       
  1203 // Delete CHsCcApiClient
       
  1204 //
       
  1205 // Expected result:
       
  1206 // Connection is successfully closed
       
  1207 //
       
  1208 // Post conditions (Teardown()):
       
  1209 // -
       
  1210 //
       
  1211 // -----------------------------------------------------------------------
       
  1212 //
       
  1213 void CMTHsCcApiClient::ViewListChangeNtfL()
       
  1214     {
       
  1215     // Test step 1
       
  1216     ConnectHsCcApiClientL( this );
       
  1217 
       
  1218     // Test step 2
       
  1219     iViewListNtfExpected = ETrue;
       
  1220     CHsContentInfo* view = AddViewL( KTemplateViewUid );
       
  1221     User::LeaveIfNull( view );
       
  1222     CleanupStack::PushL( view );
       
  1223 
       
  1224     // Wait for notification
       
  1225     iWait.Start();
       
  1226     if ( !iViewListNtfReceived )
       
  1227         {
       
  1228         User::Leave( KErrGeneral );
       
  1229         }
       
  1230     CleanupStack::PopAndDestroy( view );
       
  1231 
       
  1232     // Test step 6
       
  1233     DisconnectHsCcApiClient();
       
  1234     }
       
  1235 
       
  1236 // -----------------------------------------------------------------------
       
  1237 // CMTHsCcApiClient::AppListL()
       
  1238 // 
       
  1239 // Test purpose:
       
  1240 // The purpose of this test case is to verify that a correct list of
       
  1241 // application configurations is returned
       
  1242 //
       
  1243 // Pre conditions (SetupL()):
       
  1244 // Empty homescreen
       
  1245 //
       
  1246 // Test step 1:
       
  1247 // Create CHsCcApiClient
       
  1248 //
       
  1249 // Expected result:
       
  1250 // Connection is successfully established
       
  1251 //
       
  1252 // Test step 2:
       
  1253 // Get app list
       
  1254 //
       
  1255 // Expected result:
       
  1256 // Content info list with app type content info
       
  1257 //
       
  1258 // Test step 3:
       
  1259 // Delete CHsCcApiClient
       
  1260 //
       
  1261 // Expected result:
       
  1262 // Connection is successfully closed
       
  1263 //
       
  1264 // Post conditions (Teardown()):
       
  1265 // -
       
  1266 //
       
  1267 // -----------------------------------------------------------------------
       
  1268 //
       
  1269 void CMTHsCcApiClient::AppListL()
       
  1270     {
       
  1271     // Test step 1
       
  1272     ConnectHsCcApiClientL( NULL );
       
  1273 
       
  1274     // Test step 2
       
  1275     CHsContentInfoArray* apps = CHsContentInfoArray::NewL();
       
  1276     CleanupStack::PushL( apps );
       
  1277     TInt err = iApiClient->AppListL( *apps );
       
  1278     // Check app list
       
  1279     for ( TInt i = 0; i < apps->Array().Count() && !err ; i++ )
       
  1280         {
       
  1281         CHsContentInfo* info = apps->Array()[ i ];
       
  1282         if ( info->Type().Compare( KInfoTypeApp ) != 0 )
       
  1283             {
       
  1284             // Invalid widget type
       
  1285             err = KErrArgument;
       
  1286             }
       
  1287         }
       
  1288     CleanupStack::PopAndDestroy( apps );
       
  1289     User::LeaveIfError( err );
       
  1290 
       
  1291     // Test step 3
       
  1292     DisconnectHsCcApiClient();
       
  1293     }
       
  1294 
       
  1295 // -----------------------------------------------------------------------
       
  1296 // CMTHsCcApiClient::ActivateAppL()
       
  1297 // 
       
  1298 // Test purpose:
       
  1299 // The purpose of this test case is to verify that a application
       
  1300 // configuration can be successfully activated
       
  1301 //
       
  1302 // Pre conditions (SetupL()):
       
  1303 // Empty homescreen
       
  1304 //
       
  1305 // Test step 1:
       
  1306 // Create CHsCcApiClient
       
  1307 //
       
  1308 // Expected result:
       
  1309 // Connection is successfully established
       
  1310 //
       
  1311 // Test step 2:
       
  1312 // Get app list
       
  1313 //
       
  1314 // Expected result:
       
  1315 // Content info list with application type content info
       
  1316 //
       
  1317 // Test step 3:
       
  1318 // Activate application type content info
       
  1319 //
       
  1320 // Expected result
       
  1321 // Application content info is activated
       
  1322 //
       
  1323 // Test step 4:
       
  1324 // Delete CHsCcApiClient
       
  1325 //
       
  1326 // Expected result:
       
  1327 // Connection is successfully closed
       
  1328 //
       
  1329 // Post conditions (Teardown()):
       
  1330 // -
       
  1331 //
       
  1332 // -----------------------------------------------------------------------
       
  1333 //
       
  1334 void CMTHsCcApiClient::ActivateAppL()
       
  1335     {
       
  1336     // Test step 1
       
  1337     ConnectHsCcApiClientL( NULL );
       
  1338 
       
  1339     // Test step 2
       
  1340     CHsContentInfoArray* apps = CHsContentInfoArray::NewL();
       
  1341     CleanupStack::PushL( apps );
       
  1342     TInt err = iApiClient->AppListL( *apps );
       
  1343     User::LeaveIfError( err );
       
  1344     // Get application content info which can be activated
       
  1345     CHsContentInfo* info = NULL;
       
  1346     if ( apps->Array().Count() )
       
  1347         {
       
  1348         info = apps->Array()[ 0 ];
       
  1349         apps->Array().Remove( 0 );
       
  1350         }
       
  1351     apps->Array().ResetAndDestroy();
       
  1352     User::LeaveIfNull( info );
       
  1353     CleanupStack::PushL( info );
       
  1354 
       
  1355     // Test step 3
       
  1356     err = iApiClient->ActivateAppL( *info );
       
  1357     User::LeaveIfError( err );
       
  1358 
       
  1359     CleanupStack::PopAndDestroy( info );
       
  1360     CleanupStack::PopAndDestroy( apps );
       
  1361 
       
  1362     // Test step 4
       
  1363     DisconnectHsCcApiClient();
       
  1364     }
       
  1365 
       
  1366 // -----------------------------------------------------------------------
       
  1367 // CMTHsCcApiClient::ActiveAppL()
       
  1368 // 
       
  1369 // Test purpose:
       
  1370 // The purpose of this test case is to verify that an active application
       
  1371 // configuration is successfully returned
       
  1372 //
       
  1373 // Pre conditions (SetupL()):
       
  1374 // Empty homescreen
       
  1375 //
       
  1376 // Test step 1:
       
  1377 // Create CHsCcApiClient
       
  1378 //
       
  1379 // Expected result:
       
  1380 // Connection is successfully established
       
  1381 //
       
  1382 // Test step 2:
       
  1383 // Get app list
       
  1384 //
       
  1385 // Expected result:
       
  1386 // Content info list with application type content info
       
  1387 //
       
  1388 // Test step 3:
       
  1389 // Activate application type content info
       
  1390 //
       
  1391 // Expected result
       
  1392 // Application content info is activated
       
  1393 //
       
  1394 // Test step 4:
       
  1395 // Get active app
       
  1396 //
       
  1397 // Expected result:
       
  1398 // Content info with active application info
       
  1399 //
       
  1400 // Test step 5:
       
  1401 // Delete CHsCcApiClient
       
  1402 //
       
  1403 // Expected result:
       
  1404 // Connection is successfully closed
       
  1405 //
       
  1406 // Post conditions (Teardown()):
       
  1407 // -
       
  1408 //
       
  1409 // -----------------------------------------------------------------------
       
  1410 //
       
  1411 void CMTHsCcApiClient::ActiveAppL()
       
  1412     {
       
  1413     // Test step 1
       
  1414     ConnectHsCcApiClientL( NULL );
       
  1415 
       
  1416     // Test step 2
       
  1417     CHsContentInfoArray* apps = CHsContentInfoArray::NewL();
       
  1418     CleanupStack::PushL( apps );
       
  1419     TInt err = iApiClient->AppListL( *apps );
       
  1420     User::LeaveIfError( err );
       
  1421     // Get application content info which can be activated
       
  1422     CHsContentInfo* info = NULL;
       
  1423     if ( apps->Array().Count() )
       
  1424         {
       
  1425         info = apps->Array()[ 0 ];
       
  1426         apps->Array().Remove( 0 );
       
  1427         }
       
  1428     apps->Array().ResetAndDestroy();
       
  1429     User::LeaveIfNull( info );
       
  1430     CleanupStack::PushL( info );
       
  1431 
       
  1432     // Test step 3
       
  1433     err = iApiClient->ActivateAppL( *info );
       
  1434     User::LeaveIfError( err );
       
  1435 
       
  1436 
       
  1437     // Test step 4
       
  1438     CHsContentInfo* app = CHsContentInfo::NewL();
       
  1439     CleanupStack::PushL( app );
       
  1440 
       
  1441     err = iApiClient->ActiveAppL( *app );
       
  1442     User::LeaveIfError( err );
       
  1443     
       
  1444     if ( app->Uid().CompareF( info->Uid() ) != 0 )
       
  1445         {
       
  1446         User::Leave( KErrGeneral );
       
  1447         }
       
  1448 
       
  1449     CleanupStack::PopAndDestroy( app );
       
  1450     
       
  1451     CleanupStack::PopAndDestroy( info );
       
  1452     CleanupStack::PopAndDestroy( apps );
       
  1453 
       
  1454     // Test step 5
       
  1455     DisconnectHsCcApiClient();
       
  1456     }
       
  1457 
       
  1458 // -----------------------------------------------------------------------
       
  1459 // CMTHsCcApiClient::ActiveViewL()
       
  1460 // 
       
  1461 // Test purpose:
       
  1462 // The purpose of this test case is to verify that an active view is
       
  1463 // successfully returned
       
  1464 //
       
  1465 // Pre conditions (SetupL()):
       
  1466 // Empty homescreen
       
  1467 //
       
  1468 // Test step 1:
       
  1469 // Create CHsCcApiClient
       
  1470 //
       
  1471 // Expected result:
       
  1472 // Connection is successfully established
       
  1473 //
       
  1474 // Test step 2:
       
  1475 // Get active view
       
  1476 //
       
  1477 // Expected result:
       
  1478 // Active view successfully returned
       
  1479 //
       
  1480 // Test step 3:
       
  1481 // Delete CHsCcApiClient
       
  1482 //
       
  1483 // Expected result:
       
  1484 // Connection is successfully closed
       
  1485 //
       
  1486 // Post conditions (Teardown()):
       
  1487 // -
       
  1488 //
       
  1489 // -----------------------------------------------------------------------
       
  1490 //
       
  1491 void CMTHsCcApiClient::ActiveViewL()
       
  1492     {
       
  1493     // Test step 1
       
  1494     ConnectHsCcApiClientL( NULL );
       
  1495 
       
  1496     // Test step 2
       
  1497     CHsContentInfo* view = CHsContentInfo::NewL();
       
  1498     CleanupStack::PushL( view );
       
  1499     TInt err = iApiClient->ActiveViewL( *view );
       
  1500     User::LeaveIfError( err );
       
  1501     if ( view->Uid().CompareF( KHsViewUid ) != 0 )
       
  1502         {
       
  1503         User::Leave( KErrGeneral );
       
  1504         }
       
  1505     CleanupStack::PopAndDestroy( view );
       
  1506 
       
  1507     // Test step 7
       
  1508     DisconnectHsCcApiClient();
       
  1509     }
       
  1510 
       
  1511 // -----------------------------------------------------------------------
       
  1512 // CMTHsCcApiClient::ViewWidgetList1L()
       
  1513 // 
       
  1514 // Test purpose:
       
  1515 // The purpose of this test case is to verify that an empty widget list
       
  1516 // is returned if the active view is empty
       
  1517 //
       
  1518 // Pre conditions (SetupL()):
       
  1519 // Empty homescreen
       
  1520 //
       
  1521 // Test step 1:
       
  1522 // Create CHsCcApiClient
       
  1523 //
       
  1524 // Expected result:
       
  1525 // Connection is successfully established
       
  1526 //
       
  1527 // Test step 2:
       
  1528 // Add empty view to Home screen
       
  1529 //
       
  1530 // Expected result:
       
  1531 // Empty view successfully added
       
  1532 //
       
  1533 // Test step 3:
       
  1534 // Activate added view
       
  1535 //
       
  1536 // Expected result:
       
  1537 // View is successfully activated
       
  1538 //
       
  1539 // Test step 4:
       
  1540 // Get widget list of active view
       
  1541 //
       
  1542 // Expected result:
       
  1543 // Empty widget list is returned
       
  1544 //
       
  1545 // Test step 5:
       
  1546 // Delete CHsCcApiClient
       
  1547 //
       
  1548 // Expected result:
       
  1549 // Connection is successfully closed
       
  1550 //
       
  1551 // Post conditions (Teardown()):
       
  1552 // -
       
  1553 //
       
  1554 // -----------------------------------------------------------------------
       
  1555 //
       
  1556 void CMTHsCcApiClient::ViewWidgetList1L()
       
  1557     {
       
  1558     // Test step 1
       
  1559     ConnectHsCcApiClientL( NULL );
       
  1560 
       
  1561     // Test step 2
       
  1562     CHsContentInfo* view = AddViewL( KTemplateViewUid );
       
  1563     CleanupStack::PushL( view );
       
  1564 
       
  1565     // Test step 3
       
  1566     TInt err = iApiClient->ActivateViewL( *view );
       
  1567     User::LeaveIfError( err );
       
  1568 
       
  1569     // Test step 4
       
  1570     CHsContentInfoArray* widgets = CHsContentInfoArray::NewL();
       
  1571     CleanupStack::PushL( widgets );
       
  1572     err = iApiClient->WidgetListL( *view, *widgets );
       
  1573     User::LeaveIfError( err );
       
  1574 
       
  1575     if ( widgets->Array().Count() != 0 )
       
  1576         {
       
  1577         User::Leave( KErrGeneral );
       
  1578         }
       
  1579     CleanupStack::PopAndDestroy( widgets );
       
  1580     CleanupStack::PopAndDestroy( view );
       
  1581 
       
  1582     // Test step 5
       
  1583     DisconnectHsCcApiClient();
       
  1584     }
       
  1585 
       
  1586 // -----------------------------------------------------------------------
       
  1587 // CMTHsCcApiClient::ViewWidgetList2L()
       
  1588 // 
       
  1589 // Test purpose:
       
  1590 // The purpose of this test case is to verify that an empty widget list
       
  1591 // is returned if the active view is empty
       
  1592 //
       
  1593 // Pre conditions (SetupL()):
       
  1594 // Empty homescreen
       
  1595 //
       
  1596 // Test step 1:
       
  1597 // Create CHsCcApiClient
       
  1598 //
       
  1599 // Expected result:
       
  1600 // Connection is successfully established
       
  1601 //
       
  1602 // Test step 2:
       
  1603 // Add empty view to Home screen
       
  1604 //
       
  1605 // Expected result:
       
  1606 // Empty view successfully added
       
  1607 //
       
  1608 // Test step 3:
       
  1609 // Activate added view
       
  1610 //
       
  1611 // Expected result:
       
  1612 // View is successfully activated
       
  1613 //
       
  1614 // Test step 4:
       
  1615 // Add widget to Home screen view
       
  1616 //
       
  1617 // Expected result:
       
  1618 // Widget added successfully
       
  1619 //
       
  1620 // Test step 5:
       
  1621 // Get widget list of active view
       
  1622 //
       
  1623 // Expected result:
       
  1624 // Widget list including added widget
       
  1625 //
       
  1626 // Test step 6:
       
  1627 // Delete CHsCcApiClient
       
  1628 //
       
  1629 // Expected result:
       
  1630 // Connection is successfully closed
       
  1631 //
       
  1632 // Post conditions (Teardown()):
       
  1633 // -
       
  1634 //
       
  1635 // -----------------------------------------------------------------------
       
  1636 //
       
  1637 void CMTHsCcApiClient::ViewWidgetList2L()
       
  1638     {
       
  1639     // Test step 1
       
  1640     ConnectHsCcApiClientL( NULL );
       
  1641 
       
  1642     // Test step 2
       
  1643     CHsContentInfo* view = AddViewL( KTemplateViewUid );
       
  1644     CleanupStack::PushL( view );
       
  1645 
       
  1646     // Test step 3
       
  1647     TInt err = iApiClient->ActivateViewL( *view );
       
  1648     User::LeaveIfError( err );
       
  1649 
       
  1650     // Test step 4
       
  1651     CHsContentInfo* widget = AddWidgetL( KDesktopWidgetUid );
       
  1652     CleanupStack::PushL( widget );
       
  1653 
       
  1654     // Test step 5
       
  1655     CHsContentInfoArray* widgets = CHsContentInfoArray::NewL();
       
  1656     CleanupStack::PushL( widgets );
       
  1657     err = iApiClient->WidgetListL( *view, *widgets );
       
  1658     User::LeaveIfError( err );
       
  1659 
       
  1660     err = KErrGeneral;
       
  1661     if ( widgets->Array().Count() == 1 && 
       
  1662          widgets->Array()[ 0 ]->PluginId().CompareF( widget->PluginId() ) ==
       
  1663          0 && widgets->Array()[ 0 ]->Uid().CompareF( widget->Uid() ) == 0 )
       
  1664         {
       
  1665         err = KErrNone;
       
  1666         }
       
  1667     User::LeaveIfError( err );
       
  1668 
       
  1669     CleanupStack::PopAndDestroy( widgets );
       
  1670     CleanupStack::PopAndDestroy( widget );
       
  1671     CleanupStack::PopAndDestroy( view );
       
  1672 
       
  1673     // Test step 6
       
  1674     DisconnectHsCcApiClient();
       
  1675     }
       
  1676 
       
  1677 // -----------------------------------------------------------------------
       
  1678 // CMTHsCcApiClient::ViewWidgetListFailsL()
       
  1679 // 
       
  1680 // Test purpose:
       
  1681 // The purpose of this test case is to verify that requesting of a
       
  1682 // widget list fails if the widget list is requested from a view which
       
  1683 // cannot be found
       
  1684 //
       
  1685 // Pre conditions (SetupL()):
       
  1686 // Empty homescreen
       
  1687 //
       
  1688 // Test step 1:
       
  1689 // Create CHsCcApiClient
       
  1690 //
       
  1691 // Expected result:
       
  1692 // Connection is successfully established
       
  1693 //
       
  1694 // Test step 2:
       
  1695 // Add empty view to Home screen
       
  1696 //
       
  1697 // Expected result:
       
  1698 // Empty view successfully added
       
  1699 //
       
  1700 // Test step 3:
       
  1701 // Get widget list of invalid view
       
  1702 //
       
  1703 // Expected result:
       
  1704 // Widget list request fails
       
  1705 //
       
  1706 // Test step 4:
       
  1707 // Delete CHsCcApiClient
       
  1708 //
       
  1709 // Expected result:
       
  1710 // Connection is successfully closed
       
  1711 //
       
  1712 // Post conditions (Teardown()):
       
  1713 // -
       
  1714 //
       
  1715 // -----------------------------------------------------------------------
       
  1716 //
       
  1717 void CMTHsCcApiClient::ViewWidgetListFailsL()
       
  1718     {
       
  1719     // Test step 1
       
  1720     ConnectHsCcApiClientL( NULL );
       
  1721 
       
  1722     // Test step 2
       
  1723     CHsContentInfo* view = AddViewL( KTemplateViewUid );
       
  1724     CleanupStack::PushL( view );
       
  1725 
       
  1726     // Test step 3
       
  1727     view->SetPluginIdL( KNotFoundViewPluginId );
       
  1728     CHsContentInfoArray* widgets = CHsContentInfoArray::NewL();
       
  1729     CleanupStack::PushL( widgets );
       
  1730     TInt err = iApiClient->WidgetListL( *view, *widgets );
       
  1731     if ( err != KErrArgument )
       
  1732         {
       
  1733         User::Leave( KErrGeneral );
       
  1734         }
       
  1735 
       
  1736     CleanupStack::PopAndDestroy( widgets );
       
  1737     CleanupStack::PopAndDestroy( view );
       
  1738 
       
  1739     // Test step 4
       
  1740     DisconnectHsCcApiClient();
       
  1741     }
       
  1742 
       
  1743 // -----------------------------------------------------------------------
       
  1744 // CMTHsCcApiClient::AppWidgetList1L()
       
  1745 // 
       
  1746 // Test purpose:
       
  1747 // The purpose of this test case is to verify that correct list of widgets
       
  1748 // is returned when a widget list of an application configuration is
       
  1749 // requested
       
  1750 //
       
  1751 // Pre conditions (SetupL()):
       
  1752 // Empty homescreen
       
  1753 //
       
  1754 // Test step 1:
       
  1755 // Create CHsCcApiClient
       
  1756 //
       
  1757 // Expected result:
       
  1758 // Connection is successfully established
       
  1759 //
       
  1760 // Test step 2:
       
  1761 // Get active application configuration
       
  1762 //
       
  1763 // Expected result:
       
  1764 // Application configuration successfully received
       
  1765 //
       
  1766 // Test step 3:
       
  1767 // Get widget list of active application configuration
       
  1768 //
       
  1769 // Expected result:
       
  1770 // Widget list is successfully returned
       
  1771 //
       
  1772 // Test step 4:
       
  1773 // Add empty view to Home screen
       
  1774 //
       
  1775 // Expected result:
       
  1776 // Empty view successfully added
       
  1777 //
       
  1778 // Test step 5:
       
  1779 // Activate added view
       
  1780 //
       
  1781 // Expected result:
       
  1782 // View is successfully activated
       
  1783 //
       
  1784 // Test step 6:
       
  1785 // Add widget to Home screen view
       
  1786 //
       
  1787 // Expected result:
       
  1788 // Widget added successfully
       
  1789 //
       
  1790 // Test step 7:
       
  1791 // Get widget list of active application configuration
       
  1792 //
       
  1793 // Expected result:
       
  1794 // Widget list is successfully returned
       
  1795 //
       
  1796 // Test step 8:
       
  1797 // Delete CHsCcApiClient
       
  1798 //
       
  1799 // Expected result:
       
  1800 // Connection is successfully closed
       
  1801 //
       
  1802 // Post conditions (Teardown()):
       
  1803 // -
       
  1804 //
       
  1805 // -----------------------------------------------------------------------
       
  1806 //
       
  1807 void CMTHsCcApiClient::AppWidgetList1L()
       
  1808     {
       
  1809     // Test step 1
       
  1810     ConnectHsCcApiClientL( NULL );
       
  1811 
       
  1812     // Test step 2
       
  1813     CHsContentInfo* app = CHsContentInfo::NewL();
       
  1814     CleanupStack::PushL( app );
       
  1815 
       
  1816     TInt err = iApiClient->ActiveAppL( *app );
       
  1817     User::LeaveIfError( err );
       
  1818     
       
  1819     // Test step 3
       
  1820     CHsContentInfoArray* widgets1 = CHsContentInfoArray::NewL();
       
  1821     CleanupStack::PushL( widgets1 );
       
  1822     err = iApiClient->WidgetListL( *app, *widgets1 );
       
  1823     User::LeaveIfError( err );
       
  1824 
       
  1825     // Test step 4
       
  1826     CHsContentInfo* view = AddViewL( KTemplateViewUid );
       
  1827     CleanupStack::PushL( view );
       
  1828 
       
  1829     // Test step 5
       
  1830     err = iApiClient->ActivateViewL( *view );
       
  1831     User::LeaveIfError( err );
       
  1832     CleanupStack::PopAndDestroy( view );
       
  1833 
       
  1834     // Test step 6
       
  1835     CHsContentInfo* widget = AddWidgetL( KDesktopWidgetUid );
       
  1836     CleanupStack::PushL( widget );
       
  1837     widgets1->Array().AppendL( widget );
       
  1838     CleanupStack::Pop( widget );
       
  1839 
       
  1840     // Test step 7
       
  1841     CHsContentInfoArray* widgets2 = CHsContentInfoArray::NewL();
       
  1842     CleanupStack::PushL( widgets2 );
       
  1843     err = iApiClient->WidgetListL( *app, *widgets2 );
       
  1844     User::LeaveIfError( err );
       
  1845 
       
  1846     err = KErrGeneral;
       
  1847     if ( widgets1->Array().Count() == widgets2->Array().Count() )
       
  1848         {
       
  1849         err = KErrNone;
       
  1850         for ( TInt i = 0; i < widgets1->Array().Count() &&
       
  1851             err == KErrNone; i++ )
       
  1852             {
       
  1853             TBool found( EFalse );
       
  1854             for ( TInt j = 0; j < widgets2->Array().Count() && !found; j++ )
       
  1855                 {
       
  1856                 if ( widgets1->Array()[ i ]->PluginId() ==
       
  1857                     widgets2->Array()[ j ]->PluginId() )
       
  1858                     {
       
  1859                     found = ETrue;
       
  1860                     }
       
  1861                 }
       
  1862             if ( !found )
       
  1863                 {
       
  1864                 err = KErrGeneral;
       
  1865                 }
       
  1866             }
       
  1867         }
       
  1868 
       
  1869     CleanupStack::PopAndDestroy( widgets2 );
       
  1870     CleanupStack::PopAndDestroy( widgets1 );
       
  1871     CleanupStack::PopAndDestroy( app );
       
  1872 
       
  1873     // Test step 8
       
  1874     DisconnectHsCcApiClient();
       
  1875     }
       
  1876 
       
  1877 // -----------------------------------------------------------------------
       
  1878 // CMTHsCcApiClient::AppWidgetListFailsL()
       
  1879 // 
       
  1880 // Test purpose:
       
  1881 // The purpose of this test case is to verify that requesting of a
       
  1882 // widget list fails if the widget list is requested from a application 
       
  1883 // configuration which cannot be found
       
  1884 //
       
  1885 // Pre conditions (SetupL()):
       
  1886 // Empty homescreen
       
  1887 //
       
  1888 // Test step 1:
       
  1889 // Create CHsCcApiClient
       
  1890 //
       
  1891 // Expected result:
       
  1892 // Connection is successfully established
       
  1893 //
       
  1894 // Test step 2:
       
  1895 // Get active application configuration
       
  1896 //
       
  1897 // Expected result:
       
  1898 // Application configuration successfully received
       
  1899 //
       
  1900 // Test step 3:
       
  1901 // Get widget list of invalid application configuration
       
  1902 //
       
  1903 // Expected result:
       
  1904 // Widget list request fails
       
  1905 //
       
  1906 // Test step 4:
       
  1907 // Delete CHsCcApiClient
       
  1908 //
       
  1909 // Expected result:
       
  1910 // Connection is successfully closed
       
  1911 //
       
  1912 // Post conditions (Teardown()):
       
  1913 // -
       
  1914 //
       
  1915 // -----------------------------------------------------------------------
       
  1916 //
       
  1917 void CMTHsCcApiClient::AppWidgetListFailsL()
       
  1918     {
       
  1919     // Test step 1
       
  1920     ConnectHsCcApiClientL( NULL );
       
  1921 
       
  1922     // Test step 2
       
  1923     CHsContentInfo* app = CHsContentInfo::NewL();
       
  1924     CleanupStack::PushL( app );
       
  1925 
       
  1926     TInt err = iApiClient->ActiveAppL( *app );
       
  1927     User::LeaveIfError( err );
       
  1928 
       
  1929     // Test step 3
       
  1930     CHsContentInfoArray* widgets = CHsContentInfoArray::NewL();
       
  1931     CleanupStack::PushL( widgets );
       
  1932     app->SetUidL( KNotFoundAppUid );
       
  1933     err = iApiClient->WidgetListL( *app, *widgets );
       
  1934     if ( err != KErrArgument )
       
  1935         {
       
  1936         User::Leave( KErrGeneral );
       
  1937         }
       
  1938 
       
  1939     CleanupStack::PopAndDestroy( widgets );
       
  1940     CleanupStack::PopAndDestroy( app );
       
  1941 
       
  1942     // Test step 4
       
  1943     DisconnectHsCcApiClient();
       
  1944     }
       
  1945 
       
  1946 // -----------------------------------------------------------------------
       
  1947 // CMTHsCcApiClient::AppViewList1L()
       
  1948 // 
       
  1949 // Test purpose:
       
  1950 // The purpose of this test case is to verify that correct view list is
       
  1951 // returned when there is mandatory views included in active application 
       
  1952 // configuration
       
  1953 //
       
  1954 // Pre conditions (SetupL()):
       
  1955 // Empty homescreen
       
  1956 //
       
  1957 // Test step 1:
       
  1958 // Create CHsCcApiClient
       
  1959 //
       
  1960 // Expected result:
       
  1961 // Connection is successfully established
       
  1962 //
       
  1963 // Test step 2:
       
  1964 // Get active application configuration
       
  1965 //
       
  1966 // Expected result:
       
  1967 // Application configuration is successfully returned
       
  1968 //
       
  1969 // Test step 3:
       
  1970 // Get view list from active application configuration
       
  1971 //
       
  1972 // Expected result:
       
  1973 // View list is successfully returned
       
  1974 //
       
  1975 // Test step 4:
       
  1976 // Delete CHsCcApiClient
       
  1977 //
       
  1978 // Expected result:
       
  1979 // Connection is successfully closed
       
  1980 //
       
  1981 // Post conditions (Teardown()):
       
  1982 // -
       
  1983 //
       
  1984 // -----------------------------------------------------------------------
       
  1985 //
       
  1986 void CMTHsCcApiClient::AppViewList1L()
       
  1987     {
       
  1988     // Test step 1
       
  1989     ConnectHsCcApiClientL( NULL );
       
  1990 
       
  1991     // Test step 2
       
  1992     CHsContentInfo* app = CHsContentInfo::NewL();
       
  1993     CleanupStack::PushL( app );
       
  1994 
       
  1995     TInt err = iApiClient->ActiveAppL( *app );
       
  1996     User::LeaveIfError( err );
       
  1997 
       
  1998     // Test step 3
       
  1999     CHsContentInfoArray* views = CHsContentInfoArray::NewL();
       
  2000     CleanupStack::PushL( views );
       
  2001 
       
  2002     err = iApiClient->ViewListL( *app, *views );
       
  2003     User::LeaveIfError( err );
       
  2004 
       
  2005     for ( TInt i = 0; i < views->Array().Count(); i++ )
       
  2006         {
       
  2007         CHsContentInfo* view = views->Array()[ i ];
       
  2008         if ( view->Type().Compare( KInfoTypeView ) != 0 )
       
  2009             {
       
  2010             User::Leave( KErrGeneral );
       
  2011             }
       
  2012         }
       
  2013 
       
  2014     CleanupStack::PopAndDestroy( views );
       
  2015     CleanupStack::PopAndDestroy( app );
       
  2016 
       
  2017     // Test step 4
       
  2018     DisconnectHsCcApiClient();
       
  2019     }
       
  2020 
       
  2021 // -----------------------------------------------------------------------
       
  2022 // CMTHsCcApiClient::AppViewList2L()
       
  2023 // 
       
  2024 // Test purpose:
       
  2025 // The purpose of this test case is to verify that correct view list is
       
  2026 // returned when there is maximum count of views in application 
       
  2027 // configuration
       
  2028 //
       
  2029 // Pre conditions (SetupL()):
       
  2030 // Empty homescreen
       
  2031 //
       
  2032 // Test step 1:
       
  2033 // Create CHsCcApiClient
       
  2034 //
       
  2035 // Expected result:
       
  2036 // Connection is successfully established
       
  2037 //
       
  2038 // Test step 2:
       
  2039 // Add test views
       
  2040 //
       
  2041 // Expected result:
       
  2042 // Views added successfully
       
  2043 //
       
  2044 // Test step 3:
       
  2045 // Get active application configuration
       
  2046 //
       
  2047 // Expected result:
       
  2048 // Application configuration is successfully returned
       
  2049 //
       
  2050 // Test step 4:
       
  2051 // Get view list from active application configuration
       
  2052 //
       
  2053 // Expected result:
       
  2054 // View list is successfully returned
       
  2055 //
       
  2056 // Test step 5:
       
  2057 // Delete CHsCcApiClient
       
  2058 //
       
  2059 // Expected result:
       
  2060 // Connection is successfully closed
       
  2061 //
       
  2062 // Post conditions (Teardown()):
       
  2063 // -
       
  2064 //
       
  2065 // -----------------------------------------------------------------------
       
  2066 //
       
  2067 void CMTHsCcApiClient::AppViewList2L()
       
  2068     {
       
  2069     // Test step 1
       
  2070     ConnectHsCcApiClientL( NULL );
       
  2071 
       
  2072     // Test step 2
       
  2073     TInt err( KErrNone );
       
  2074     CHsContentInfo* view( NULL );
       
  2075     while ( !err )
       
  2076         {
       
  2077         TRAP( err, view = AddViewL( KTemplateViewUid ) );
       
  2078         delete view;
       
  2079         view = NULL;
       
  2080         }
       
  2081 
       
  2082     // Test step 3
       
  2083     CHsContentInfo* app = CHsContentInfo::NewL();
       
  2084     CleanupStack::PushL( app );
       
  2085 
       
  2086     err = iApiClient->ActiveAppL( *app );
       
  2087     User::LeaveIfError( err );
       
  2088 
       
  2089     // Test step 4
       
  2090     CHsContentInfoArray* views = CHsContentInfoArray::NewL();
       
  2091     CleanupStack::PushL( views );
       
  2092 
       
  2093     err = iApiClient->ViewListL( *app, *views );
       
  2094     User::LeaveIfError( err );
       
  2095 
       
  2096     for ( TInt i = 0; i < views->Array().Count(); i++ )
       
  2097         {
       
  2098         CHsContentInfo* view = views->Array()[ i ];
       
  2099         if ( view->Type().Compare( KInfoTypeView ) != 0 )
       
  2100             {
       
  2101             User::Leave( KErrGeneral );
       
  2102             }
       
  2103         }
       
  2104 
       
  2105     CleanupStack::PopAndDestroy( views );
       
  2106     CleanupStack::PopAndDestroy( app );
       
  2107 
       
  2108     // Test step 5
       
  2109     DisconnectHsCcApiClient();
       
  2110     }
       
  2111 
       
  2112 // -----------------------------------------------------------------------
       
  2113 // CMTHsCcApiClient::AppViewListFails1L()
       
  2114 // 
       
  2115 // Test purpose:
       
  2116 // The purpose of this test case is to verify that requesting of a
       
  2117 // view list fails if the view list is requested from a application 
       
  2118 // configuration which cannot be found
       
  2119 //
       
  2120 // Pre conditions (SetupL()):
       
  2121 // Empty homescreen
       
  2122 //
       
  2123 // Test step 1:
       
  2124 // Create CHsCcApiClient
       
  2125 //
       
  2126 // Expected result:
       
  2127 // Connection is successfully established
       
  2128 //
       
  2129 // Test step 1:
       
  2130 // Create CHsCcApiClient
       
  2131 //
       
  2132 // Expected result:
       
  2133 // Connection is successfully established
       
  2134 //
       
  2135 // Test step 2:
       
  2136 // Get active application configuration
       
  2137 //
       
  2138 // Expected result:
       
  2139 // Application configuration is successfully returned
       
  2140 //
       
  2141 // Test step 3:
       
  2142 // Get view list from invalid active application configuration
       
  2143 //
       
  2144 // Expected result:
       
  2145 // Request fails
       
  2146 //
       
  2147 // Test step 4:
       
  2148 // Delete CHsCcApiClient
       
  2149 //
       
  2150 // Expected result:
       
  2151 // Connection is successfully closed
       
  2152 //
       
  2153 // Post conditions (Teardown()):
       
  2154 // -
       
  2155 //
       
  2156 // -----------------------------------------------------------------------
       
  2157 //
       
  2158 void CMTHsCcApiClient::AppViewListFails1L()
       
  2159     {
       
  2160     // Test step 1
       
  2161     ConnectHsCcApiClientL( NULL );
       
  2162 
       
  2163     // Test step 2
       
  2164     CHsContentInfo* app = CHsContentInfo::NewL();
       
  2165     CleanupStack::PushL( app );
       
  2166 
       
  2167     TInt err = iApiClient->ActiveAppL( *app );
       
  2168     User::LeaveIfError( err );
       
  2169 
       
  2170     // Test step 3
       
  2171     app->SetUidL( KNotFoundAppUid );
       
  2172     CHsContentInfoArray* views = CHsContentInfoArray::NewL();
       
  2173     CleanupStack::PushL( views );
       
  2174 
       
  2175     err = iApiClient->ViewListL( *app, *views );
       
  2176 
       
  2177     if ( err != KErrArgument )
       
  2178         {
       
  2179         User::Leave( KErrGeneral );
       
  2180         }
       
  2181 
       
  2182     CleanupStack::PopAndDestroy( views );
       
  2183     CleanupStack::PopAndDestroy( app );
       
  2184 
       
  2185     // Test step 4
       
  2186     DisconnectHsCcApiClient();
       
  2187     }
       
  2188 
       
  2189 //------------------------------------------------------------------------------
       
  2190 // Test case table
       
  2191 //------------------------------------------------------------------------------
       
  2192 EUNIT_BEGIN_TEST_TABLE(
       
  2193     CMTHsCcApiClient,
       
  2194     "This is a test suite for Home screen Content Control API Client",
       
  2195     "UNIT" )
       
  2196 
       
  2197     EUNIT_TEST(
       
  2198         "Connect/disconnect",
       
  2199         "CHsCcApiClient",
       
  2200         "",
       
  2201         "FUNCTIONALITY",
       
  2202         SetupL, ConnectDisconnectHsCcApiClientL, Teardown )
       
  2203 
       
  2204     EUNIT_TEST(
       
  2205         "Register/Unregister observer",
       
  2206         "CHsCcApiClient",
       
  2207         "",
       
  2208         "FUNCTIONALITY",
       
  2209         SetupL, RegisterUnregisterHsCcApiObserverL, Teardown )
       
  2210 
       
  2211     EUNIT_TEST(
       
  2212         "Register/Unregister multiple observers",
       
  2213         "CHsCcApiClient",
       
  2214         "",
       
  2215         "FUNCTIONALITY",
       
  2216         SetupL, RegisterUnregisterMultipleObserversL, Teardown )
       
  2217 
       
  2218     EUNIT_TEST(
       
  2219         "Widget List",
       
  2220         "CHsCcApiClient",
       
  2221         "",
       
  2222         "FUNCTIONALITY",
       
  2223         SetupL, WidgetListL, Teardown )
       
  2224 
       
  2225     EUNIT_TEST(
       
  2226         "Add/Remove Widget",
       
  2227         "CHsCcApiClient",
       
  2228         "",
       
  2229         "FUNCTIONALITY",
       
  2230         SetupL, AddRemoveWidgetL, Teardown )
       
  2231 
       
  2232     EUNIT_TEST(
       
  2233         "Add Widget fails 1",
       
  2234         "CHsCcApiClient",
       
  2235         "",
       
  2236         "FUNCTIONALITY",
       
  2237         SetupL, AddWidgetFails1L, Teardown )
       
  2238 
       
  2239     EUNIT_TEST(
       
  2240         "Remove Widget fails 1",
       
  2241         "CHsCcApiClient",
       
  2242         "",
       
  2243         "FUNCTIONALITY",
       
  2244         SetupL, RemoveWidgetFails1L, Teardown )
       
  2245 
       
  2246     EUNIT_TEST(
       
  2247         "Widget list change notification",
       
  2248         "CHsCcApiClient",
       
  2249         "",
       
  2250         "FUNCTIONALITY",
       
  2251         SetupL, WidgetListChangeNtfL, Teardown )
       
  2252 
       
  2253     EUNIT_TEST(
       
  2254         "View List",
       
  2255         "CHsCcApiClient",
       
  2256         "",
       
  2257         "FUNCTIONALITY",
       
  2258         SetupL, ViewListL, Teardown )
       
  2259 
       
  2260     EUNIT_TEST(
       
  2261         "Add/Remove View",
       
  2262         "CHsCcApiClient",
       
  2263         "",
       
  2264         "FUNCTIONALITY",
       
  2265         SetupL, AddRemoveViewL, Teardown )
       
  2266 
       
  2267     EUNIT_TEST(
       
  2268         "Activate View",
       
  2269         "CHsCcApiClient",
       
  2270         "",
       
  2271         "FUNCTIONALITY",
       
  2272         SetupL, ActivateViewL, Teardown )
       
  2273 
       
  2274     EUNIT_TEST(
       
  2275         "Add View fails 1",
       
  2276         "CHsCcApiClient",
       
  2277         "",
       
  2278         "FUNCTIONALITY",
       
  2279         SetupL, AddViewFails1L, Teardown )
       
  2280 
       
  2281     EUNIT_TEST(
       
  2282         "Remove View fails 1",
       
  2283         "CHsCcApiClient",
       
  2284         "",
       
  2285         "FUNCTIONALITY",
       
  2286         SetupL, RemoveViewFails1L, Teardown )
       
  2287 
       
  2288     EUNIT_TEST(
       
  2289         "View list change notification",
       
  2290         "CHsCcApiClient",
       
  2291         "",
       
  2292         "FUNCTIONALITY",
       
  2293         SetupL, ViewListChangeNtfL, Teardown )
       
  2294 
       
  2295     EUNIT_TEST(
       
  2296         "App list",
       
  2297         "CHsCcApiClient",
       
  2298         "",
       
  2299         "FUNCTIONALITY",
       
  2300         SetupL, AppListL, Teardown )
       
  2301 
       
  2302     EUNIT_TEST(
       
  2303         "Activate App",
       
  2304         "CHsCcApiClient",
       
  2305         "",
       
  2306         "FUNCTIONALITY",
       
  2307         SetupL, ActivateAppL, Teardown )
       
  2308 
       
  2309     EUNIT_TEST(
       
  2310         "Active App",
       
  2311         "CHsCcApiClient",
       
  2312         "",
       
  2313         "FUNCTIONALITY",
       
  2314         SetupL, ActiveAppL, Teardown )
       
  2315 
       
  2316     EUNIT_TEST(
       
  2317         "Active View",
       
  2318         "CHsCcApiClient",
       
  2319         "",
       
  2320         "FUNCTIONALITY",
       
  2321         SetupL, ActiveViewL, Teardown )
       
  2322 
       
  2323     EUNIT_TEST(
       
  2324         "Widget list of a view",
       
  2325         "CHsCcApiClient",
       
  2326         "",
       
  2327         "FUNCTIONALITY",
       
  2328         SetupL, ViewWidgetList1L, Teardown )
       
  2329 
       
  2330     EUNIT_TEST(
       
  2331         "Widget list of a view",
       
  2332         "CHsCcApiClient",
       
  2333         "",
       
  2334         "FUNCTIONALITY",
       
  2335         SetupL, ViewWidgetList2L, Teardown )
       
  2336 
       
  2337     EUNIT_TEST(
       
  2338         "Widget list of a view fails",
       
  2339         "CHsCcApiClient",
       
  2340         "",
       
  2341         "FUNCTIONALITY",
       
  2342         SetupL, ViewWidgetListFailsL, Teardown )
       
  2343 
       
  2344     EUNIT_TEST(
       
  2345         "Widget list of an app",
       
  2346         "CHsCcApiClient",
       
  2347         "",
       
  2348         "FUNCTIONALITY",
       
  2349         SetupL, AppWidgetList1L, Teardown )
       
  2350     
       
  2351     EUNIT_TEST(
       
  2352         "Widget list of an app fails",
       
  2353         "CHsCcApiClient",
       
  2354         "",
       
  2355         "FUNCTIONALITY",
       
  2356         SetupL, AppWidgetListFailsL, Teardown )
       
  2357 
       
  2358     EUNIT_TEST(
       
  2359         "View list of an app mandatory views",
       
  2360         "CHsCcApiClient",
       
  2361         "",
       
  2362         "FUNCTIONALITY",
       
  2363         SetupL, AppViewList1L, Teardown )
       
  2364 
       
  2365     EUNIT_TEST(
       
  2366         "View list of an app view list full",
       
  2367         "CHsCcApiClient",
       
  2368         "",
       
  2369         "FUNCTIONALITY",
       
  2370         SetupL, AppViewList2L, Teardown )
       
  2371 
       
  2372     EUNIT_TEST(
       
  2373         "View list fails invalid app",
       
  2374         "CHsCcApiClient",
       
  2375         "",
       
  2376         "FUNCTIONALITY",
       
  2377         SetupL, AppViewListFails1L, Teardown )
       
  2378 
       
  2379     EUNIT_END_TEST_TABLE
       
  2380 
       
  2381 // End of file