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