1232 } |
1235 } |
1233 TInt CheckLog(CCheckingLogger& a) |
1236 TInt CheckLog(CCheckingLogger& a) |
1234 { |
1237 { |
1235 if (a.Passed()) |
1238 if (a.Passed()) |
1236 return 0; |
1239 return 0; |
1237 test.Printf(_L("CCommandStack... : log failed")); |
1240 TESTPRINT(_L("CCommandStack... : log failed")); |
1238 return 1; |
1241 return 1; |
1239 } |
1242 } |
1240 TInt CheckTop(CCommandStack& aStack, CCommand* aTop) |
1243 TInt CheckTop(CCommandStack& aStack, CCommand* aTop) |
1241 { |
1244 { |
1242 if (aStack.Top() != aTop) |
1245 if (aStack.Top() != aTop) |
1243 { |
1246 { |
1244 test.Printf(_L("CCommandStack : unexpected item at top of stack")); |
1247 TESTPRINT(_L("CCommandStack : unexpected item at top of stack")); |
1245 return 1; |
1248 return 1; |
1246 } |
1249 } |
1247 return 0; |
1250 return 0; |
1248 } |
1251 } |
1249 TInt CheckCount(CCommandStack& aStack, TInt aExpectedCount) |
1252 TInt CheckCount(CCommandStack& aStack, TInt aExpectedCount) |
1250 { |
1253 { |
1251 if (aStack.Count() != aExpectedCount) |
1254 if (aStack.Count() != aExpectedCount) |
1252 { |
1255 { |
1253 test.Printf(_L("CCommandStack : stack an unexpected size")); |
1256 TESTPRINT(_L("CCommandStack : stack an unexpected size")); |
1254 return 1; |
1257 return 1; |
1255 } |
1258 } |
1256 return 0; |
1259 return 0; |
1257 } |
1260 } |
1258 TInt CheckPop(CCommandStack& aStack) |
1261 TInt CheckPop(CCommandStack& aStack) |
1259 { |
1262 { |
1260 CCommand* check = aStack.Top(); |
1263 CCommand* check = aStack.Top(); |
1261 if (aStack.Pop() != check) |
1264 if (aStack.Pop() != check) |
1262 { |
1265 { |
1263 test.Printf(_L("CCommandStack : Pop() does not match Top()")); |
1266 TESTPRINT(_L("CCommandStack : Pop() does not match Top()")); |
1264 return 1; |
1267 return 1; |
1265 } |
1268 } |
1266 return 0; |
1269 return 0; |
1267 } |
1270 } |
1268 void AddStuffL(CCommandStack& aStack, TInt* aTarget, CLogger* aLog) |
1271 void AddStuffL(CCommandStack& aStack, TInt* aTarget, CLogger* aLog) |
1604 // 4 - CCommandManager test |
1607 // 4 - CCommandManager test |
1605 void TestCanUndo(const CCommandManager& aMan) |
1608 void TestCanUndo(const CCommandManager& aMan) |
1606 { |
1609 { |
1607 if (aMan.CanUndo()) |
1610 if (aMan.CanUndo()) |
1608 { |
1611 { |
1609 test(1); |
1612 TESTPOINT(1); |
1610 return; |
1613 return; |
1611 } |
1614 } |
1612 test.Printf(_L("CCommandManager : unexpectedly could not undo")); |
1615 TESTPRINT(_L("CCommandManager : unexpectedly could not undo")); |
1613 test(0); |
1616 TESTPOINT(0); |
1614 } |
1617 } |
1615 void TestCanRedo(const CCommandManager& aMan) |
1618 void TestCanRedo(const CCommandManager& aMan) |
1616 { |
1619 { |
1617 if (aMan.CanRedo()) |
1620 if (aMan.CanRedo()) |
1618 { |
1621 { |
1619 test(1); |
1622 TESTPOINT(1); |
1620 return; |
1623 return; |
1621 } |
1624 } |
1622 test.Printf(_L("CCommandManager : unexpectedly could not redo")); |
1625 TESTPRINT(_L("CCommandManager : unexpectedly could not redo")); |
1623 test(0); |
1626 TESTPOINT(0); |
1624 } |
1627 } |
1625 void TestCannotUndo(const CCommandManager& aMan) |
1628 void TestCannotUndo(const CCommandManager& aMan) |
1626 { |
1629 { |
1627 if (!aMan.CanUndo()) |
1630 if (!aMan.CanUndo()) |
1628 { |
1631 { |
1629 test(1); |
1632 TESTPOINT(1); |
1630 return; |
1633 return; |
1631 } |
1634 } |
1632 test.Printf(_L("CCommandManager : unexpectedly could undo")); |
1635 TESTPRINT(_L("CCommandManager : unexpectedly could undo")); |
1633 test(0); |
1636 TESTPOINT(0); |
1634 } |
1637 } |
1635 void TestCannotRedo(const CCommandManager& aMan) |
1638 void TestCannotRedo(const CCommandManager& aMan) |
1636 { |
1639 { |
1637 if (!aMan.CanRedo()) |
1640 if (!aMan.CanRedo()) |
1638 { |
1641 { |
1639 test(1); |
1642 TESTPOINT(1); |
1640 return; |
1643 return; |
1641 } |
1644 } |
1642 test.Printf(_L("CCommandManager : unexpectedly could undo")); |
1645 TESTPRINT(_L("CCommandManager : unexpectedly could undo")); |
1643 test(0); |
1646 TESTPOINT(0); |
1644 } |
1647 } |
1645 void SetUpTestL(CCommandManager& aMan, CSingleCommand& aCommand, TInt* aTarget, CLogger* aLogger) |
1648 void SetUpTestL(CCommandManager& aMan, CSingleCommand& aCommand, TInt* aTarget, CLogger* aLogger) |
1646 { |
1649 { |
1647 CCommandIncProto* inc = CCommandIncProto::NewL(aTarget, aLogger); |
1650 CCommandIncProto* inc = CCommandIncProto::NewL(aTarget, aLogger); |
1648 CleanupStack::PushL(inc); |
1651 CleanupStack::PushL(inc); |
2790 TInt retval = ed->StyleSupport()->SetStyleL(1, 3, _L("author")); |
2793 TInt retval = ed->StyleSupport()->SetStyleL(1, 3, _L("author")); |
2791 testEd->Print(*log); |
2794 testEd->Print(*log); |
2792 styleLog2 = log->GetStore(); |
2795 styleLog2 = log->GetStore(); |
2793 if (retval != KErrNone) |
2796 if (retval != KErrNone) |
2794 { |
2797 { |
2795 test.Printf(_L("EditorUndo : apply style failed")); |
2798 TESTPRINT(_L("EditorUndo : apply style failed")); |
2796 test(0); |
2799 TESTPOINT(0); |
2797 } |
2800 } |
2798 TPtrC testStyleName; |
2801 TPtrC testStyleName; |
2799 TInt testStyleRunLength; |
2802 TInt testStyleRunLength; |
2800 ed->StyleSupport()->GetStyle(1, testStyleName, testStyleRunLength); |
2803 ed->StyleSupport()->GetStyle(1, testStyleName, testStyleRunLength); |
2801 if (testStyleRunLength != 3 || testStyleName != style1.iName) |
2804 if (testStyleRunLength != 3 || testStyleName != style1.iName) |
2802 { |
2805 { |
2803 test.Printf(_L("EditorUndo : apply style failed")); |
2806 TESTPRINT(_L("EditorUndo : apply style failed")); |
2804 test(0); |
2807 TESTPOINT(0); |
2805 } |
2808 } |
2806 ed->InsertTextL(5, _L(","), &style1.iName, 0, 0); |
2809 ed->InsertTextL(5, _L(","), &style1.iName, 0, 0); |
2807 testEd->Print(*log); |
2810 testEd->Print(*log); |
2808 styleLog3 = log->GetStore(); |
2811 styleLog3 = log->GetStore(); |
2809 ed->StyleSupport()->CreateStyleL(style2); |
2812 ed->StyleSupport()->CreateStyleL(style2); |
2830 retval = ed->StyleSupport()->SetStyleL(10, 1, _L("version")); |
2833 retval = ed->StyleSupport()->SetStyleL(10, 1, _L("version")); |
2831 testEd->Print(*log); |
2834 testEd->Print(*log); |
2832 styleLog10 = log->GetStore(); |
2835 styleLog10 = log->GetStore(); |
2833 if (retval != KErrNone) |
2836 if (retval != KErrNone) |
2834 { |
2837 { |
2835 test.Printf(_L("EditorUndo : rename style failed")); |
2838 TESTPRINT(_L("EditorUndo : rename style failed")); |
2836 test(0); |
2839 TESTPOINT(0); |
2837 } |
2840 } |
2838 ed->StyleSupport()->GetStyle(1, testStyleName, testStyleRunLength); |
2841 ed->StyleSupport()->GetStyle(1, testStyleName, testStyleRunLength); |
2839 if (testStyleRunLength != 1 || testStyleName != style1.iName) |
2842 if (testStyleRunLength != 1 || testStyleName != style1.iName) |
2840 { |
2843 { |
2841 test.Printf(_L("EditorUndo : rename or apply style failed")); |
2844 TESTPRINT(_L("EditorUndo : rename or apply style failed")); |
2842 test(0); |
2845 TESTPOINT(0); |
2843 } |
2846 } |
2844 ed->StyleSupport()->RenameStyleL(_L("title"), _L("zip")); |
2847 ed->StyleSupport()->RenameStyleL(_L("title"), _L("zip")); |
2845 style2.iName = _L("zip"); |
2848 style2.iName = _L("zip"); |
2846 testEd->Print(*log); |
2849 testEd->Print(*log); |
2847 styleLog11 = log->GetStore(); |
2850 styleLog11 = log->GetStore(); |
3167 ed->UndoL(); |
3170 ed->UndoL(); |
3168 // coalescence should have happenned unless there is a bookmark |
3171 // coalescence should have happenned unless there is a bookmark |
3169 // in the way. |
3172 // in the way. |
3170 if (i == 5) |
3173 if (i == 5) |
3171 { |
3174 { |
3172 test(manager->IsAtBookmark()); |
3175 TESTPOINT(manager->IsAtBookmark()); |
3173 check->SetCheckString(*bookMarkLog4); |
3176 check->SetCheckString(*bookMarkLog4); |
3174 testEd->Print(*check); |
3177 testEd->Print(*check); |
3175 CheckEditorLog(*check); |
3178 CheckEditorLog(*check); |
3176 ed->UndoL(); |
3179 ed->UndoL(); |
3177 } |
3180 } |
3178 if (i == 4) |
3181 if (i == 4) |
3179 test(manager->IsAtBookmark()); |
3182 TESTPOINT(manager->IsAtBookmark()); |
3180 else |
3183 else |
3181 test(!manager->IsAtBookmark()); |
3184 TESTPOINT(!manager->IsAtBookmark()); |
3182 check->SetCheckString(*bookMarkLog3); |
3185 check->SetCheckString(*bookMarkLog3); |
3183 testEd->Print(*check); |
3186 testEd->Print(*check); |
3184 CheckEditorLog(*check); |
3187 CheckEditorLog(*check); |
3185 ed->UndoL(); |
3188 ed->UndoL(); |
3186 if (i == 2) |
3189 if (i == 2) |
3187 test(manager->IsAtBookmark()); |
3190 TESTPOINT(manager->IsAtBookmark()); |
3188 else |
3191 else |
3189 test(!manager->IsAtBookmark()); |
3192 TESTPOINT(!manager->IsAtBookmark()); |
3190 check->SetCheckString(*bookMarkLog2); |
3193 check->SetCheckString(*bookMarkLog2); |
3191 testEd->Print(*check); |
3194 testEd->Print(*check); |
3192 CheckEditorLog(*check); |
3195 CheckEditorLog(*check); |
3193 ed->UndoL(); |
3196 ed->UndoL(); |
3194 if (i == 1) |
3197 if (i == 1) |
3195 test(manager->IsAtBookmark()); |
3198 TESTPOINT(manager->IsAtBookmark()); |
3196 else |
3199 else |
3197 test(!manager->IsAtBookmark()); |
3200 TESTPOINT(!manager->IsAtBookmark()); |
3198 check->SetCheckString(*bookMarkLog1); |
3201 check->SetCheckString(*bookMarkLog1); |
3199 testEd->Print(*check); |
3202 testEd->Print(*check); |
3200 CheckEditorLog(*check); |
3203 CheckEditorLog(*check); |
3201 ed->UndoL(); |
3204 ed->UndoL(); |
3202 if (i == 0) |
3205 if (i == 0) |
3203 test(manager->IsAtBookmark()); |
3206 TESTPOINT(manager->IsAtBookmark()); |
3204 else |
3207 else |
3205 test(!manager->IsAtBookmark()); |
3208 TESTPOINT(!manager->IsAtBookmark()); |
3206 check->SetCheckString(*bookMarkLog0); |
3209 check->SetCheckString(*bookMarkLog0); |
3207 testEd->Print(*check); |
3210 testEd->Print(*check); |
3208 CheckEditorLog(*check); |
3211 CheckEditorLog(*check); |
3209 test(!ed->CanUndo()); |
3212 TESTPOINT(!ed->CanUndo()); |
3210 ed->RedoL(); |
3213 ed->RedoL(); |
3211 if (i == 1) |
3214 if (i == 1) |
3212 test(manager->IsAtBookmark()); |
3215 TESTPOINT(manager->IsAtBookmark()); |
3213 else |
3216 else |
3214 test(!manager->IsAtBookmark()); |
3217 TESTPOINT(!manager->IsAtBookmark()); |
3215 check->SetCheckString(*bookMarkLog1); |
3218 check->SetCheckString(*bookMarkLog1); |
3216 testEd->Print(*check); |
3219 testEd->Print(*check); |
3217 CheckEditorLog(*check); |
3220 CheckEditorLog(*check); |
3218 ed->RedoL(); |
3221 ed->RedoL(); |
3219 if (i == 2) |
3222 if (i == 2) |
3220 test(manager->IsAtBookmark()); |
3223 TESTPOINT(manager->IsAtBookmark()); |
3221 else |
3224 else |
3222 test(!manager->IsAtBookmark()); |
3225 TESTPOINT(!manager->IsAtBookmark()); |
3223 check->SetCheckString(*bookMarkLog2); |
3226 check->SetCheckString(*bookMarkLog2); |
3224 testEd->Print(*check); |
3227 testEd->Print(*check); |
3225 CheckEditorLog(*check); |
3228 CheckEditorLog(*check); |
3226 ed->RedoL(); |
3229 ed->RedoL(); |
3227 if (i == 4) |
3230 if (i == 4) |
3228 test(manager->IsAtBookmark()); |
3231 TESTPOINT(manager->IsAtBookmark()); |
3229 else |
3232 else |
3230 test(!manager->IsAtBookmark()); |
3233 TESTPOINT(!manager->IsAtBookmark()); |
3231 check->SetCheckString(*bookMarkLog3); |
3234 check->SetCheckString(*bookMarkLog3); |
3232 testEd->Print(*check); |
3235 testEd->Print(*check); |
3233 CheckEditorLog(*check); |
3236 CheckEditorLog(*check); |
3234 ed->RedoL(); |
3237 ed->RedoL(); |
3235 if (i == 5) |
3238 if (i == 5) |
3236 { |
3239 { |
3237 test(manager->IsAtBookmark()); |
3240 TESTPOINT(manager->IsAtBookmark()); |
3238 check->SetCheckString(*bookMarkLog4); |
3241 check->SetCheckString(*bookMarkLog4); |
3239 testEd->Print(*check); |
3242 testEd->Print(*check); |
3240 CheckEditorLog(*check); |
3243 CheckEditorLog(*check); |
3241 ed->RedoL(); |
3244 ed->RedoL(); |
3242 } |
3245 } |
3243 test(!ed->CanRedo()); |
3246 TESTPOINT(!ed->CanRedo()); |
3244 if (i == 6) |
3247 if (i == 6) |
3245 test(manager->IsAtBookmark()); |
3248 TESTPOINT(manager->IsAtBookmark()); |
3246 else |
3249 else |
3247 test(!manager->IsAtBookmark()); |
3250 TESTPOINT(!manager->IsAtBookmark()); |
3248 |
3251 |
3249 delete bookMarkLog0; |
3252 delete bookMarkLog0; |
3250 delete bookMarkLog1; |
3253 delete bookMarkLog1; |
3251 delete bookMarkLog2; |
3254 delete bookMarkLog2; |
3252 delete bookMarkLog3; |
3255 delete bookMarkLog3; |