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