* 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
This commit is contained in:
Ingo Weinhold 2005-01-13 00:48:38 +00:00
parent 58b5124e46
commit caf19c8b0a

View File

@ -38,7 +38,7 @@ void CountTester::LocalCount1()
/* /*
LocalCount() LocalCount()
@case 2 @case 2
@results count == 1 @results count == +1
*/ */
void CountTester::LocalCount2() void CountTester::LocalCount2()
{ {
@ -46,24 +46,24 @@ void CountTester::LocalCount2()
BClipboard clip("LocalCount2"); BClipboard clip("LocalCount2");
BMessage *data; BMessage *data;
if ( clip.Lock() ) uint32 oldCount = clip.SystemCount();
{
if (clip.Lock()) {
clip.Clear(); clip.Clear();
if ( (data = clip.Data()) ) if ((data = clip.Data())) {
{
data->AddData("text/plain", B_MIME_TYPE, "LocalCount2", 12); data->AddData("text/plain", B_MIME_TYPE, "LocalCount2", 12);
clip.Commit(); clip.Commit();
} }
clip.Unlock(); clip.Unlock();
} }
CHK(clip.LocalCount() == 1); CHK(clip.LocalCount() == oldCount + 1);
} }
/* /*
LocalCount() LocalCount()
@case 3 @case 3
@results both counts == 1 @results both counts == +1
*/ */
void CountTester::LocalCount3() void CountTester::LocalCount3()
{ {
@ -72,30 +72,28 @@ void CountTester::LocalCount3()
BClipboard clipB("LocalCount3"); BClipboard clipB("LocalCount3");
BMessage *data; BMessage *data;
if ( clipB.Lock() ) uint32 oldCount = clipA.SystemCount();
{
CHK(clipB.Lock());
clipB.Clear(); clipB.Clear();
if ( (data = clipB.Data()) ) if ((data = clipB.Data())) {
{
data->AddData("text/plain", B_MIME_TYPE, "LocalCount3", 12); data->AddData("text/plain", B_MIME_TYPE, "LocalCount3", 12);
clipB.Commit(); clipB.Commit();
} }
clipB.Unlock(); clipB.Unlock();
}
if ( clipA.Lock() )
{
clipA.Unlock();
}
CHK(clipA.LocalCount() == 1); CHK(clipA.Lock());
CHK(clipB.LocalCount() == 1); clipA.Unlock();
CHK(clipA.LocalCount() == oldCount + 1);
CHK(clipB.LocalCount() == oldCount + 1);
} }
/* /*
LocalCount() LocalCount()
@case 4 @case 4
@results clipA.LocalCount() == 1 @results clipA.LocalCount() == +1
clipB.LocalCount() == 2 clipB.LocalCount() == +2
*/ */
void CountTester::LocalCount4() void CountTester::LocalCount4()
{ {
@ -104,33 +102,31 @@ void CountTester::LocalCount4()
BClipboard clipB("LocalCount4"); BClipboard clipB("LocalCount4");
BMessage *data; BMessage *data;
if ( clipB.Lock() ) uint32 oldCount = clipA.SystemCount();
{
if (clipB.Lock()) {
clipB.Clear(); clipB.Clear();
if ( (data = clipB.Data()) ) 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); data->AddData("text/plain", B_MIME_TYPE, "LocalCount4", 12);
clipB.Commit(); clipB.Commit();
} }
clipB.Unlock(); clipB.Unlock();
} }
CHK(clipA.LocalCount() == 1); if (clipA.Lock())
CHK(clipB.LocalCount() == 2); 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);
} }
/* /*
@ -146,35 +142,34 @@ void CountTester::LocalCount5()
BClipboard clipB("LocalCount5"); BClipboard clipB("LocalCount5");
BMessage *data; BMessage *data;
if ( clipA.Lock() ) uint32 oldCount = clipA.SystemCount();
{
if (clipA.Lock()) {
clipA.Clear(); clipA.Clear();
if ( (data = clipA.Data()) ) if ((data = clipA.Data())) {
{
data->AddData("text/plain", B_MIME_TYPE, "LocalCount5", 12); data->AddData("text/plain", B_MIME_TYPE, "LocalCount5", 12);
clipA.Commit(); clipA.Commit();
} }
clipA.Unlock(); clipA.Unlock();
} }
if ( clipB.Lock() )
{ if (clipB.Lock()) {
clipB.Clear(); clipB.Clear();
if ( (data = clipB.Data()) ) if ((data = clipB.Data())) {
{
data->AddData("text/plain", B_MIME_TYPE, "LocalCount5", 12); data->AddData("text/plain", B_MIME_TYPE, "LocalCount5", 12);
clipB.Commit(); clipB.Commit();
} }
clipB.Unlock(); clipB.Unlock();
} }
CHK(clipA.LocalCount() == 1); CHK(clipA.LocalCount() == oldCount + 1);
CHK(clipB.LocalCount() == 2); CHK(clipB.LocalCount() == oldCount + 2);
} }
/* /*
LocalCount() LocalCount()
@case 6 @case 6
@results clipA.LocalCount() == 1 @results clipA.LocalCount() == +1
clipB.LocalCount() == 0 clipB.LocalCount() == 0
*/ */
void CountTester::LocalCount6() void CountTester::LocalCount6()
@ -184,22 +179,21 @@ void CountTester::LocalCount6()
BClipboard clipB("LocalCount6B"); BClipboard clipB("LocalCount6B");
BMessage *data; BMessage *data;
if ( clipA.Lock() ) uint32 oldCount = clipA.SystemCount();
{
if (clipA.Lock()) {
clipA.Clear(); clipA.Clear();
if ( (data = clipA.Data()) ) if ((data = clipA.Data())) {
{
data->AddData("text/plain", B_MIME_TYPE, "LocalCount6" ,12); data->AddData("text/plain", B_MIME_TYPE, "LocalCount6" ,12);
clipA.Commit(); clipA.Commit();
} }
clipA.Unlock(); clipA.Unlock();
} }
if ( clipB.Lock() )
{
clipB.Unlock();
}
CHK(clipA.LocalCount() == 1); if (clipB.Lock())
clipB.Unlock();
CHK(clipA.LocalCount() == oldCount + 1);
CHK(clipB.LocalCount() == 0); CHK(clipB.LocalCount() == 0);
} }
@ -219,8 +213,8 @@ void CountTester::SystemCount1()
/* /*
SystemCount() SystemCount()
@case 2 @case 2
@results clipA.SystemCount() == 1 @results clipA.SystemCount() == +1
clipB.SystemCount() == 1 clipB.SystemCount() == +1
*/ */
void CountTester::SystemCount2() void CountTester::SystemCount2()
{ {
@ -229,25 +223,25 @@ void CountTester::SystemCount2()
BClipboard clipB("SystemCount2"); BClipboard clipB("SystemCount2");
BMessage *data; BMessage *data;
if ( clipA.Lock() ) uint32 oldCount = clipA.SystemCount();
{
if (clipA.Lock()) {
clipA.Clear(); clipA.Clear();
if ( (data = clipA.Data()) ) if ((data = clipA.Data())) {
{
data->AddData("text/plain", B_MIME_TYPE, "SystemCount2", 12); data->AddData("text/plain", B_MIME_TYPE, "SystemCount2", 12);
clipA.Commit(); clipA.Commit();
} }
clipA.Unlock(); clipA.Unlock();
} }
CHK(clipA.SystemCount() == 1); CHK(clipA.SystemCount() == oldCount + 1);
CHK(clipB.SystemCount() == 1); CHK(clipB.SystemCount() == oldCount + 1);
} }
/* /*
SystemCount() SystemCount()
@case 3 @case 3
@results clipA.SystemCount() == 1 @results clipA.SystemCount() == +1
clipB.SystemCount() == 0 clipB.SystemCount() == 0
*/ */
void CountTester::SystemCount3() void CountTester::SystemCount3()
@ -257,18 +251,18 @@ void CountTester::SystemCount3()
BClipboard clipB("SystemCount3B"); BClipboard clipB("SystemCount3B");
BMessage *data; BMessage *data;
if ( clipA.Lock() ) uint32 oldCount = clipA.SystemCount();
{
if (clipA.Lock()) {
clipA.Clear(); clipA.Clear();
if ( (data = clipA.Data()) ) if ((data = clipA.Data())) {
{
data->AddData("text/plain", B_MIME_TYPE, "SystemCount3", 12); data->AddData("text/plain", B_MIME_TYPE, "SystemCount3", 12);
clipA.Commit(); clipA.Commit();
} }
clipA.Unlock(); clipA.Unlock();
} }
CHK(clipA.SystemCount() == 1); CHK(clipA.SystemCount() == oldCount + 1);
CHK(clipB.SystemCount() == 0); CHK(clipB.SystemCount() == 0);
} }
@ -288,6 +282,3 @@ Test* CountTester::Suite()
return SuiteOfTests; return SuiteOfTests;
} }