classicui_pub/queries_api/tsrc/src/testsdkqueriesblocksmessagequerydlg.cpp
branchRCL_3
changeset 20 d48ab3b357f1
parent 0 2f259fa3e83a
equal deleted inserted replaced
19:aecbbf00d063 20:d48ab3b357f1
       
     1 /*
       
     2 * Copyright (c) 2002 - 2007 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:  Test aknmessagequerydialog.h
       
    15 *
       
    16 */
       
    17 
       
    18 //INCLUDE
       
    19 #include <aknmessagequerydialog.h>
       
    20 #include <testsdkqueries.rsg>
       
    21 #include <e32std.h>
       
    22 #include <eikimage.h>
       
    23 
       
    24 #include "testsdkqueries.h"
       
    25 #include "testsdkqueriescontainer.h"
       
    26 #include "testsdkaknmessagequerydialogprotected.h"
       
    27 
       
    28 const TInt KZero = 0;
       
    29 const TInt KTwo = 2;
       
    30 const TInt KThree = 3;
       
    31 const TInt KBufSize = 32;
       
    32 _LIT( KTestString, "It is a test!");
       
    33 
       
    34 // -----------------------------------------------------------------------------
       
    35 // CTestSDKQueries::TestMqdlgNewL
       
    36 // -----------------------------------------------------------------------------
       
    37 //
       
    38 TInt CTestSDKQueries::TestMqdlgNewL( CStifItemParser& /*aItem*/ )
       
    39     {
       
    40     TBuf< KBufSize > message( KTestString );
       
    41     CAknMessageQueryDialog* dlg = CAknMessageQueryDialog::NewL( message,
       
    42         CAknQueryDialog::EConfirmationTone );
       
    43     CleanupStack::PushL( dlg );
       
    44     STIF_ASSERT_NOT_NULL( dlg );
       
    45     CleanupStack::PopAndDestroy( dlg );
       
    46     return KErrNone;
       
    47     }
       
    48 
       
    49 // -----------------------------------------------------------------------------
       
    50 // CTestSDKQueries::TestMqdlgDestructorL
       
    51 // -----------------------------------------------------------------------------
       
    52 //
       
    53 TInt CTestSDKQueries::TestMqdlgDestructorL( CStifItemParser& /*aItem*/ )
       
    54     {
       
    55     TBuf< KBufSize > message( KTestString );
       
    56     CAknMessageQueryDialog* dlg = CAknMessageQueryDialog::NewL( message,
       
    57         CAknQueryDialog::EConfirmationTone );
       
    58     CleanupStack::PushL( dlg );
       
    59     CleanupStack::PopAndDestroy( dlg );
       
    60     return KErrNone;
       
    61     }
       
    62 
       
    63 // -----------------------------------------------------------------------------
       
    64 // CTestSDKQueries::TestMqdlgConstructorOneL
       
    65 // -----------------------------------------------------------------------------
       
    66 //
       
    67 TInt CTestSDKQueries::TestMqdlgConstructorOneL( CStifItemParser& /*aItem*/ )
       
    68     {
       
    69     CAknMessageQueryDialog* dlg = new( ELeave ) CAknMessageQueryDialog( CAknQueryDialog::EConfirmationTone );
       
    70     CleanupStack::PushL( dlg );
       
    71     STIF_ASSERT_NOT_NULL( dlg );
       
    72     CleanupStack::PopAndDestroy( dlg );
       
    73     return KErrNone;
       
    74     }
       
    75 
       
    76 // -----------------------------------------------------------------------------
       
    77 // CTestSDKQueries::TestMqdlgSetMessageTextOneL
       
    78 // -----------------------------------------------------------------------------
       
    79 //
       
    80 TInt CTestSDKQueries::TestMqdlgSetMessageTextOneL( CStifItemParser& /*aItem*/ )
       
    81     {
       
    82     TBuf< KBufSize > message( KTestString );
       
    83     CAknMessageQueryDialog* dlg = CAknMessageQueryDialog::NewL( message,
       
    84         CAknQueryDialog::EConfirmationTone );
       
    85     CleanupStack::PushL( dlg );
       
    86     
       
    87     dlg->SetMessageTextL( message );
       
    88     
       
    89     CleanupStack::PopAndDestroy( dlg );
       
    90     return KErrNone;
       
    91     }
       
    92 
       
    93 // -----------------------------------------------------------------------------
       
    94 // CTestSDKQueries::TestMqdlgSetHeaderTextOneL
       
    95 // -----------------------------------------------------------------------------
       
    96 //
       
    97 TInt CTestSDKQueries::TestMqdlgSetHeaderTextOneL( CStifItemParser& /*aItem*/ )
       
    98     {
       
    99     TBuf< KBufSize > message( KTestString );
       
   100     CAknMessageQueryDialog* dlg = CAknMessageQueryDialog::NewL( message,
       
   101         CAknQueryDialog::EConfirmationTone );
       
   102     CleanupStack::PushL( dlg );
       
   103     
       
   104     dlg->SetHeaderTextL( message );
       
   105     
       
   106     CleanupStack::PopAndDestroy( dlg );
       
   107     return KErrNone;
       
   108     }
       
   109 
       
   110 // -----------------------------------------------------------------------------
       
   111 // CTestSDKQueries::TestMqdlgSetLinkTextL
       
   112 // -----------------------------------------------------------------------------
       
   113 //
       
   114 TInt CTestSDKQueries::TestMqdlgSetLinkTextL( CStifItemParser& /*aItem*/ )
       
   115     {
       
   116     TBuf< KBufSize > message( KTestString );
       
   117     CAknMessageQueryDialog* dlg = CAknMessageQueryDialog::NewL( message,
       
   118         CAknQueryDialog::EConfirmationTone );
       
   119     CleanupStack::PushL( dlg );
       
   120     
       
   121     dlg->SetLinkTextL( message );
       
   122     
       
   123     CleanupStack::PopAndDestroy( dlg );
       
   124     return KErrNone;
       
   125     }
       
   126 
       
   127 // -----------------------------------------------------------------------------
       
   128 // CTestSDKQueries::TestMqdlgSetLinkL
       
   129 // -----------------------------------------------------------------------------
       
   130 //
       
   131 TInt CTestSDKQueries::TestMqdlgSetLinkL( CStifItemParser& /*aItem*/ )
       
   132     {
       
   133     TBuf< KBufSize > message( KTestString );
       
   134     CAknMessageQueryDialog* dlg = CAknMessageQueryDialog::NewL( message,
       
   135         CAknQueryDialog::EConfirmationTone );
       
   136     CleanupStack::PushL( dlg );
       
   137     
       
   138     TCallBack callBack;
       
   139     dlg->SetLink( callBack );
       
   140     
       
   141     CleanupStack::PopAndDestroy( dlg );
       
   142     return KErrNone;
       
   143     }
       
   144 
       
   145 // -----------------------------------------------------------------------------
       
   146 // CTestSDKQueries::TestMqdlgOfferKeyEventL
       
   147 // -----------------------------------------------------------------------------
       
   148 //
       
   149 TInt CTestSDKQueries::TestMqdlgOfferKeyEventL( CStifItemParser& /*aItem*/ )
       
   150     {
       
   151     TBuf< KBufSize > message( KTestString );
       
   152     CAknMessageQueryDialog* dlg = CAknMessageQueryDialog::NewL( message,
       
   153         CAknQueryDialog::EConfirmationTone );
       
   154     
       
   155     dlg->PrepareLC( R_MESSAGE_DIALOG );
       
   156 
       
   157     TKeyEvent event;
       
   158     event.iCode = EKeyDownArrow;
       
   159     TKeyResponse response = dlg->OfferKeyEventL( event, EEventKey );
       
   160     STIF_ASSERT_EQUALS( EKeyWasConsumed, response );
       
   161     
       
   162     event.iCode = EKeyOK;
       
   163     response = dlg->OfferKeyEventL( event, EEventKey );
       
   164     STIF_ASSERT_EQUALS( EKeyWasConsumed, response );
       
   165     
       
   166     CleanupStack::Pop( dlg );
       
   167     return KErrNone;
       
   168     }
       
   169 
       
   170 // -----------------------------------------------------------------------------
       
   171 // CTestSDKQueries::TestMqdlgHandlePointerEventL
       
   172 // -----------------------------------------------------------------------------
       
   173 //
       
   174 TInt CTestSDKQueries::TestMqdlgHandlePointerEventL( CStifItemParser& /*aItem*/ )
       
   175     {
       
   176     TBuf< KBufSize > message( KTestString );
       
   177     CAknMessageQueryDialog* dlg = CAknMessageQueryDialog::NewL( message,
       
   178         CAknQueryDialog::EConfirmationTone );
       
   179     
       
   180     dlg->PrepareLC( R_MESSAGE_DIALOG );
       
   181     
       
   182     TPointerEvent event;
       
   183     event.iType = TPointerEvent::EButton1Down;
       
   184     event.iModifiers = KZero;
       
   185     TPoint eventPos( 10, 30 );
       
   186     event.iPosition = eventPos;
       
   187     event.iParentPosition = eventPos;
       
   188     TInt err = KErrNone;
       
   189     
       
   190     TRAP( err, dlg->HandlePointerEventL( event ) );
       
   191     
       
   192     CleanupStack::PopAndDestroy( dlg );
       
   193     return KErrNone;
       
   194     }
       
   195 
       
   196 // -----------------------------------------------------------------------------
       
   197 // CTestSDKQueries::TestMqdlgPreLayoutDynInitL
       
   198 // -----------------------------------------------------------------------------
       
   199 //
       
   200 TInt CTestSDKQueries::TestMqdlgPreLayoutDynInitL( CStifItemParser& /*aItem*/ )
       
   201     {
       
   202     TBuf< KBufSize > message( KTestString );
       
   203     CAknMessageQueryDialog* dlg = CAknMessageQueryDialog::NewL( message,
       
   204         CAknQueryDialog::EConfirmationTone );
       
   205     
       
   206     dlg->PrepareLC( R_MESSAGE_DIALOG );
       
   207     CTestCAknMessageQueryDialog* dlgProtected = static_cast<CTestCAknMessageQueryDialog*>( dlg );
       
   208     
       
   209     TInt err = KErrNone;
       
   210     TRAP( err, dlgProtected->PreLayoutDynInitL() );
       
   211     
       
   212     CleanupStack::PopAndDestroy( dlg );
       
   213     return err;
       
   214     }
       
   215 
       
   216 // -----------------------------------------------------------------------------
       
   217 // CTestSDKQueries::TestMqdlgSetSizeAndPositionL
       
   218 // -----------------------------------------------------------------------------
       
   219 //
       
   220 TInt CTestSDKQueries::TestMqdlgSetSizeAndPositionL( CStifItemParser& /*aItem*/ )
       
   221     {
       
   222     TBuf< KBufSize > message( KTestString );
       
   223     CAknMessageQueryDialog* dlg = CAknMessageQueryDialog::NewL( message,
       
   224         CAknQueryDialog::EConfirmationTone );
       
   225     
       
   226     dlg->PrepareLC( R_MESSAGE_DIALOG );
       
   227     CTestCAknMessageQueryDialog* dlgProtected = static_cast<CTestCAknMessageQueryDialog*>( dlg );
       
   228     
       
   229     dlgProtected->PreLayoutDynInitL();
       
   230     TSize size = iContainer->Rect().Size();
       
   231     dlgProtected->SetSizeAndPosition( size );
       
   232     
       
   233     CleanupStack::PopAndDestroy( dlg );
       
   234     return KErrNone;
       
   235     }
       
   236 
       
   237 // -----------------------------------------------------------------------------
       
   238 // CTestSDKQueries::TestMqdlgPostLayoutDynInitL
       
   239 // -----------------------------------------------------------------------------
       
   240 //
       
   241 TInt CTestSDKQueries::TestMqdlgPostLayoutDynInitL( CStifItemParser& /*aItem*/ )
       
   242     {
       
   243     TBuf< KBufSize > message( KTestString );
       
   244     CAknMessageQueryDialog* dlg = CAknMessageQueryDialog::NewL( message,
       
   245         CAknQueryDialog::EConfirmationTone );
       
   246     
       
   247     dlg->PrepareLC( R_MESSAGE_DIALOG );
       
   248     CTestCAknMessageQueryDialog* dlgProtected = static_cast<CTestCAknMessageQueryDialog*>( dlg );
       
   249     
       
   250     dlgProtected->PostLayoutDynInitL();
       
   251     
       
   252     CleanupStack::PopAndDestroy( dlg );
       
   253     return KErrNone;
       
   254     }
       
   255 
       
   256 // -----------------------------------------------------------------------------
       
   257 // CTestSDKQueries::TestMqdlgProcessCommandL
       
   258 // -----------------------------------------------------------------------------
       
   259 //
       
   260 TInt CTestSDKQueries::TestMqdlgProcessCommandL( CStifItemParser& /*aItem*/ )
       
   261     {
       
   262     TBuf< KBufSize > message( KTestString );
       
   263     CAknMessageQueryDialog* dlg = CAknMessageQueryDialog::NewL( message,
       
   264         CAknQueryDialog::EConfirmationTone );
       
   265     
       
   266     dlg->PrepareLC( R_MESSAGE_DIALOG );
       
   267     CTestCAknMessageQueryDialog* dlgProtected = static_cast<CTestCAknMessageQueryDialog*>( dlg );
       
   268     
       
   269     TInt commandId = EAknSoftkeyView;
       
   270     dlgProtected->ProcessCommandL( commandId );
       
   271     
       
   272     CleanupStack::PopAndDestroy( dlg );
       
   273     return KErrNone;
       
   274     }
       
   275 
       
   276 // -----------------------------------------------------------------------------
       
   277 // CTestSDKQueries::TestMqdlgConstructorTwoL
       
   278 // -----------------------------------------------------------------------------
       
   279 //
       
   280 TInt CTestSDKQueries::TestMqdlgConstructorTwoL( CStifItemParser& /*aItem*/ )
       
   281     {
       
   282     TBuf< KBufSize > message( KTestString );
       
   283     
       
   284     HBufC* buf = message.AllocL();
       
   285     CleanupStack::PushL( buf );
       
   286     HBufC* buffer = message.AllocL();
       
   287     CleanupStack::PushL( buffer );
       
   288     
       
   289     CAknMessageQueryDialog* dlg = new( ELeave ) CAknMessageQueryDialog( buf, buffer );
       
   290     CleanupStack::PushL( dlg );
       
   291     
       
   292     STIF_ASSERT_NOT_NULL( dlg );
       
   293     
       
   294     CleanupStack::PopAndDestroy( dlg );
       
   295     CleanupStack::Pop( KTwo );
       
   296     return KErrNone;
       
   297     }
       
   298 
       
   299 // -----------------------------------------------------------------------------
       
   300 // CTestSDKQueries::TestMqdlgConstructorThreeL
       
   301 // -----------------------------------------------------------------------------
       
   302 //
       
   303 TInt CTestSDKQueries::TestMqdlgConstructorThreeL( CStifItemParser& /*aItem*/ )
       
   304     {
       
   305     TBuf< KBufSize > message( KTestString );
       
   306     
       
   307     CEikImage* mImage = new( ELeave ) CEikImage;
       
   308     CleanupStack::PushL( mImage );
       
   309     
       
   310     CAknMessageQueryDialog* dlg = new( ELeave ) CAknMessageQueryDialog( &message, &message,
       
   311         mImage );
       
   312     CleanupStack::PushL( dlg );
       
   313     
       
   314     STIF_ASSERT_NOT_NULL( dlg );
       
   315     
       
   316     CleanupStack::Pop( dlg );
       
   317     CleanupStack::PopAndDestroy( mImage );
       
   318     return KErrNone;
       
   319     }
       
   320 
       
   321 // -----------------------------------------------------------------------------
       
   322 // CTestSDKQueries::TestMqdlgConstructorFourL
       
   323 // -----------------------------------------------------------------------------
       
   324 //
       
   325 TInt CTestSDKQueries::TestMqdlgConstructorFourL( CStifItemParser& /*aItem*/ )
       
   326     {
       
   327     TBuf< KBufSize > message( KTestString );
       
   328     
       
   329     HBufC* buf = message.AllocL();
       
   330     CleanupStack::PushL( buf );
       
   331     HBufC* buffer = message.AllocL();
       
   332     CleanupStack::PushL( buffer );
       
   333     
       
   334     CAknMessageQueryDialog* dlg = new( ELeave ) CAknMessageQueryDialog( buf, buffer, 
       
   335         CAknQueryDialog::EConfirmationTone );
       
   336     CleanupStack::PushL( dlg );
       
   337     
       
   338     STIF_ASSERT_NOT_NULL( dlg );
       
   339     
       
   340     CleanupStack::PopAndDestroy( dlg );
       
   341     CleanupStack::Pop( KTwo );
       
   342     return KErrNone;
       
   343     }
       
   344 
       
   345 // -----------------------------------------------------------------------------
       
   346 // CTestSDKQueries::TestMqdlgConstructorFiveL
       
   347 // -----------------------------------------------------------------------------
       
   348 //
       
   349 TInt CTestSDKQueries::TestMqdlgConstructorFiveL( CStifItemParser& /*aItem*/ )
       
   350     {
       
   351     TBuf< KBufSize > message( KTestString );
       
   352     
       
   353     HBufC* buf = message.AllocL();
       
   354     CleanupStack::PushL( buf );
       
   355     HBufC* buffer = message.AllocL();
       
   356     CleanupStack::PushL( buffer );
       
   357     
       
   358     CEikImage* mImage = new( ELeave ) CEikImage;
       
   359     CleanupStack::PushL( mImage );
       
   360     
       
   361     CAknMessageQueryDialog* dlg = new( ELeave ) CAknMessageQueryDialog( buf, buffer,
       
   362         mImage, CAknQueryDialog::EConfirmationTone );
       
   363     CleanupStack::PushL( dlg );
       
   364     
       
   365     STIF_ASSERT_NOT_NULL( dlg );
       
   366     
       
   367     CleanupStack::PopAndDestroy( dlg );
       
   368     CleanupStack::Pop( KThree );
       
   369     return KErrNone;
       
   370     }
       
   371 
       
   372 // -----------------------------------------------------------------------------
       
   373 // CTestSDKQueries::TestMqdlgSetMessageTextTwoL
       
   374 // -----------------------------------------------------------------------------
       
   375 //
       
   376 TInt CTestSDKQueries::TestMqdlgSetMessageTextTwoL( CStifItemParser& /*aItem*/ )
       
   377     {
       
   378     TBuf< KBufSize > message( KTestString );
       
   379     CAknMessageQueryDialog* dlg = CAknMessageQueryDialog::NewL( message,
       
   380         CAknQueryDialog::EConfirmationTone );
       
   381     
       
   382     dlg->PrepareLC( R_MESSAGE_DIALOG );
       
   383     
       
   384     dlg->SetMessageText( &message );
       
   385     
       
   386     CleanupStack::Pop( dlg );
       
   387     return KErrNone;
       
   388     }
       
   389 
       
   390 // -----------------------------------------------------------------------------
       
   391 // CTestSDKQueries::TestMqdlgSetMessageTextThreeL
       
   392 // -----------------------------------------------------------------------------
       
   393 //
       
   394 TInt CTestSDKQueries::TestMqdlgSetMessageTextThreeL( CStifItemParser& /*aItem*/ )
       
   395     {
       
   396     TBuf16< KBufSize > msg( KTestString );
       
   397     const TBuf16< KBufSize > message( KTestString );
       
   398     CAknMessageQueryDialog* dlg = CAknMessageQueryDialog::NewL( msg,
       
   399         CAknQueryDialog::EConfirmationTone );
       
   400     
       
   401     dlg->PrepareLC( R_MESSAGE_DIALOG );
       
   402     
       
   403     dlg->SetMessageText( message );
       
   404     
       
   405     CleanupStack::PopAndDestroy( dlg );
       
   406     return KErrNone;
       
   407     }
       
   408 
       
   409 // -----------------------------------------------------------------------------
       
   410 // CTestSDKQueries::TestMqdlgSetHeaderTextTwoL
       
   411 // -----------------------------------------------------------------------------
       
   412 //
       
   413 TInt CTestSDKQueries::TestMqdlgSetHeaderTextTwoL( CStifItemParser& /*aItem*/ )
       
   414     {
       
   415     TBuf< KBufSize > message( KTestString );
       
   416     HBufC* buffer = message.AllocL();
       
   417     CleanupStack::PushL( buffer );
       
   418     CAknMessageQueryDialog* dlg = CAknMessageQueryDialog::NewL( *buffer,
       
   419         CAknQueryDialog::EConfirmationTone );
       
   420     
       
   421     dlg->PrepareLC( R_MESSAGE_DIALOG );
       
   422     
       
   423     dlg->SetHeaderText( &message );
       
   424     
       
   425     CleanupStack::Pop( dlg );
       
   426     CleanupStack::PopAndDestroy( buffer );
       
   427     return KErrNone;
       
   428     }
       
   429 
       
   430 // -----------------------------------------------------------------------------
       
   431 // CTestSDKQueries::TestMqdlgSetHeaderTextThreeL
       
   432 // -----------------------------------------------------------------------------
       
   433 //
       
   434 TInt CTestSDKQueries::TestMqdlgSetHeaderTextThreeL( CStifItemParser& /*aItem*/ )
       
   435     {
       
   436     TBuf< KBufSize > message( KTestString );
       
   437     const TBuf< KBufSize > msg( KTestString );
       
   438     CAknMessageQueryDialog* dlg = CAknMessageQueryDialog::NewL( message,
       
   439         CAknQueryDialog::EConfirmationTone );
       
   440     
       
   441     dlg->PrepareLC( R_MESSAGE_DIALOG );
       
   442     
       
   443     dlg->SetHeaderText( msg );
       
   444     
       
   445     CleanupStack::PopAndDestroy( dlg );
       
   446     return KErrNone;
       
   447     }
       
   448 
       
   449 // -----------------------------------------------------------------------------
       
   450 // CTestSDKQueries::TestMqcConstructFromResourceL
       
   451 // -----------------------------------------------------------------------------
       
   452 //
       
   453 TInt CTestSDKQueries::TestMqdlgConstructorSixL( CStifItemParser& /*aItem*/ )
       
   454     {
       
   455     CAknMessageQueryDialog* dlg = new( ELeave ) CAknMessageQueryDialog;
       
   456     CleanupStack::PushL( dlg );
       
   457     STIF_ASSERT_NOT_NULL( dlg );
       
   458     CleanupStack::PopAndDestroy( dlg );
       
   459     return KErrNone;
       
   460     }
       
   461 
       
   462 //End file
       
   463 
       
   464