|
1 // Copyright (c) 1998-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 // T_ImapIoProgress.CPP |
|
15 // |
|
16 // |
|
17 |
|
18 #include <e32test.h> |
|
19 #include <e32base.h> |
|
20 #include "impspan.h" |
|
21 #include "imapio.h" |
|
22 #include "emailtestutils.h" |
|
23 |
|
24 //---------------------------------------------------------------------------------------- |
|
25 |
|
26 LOCAL_D RTest test(_L("T_ImapIO Test Harness")); |
|
27 TInt testNum = 1; |
|
28 LOCAL_D CTrapCleanup* theCleanup; |
|
29 LOCAL_D RFs theFs; |
|
30 LOCAL_C CActiveScheduler* theScheduler; |
|
31 CEmailTestUtils* testUtils; |
|
32 TMsvId serviceId; |
|
33 |
|
34 GLDEF_C void gPanic( TImpsPanic aReason) |
|
35 { |
|
36 User::Panic(_L("T_ImapIO") ,aReason); |
|
37 } |
|
38 |
|
39 //---------------------------------------------------------------------------------------- |
|
40 LOCAL_C void testImapIOProgress() |
|
41 //---------------------------------------------------------------------------------------- |
|
42 { |
|
43 CImapIO* imapIO = CImapIO::NewL(0); |
|
44 CleanupStack::PushL(imapIO); |
|
45 |
|
46 testUtils->TestStart(testNum, _L("Test Progress With Disconnect")); |
|
47 |
|
48 TRequestStatus status; |
|
49 CImIAPPreferences* prefs = CImIAPPreferences::NewLC(); |
|
50 testUtils->WriteComment(_L("Creating an CImapIO object and leave it in a connecting state...\n")); |
|
51 imapIO->ConnectL(status, _L("localhost"), 143, *prefs, EFalse); |
|
52 |
|
53 TUint32 iap; |
|
54 TInt returnValue; |
|
55 testUtils->WriteComment(_L("Checking GetIAPValue returns a valid value...\n")); |
|
56 returnValue = imapIO->GetIAPValue(iap); |
|
57 test(returnValue != KErrNotFound); |
|
58 testUtils->WriteComment(_L("Checking GetConnectionStage returns a valid value...\n")); |
|
59 returnValue = imapIO->GetConnectionStage(); |
|
60 test(returnValue != KErrNotFound); |
|
61 |
|
62 // Disconnect deletes its iSession. This sets up the conditions for the test |
|
63 // of behaviour change. |
|
64 testUtils->WriteComment(_L("Disconnect the CImapIO object. This removes its CImTextServerSession.\n")); |
|
65 imapIO->Disconnect(); |
|
66 |
|
67 testUtils->WriteComment(_L("Checking GetIAPValue still returns KErrNotFound value after disconnect...\n")); |
|
68 returnValue = imapIO->GetIAPValue(iap); |
|
69 test(returnValue == KErrNotFound); |
|
70 testUtils->WriteComment(_L("Checking GetConnectionStage still returns KErrNotFound value after disconnect...\n")); |
|
71 returnValue = imapIO->GetConnectionStage(); |
|
72 test(returnValue == KErrNotFound); |
|
73 |
|
74 testUtils->TestFinish(testNum++); |
|
75 CleanupStack::PopAndDestroy(); // prefs |
|
76 CleanupStack::PopAndDestroy(); // imapIO |
|
77 |
|
78 } |
|
79 |
|
80 //---------------------------------------------------------------------------------------- |
|
81 LOCAL_C void doMainL() |
|
82 //---------------------------------------------------------------------------------------- |
|
83 { |
|
84 |
|
85 __UHEAP_MARK; |
|
86 theScheduler = new(ELeave) CActiveScheduler; |
|
87 CleanupStack::PushL(theScheduler); |
|
88 |
|
89 CActiveScheduler::Install( theScheduler ); |
|
90 |
|
91 testUtils = CEmailTestUtils::NewL(test); |
|
92 CleanupStack::PushL(testUtils); |
|
93 |
|
94 test.SetLogged(ETrue); |
|
95 testImapIOProgress(); |
|
96 testUtils->TestHarnessCompleted(); |
|
97 |
|
98 CleanupStack::PopAndDestroy(2); |
|
99 __UHEAP_MARKEND; |
|
100 } |
|
101 |
|
102 //---------------------------------------------------------------------------------------- |
|
103 GLDEF_C TInt E32Main() |
|
104 //---------------------------------------------------------------------------------------- |
|
105 { |
|
106 __UHEAP_MARK; |
|
107 test.Start(_L("T_ImapIO Test Harness")); |
|
108 theCleanup=CTrapCleanup::New(); |
|
109 |
|
110 TRAPD(ret,doMainL()); |
|
111 |
|
112 test(ret==KErrNone); |
|
113 delete theCleanup; |
|
114 test.End(); |
|
115 test.Close(); |
|
116 __UHEAP_MARKEND; |
|
117 return(KErrNone); |
|
118 } |