diff -r f902e87c146f -r 748ec5531811 textrendering/textformatting/test/src/TUndo.cpp --- a/textrendering/textformatting/test/src/TUndo.cpp Wed Jun 09 11:40:52 2010 +0300 +++ b/textrendering/textformatting/test/src/TUndo.cpp Tue Aug 31 17:01:26 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2000-2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of "Eclipse Public License v1.0" @@ -35,14 +35,17 @@ #include "txtfmlyr_internal.h" #endif +#include "tundo.h" + #define UNUSED_VAR(a) a = a using namespace UndoSystem; namespace { -CTrapCleanup* TrapCleanup; -RTest test(_L("TUndo - Undo system")); +CTUndoStep* TestStep = NULL; +#define TESTPOINT(p) TestStep->testpoint(p,(TText8*)__FILE__,__LINE__) +#define TESTPRINT(p) TestStep->print(p,(TText8*)__FILE__,__LINE__) } // @@ -1220,7 +1223,7 @@ CSingleCommand* single = a.Top()->Single(); if (!single) { - test.Printf(_L("CCommandStack : stack unexpectedly contained batches")); + TESTPRINT(_L("CCommandStack : stack unexpectedly contained batches")); a.Reset(); return 1; } @@ -1234,14 +1237,14 @@ { if (a.Passed()) return 0; - test.Printf(_L("CCommandStack... : log failed")); + TESTPRINT(_L("CCommandStack... : log failed")); return 1; } TInt CheckTop(CCommandStack& aStack, CCommand* aTop) { if (aStack.Top() != aTop) { - test.Printf(_L("CCommandStack : unexpected item at top of stack")); + TESTPRINT(_L("CCommandStack : unexpected item at top of stack")); return 1; } return 0; @@ -1250,7 +1253,7 @@ { if (aStack.Count() != aExpectedCount) { - test.Printf(_L("CCommandStack : stack an unexpected size")); + TESTPRINT(_L("CCommandStack : stack an unexpected size")); return 1; } return 0; @@ -1260,7 +1263,7 @@ CCommand* check = aStack.Top(); if (aStack.Pop() != check) { - test.Printf(_L("CCommandStack : Pop() does not match Top()")); + TESTPRINT(_L("CCommandStack : Pop() does not match Top()")); return 1; } return 0; @@ -1392,21 +1395,21 @@ single->ExecuteL(); if (a.Pop() != single) { - test.Printf(_L("CBatchCommand : Pop() didn't match Top()")); - test(0); + TESTPRINT(_L("CBatchCommand : Pop() didn't match Top()")); + TESTPOINT(0); } delete single; } - test(1); + TESTPOINT(1); } void CheckTop(CBatchCommand& aBatch, CCommand* aTop) { if (aBatch.Top() != aTop) { - test.Printf(_L("CCommandBatch : unexpected item at top of stack")); - test(0); + TESTPRINT(_L("CCommandBatch : unexpected item at top of stack")); + TESTPOINT(0); } - test(1); + TESTPOINT(1); } void TestCBatchCommandL() { @@ -1531,7 +1534,7 @@ else { CBatchCommand* batch = aHistory.Top()->Batch(); - test(batch != 0); + TESTPOINT(batch != 0); aLog << _L("batch{"); ExecuteBatchL(*batch); aLog << _L("}"); @@ -1606,41 +1609,41 @@ { if (aMan.CanUndo()) { - test(1); + TESTPOINT(1); return; } - test.Printf(_L("CCommandManager : unexpectedly could not undo")); - test(0); + TESTPRINT(_L("CCommandManager : unexpectedly could not undo")); + TESTPOINT(0); } void TestCanRedo(const CCommandManager& aMan) { if (aMan.CanRedo()) { - test(1); + TESTPOINT(1); return; } - test.Printf(_L("CCommandManager : unexpectedly could not redo")); - test(0); + TESTPRINT(_L("CCommandManager : unexpectedly could not redo")); + TESTPOINT(0); } void TestCannotUndo(const CCommandManager& aMan) { if (!aMan.CanUndo()) { - test(1); + TESTPOINT(1); return; } - test.Printf(_L("CCommandManager : unexpectedly could undo")); - test(0); + TESTPRINT(_L("CCommandManager : unexpectedly could undo")); + TESTPOINT(0); } void TestCannotRedo(const CCommandManager& aMan) { if (!aMan.CanRedo()) { - test(1); + TESTPOINT(1); return; } - test.Printf(_L("CCommandManager : unexpectedly could undo")); - test(0); + TESTPRINT(_L("CCommandManager : unexpectedly could undo")); + TESTPOINT(0); } void SetUpTestL(CCommandManager& aMan, CSingleCommand& aCommand, TInt* aTarget, CLogger* aLogger) { @@ -1669,9 +1672,9 @@ if (aErr == aExpected) return 0; if (aErr == KErrNone) - test.Printf(_L("CCommandManager : no leave where one was expected")); + TESTPRINT(_L("CCommandManager : no leave where one was expected")); else - test.Printf(_L("CCommandManager : unexpected leave code")); + TESTPRINT(_L("CCommandManager : unexpected leave code")); return 1; } void TestCCommandManagerL() @@ -1996,11 +1999,11 @@ { if (a.Passed()) { - test(1); + TESTPOINT(1); return; } - test.Printf(_L("EditorUndo : log failed")); - test(0); + TESTPRINT(_L("EditorUndo : log failed")); + TESTPOINT(0); } void TestPlainText(CTestEditor& aTestEditor, MUnifiedEditor& aUndoEditor, @@ -2792,16 +2795,16 @@ styleLog2 = log->GetStore(); if (retval != KErrNone) { - test.Printf(_L("EditorUndo : apply style failed")); - test(0); + TESTPRINT(_L("EditorUndo : apply style failed")); + TESTPOINT(0); } TPtrC testStyleName; TInt testStyleRunLength; ed->StyleSupport()->GetStyle(1, testStyleName, testStyleRunLength); if (testStyleRunLength != 3 || testStyleName != style1.iName) { - test.Printf(_L("EditorUndo : apply style failed")); - test(0); + TESTPRINT(_L("EditorUndo : apply style failed")); + TESTPOINT(0); } ed->InsertTextL(5, _L(","), &style1.iName, 0, 0); testEd->Print(*log); @@ -2832,14 +2835,14 @@ styleLog10 = log->GetStore(); if (retval != KErrNone) { - test.Printf(_L("EditorUndo : rename style failed")); - test(0); + TESTPRINT(_L("EditorUndo : rename style failed")); + TESTPOINT(0); } ed->StyleSupport()->GetStyle(1, testStyleName, testStyleRunLength); if (testStyleRunLength != 1 || testStyleName != style1.iName) { - test.Printf(_L("EditorUndo : rename or apply style failed")); - test(0); + TESTPRINT(_L("EditorUndo : rename or apply style failed")); + TESTPOINT(0); } ed->StyleSupport()->RenameStyleL(_L("title"), _L("zip")); style2.iName = _L("zip"); @@ -3169,82 +3172,82 @@ // in the way. if (i == 5) { - test(manager->IsAtBookmark()); + TESTPOINT(manager->IsAtBookmark()); check->SetCheckString(*bookMarkLog4); testEd->Print(*check); CheckEditorLog(*check); ed->UndoL(); } if (i == 4) - test(manager->IsAtBookmark()); + TESTPOINT(manager->IsAtBookmark()); else - test(!manager->IsAtBookmark()); + TESTPOINT(!manager->IsAtBookmark()); check->SetCheckString(*bookMarkLog3); testEd->Print(*check); CheckEditorLog(*check); ed->UndoL(); if (i == 2) - test(manager->IsAtBookmark()); + TESTPOINT(manager->IsAtBookmark()); else - test(!manager->IsAtBookmark()); + TESTPOINT(!manager->IsAtBookmark()); check->SetCheckString(*bookMarkLog2); testEd->Print(*check); CheckEditorLog(*check); ed->UndoL(); if (i == 1) - test(manager->IsAtBookmark()); + TESTPOINT(manager->IsAtBookmark()); else - test(!manager->IsAtBookmark()); + TESTPOINT(!manager->IsAtBookmark()); check->SetCheckString(*bookMarkLog1); testEd->Print(*check); CheckEditorLog(*check); ed->UndoL(); if (i == 0) - test(manager->IsAtBookmark()); + TESTPOINT(manager->IsAtBookmark()); else - test(!manager->IsAtBookmark()); + TESTPOINT(!manager->IsAtBookmark()); check->SetCheckString(*bookMarkLog0); testEd->Print(*check); CheckEditorLog(*check); - test(!ed->CanUndo()); + TESTPOINT(!ed->CanUndo()); ed->RedoL(); if (i == 1) - test(manager->IsAtBookmark()); + TESTPOINT(manager->IsAtBookmark()); else - test(!manager->IsAtBookmark()); + TESTPOINT(!manager->IsAtBookmark()); check->SetCheckString(*bookMarkLog1); testEd->Print(*check); CheckEditorLog(*check); ed->RedoL(); if (i == 2) - test(manager->IsAtBookmark()); + TESTPOINT(manager->IsAtBookmark()); else - test(!manager->IsAtBookmark()); + TESTPOINT(!manager->IsAtBookmark()); check->SetCheckString(*bookMarkLog2); testEd->Print(*check); CheckEditorLog(*check); ed->RedoL(); if (i == 4) - test(manager->IsAtBookmark()); + TESTPOINT(manager->IsAtBookmark()); else - test(!manager->IsAtBookmark()); + TESTPOINT(!manager->IsAtBookmark()); check->SetCheckString(*bookMarkLog3); testEd->Print(*check); CheckEditorLog(*check); ed->RedoL(); if (i == 5) { - test(manager->IsAtBookmark()); + TESTPOINT(manager->IsAtBookmark()); check->SetCheckString(*bookMarkLog4); testEd->Print(*check); CheckEditorLog(*check); ed->RedoL(); } - test(!ed->CanRedo()); + TESTPOINT(!ed->CanRedo()); if (i == 6) - test(manager->IsAtBookmark()); + TESTPOINT(manager->IsAtBookmark()); else - test(!manager->IsAtBookmark()); + TESTPOINT(!manager->IsAtBookmark()); delete bookMarkLog0; delete bookMarkLog1; @@ -3437,8 +3440,8 @@ TTmCharFormat charB1; RTmParFormat parT1; ed0->GetBaseFormatL(charB1,parT1); - test(charB1==charB); - test(parT1==parT); + TESTPOINT(charB1==charB); + TESTPOINT(parT1==parT); //Getting the character format TTmCharFormatLayer charLayer1; @@ -3453,7 +3456,7 @@ //Getting the text TPtrC text; ed0->GetText(0,text); - test(text==_L("a")); + TESTPOINT(text==_L("a")); //Deleting the formating ed0->DeleteCharFormatL(0,1); @@ -3541,13 +3544,15 @@ // // -void RunTests() +TVerdict CTUndoStep::doTestStepL() { - __UHEAP_MARK; - - test.Title(); - test.Start(_L("@SYMTestCaseID:SYSLIB-FORM-LEGACY-UNDO-0001 Undo System Tests: ")); - + SetTestStepResult(EPass); + TestStep = this; + TESTPRINT(_L("TUndo - Undo system")); + + __UHEAP_MARK; + TESTPRINT(_L("@SYMTestCaseID:SYSLIB-FORM-LEGACY-UNDO-0001 Undo System Tests: ")); + // test of general undo system components TestCCommandStackL(); TestCBatchCommandL(); @@ -3560,17 +3565,8 @@ // test that command manager and multiple editors integrate correctly TestMultipleEditorsL(); - test.End(); - test.Close(); - __UHEAP_MARKENDC(0); + + return TestStepResult(); } -TInt E32Main() - { - TrapCleanup = CTrapCleanup::New(); - TRAPD(err, RunTests()); - test(err == KErrNone); - delete TrapCleanup; - return 0; - }