kerneltest/e32test/locale/t_msgtxt.cpp
changeset 271 dc268b18d709
parent 0 a41df078684a
equal deleted inserted replaced
269:d57b86b1867a 271:dc268b18d709
     1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 1997-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     3 // This component and the accompanying materials are made available
     4 // under the terms of the License "Eclipse Public License v1.0"
     4 // under the terms of the License "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
    20 #include <e32svr.h>
    20 #include <e32svr.h>
    21 
    21 
    22 LOCAL_D	TBuf<KMaxLocaleMessageText>* localeBufs[ELocaleMessages_LastMsg];
    22 LOCAL_D	TBuf<KMaxLocaleMessageText>* localeBufs[ELocaleMessages_LastMsg];
    23 
    23 
    24 RTest test(_L("T_MSGTXT"));
    24 RTest test(_L("T_MSGTXT"));
       
    25 	
       
    26 const TUint KTimeOut=5000000; // 5 seconds timeout for the notifier
    25 
    27 
    26 LOCAL_C void DisplayMessages()
    28 LOCAL_C void DisplayMessages()
    27 //
    29 //
    28 // Display the locale messages
    30 // Display the locale messages
    29 //
    31 //
    30 	{
    32 	{
    31 
       
    32 	RNotifier notifier;
    33 	RNotifier notifier;
    33 	TInt r=notifier.Connect();
    34 	TInt r=notifier.Connect();
    34 	test(r==KErrNone);
    35 	test(r==KErrNone);
    35 	TRequestStatus status;
    36 	TRequestStatus status;
       
    37 	TRequestStatus timerStatus;
    36 	TInt buttonVal=0;
    38 	TInt buttonVal=0;
       
    39 	RTimer timer;
       
    40 	timer.CreateLocal();
    37 
    41 
    38 	test.Next(_L("Test File Server Error Dialogs"));
    42 	test.Next(_L("Test File Server Error Dialogs"));
    39 	TLocaleMessageText msgTxt;
    43 	TLocaleMessageText msgTxt;
    40 	msgTxt.Set(EFileServer_Button1);
    44 	msgTxt.Set(EFileServer_Button1);
    41 	TBuf<KMaxLocaleMessageText> button1(msgTxt);
    45 	TBuf<KMaxLocaleMessageText> button1(msgTxt);
    42 	msgTxt.Set(EFileServer_Button2);
    46 	msgTxt.Set(EFileServer_Button2);
    43 	TBuf<KMaxLocaleMessageText> button2(msgTxt);
    47 	TBuf<KMaxLocaleMessageText> button2(msgTxt);
    44 
    48 
    45 	test.Next(_L("DIALOG1: Displayed if a disk is removed during a write"));
    49 	test.Next(_L("DIALOG1: Displayed if a disk is removed during a write (will timeout in 5 seconds)"));
    46 	User::After(300000);
       
    47 	test.Printf(_L("***Press SHIFT+R or SHIFT+S to confim dialogue***\n"));
       
    48 	TInt count=2;
    50 	TInt count=2;
    49 	msgTxt.Set((TLocaleMessage)count++);
    51 	msgTxt.Set((TLocaleMessage)count++);
    50 	TBuf<KMaxLocaleMessageText> line1=msgTxt;
    52 	TBuf<KMaxLocaleMessageText> line1=msgTxt;
    51 	msgTxt.Set((TLocaleMessage)count++);
    53 	msgTxt.Set((TLocaleMessage)count++);
    52 	TBuf<KMaxLocaleMessageText> line2=msgTxt;
    54 	TBuf<KMaxLocaleMessageText> line2=msgTxt;
    53 	notifier.Notify(line1,line2,button1,button2,buttonVal,status);
    55 	notifier.Notify(line1,line2,button1,button2,buttonVal,status);
    54 	User::WaitForRequest(status);
    56 	timer.After(timerStatus,KTimeOut);
    55 	User::After(300000);
    57 	User::WaitForRequest(status,timerStatus);
    56 
    58 	if (status==KRequestPending)
    57 	test.Next(_L("DIALOG2: Write failed due to low power"));
    59 		{
    58 	User::After(300000);
    60 		test.Printf(_L("Timeout in waiting for keypress, continuing\n"));
       
    61 		// make the notifier to disappear
       
    62 		TRawEvent eventDown;
       
    63 		eventDown.Set(TRawEvent::EKeyDown,EStdKeyEnter);
       
    64 		TRawEvent eventUp;
       
    65 		eventUp.Set(TRawEvent::EKeyUp,EStdKeyEnter);
       
    66 		UserSvr::AddEvent(eventDown);
       
    67 		UserSvr::AddEvent(eventUp);
       
    68 		}
       
    69 	else
       
    70 		{
       
    71 		timer.Cancel();
       
    72 		}
       
    73 
       
    74 	test.Next(_L("DIALOG2: Write failed due to low power (will timeout in 5 seconds)"));
    59 	msgTxt.Set((TLocaleMessage)count++);
    75 	msgTxt.Set((TLocaleMessage)count++);
    60 	line1=msgTxt;
    76 	line1=msgTxt;
    61 	msgTxt.Set((TLocaleMessage)count++);
    77 	msgTxt.Set((TLocaleMessage)count++);
    62 	line2=msgTxt;
    78 	line2=msgTxt;
    63 	notifier.Notify(line1,line2,button1,button2,buttonVal,status);
    79 	notifier.Notify(line1,line2,button1,button2,buttonVal,status);
    64 	User::WaitForRequest(status);
    80 	timer.After(timerStatus,KTimeOut);
    65 	User::After(300000);
    81 	User::WaitForRequest(status,timerStatus);
    66 
    82 	if (status==KRequestPending)
    67 	test.Next(_L("DIALOG3: General error message - disk write failed"));
    83 		{
    68 	User::After(300000);
    84 		test.Printf(_L("Timeout in waiting for keypress, continuing\n"));
       
    85 		// make the notifier to disappear
       
    86 		TRawEvent eventDown;
       
    87 		eventDown.Set(TRawEvent::EKeyDown,EStdKeyEnter);
       
    88 		TRawEvent eventUp;
       
    89 		eventUp.Set(TRawEvent::EKeyUp,EStdKeyEnter);
       
    90 		UserSvr::AddEvent(eventDown);
       
    91 		UserSvr::AddEvent(eventUp);
       
    92 		}
       
    93 	else
       
    94 		{
       
    95 		timer.Cancel();
       
    96 		}
       
    97 
       
    98 	test.Next(_L("DIALOG3: General error message - disk write failed (will timeout in 5 seconds)"));
    69 	msgTxt.Set((TLocaleMessage)count++);
    99 	msgTxt.Set((TLocaleMessage)count++);
    70 	line1=msgTxt;
   100 	line1=msgTxt;
    71 	msgTxt.Set((TLocaleMessage)count++);
   101 	msgTxt.Set((TLocaleMessage)count++);
    72 	line2=msgTxt;
   102 	line2=msgTxt;
    73 	notifier.Notify(line1,line2,button1,button2,buttonVal,status);
   103 	notifier.Notify(line1,line2,button1,button2,buttonVal,status);
    74 	User::WaitForRequest(status);
   104 	timer.After(timerStatus,KTimeOut);
    75 	User::After(300000);
   105 	User::WaitForRequest(status,timerStatus);
       
   106 	if (status==KRequestPending)
       
   107 		{
       
   108 		test.Printf(_L("Timeout in waiting for keypress, continuing\n"));
       
   109 		// make the notifier to disappear
       
   110 		TRawEvent eventDown;
       
   111 		eventDown.Set(TRawEvent::EKeyDown,EStdKeyEnter);
       
   112 		TRawEvent eventUp;
       
   113 		eventUp.Set(TRawEvent::EKeyUp,EStdKeyEnter);
       
   114 		UserSvr::AddEvent(eventDown);
       
   115 		UserSvr::AddEvent(eventUp);
       
   116 		}
       
   117 	else
       
   118 		{
       
   119 		timer.Cancel();
       
   120 		}
       
   121 
       
   122 	timer.Close();
    76 	test.Printf(_L("***End***\n\n"));
   123 	test.Printf(_L("***End***\n\n"));
    77 
   124 
    78 	msgTxt.Set((TLocaleMessage)count++);
   125 	msgTxt.Set((TLocaleMessage)count++);
    79 	test.Printf(_L("ALARMNAME: 'Chimes' - %S\n"),&msgTxt);
   126 	test.Printf(_L("ALARMNAME: 'Chimes' - %S\n"),&msgTxt);
    80 	msgTxt.Set((TLocaleMessage)count++);
   127 	msgTxt.Set((TLocaleMessage)count++);
    81 	test.Printf(_L("ALARMNAME: 'Rings' - %S\n"),&msgTxt);
   128 	test.Printf(_L("ALARMNAME: 'Rings' - %S\n"),&msgTxt);
    82 	msgTxt.Set((TLocaleMessage)count++);
   129 	msgTxt.Set((TLocaleMessage)count++);
    83 	test.Printf(_L("ALARMNAME: 'Signal' - %S\n"),&msgTxt);
   130 	test.Printf(_L("ALARMNAME: 'Signal' - %S\n"),&msgTxt);
    84 	test.Printf(_L("***Press any key***\n\n"));
       
    85 	test.Getch();
       
    86 
   131 
    87 	msgTxt.Set((TLocaleMessage)count++);
   132 	msgTxt.Set((TLocaleMessage)count++);
    88 	test.Printf(_L("DISKNAME: 'Internal' - %S\n"),&msgTxt);
   133 	test.Printf(_L("DISKNAME: 'Internal' - %S\n"),&msgTxt);
    89 	msgTxt.Set((TLocaleMessage)count++);
   134 	msgTxt.Set((TLocaleMessage)count++);
    90 	test.Printf(_L("DISKNAME: 'External1' - %S\n"),&msgTxt);
   135 	test.Printf(_L("DISKNAME: 'External1' - %S\n"),&msgTxt);
   100 	test.Printf(_L("DISKNAME: 'External6' - %S\n"),&msgTxt);
   145 	test.Printf(_L("DISKNAME: 'External6' - %S\n"),&msgTxt);
   101 	msgTxt.Set((TLocaleMessage)count++);
   146 	msgTxt.Set((TLocaleMessage)count++);
   102 	test.Printf(_L("DISKNAME: 'External7' - %S\n"),&msgTxt);
   147 	test.Printf(_L("DISKNAME: 'External7' - %S\n"),&msgTxt);
   103 	msgTxt.Set((TLocaleMessage)count++);
   148 	msgTxt.Set((TLocaleMessage)count++);
   104 	test.Printf(_L("DISKNAME: 'External8' - %S\n"),&msgTxt);
   149 	test.Printf(_L("DISKNAME: 'External8' - %S\n"),&msgTxt);
   105 	test.Printf(_L("***Press any key***\n\n"));
       
   106 	test.Getch();
       
   107 	
   150 	
   108 	msgTxt.Set((TLocaleMessage)count++);
   151 	msgTxt.Set((TLocaleMessage)count++);
   109 	test.Printf(_L("SOCKETNAME0: - %S\n"),&msgTxt);
   152 	test.Printf(_L("SOCKETNAME0: - %S\n"),&msgTxt);
   110 	msgTxt.Set((TLocaleMessage)count++);
   153 	msgTxt.Set((TLocaleMessage)count++);
   111 	test.Printf(_L("SOCKETNAME1: - %S\n"),&msgTxt);
   154 	test.Printf(_L("SOCKETNAME1: - %S\n"),&msgTxt);
   121 // Main
   164 // Main
   122 //
   165 //
   123 	{
   166 	{
   124 
   167 
   125 	test.Title();
   168 	test.Title();
   126 //	TBuf<KMaxLocaleMessageText>* localeBufs[ELocaleMessages_LastMsg];    {Too big for local decleration}
       
   127 																	   															
       
   128 	test.Start(_L("Constructor"));
   169 	test.Start(_L("Constructor"));
       
   170 
   129 	TLocaleMessageText msgTxt;
   171 	TLocaleMessageText msgTxt;
   130 	msgTxt.Set((TLocaleMessage)4);
   172 	msgTxt.Set((TLocaleMessage)4);
   131 	TInt count=0;
   173 	TInt count=0;
   132 	for (count=0;count<ELocaleMessages_LastMsg;count++)
   174 	for (count=0;count<ELocaleMessages_LastMsg;count++)
   133 		{
   175 		{