From caf19c8b0a7af2d4ff5c0bddd8fd9e3c932a8885 Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Thu, 13 Jan 2005 00:48:38 +0000 Subject: [PATCH] * When run more than one time, the tests the increment the clipboard count didn't pass anymore. Now we check only the difference, not for absolute values. * Fixed the style. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10704 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/tests/kits/app/bclipboard/CountTester.cpp | 311 +++++++++--------- 1 file changed, 151 insertions(+), 160 deletions(-) diff --git a/src/tests/kits/app/bclipboard/CountTester.cpp b/src/tests/kits/app/bclipboard/CountTester.cpp index dc8e1b50ec..8c0386f655 100644 --- a/src/tests/kits/app/bclipboard/CountTester.cpp +++ b/src/tests/kits/app/bclipboard/CountTester.cpp @@ -29,178 +29,172 @@ */ void CountTester::LocalCount1() { - BApplication app("application/x-vnd.clipboardtest"); - BClipboard clip("LocalCount1"); + BApplication app("application/x-vnd.clipboardtest"); + BClipboard clip("LocalCount1"); - CHK(clip.LocalCount() == 0); + CHK(clip.LocalCount() == 0); } /* LocalCount() @case 2 - @results count == 1 + @results count == +1 */ void CountTester::LocalCount2() { - BApplication app("application/x-vnd.clipboardtest"); - BClipboard clip("LocalCount2"); - BMessage *data; + BApplication app("application/x-vnd.clipboardtest"); + BClipboard clip("LocalCount2"); + BMessage *data; - if ( clip.Lock() ) - { - clip.Clear(); - if ( (data = clip.Data()) ) - { - data->AddData("text/plain",B_MIME_TYPE,"LocalCount2",12); - clip.Commit(); - } - clip.Unlock(); - } + uint32 oldCount = clip.SystemCount(); - CHK(clip.LocalCount() == 1); + if (clip.Lock()) { + clip.Clear(); + if ((data = clip.Data())) { + data->AddData("text/plain", B_MIME_TYPE, "LocalCount2", 12); + clip.Commit(); + } + clip.Unlock(); + } + + CHK(clip.LocalCount() == oldCount + 1); } /* LocalCount() @case 3 - @results both counts == 1 + @results both counts == +1 */ void CountTester::LocalCount3() { - BApplication app("application/x-vnd.clipboardtest"); - BClipboard clipA("LocalCount3"); - BClipboard clipB("LocalCount3"); - BMessage *data; + BApplication app("application/x-vnd.clipboardtest"); + BClipboard clipA("LocalCount3"); + BClipboard clipB("LocalCount3"); + BMessage *data; - if ( clipB.Lock() ) - { - clipB.Clear(); - if ( (data = clipB.Data()) ) - { - data->AddData("text/plain",B_MIME_TYPE,"LocalCount3",12); - clipB.Commit(); - } - clipB.Unlock(); - } - if ( clipA.Lock() ) - { - clipA.Unlock(); - } + uint32 oldCount = clipA.SystemCount(); - CHK(clipA.LocalCount() == 1); - CHK(clipB.LocalCount() == 1); + CHK(clipB.Lock()); + clipB.Clear(); + if ((data = clipB.Data())) { + data->AddData("text/plain", B_MIME_TYPE, "LocalCount3", 12); + clipB.Commit(); + } + clipB.Unlock(); + + CHK(clipA.Lock()); + clipA.Unlock(); + + CHK(clipA.LocalCount() == oldCount + 1); + CHK(clipB.LocalCount() == oldCount + 1); } /* LocalCount() @case 4 - @results clipA.LocalCount() == 1 - clipB.LocalCount() == 2 + @results clipA.LocalCount() == +1 + clipB.LocalCount() == +2 */ void CountTester::LocalCount4() { - BApplication app("application/x-vnd.clipboardtest"); - BClipboard clipA("LocalCount4"); - BClipboard clipB("LocalCount4"); - BMessage *data; + BApplication app("application/x-vnd.clipboardtest"); + BClipboard clipA("LocalCount4"); + BClipboard clipB("LocalCount4"); + BMessage *data; - if ( clipB.Lock() ) - { - clipB.Clear(); - if ( (data = clipB.Data()) ) - { - data->AddData("text/plain",B_MIME_TYPE,"LocalCount4",12); - clipB.Commit(); - } - clipB.Unlock(); - } - if ( clipA.Lock() ) - { - clipA.Unlock(); - } - if ( clipB.Lock() ) - { - clipB.Clear(); - if ( (data = clipB.Data()) ) - { - data->AddData("text/plain",B_MIME_TYPE,"LocalCount4",12); - clipB.Commit(); - } - clipB.Unlock(); - } + uint32 oldCount = clipA.SystemCount(); - CHK(clipA.LocalCount() == 1); - CHK(clipB.LocalCount() == 2); + if (clipB.Lock()) { + clipB.Clear(); + if ((data = clipB.Data())) { + data->AddData("text/plain", B_MIME_TYPE, "LocalCount4", 12); + clipB.Commit(); + } + clipB.Unlock(); + } + + if (clipA.Lock()) + clipA.Unlock(); + + if (clipB.Lock()) { + clipB.Clear(); + if ((data = clipB.Data())) { + data->AddData("text/plain",B_MIME_TYPE,"LocalCount4",12); + clipB.Commit(); + } + clipB.Unlock(); + } + + CHK(clipA.LocalCount() == oldCount + 1); + CHK(clipB.LocalCount() == oldCount + 2); } /* LocalCount() @case 5 - @results clipA.LocalCount() == 1 + @results clipA.LocalCount() == 1 clipB.LocalCount() == 2 */ void CountTester::LocalCount5() { - BApplication app("application/x-vnd.clipboardtest"); - BClipboard clipA("LocalCount5"); - BClipboard clipB("LocalCount5"); - BMessage *data; + BApplication app("application/x-vnd.clipboardtest"); + BClipboard clipA("LocalCount5"); + BClipboard clipB("LocalCount5"); + BMessage *data; - if ( clipA.Lock() ) - { - clipA.Clear(); - if ( (data = clipA.Data()) ) - { - data->AddData("text/plain",B_MIME_TYPE,"LocalCount5",12); - clipA.Commit(); - } - clipA.Unlock(); - } - if ( clipB.Lock() ) - { - clipB.Clear(); - if ( (data = clipB.Data()) ) - { - data->AddData("text/plain",B_MIME_TYPE,"LocalCount5",12); - clipB.Commit(); - } - clipB.Unlock(); - } + uint32 oldCount = clipA.SystemCount(); - CHK(clipA.LocalCount() == 1); - CHK(clipB.LocalCount() == 2); + if (clipA.Lock()) { + clipA.Clear(); + if ((data = clipA.Data())) { + data->AddData("text/plain", B_MIME_TYPE, "LocalCount5", 12); + clipA.Commit(); + } + clipA.Unlock(); + } + + if (clipB.Lock()) { + clipB.Clear(); + if ((data = clipB.Data())) { + data->AddData("text/plain", B_MIME_TYPE, "LocalCount5", 12); + clipB.Commit(); + } + clipB.Unlock(); + } + + CHK(clipA.LocalCount() == oldCount + 1); + CHK(clipB.LocalCount() == oldCount + 2); } /* LocalCount() @case 6 - @results clipA.LocalCount() == 1 + @results clipA.LocalCount() == +1 clipB.LocalCount() == 0 */ void CountTester::LocalCount6() { - BApplication app("application/x-vnd.clipboardtest"); - BClipboard clipA("LocalCount6A"); - BClipboard clipB("LocalCount6B"); - BMessage *data; + BApplication app("application/x-vnd.clipboardtest"); + BClipboard clipA("LocalCount6A"); + BClipboard clipB("LocalCount6B"); + BMessage *data; - if ( clipA.Lock() ) - { - clipA.Clear(); - if ( (data = clipA.Data()) ) - { - data->AddData("text/plain",B_MIME_TYPE,"LocalCount6",12); - clipA.Commit(); - } - clipA.Unlock(); - } - if ( clipB.Lock() ) - { - clipB.Unlock(); - } + uint32 oldCount = clipA.SystemCount(); - CHK(clipA.LocalCount() == 1); - CHK(clipB.LocalCount() == 0); + if (clipA.Lock()) { + clipA.Clear(); + if ((data = clipA.Data())) { + data->AddData("text/plain", B_MIME_TYPE, "LocalCount6" ,12); + clipA.Commit(); + } + clipA.Unlock(); + } + + if (clipB.Lock()) + clipB.Unlock(); + + CHK(clipA.LocalCount() == oldCount + 1); + CHK(clipB.LocalCount() == 0); } /* @@ -210,66 +204,66 @@ void CountTester::LocalCount6() */ void CountTester::SystemCount1() { - BApplication app("application/x-vnd.clipboardtest"); - BClipboard clip("SystemCount1"); + BApplication app("application/x-vnd.clipboardtest"); + BClipboard clip("SystemCount1"); - CHK(clip.SystemCount() == 0); + CHK(clip.SystemCount() == 0); } /* SystemCount() @case 2 - @results clipA.SystemCount() == 1 - clipB.SystemCount() == 1 + @results clipA.SystemCount() == +1 + clipB.SystemCount() == +1 */ void CountTester::SystemCount2() { - BApplication app("application/x-vnd.clipboardtest"); - BClipboard clipA("SystemCount2"); - BClipboard clipB("SystemCount2"); - BMessage *data; + BApplication app("application/x-vnd.clipboardtest"); + BClipboard clipA("SystemCount2"); + BClipboard clipB("SystemCount2"); + BMessage *data; - if ( clipA.Lock() ) - { - clipA.Clear(); - if ( (data = clipA.Data()) ) - { - data->AddData("text/plain",B_MIME_TYPE,"SystemCount2",12); - clipA.Commit(); - } - clipA.Unlock(); - } + uint32 oldCount = clipA.SystemCount(); - CHK(clipA.SystemCount() == 1); - CHK(clipB.SystemCount() == 1); + if (clipA.Lock()) { + clipA.Clear(); + if ((data = clipA.Data())) { + data->AddData("text/plain", B_MIME_TYPE, "SystemCount2", 12); + clipA.Commit(); + } + clipA.Unlock(); + } + + CHK(clipA.SystemCount() == oldCount + 1); + CHK(clipB.SystemCount() == oldCount + 1); } /* SystemCount() @case 3 - @results clipA.SystemCount() == 1 + @results clipA.SystemCount() == +1 clipB.SystemCount() == 0 */ void CountTester::SystemCount3() { - BApplication app("application/x-vnd.clipboardtest"); - BClipboard clipA("SystemCount3A"); - BClipboard clipB("SystemCount3B"); - BMessage *data; + BApplication app("application/x-vnd.clipboardtest"); + BClipboard clipA("SystemCount3A"); + BClipboard clipB("SystemCount3B"); + BMessage *data; - if ( clipA.Lock() ) - { - clipA.Clear(); - if ( (data = clipA.Data()) ) - { - data->AddData("text/plain",B_MIME_TYPE,"SystemCount3",12); - clipA.Commit(); - } - clipA.Unlock(); - } + uint32 oldCount = clipA.SystemCount(); - CHK(clipA.SystemCount() == 1); - CHK(clipB.SystemCount() == 0); + if (clipA.Lock()) { + clipA.Clear(); + if ((data = clipA.Data())) { + data->AddData("text/plain", B_MIME_TYPE, "SystemCount3", 12); + clipA.Commit(); + } + clipA.Unlock(); + } + + CHK(clipA.SystemCount() == oldCount + 1); + CHK(clipB.SystemCount() == 0); } Test* CountTester::Suite() @@ -288,6 +282,3 @@ Test* CountTester::Suite() return SuiteOfTests; } - - -