|
1 // Copyright (c) 2006-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 "ctestimaplogout.h" |
|
17 |
|
18 #include "cfakeinputstream.h" |
|
19 #include "cfakeoutputstream.h" |
|
20 #include "cactivewaiter.h" |
|
21 |
|
22 #include "moutputstream.h" |
|
23 #include "cimapsession.h" |
|
24 #include "cimaputils.h" |
|
25 |
|
26 CTestImapLogout::CTestImapLogout() |
|
27 : iInputStream(NULL) |
|
28 , iOutputStream(NULL) |
|
29 , iActiveWaiter(NULL) |
|
30 , iImapSession(NULL) |
|
31 {} |
|
32 |
|
33 CTestImapLogout::~CTestImapLogout() |
|
34 { |
|
35 delete iImapSession; |
|
36 delete iActiveWaiter; |
|
37 delete iOutputStream; |
|
38 delete iInputStream; |
|
39 CImapUtils::Delete(); |
|
40 } |
|
41 |
|
42 void CTestImapLogout::SetupL() |
|
43 { |
|
44 ASSERT(iInputStream == NULL); |
|
45 ASSERT(iOutputStream == NULL); |
|
46 ASSERT(iActiveWaiter == NULL); |
|
47 ASSERT(iImapSession == NULL); |
|
48 |
|
49 CImapUtils::CreateL(); |
|
50 iInputStream = CFakeInputStream::NewL(Logger()); |
|
51 iOutputStream = CFakeOutputStream::NewL(Logger()); |
|
52 iActiveWaiter = new(ELeave)CActiveWaiter(Logger()); |
|
53 |
|
54 CImapSettings* imapSettings=NULL; |
|
55 CImapMailStore* imapMailStore=NULL; |
|
56 |
|
57 iImapSession = CImapSession::NewL(*imapSettings,*imapMailStore, *iInputStream, *iOutputStream); |
|
58 |
|
59 INFO_PRINTF1(_L("Setup: ServerGreeting")); |
|
60 iInputStream->ResetInputStrings(); |
|
61 iInputStream->AppendInputStringL(_L8("* OK Microsoft Exchange 2000 IMAP4rev1 server version 6.0.6249.0 (lon-cn-exchng2k.msexchange2k.closedtest.intra) ready.\r\n")); |
|
62 |
|
63 ASSERT_EQUALS(CImapSession::EServerStateNone, iImapSession->ServerState()); |
|
64 |
|
65 iImapSession->ReadServerGreetingL(iActiveWaiter->iStatus); |
|
66 iActiveWaiter->WaitActive(); |
|
67 |
|
68 ASSERT_EQUALS(CImapSession::EServerStateNotAuthenticated, iImapSession->ServerState()); |
|
69 |
|
70 INFO_PRINTF1(_L("Setup: Complete")); |
|
71 } |
|
72 |
|
73 void CTestImapLogout::TearDownL() |
|
74 { |
|
75 delete iImapSession; |
|
76 iImapSession = NULL; |
|
77 |
|
78 delete iActiveWaiter; |
|
79 iActiveWaiter = NULL; |
|
80 |
|
81 delete iOutputStream; |
|
82 iOutputStream = NULL; |
|
83 |
|
84 delete iInputStream; |
|
85 iInputStream = NULL; |
|
86 |
|
87 CImapUtils::Delete(); |
|
88 } |
|
89 |
|
90 // Tests |
|
91 void CTestImapLogout::TestSimpleLogoutL() |
|
92 { |
|
93 INFO_PRINTF1(_L("TestSimpleLogoutL")); |
|
94 |
|
95 iInputStream->ResetInputStrings(); |
|
96 iInputStream->AppendInputStringL(_L8("1 OK LOGOUT completed\r\n")); |
|
97 |
|
98 iImapSession->LogoutL(iActiveWaiter->iStatus); |
|
99 iActiveWaiter->WaitActive(); |
|
100 |
|
101 ASSERT_EQUALS(iOutputStream->PtrOutput(), _L8("1 LOGOUT\r\n")); |
|
102 |
|
103 INFO_PRINTF1(_L("Complete")); |
|
104 } |
|
105 |
|
106 void CTestImapLogout::TestLogoutWithByeL() |
|
107 { |
|
108 INFO_PRINTF1(_L("TestLogoutWithByeL")); |
|
109 |
|
110 iInputStream->ResetInputStrings(); |
|
111 iInputStream->AppendInputStringL(_L8("* BYE IMAP4rev1 Server logging out\r\n")); |
|
112 iInputStream->AppendInputStringL(_L8("1 OK LOGOUT completed\r\n")); |
|
113 |
|
114 iImapSession->LogoutL(iActiveWaiter->iStatus); |
|
115 iActiveWaiter->WaitActive(); |
|
116 |
|
117 ASSERT_EQUALS(iOutputStream->PtrOutput(), _L8("1 LOGOUT\r\n")); |
|
118 |
|
119 INFO_PRINTF1(_L("Complete")); |
|
120 } |
|
121 |
|
122 CTestSuite* CTestImapLogout::CreateSuiteL(const TDesC& aName) |
|
123 // static |
|
124 { |
|
125 SUB_SUITE; |
|
126 ADD_ASYNC_TEST_STEP(TestSimpleLogoutL); |
|
127 ADD_ASYNC_TEST_STEP(TestLogoutWithByeL); |
|
128 END_SUITE; |
|
129 } |