Minor tweaks and finish StartWatching test
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1906 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -8,28 +8,28 @@ case 2: name points to valid string =>
|
||||
|
||||
status_t Clear(void)
|
||||
case 1: BClipboard not locked =>
|
||||
return B_ERROR
|
||||
return B_ERROR (R5 segfaults)
|
||||
case 2: BClipboard is locked =>
|
||||
return B_OK
|
||||
Data() returns an empty message
|
||||
|
||||
status_t Commit(void)
|
||||
case 1: BClipboard not locked =>
|
||||
return B_ERROR
|
||||
return B_ERROR (R5 segfaults)
|
||||
case 2: BClipboard is locked =>
|
||||
return B_OK
|
||||
data is uploaded to system
|
||||
|
||||
status_t Revert(void)
|
||||
case 1: BClipboard not locked =>
|
||||
return B_ERROR
|
||||
return B_ERROR (R5 segfaults)
|
||||
case 2: BClipboard is locked =>
|
||||
return B_OK
|
||||
message returned by Data() is reset to value acquired on Lock()
|
||||
|
||||
BMessage *Data(void) const
|
||||
case 1: BClipboard not locked =>
|
||||
return NULL
|
||||
return NULL (R5 segfaults)
|
||||
case 2: BClipboard is locked =>
|
||||
returns a BMessage containing correct data
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <string.h>
|
||||
|
||||
// System Includes -------------------------------------------------------------
|
||||
#include <Application.h>
|
||||
#include <Clipboard.h>
|
||||
|
||||
#define CHK CPPUNIT_ASSERT
|
||||
@@ -29,6 +30,7 @@
|
||||
*/
|
||||
void BClipboardTester::BClipboard1()
|
||||
{
|
||||
BApplication app("application/x-vnd.clipboardtest");
|
||||
#ifdef TEST_R5
|
||||
CHK(false);
|
||||
#endif
|
||||
@@ -43,6 +45,7 @@ void BClipboardTester::BClipboard1()
|
||||
*/
|
||||
void BClipboardTester::BClipboard2()
|
||||
{
|
||||
BApplication app("application/x-vnd.clipboardtest");
|
||||
char name[18] = "BClipboard Case 2";
|
||||
BClipboard clip(name);
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
// Standard Includes -----------------------------------------------------------
|
||||
|
||||
// System Includes -------------------------------------------------------------
|
||||
#include <Application.h>
|
||||
#include <Clipboard.h>
|
||||
|
||||
#define CHK CPPUNIT_ASSERT
|
||||
@@ -28,6 +29,7 @@
|
||||
*/
|
||||
void CountTester::LocalCount1()
|
||||
{
|
||||
BApplication app("application/x-vnd.clipboardtest");
|
||||
BClipboard clip("LocalCount1");
|
||||
|
||||
CHK(clip.LocalCount() == 0);
|
||||
@@ -40,6 +42,7 @@ void CountTester::LocalCount1()
|
||||
*/
|
||||
void CountTester::LocalCount2()
|
||||
{
|
||||
BApplication app("application/x-vnd.clipboardtest");
|
||||
BClipboard clip("LocalCount2");
|
||||
BMessage *data;
|
||||
|
||||
@@ -64,6 +67,7 @@ void CountTester::LocalCount2()
|
||||
*/
|
||||
void CountTester::LocalCount3()
|
||||
{
|
||||
BApplication app("application/x-vnd.clipboardtest");
|
||||
BClipboard clipA("LocalCount3");
|
||||
BClipboard clipB("LocalCount3");
|
||||
BMessage *data;
|
||||
@@ -95,6 +99,7 @@ void CountTester::LocalCount3()
|
||||
*/
|
||||
void CountTester::LocalCount4()
|
||||
{
|
||||
BApplication app("application/x-vnd.clipboardtest");
|
||||
BClipboard clipA("LocalCount4");
|
||||
BClipboard clipB("LocalCount4");
|
||||
BMessage *data;
|
||||
@@ -136,6 +141,7 @@ void CountTester::LocalCount4()
|
||||
*/
|
||||
void CountTester::LocalCount5()
|
||||
{
|
||||
BApplication app("application/x-vnd.clipboardtest");
|
||||
BClipboard clipA("LocalCount5");
|
||||
BClipboard clipB("LocalCount5");
|
||||
BMessage *data;
|
||||
@@ -173,6 +179,7 @@ void CountTester::LocalCount5()
|
||||
*/
|
||||
void CountTester::LocalCount6()
|
||||
{
|
||||
BApplication app("application/x-vnd.clipboardtest");
|
||||
BClipboard clipA("LocalCount6A");
|
||||
BClipboard clipB("LocalCount6B");
|
||||
BMessage *data;
|
||||
@@ -203,6 +210,7 @@ void CountTester::LocalCount6()
|
||||
*/
|
||||
void CountTester::SystemCount1()
|
||||
{
|
||||
BApplication app("application/x-vnd.clipboardtest");
|
||||
BClipboard clip("SystemCount1");
|
||||
|
||||
CHK(clip.SystemCount() == 0);
|
||||
@@ -216,6 +224,7 @@ void CountTester::SystemCount1()
|
||||
*/
|
||||
void CountTester::SystemCount2()
|
||||
{
|
||||
BApplication app("application/x-vnd.clipboardtest");
|
||||
BClipboard clipA("SystemCount2");
|
||||
BClipboard clipB("SystemCount2");
|
||||
BMessage *data;
|
||||
@@ -243,6 +252,7 @@ void CountTester::SystemCount2()
|
||||
*/
|
||||
void CountTester::SystemCount3()
|
||||
{
|
||||
BApplication app("application/x-vnd.clipboardtest");
|
||||
BClipboard clipA("SystemCount3A");
|
||||
BClipboard clipB("SystemCount3B");
|
||||
BMessage *data;
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
// Standard Includes -----------------------------------------------------------
|
||||
|
||||
// System Includes -------------------------------------------------------------
|
||||
#include <Application.h>
|
||||
#include <Clipboard.h>
|
||||
|
||||
#define CHK CPPUNIT_ASSERT
|
||||
@@ -28,6 +29,7 @@
|
||||
*/
|
||||
void LockTester::Lock1()
|
||||
{
|
||||
BApplication app("application/x-vnd.clipboardtest");
|
||||
BClipboard clip("Lock1");
|
||||
|
||||
CHK(clip.Lock());
|
||||
@@ -37,7 +39,7 @@ static int32 LockTest2(void *data)
|
||||
{
|
||||
BClipboard *clip = (BClipboard *)data;
|
||||
clip->Lock();
|
||||
snooze(3000000); //Should be 3 seconds
|
||||
snooze(300000); //Should be .3 seconds
|
||||
delete clip;
|
||||
return 0;
|
||||
}
|
||||
@@ -48,21 +50,21 @@ static int32 LockTest2(void *data)
|
||||
*/
|
||||
void LockTester::Lock2()
|
||||
{
|
||||
CHK(false); // fail until I figure out why it is hanging
|
||||
BApplication app("application/x-vnd.clipboardtest");
|
||||
BClipboard *clip = new BClipboard("Lock2");
|
||||
|
||||
/* This method isn't guaranteed to work, but *should* work.
|
||||
Spawn a thread which locks the clipboard, waits several seconds
|
||||
Spawn a thread which locks the clipboard, waits .3 seconds
|
||||
and then deletes the locked clipboard. After spawning
|
||||
the thread, the main thread should keep checking if the clipboard
|
||||
is locked. Once it is locked, the thread tries to lock it and gets
|
||||
blocked. Once the clipboard is deleted, it should return false.
|
||||
the thread, the main thread waits .1 second. It then tries to
|
||||
lock the clipboard and gets blocked. Once the clipboard is deleted,
|
||||
it should return false.
|
||||
*/
|
||||
thread_id thread = spawn_thread(LockTest2,"locktest",B_NORMAL_PRIORITY,clip);
|
||||
|
||||
while(!clip->IsLocked());
|
||||
CHK(thread >= B_OK);
|
||||
resume_thread(thread);
|
||||
snooze(100000); //Should be .1 seconds
|
||||
CHK(clip->Lock() == false);
|
||||
kill_thread(thread);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -72,6 +74,7 @@ void LockTester::Lock2()
|
||||
*/
|
||||
void LockTester::IsLocked1()
|
||||
{
|
||||
BApplication app("application/x-vnd.clipboardtest");
|
||||
BClipboard clip("IsLocked1");
|
||||
|
||||
clip.Lock();
|
||||
@@ -85,6 +88,7 @@ void LockTester::IsLocked1()
|
||||
*/
|
||||
void LockTester::IsLocked2()
|
||||
{
|
||||
BApplication app("application/x-vnd.clipboardtest");
|
||||
BClipboard clip("IsLocked2");
|
||||
|
||||
CHK(!clip.IsLocked());
|
||||
@@ -97,6 +101,7 @@ void LockTester::IsLocked2()
|
||||
*/
|
||||
void LockTester::Unlock1()
|
||||
{
|
||||
BApplication app("application/x-vnd.clipboardtest");
|
||||
BClipboard clip("Unlock1");
|
||||
|
||||
clip.Lock();
|
||||
|
||||
@@ -41,7 +41,7 @@ void ReadWriteTester::Clear1()
|
||||
|
||||
/*
|
||||
status_t Clear()
|
||||
@case 1
|
||||
@case 2
|
||||
@results Clear() returns B_OK
|
||||
data message is empty
|
||||
*/
|
||||
@@ -297,7 +297,10 @@ void ReadWriteTester::StartWatching1()
|
||||
char *str;
|
||||
ssize_t size;
|
||||
|
||||
BLooper *looper = new BLooper();
|
||||
RWHandler handler;
|
||||
looper->AddHandler(&handler);
|
||||
looper->Run();
|
||||
BMessenger target(&handler);
|
||||
CHK(clip.StartWatching(target) == B_OK);
|
||||
if ( clip.Lock() )
|
||||
@@ -308,6 +311,9 @@ void ReadWriteTester::StartWatching1()
|
||||
clip.Commit();
|
||||
clip.Unlock();
|
||||
}
|
||||
snooze(100000);
|
||||
looper->Lock();
|
||||
looper->Quit();
|
||||
CHK(handler.ClipboardModified());
|
||||
clip.StopWatching(target);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user