|
1 // Copyright (c) 2007-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 "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 // |
|
15 |
|
16 #include "tealarmtestgetalarmdatastep.h" |
|
17 |
|
18 |
|
19 CTEAlarmTestGetAlarmDataStep::CTEAlarmTestGetAlarmDataStep() |
|
20 { |
|
21 SetTestStepName(KTEAlarmTestGetAlarmDataStep); |
|
22 } |
|
23 |
|
24 |
|
25 CTEAlarmTestGetAlarmDataStep::~CTEAlarmTestGetAlarmDataStep() |
|
26 { |
|
27 } |
|
28 |
|
29 |
|
30 TVerdict CTEAlarmTestGetAlarmDataStep::doTestStepL() |
|
31 { |
|
32 __UHEAP_MARK; |
|
33 |
|
34 _LIT8(KSomeAlarmData, "This is some 8-bit data"); |
|
35 const TInt KWaitAlarmTime = 10; // time delay for the test alarm |
|
36 |
|
37 TASShdAlarm alarm; |
|
38 alarm.Message() = _L("Alarm with data"); |
|
39 TTime alarmTime; |
|
40 alarmTime.HomeTime(); |
|
41 alarmTime += TTimeIntervalSeconds(KWaitAlarmTime); |
|
42 |
|
43 alarm.NextDueTime() = alarmTime; |
|
44 |
|
45 TInt err = iSession.AlarmAdd(alarm, KSomeAlarmData); |
|
46 TEST(err == KErrNone); |
|
47 |
|
48 // Test no memory case |
|
49 __UHEAP_FAILNEXT(1); |
|
50 HBufC8* buff = NULL; |
|
51 err = iSession.GetAlarmData(alarm.Id(), buff); |
|
52 TEST(err == KErrNoMemory); |
|
53 __UHEAP_RESET; |
|
54 |
|
55 // Test normal case that the retrieved data is the same |
|
56 err = iSession.GetAlarmData(alarm.Id(), buff); |
|
57 TEST(err == KErrNone); |
|
58 TEST(0 == buff->Compare(KSomeAlarmData)); |
|
59 |
|
60 // now do cleanup, i.e. delete added alarm and buff |
|
61 delete buff; |
|
62 iSession.AlarmDelete(alarm.Id()); |
|
63 |
|
64 __UHEAP_MARKEND; |
|
65 |
|
66 return TestStepResult(); |
|
67 } |