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 "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 |
// Started by BLB, November 1996
|
sl@0
|
15 |
// test code for CEnvironmentChangeNotifier
|
sl@0
|
16 |
//
|
sl@0
|
17 |
//
|
sl@0
|
18 |
|
sl@0
|
19 |
#include <bacntf.h>
|
sl@0
|
20 |
#include <e32test.h>
|
sl@0
|
21 |
|
sl@0
|
22 |
LOCAL_D RTest test(_L("T_CNTF"));
|
sl@0
|
23 |
|
sl@0
|
24 |
TInt TheStatus=0;
|
sl@0
|
25 |
TBool WasCalled=EFalse;
|
sl@0
|
26 |
CEnvironmentChangeNotifier* TheNotifier=NULL;
|
sl@0
|
27 |
|
sl@0
|
28 |
GLDEF_C TInt MyCallback(TAny*)
|
sl@0
|
29 |
{
|
sl@0
|
30 |
TInt stat=TheNotifier->Change()&~(EChangesPowerStatus|EChangesThreadDeath);
|
sl@0
|
31 |
if (stat)
|
sl@0
|
32 |
{ // ignore just changes in power status etc
|
sl@0
|
33 |
WasCalled=ETrue;
|
sl@0
|
34 |
TheStatus=stat;
|
sl@0
|
35 |
CActiveScheduler::Stop();
|
sl@0
|
36 |
}
|
sl@0
|
37 |
return(KErrNone);
|
sl@0
|
38 |
}
|
sl@0
|
39 |
|
sl@0
|
40 |
/**
|
sl@0
|
41 |
@SYMTestCaseID SYSLIB-BAFL-CT-0406
|
sl@0
|
42 |
@SYMTestCaseDesc TLocale class functionality test
|
sl@0
|
43 |
@SYMTestPriority Medium
|
sl@0
|
44 |
@SYMTestActions Tests for environment setting changes.
|
sl@0
|
45 |
@SYMTestExpectedResults Tests must not fail
|
sl@0
|
46 |
@SYMREQ REQ0000
|
sl@0
|
47 |
*/
|
sl@0
|
48 |
LOCAL_C void testLocale()
|
sl@0
|
49 |
{
|
sl@0
|
50 |
test.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-0406 Changing locale "));
|
sl@0
|
51 |
TLocale locale;
|
sl@0
|
52 |
test(!WasCalled);
|
sl@0
|
53 |
locale.SetCountryCode(locale.CountryCode()+1);
|
sl@0
|
54 |
locale.Set();
|
sl@0
|
55 |
CActiveScheduler::Start();
|
sl@0
|
56 |
test(WasCalled);
|
sl@0
|
57 |
test(TheStatus&EChangesLocale);
|
sl@0
|
58 |
test((TheStatus&EChangesMidnightCrossover)==0);
|
sl@0
|
59 |
WasCalled=EFalse;
|
sl@0
|
60 |
TheStatus=0;
|
sl@0
|
61 |
}
|
sl@0
|
62 |
|
sl@0
|
63 |
/**
|
sl@0
|
64 |
@SYMTestCaseID SYSLIB-BAFL-CT-0407
|
sl@0
|
65 |
@SYMTestCaseDesc Tests for Locale changes
|
sl@0
|
66 |
@SYMTestPriority Medium
|
sl@0
|
67 |
@SYMTestActions Tests for change in systems time.
|
sl@0
|
68 |
@SYMTestExpectedResults Tests must not fail
|
sl@0
|
69 |
@SYMREQ REQ0000
|
sl@0
|
70 |
*/
|
sl@0
|
71 |
LOCAL_C void testMidnight()
|
sl@0
|
72 |
{
|
sl@0
|
73 |
test.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-0407 Midnight crossover "));
|
sl@0
|
74 |
TTime timeNow;
|
sl@0
|
75 |
timeNow.HomeTime();
|
sl@0
|
76 |
TDateTime dateTime=timeNow.DateTime();
|
sl@0
|
77 |
dateTime.SetHour(23);
|
sl@0
|
78 |
dateTime.SetSecond(58);
|
sl@0
|
79 |
dateTime.SetMinute(59);
|
sl@0
|
80 |
timeNow=dateTime;
|
sl@0
|
81 |
User::SetHomeTime(timeNow);
|
sl@0
|
82 |
test(!WasCalled);
|
sl@0
|
83 |
CActiveScheduler::Start();
|
sl@0
|
84 |
test(WasCalled);
|
sl@0
|
85 |
test(TheStatus&EChangesSystemTime);
|
sl@0
|
86 |
test((TheStatus&EChangesLocale)==0);
|
sl@0
|
87 |
if ((TheStatus&EChangesMidnightCrossover)==0)
|
sl@0
|
88 |
{
|
sl@0
|
89 |
WasCalled=EFalse;
|
sl@0
|
90 |
TheStatus=0;
|
sl@0
|
91 |
CActiveScheduler::Start();
|
sl@0
|
92 |
test(WasCalled);
|
sl@0
|
93 |
test(TheStatus&EChangesMidnightCrossover);
|
sl@0
|
94 |
test((TheStatus&EChangesLocale)==0);
|
sl@0
|
95 |
}
|
sl@0
|
96 |
WasCalled=EFalse;
|
sl@0
|
97 |
TheStatus=0;
|
sl@0
|
98 |
}
|
sl@0
|
99 |
|
sl@0
|
100 |
// Following testLocale re-set the country code value back to the default
|
sl@0
|
101 |
// so that any more tests added in future will be starting from the OS default state
|
sl@0
|
102 |
LOCAL_C void resetLocale()
|
sl@0
|
103 |
{
|
sl@0
|
104 |
test.Next(_L("Resetting locale before next test"));
|
sl@0
|
105 |
TLocale locale;
|
sl@0
|
106 |
test(!WasCalled);
|
sl@0
|
107 |
locale.SetCountryCode(locale.CountryCode()-1);
|
sl@0
|
108 |
locale.Set();
|
sl@0
|
109 |
CActiveScheduler::Start();
|
sl@0
|
110 |
test(WasCalled);
|
sl@0
|
111 |
test(TheStatus&EChangesLocale);
|
sl@0
|
112 |
WasCalled=EFalse;
|
sl@0
|
113 |
TheStatus=0;
|
sl@0
|
114 |
}
|
sl@0
|
115 |
|
sl@0
|
116 |
GLDEF_C TInt E32Main()
|
sl@0
|
117 |
{
|
sl@0
|
118 |
__UHEAP_MARK;
|
sl@0
|
119 |
CTrapCleanup* cleanup=CTrapCleanup::New();
|
sl@0
|
120 |
CActiveScheduler* shed=new(ELeave) CActiveScheduler;
|
sl@0
|
121 |
CActiveScheduler::Install(shed);
|
sl@0
|
122 |
test.Title();
|
sl@0
|
123 |
test.Start(_L("Testing change notifier "));
|
sl@0
|
124 |
TCallBack callback(MyCallback);
|
sl@0
|
125 |
TheNotifier=CEnvironmentChangeNotifier::NewL(0,callback);
|
sl@0
|
126 |
TheNotifier->Start();
|
sl@0
|
127 |
|
sl@0
|
128 |
// Check notifier is working
|
sl@0
|
129 |
CActiveScheduler::Start();
|
sl@0
|
130 |
test(WasCalled);
|
sl@0
|
131 |
test(TheStatus!=0);
|
sl@0
|
132 |
WasCalled=EFalse;
|
sl@0
|
133 |
TheStatus=0;
|
sl@0
|
134 |
|
sl@0
|
135 |
// Test - change country code
|
sl@0
|
136 |
testLocale();
|
sl@0
|
137 |
|
sl@0
|
138 |
// Test - check midnight rollover
|
sl@0
|
139 |
testMidnight();
|
sl@0
|
140 |
|
sl@0
|
141 |
// Reset country code to default state
|
sl@0
|
142 |
resetLocale();
|
sl@0
|
143 |
|
sl@0
|
144 |
TheNotifier->Cancel();
|
sl@0
|
145 |
delete(CActiveScheduler::Current());
|
sl@0
|
146 |
delete(TheNotifier);
|
sl@0
|
147 |
test.End();
|
sl@0
|
148 |
test.Close();
|
sl@0
|
149 |
delete cleanup;
|
sl@0
|
150 |
__UHEAP_MARKEND;
|
sl@0
|
151 |
return(KErrNone);
|
sl@0
|
152 |
}
|