|
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 "ctestimaprename.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 #include "cimapfolderinfo.h" |
|
26 |
|
27 CTestImapRename::CTestImapRename() |
|
28 : iInputStream(NULL) |
|
29 , iOutputStream(NULL) |
|
30 , iActiveWaiter(NULL) |
|
31 , iImapSession(NULL) |
|
32 {} |
|
33 |
|
34 CTestImapRename::~CTestImapRename() |
|
35 { |
|
36 delete iImapSession; |
|
37 delete iActiveWaiter; |
|
38 delete iOutputStream; |
|
39 delete iInputStream; |
|
40 CImapUtils::Delete(); |
|
41 } |
|
42 |
|
43 void CTestImapRename::SetupL() |
|
44 { |
|
45 ASSERT(iInputStream == NULL); |
|
46 ASSERT(iOutputStream == NULL); |
|
47 ASSERT(iActiveWaiter == NULL); |
|
48 ASSERT(iImapSession == NULL); |
|
49 |
|
50 CImapUtils::CreateL(); |
|
51 iInputStream = CFakeInputStream::NewL(Logger()); |
|
52 iOutputStream = CFakeOutputStream::NewL(Logger()); |
|
53 iActiveWaiter = new(ELeave)CActiveWaiter(Logger()); |
|
54 |
|
55 CImapSettings* imapSettings=NULL; |
|
56 CImapMailStore* imapMailStore=NULL; |
|
57 |
|
58 iImapSession = CImapSession::NewL(*imapSettings,*imapMailStore,*iInputStream, *iOutputStream); |
|
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 INFO_PRINTF1(_L("...Login")); |
|
69 iInputStream->ResetInputStrings(); |
|
70 iInputStream->AppendInputStringL(_L8("1 OK LOGIN completed\r\n")); |
|
71 |
|
72 iImapSession->LoginL(iActiveWaiter->iStatus, _L8("username"), _L8("password")); |
|
73 iActiveWaiter->WaitActive(); |
|
74 |
|
75 ASSERT_EQUALS(CImapSession::EServerStateAuthenticated, iImapSession->ServerState()); |
|
76 |
|
77 |
|
78 INFO_PRINTF1(_L("...Select inbox")); |
|
79 iInputStream->ResetInputStrings(); |
|
80 iInputStream->AppendInputStringL(_L8("2 OK [READ-WRITE] SELECT completed\r\n")); |
|
81 |
|
82 CImapFolderInfo* folderInfo = CImapFolderInfo::NewL(); |
|
83 CleanupStack::PushL(folderInfo); |
|
84 |
|
85 folderInfo->SetNameL(_L16("inbox")); |
|
86 CleanupStack::Pop(folderInfo); |
|
87 iImapSession->SelectL(iActiveWaiter->iStatus, folderInfo); |
|
88 iActiveWaiter->WaitActive(); |
|
89 |
|
90 ASSERT_EQUALS(CImapSession::EServerStateSelected, iImapSession->ServerState()); |
|
91 ASSERT_EQUALS(folderInfo, iImapSession->SelectedFolderInfo()); |
|
92 folderInfo = NULL; |
|
93 |
|
94 |
|
95 INFO_PRINTF1(_L("Setup: Complete")); |
|
96 } |
|
97 |
|
98 void CTestImapRename::TearDownL() |
|
99 { |
|
100 delete iImapSession; |
|
101 iImapSession = NULL; |
|
102 |
|
103 delete iActiveWaiter; |
|
104 iActiveWaiter = NULL; |
|
105 |
|
106 delete iOutputStream; |
|
107 iOutputStream = NULL; |
|
108 |
|
109 delete iInputStream; |
|
110 iInputStream = NULL; |
|
111 |
|
112 CImapUtils::Delete(); |
|
113 } |
|
114 |
|
115 // Tests |
|
116 void CTestImapRename::TestRenameL() |
|
117 { |
|
118 INFO_PRINTF1(_L("TestSimpleRenameL")); |
|
119 |
|
120 iInputStream->ResetInputStrings(); |
|
121 iInputStream->AppendInputStringL(_L8("3 OK Rename completed\r\n")); |
|
122 |
|
123 TBufC16<100> folderName1(_L("MyOldFolder")); |
|
124 TBufC16<100> folderName2(_L("MyNewFolder")); |
|
125 |
|
126 iImapSession->RenameL(iActiveWaiter->iStatus,folderName1,folderName2); |
|
127 iActiveWaiter->WaitActive(); |
|
128 |
|
129 INFO_PRINTF1(_L("Complete")); |
|
130 } |
|
131 |
|
132 CTestSuite* CTestImapRename::CreateSuiteL(const TDesC& aName) |
|
133 // static |
|
134 { |
|
135 SUB_SUITE; |
|
136 ADD_ASYNC_TEST_STEP(TestRenameL); |
|
137 END_SUITE; |
|
138 } |