kerneltest/e32test/locale/t_msgtxt.cpp
changeset 0 a41df078684a
equal deleted inserted replaced
-1:000000000000 0:a41df078684a
       
     1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of the License "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // e32test\locale\t_msgtxt.cpp
       
    15 // Tests the TLocaleMessageText class
       
    16 // 
       
    17 //
       
    18 
       
    19 #include <e32test.h>
       
    20 #include <e32svr.h>
       
    21 
       
    22 LOCAL_D	TBuf<KMaxLocaleMessageText>* localeBufs[ELocaleMessages_LastMsg];
       
    23 
       
    24 RTest test(_L("T_MSGTXT"));
       
    25 
       
    26 LOCAL_C void DisplayMessages()
       
    27 //
       
    28 // Display the locale messages
       
    29 //
       
    30 	{
       
    31 
       
    32 	RNotifier notifier;
       
    33 	TInt r=notifier.Connect();
       
    34 	test(r==KErrNone);
       
    35 	TRequestStatus status;
       
    36 	TInt buttonVal=0;
       
    37 
       
    38 	test.Next(_L("Test File Server Error Dialogs"));
       
    39 	TLocaleMessageText msgTxt;
       
    40 	msgTxt.Set(EFileServer_Button1);
       
    41 	TBuf<KMaxLocaleMessageText> button1(msgTxt);
       
    42 	msgTxt.Set(EFileServer_Button2);
       
    43 	TBuf<KMaxLocaleMessageText> button2(msgTxt);
       
    44 
       
    45 	test.Next(_L("DIALOG1: Displayed if a disk is removed during a write"));
       
    46 	User::After(300000);
       
    47 	test.Printf(_L("***Press SHIFT+R or SHIFT+S to confim dialogue***\n"));
       
    48 	TInt count=2;
       
    49 	msgTxt.Set((TLocaleMessage)count++);
       
    50 	TBuf<KMaxLocaleMessageText> line1=msgTxt;
       
    51 	msgTxt.Set((TLocaleMessage)count++);
       
    52 	TBuf<KMaxLocaleMessageText> line2=msgTxt;
       
    53 	notifier.Notify(line1,line2,button1,button2,buttonVal,status);
       
    54 	User::WaitForRequest(status);
       
    55 	User::After(300000);
       
    56 
       
    57 	test.Next(_L("DIALOG2: Write failed due to low power"));
       
    58 	User::After(300000);
       
    59 	msgTxt.Set((TLocaleMessage)count++);
       
    60 	line1=msgTxt;
       
    61 	msgTxt.Set((TLocaleMessage)count++);
       
    62 	line2=msgTxt;
       
    63 	notifier.Notify(line1,line2,button1,button2,buttonVal,status);
       
    64 	User::WaitForRequest(status);
       
    65 	User::After(300000);
       
    66 
       
    67 	test.Next(_L("DIALOG3: General error message - disk write failed"));
       
    68 	User::After(300000);
       
    69 	msgTxt.Set((TLocaleMessage)count++);
       
    70 	line1=msgTxt;
       
    71 	msgTxt.Set((TLocaleMessage)count++);
       
    72 	line2=msgTxt;
       
    73 	notifier.Notify(line1,line2,button1,button2,buttonVal,status);
       
    74 	User::WaitForRequest(status);
       
    75 	User::After(300000);
       
    76 	test.Printf(_L("***End***\n\n"));
       
    77 
       
    78 	msgTxt.Set((TLocaleMessage)count++);
       
    79 	test.Printf(_L("ALARMNAME: 'Chimes' - %S\n"),&msgTxt);
       
    80 	msgTxt.Set((TLocaleMessage)count++);
       
    81 	test.Printf(_L("ALARMNAME: 'Rings' - %S\n"),&msgTxt);
       
    82 	msgTxt.Set((TLocaleMessage)count++);
       
    83 	test.Printf(_L("ALARMNAME: 'Signal' - %S\n"),&msgTxt);
       
    84 	test.Printf(_L("***Press any key***\n\n"));
       
    85 	test.Getch();
       
    86 
       
    87 	msgTxt.Set((TLocaleMessage)count++);
       
    88 	test.Printf(_L("DISKNAME: 'Internal' - %S\n"),&msgTxt);
       
    89 	msgTxt.Set((TLocaleMessage)count++);
       
    90 	test.Printf(_L("DISKNAME: 'External1' - %S\n"),&msgTxt);
       
    91 	msgTxt.Set((TLocaleMessage)count++);
       
    92 	test.Printf(_L("DISKNAME: 'External2' - %S\n"),&msgTxt);
       
    93 	msgTxt.Set((TLocaleMessage)count++);
       
    94 	test.Printf(_L("DISKNAME: 'External3' - %S\n"),&msgTxt);
       
    95 	msgTxt.Set((TLocaleMessage)count++);
       
    96 	test.Printf(_L("DISKNAME: 'External4' - %S\n"),&msgTxt);
       
    97 	msgTxt.Set((TLocaleMessage)count++);
       
    98 	test.Printf(_L("DISKNAME: 'External5' - %S\n"),&msgTxt);
       
    99 	msgTxt.Set((TLocaleMessage)count++);
       
   100 	test.Printf(_L("DISKNAME: 'External6' - %S\n"),&msgTxt);
       
   101 	msgTxt.Set((TLocaleMessage)count++);
       
   102 	test.Printf(_L("DISKNAME: 'External7' - %S\n"),&msgTxt);
       
   103 	msgTxt.Set((TLocaleMessage)count++);
       
   104 	test.Printf(_L("DISKNAME: 'External8' - %S\n"),&msgTxt);
       
   105 	test.Printf(_L("***Press any key***\n\n"));
       
   106 	test.Getch();
       
   107 	
       
   108 	msgTxt.Set((TLocaleMessage)count++);
       
   109 	test.Printf(_L("SOCKETNAME0: - %S\n"),&msgTxt);
       
   110 	msgTxt.Set((TLocaleMessage)count++);
       
   111 	test.Printf(_L("SOCKETNAME1: - %S\n"),&msgTxt);
       
   112 	msgTxt.Set((TLocaleMessage)count++);
       
   113 	test.Printf(_L("SOCKETNAME2: - %S\n"),&msgTxt);
       
   114 	msgTxt.Set((TLocaleMessage)count++);
       
   115 	test.Printf(_L("SOCKETNAME3: - %S\n"),&msgTxt);
       
   116 	notifier.Close();
       
   117 	}
       
   118 
       
   119 TInt E32Main()
       
   120 //
       
   121 // Main
       
   122 //
       
   123 	{
       
   124 
       
   125 	test.Title();
       
   126 //	TBuf<KMaxLocaleMessageText>* localeBufs[ELocaleMessages_LastMsg];    {Too big for local decleration}
       
   127 																	   															
       
   128 	test.Start(_L("Constructor"));
       
   129 	TLocaleMessageText msgTxt;
       
   130 	msgTxt.Set((TLocaleMessage)4);
       
   131 	TInt count=0;
       
   132 	for (count=0;count<ELocaleMessages_LastMsg;count++)
       
   133 		{
       
   134 		TLocaleMessageText msgTxt((TLocaleMessage)count);
       
   135 		test.Printf(_L("Message %d = \"%S\"\n"),count,&msgTxt);
       
   136 		localeBufs[count]=new TBuf<KMaxLocaleMessageText>(msgTxt);
       
   137 		test(localeBufs[count]!=NULL);
       
   138 		}
       
   139 
       
   140 	test.Next(_L("Set"));
       
   141 	for (count=0;count<ELocaleMessages_LastMsg;count++)
       
   142 		{
       
   143 		TLocaleMessageText msgTxt((TLocaleMessage)count);
       
   144 		test((*localeBufs[count])==msgTxt);
       
   145 		}
       
   146 
       
   147 	for (count=0;count<ELocaleMessages_LastMsg;count++)
       
   148 		{
       
   149 		delete localeBufs[count];
       
   150 		}
       
   151 
       
   152 	test.Next(_L("Illegal values"));
       
   153 	TLocaleMessageText error((TLocaleMessage)0x1000000);
       
   154 	test(error.Length()==0);
       
   155 	error.SetLength(20);
       
   156 	error.Set((TLocaleMessage)0x1000000);
       
   157 	test(error.Length()==0);
       
   158 	TLocaleMessageText lastMsg(ELocaleMessages_LastMsg);
       
   159 	test(lastMsg.Length()==0);
       
   160 	lastMsg.SetLength(20);
       
   161 	lastMsg.Set(ELocaleMessages_LastMsg);
       
   162 	test(lastMsg.Length()==0);
       
   163 
       
   164 	DisplayMessages();
       
   165 
       
   166 	test.End();
       
   167 	return KErrNone;
       
   168 	}