00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include <e32base.h>
00017 #include <e32cons.h>
00018
00019 #include "client.h"
00020 #include "client-server.h"
00021 #include "task.h"
00022
00023 _LIT(KTextExampleCode,"Symbian OS Example Code");
00024
00025 _LIT(KSlayNemeanLion, "Test SlayNemeanLion() passed\n");
00026 _LIT(KSlayHydra, "Test SlayHydra() passed\n");
00027 _LIT(KCaptureCeryneianHind, "Test CaptureCeryneianHind() passed\n");
00028 _LIT(KSlayErymanthianBoar, "Test SlayErymanthianBoar() passed\n");
00029 _LIT(KCleanAugeanStables, "Test CleanAugeanStables() passed\n");
00030 _LIT(KSlayStymphalianBirds, "Test SlayStymphalianBirds() passed\n");
00031
00032 _LIT(KTasksInAdditionOrder, "Tasks in addition order\n");
00033 _LIT(KTasksInAscendingOrder, "Tasks in ascending order\n");
00034
00035 _LIT(KTestArrays, "Array tests passed\n");
00036
00037 _LIT(KTextOK, "All tests Passed OK!\n");
00038 _LIT(KTextPressAnyKey,"[Press any key]");
00039
00040 CConsoleBase* gConsole;
00041
00042 void TestClientServerL()
00043 {
00044 __UHEAP_MARK;
00045
00046
00047 RHerculesSession session;
00048 User::LeaveIfError(session.Connect());
00049 CleanupClosePushL(session);
00050
00051
00052 ASSERT(session.SlayNemeanLion(KNemeanLionDes, KNemeanLionVal)==KErrNone);
00053 gConsole->Printf(KSlayNemeanLion);
00054
00055
00056 TVersion version(1,0,0);
00057 THydraData hydraData;
00058 hydraData.iHydraVersion = version;
00059 hydraData.iHeadCount = KHydraHeadCount;
00060 ASSERT(session.SlayHydra(hydraData)==KErrNone);
00061
00062
00063 ASSERT(hydraData.iHeadCount==KNoHeads);
00064 gConsole->Printf(KSlayHydra);
00065
00066
00067 TInt count=KInitialCount;
00068 if (session.CaptureCeryneianHind(count)!=KErrNone)
00069 ASSERT(EFalse);
00070
00071
00072 if (count!=KCapturedCount)
00073 ASSERT(EFalse);
00074
00075 gConsole->Printf(KCaptureCeryneianHind);
00076
00077
00078 CHerculesData* data = CHerculesData::NewLC(KHercules, KHeracles, KHerculesDataVal);
00079 if (session.SlayErymanthianBoar(*data)!=KErrNone)
00080 ASSERT(EFalse);
00081
00082 gConsole->Printf(KSlayErymanthianBoar);
00083
00084
00085 TRequestStatus status;
00086 session.CleanAugeanStables(status);
00087 User::WaitForRequest(status);
00088 ASSERT(KErrNone==status.Int());
00089 gConsole->Printf(KCleanAugeanStables);
00090
00091
00092 TBuf8<12> myBuf(KHercules);
00093 session.SlayStymphalianBirds(KBirdCount, myBuf, status);
00094 User::WaitForRequest(status);
00095
00096 ASSERT(myBuf.Compare(KHercules)==0);
00097
00098 gConsole->Printf(KSlayStymphalianBirds);
00099
00100
00101 CleanupStack::PopAndDestroy(2, &session);
00102
00103
00104 __UHEAP_MARKEND;
00105 }
00106
00107 void TestArraysL()
00108 {
00109 __UHEAP_MARK;
00110
00111
00112 CHerculeanTaskManager* taskManager = CHerculeanTaskManager::NewLC();
00113
00114
00115 taskManager->AppendTaskL(ESlayHydra);
00116 taskManager->AppendTaskL(ESlayNemeanLion);
00117 taskManager->AppendTaskL(ECaptureCeryneianHind);
00118 taskManager->AppendTaskL(ECleanAugeanStables);
00119 taskManager->AppendTaskL(ECaptureCerberus);
00120 taskManager->AppendTaskL(ECaptureMaresOfDiomedes);
00121 taskManager->AppendTaskL(ESlayHydra);
00122 taskManager->AppendTaskL(ESlayNemeanLion);
00123 taskManager->AppendTaskL(ECaptureOxenOfGeryon);
00124 taskManager->AppendTaskL(ESlayErymanthianBoar);
00125
00126 ASSERT(taskManager->TaskCount()==10);
00127 RBuf taskBuf;
00128
00129
00130 taskManager->ListTasksL(taskBuf);
00131 gConsole->Printf(taskBuf);
00132 gConsole->Printf(KTasksInAdditionOrder);
00133 gConsole->Printf(KTextPressAnyKey);
00134 gConsole->Getch();
00135
00136 taskBuf.Zero();
00137 taskBuf.ReAllocL(0);
00138
00139
00140 taskManager->DeleteTask(ESlayHydra);
00141 ASSERT(taskManager->TaskCount()==8);
00142
00143
00144 taskManager->ListTasksAscendingL(taskBuf);
00145 gConsole->Printf(taskBuf);
00146 gConsole->Printf(KTasksInAscendingOrder);
00147 gConsole->Printf(KTextPressAnyKey);
00148 gConsole->Getch();
00149 taskBuf.Zero();
00150 taskBuf.ReAlloc(0);
00151
00152
00153 taskManager->AppendTaskL(ECleanAugeanStables);
00154 taskManager->AppendTaskL(ECancelCleanAugeanStables);
00155 ASSERT(taskManager->TaskCount()==10);
00156
00157
00158 taskManager->ListTasksAscendingL(taskBuf);
00159 gConsole->Printf(taskBuf);
00160 gConsole->Printf(KTasksInAscendingOrder);
00161 gConsole->Printf(KTextPressAnyKey);
00162 gConsole->Getch();
00163 taskBuf.Zero();
00164 taskBuf.ReAlloc(0);
00165
00166
00167 gConsole->Printf(KTestArrays);
00168
00169 CleanupStack::PopAndDestroy(taskManager);
00170
00171
00172 __UHEAP_MARKEND;
00173 }
00174
00175 TInt E32Main()
00176 {
00177 __UHEAP_MARK;
00178
00179 CTrapCleanup* theCleanupStack = CTrapCleanup::New();
00180
00181 gConsole = Console::NewL(KTextExampleCode,TSize(KConsFullScreen,KConsFullScreen));
00182
00183 TRAPD(err, TestClientServerL());
00184 ASSERT(KErrNone==err);
00185
00186 User::After(500000);
00187
00188 TRAP(err, TestArraysL());
00189 ASSERT(KErrNone==err);
00190
00191
00192 gConsole->Printf(KTextOK);
00193 gConsole->Printf(KTextPressAnyKey);
00194 gConsole->Getch();
00195
00196 delete gConsole;
00197 delete theCleanupStack;
00198
00199 __UHEAP_MARKEND;
00200 return (err);
00201 }
00202