add a small test that stress tests window creation and destruction
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16721 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
df29904e48
commit
e7df4a4829
@ -20,8 +20,8 @@ UseFreeTypeHeaders ;
|
||||
local defines = [ FDefines TEST_MODE=1 ] ;
|
||||
# USE_DIRECT_WINDOW_TEST_MODE=1
|
||||
|
||||
SubDirCcFlags $(defines) ; # -fcheck-memory-usage -D_NO_INLINE_ASM ;
|
||||
SubDirC++Flags $(defines) ; #-fcheck-memory-usage -D_NO_INLINE_ASM ;
|
||||
SubDirCcFlags $(defines) ; # -fcheck-memory-usage -finstrument-functions -D_NO_INLINE_ASM ;
|
||||
SubDirC++Flags $(defines) ; #-fcheck-memory-usage -finstrument-functions -D_NO_INLINE_ASM ;
|
||||
|
||||
SEARCH_SOURCE += $(appServerDir) [ FDirName $(appServerDir) drawing ] ;
|
||||
|
||||
@ -151,6 +151,7 @@ SubInclude HAIKU_TOP src tests servers app painter ;
|
||||
SubInclude HAIKU_TOP src tests servers app playground ;
|
||||
SubInclude HAIKU_TOP src tests servers app resize_limits ;
|
||||
SubInclude HAIKU_TOP src tests servers app scrolling ;
|
||||
SubInclude HAIKU_TOP src tests servers app stress_test ;
|
||||
SubInclude HAIKU_TOP src tests servers app textview ;
|
||||
SubInclude HAIKU_TOP src tests servers app regularapps ;
|
||||
SubInclude HAIKU_TOP src tests servers app view_state ;
|
||||
|
18
src/tests/servers/app/stress_test/Jamfile
Normal file
18
src/tests/servers/app/stress_test/Jamfile
Normal file
@ -0,0 +1,18 @@
|
||||
SubDir HAIKU_TOP src tests servers app stress_test ;
|
||||
|
||||
SetSubDirSupportedPlatformsBeOSCompatible ;
|
||||
AddSubDirSupportedPlatforms libbe_test ;
|
||||
|
||||
UseHeaders [ FDirName os app ] ;
|
||||
UseHeaders [ FDirName os interface ] ;
|
||||
|
||||
Application StressTest :
|
||||
main.cpp
|
||||
: be
|
||||
;
|
||||
|
||||
if ( $(TARGET_PLATFORM) = libbe_test ) {
|
||||
HaikuInstall install-test-apps : $(HAIKU_APP_TEST_DIR) : StressTest
|
||||
: tests!apps ;
|
||||
}
|
||||
|
133
src/tests/servers/app/stress_test/main.cpp
Normal file
133
src/tests/servers/app/stress_test/main.cpp
Normal file
@ -0,0 +1,133 @@
|
||||
// main.cpp
|
||||
|
||||
#include <Application.h>
|
||||
#include <MessageRunner.h>
|
||||
#include <Window.h>
|
||||
|
||||
enum {
|
||||
TEST_MANY_WINDOWS = 0,
|
||||
TEST_SINGLE_WINDOW,
|
||||
};
|
||||
|
||||
class TestApp : public BApplication {
|
||||
public:
|
||||
TestApp(uint32 testMode);
|
||||
virtual ~TestApp();
|
||||
|
||||
virtual void ReadyToRun();
|
||||
virtual void MessageReceived(BMessage* message);
|
||||
|
||||
private:
|
||||
BMessageRunner* fPulse;
|
||||
BRect fFrame;
|
||||
BRect fScreenFrame;
|
||||
BWindow* fWindow;
|
||||
uint32 fTestMode;
|
||||
};
|
||||
|
||||
|
||||
class TestWindow : public BWindow {
|
||||
public:
|
||||
TestWindow(BRect frame);
|
||||
virtual ~TestWindow();
|
||||
|
||||
private:
|
||||
BMessageRunner* fPulse;
|
||||
};
|
||||
|
||||
|
||||
TestApp::TestApp(uint32 testMode)
|
||||
: BApplication("application/x.vnd-Haiku.stress-test"),
|
||||
fPulse(NULL),
|
||||
fFrame(10.0, 30.0, 150.0, 100.0),
|
||||
fScreenFrame(0.0, 0.0, 640.0, 480.0),
|
||||
fTestMode(testMode)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
TestApp::~TestApp()
|
||||
{
|
||||
delete fPulse;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TestApp::ReadyToRun()
|
||||
{
|
||||
fPulse = new BMessageRunner(be_app_messenger, new BMessage('tick'), 100L);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TestApp::MessageReceived(BMessage* message)
|
||||
{
|
||||
switch (message->what) {
|
||||
case 'tick':
|
||||
switch (fTestMode) {
|
||||
case TEST_MANY_WINDOWS:
|
||||
fFrame.OffsetBy(10.0, 0.0);
|
||||
if (fFrame.right > fScreenFrame.right) {
|
||||
// next row
|
||||
fFrame.OffsetTo(10.0, fFrame.top + 10.0);
|
||||
}
|
||||
if (fFrame.bottom > fScreenFrame.bottom) {
|
||||
// back to top
|
||||
fFrame.OffsetTo(10.0, 30.0);
|
||||
}
|
||||
new TestWindow(fFrame);
|
||||
break;
|
||||
case TEST_SINGLE_WINDOW:
|
||||
if (fWindow) {
|
||||
fWindow->Lock();
|
||||
fWindow->Quit();
|
||||
}
|
||||
fWindow = new BWindow(fFrame, "Test", B_TITLED_WINDOW, 0);
|
||||
fWindow->Show();
|
||||
break;
|
||||
default:
|
||||
PostMessage(B_QUIT_REQUESTED);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
BApplication::MessageReceived(message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
TestWindow::TestWindow(BRect frame)
|
||||
: BWindow(frame, "Test", B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS)
|
||||
{
|
||||
Show();
|
||||
|
||||
BMessenger self(this);
|
||||
fPulse = new BMessageRunner(self, new BMessage(B_QUIT_REQUESTED), 10000000, 1);
|
||||
}
|
||||
|
||||
|
||||
TestWindow::~TestWindow()
|
||||
{
|
||||
delete fPulse;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// main
|
||||
int
|
||||
main(int argc, char** argv)
|
||||
{
|
||||
uint32 testMode = TEST_SINGLE_WINDOW;
|
||||
|
||||
if (argc > 1) {
|
||||
if (strcmp(argv[1], "-many") == 0)
|
||||
testMode = TEST_MANY_WINDOWS;
|
||||
else if (strcmp(argv[1], "-single") == 0)
|
||||
testMode = TEST_SINGLE_WINDOW;
|
||||
}
|
||||
|
||||
TestApp app(testMode);
|
||||
app.Run();
|
||||
|
||||
return 0;
|
||||
}
|
24
src/tests/servers/app/stress_test/run
Executable file
24
src/tests/servers/app/stress_test/run
Executable file
@ -0,0 +1,24 @@
|
||||
#!/bin/sh
|
||||
|
||||
../../../../../generated/tests/apps/run_haiku_registrar || exit
|
||||
|
||||
if test -f ../../../../../generated/tests/apps/haiku_app_server; then
|
||||
../../../../../generated/tests/apps/haiku_app_server &
|
||||
else
|
||||
echo "You need to \"TARGET_PLATFORM=libbe_test jam install-test-apps\" first."
|
||||
fi
|
||||
|
||||
sleep 1s
|
||||
|
||||
#if test -f ../../../../../generated/tests/apps/MiniTerminal; then
|
||||
# ../../../../../generated/tests/apps/MiniTerminal &
|
||||
#else
|
||||
# echo "You need to \"TARGET_PLATFORM=r5 jam install-test-apps\" first."
|
||||
#fi
|
||||
|
||||
if test -f ../../../../../generated/tests/apps/StressTest; then
|
||||
../../../../../generated/tests/apps/StressTest
|
||||
else
|
||||
echo "You need to \"TARGET_PLATFORM=libbe_test jam install-test-apps\" first."
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user