diff --git a/src/tests/servers/app/Jamfile b/src/tests/servers/app/Jamfile index 735bc37813..caf768b770 100644 --- a/src/tests/servers/app/Jamfile +++ b/src/tests/servers/app/Jamfile @@ -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 ; diff --git a/src/tests/servers/app/stress_test/Jamfile b/src/tests/servers/app/stress_test/Jamfile new file mode 100644 index 0000000000..aa0f6d9e25 --- /dev/null +++ b/src/tests/servers/app/stress_test/Jamfile @@ -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 ; +} + diff --git a/src/tests/servers/app/stress_test/main.cpp b/src/tests/servers/app/stress_test/main.cpp new file mode 100644 index 0000000000..1fc1c8e13e --- /dev/null +++ b/src/tests/servers/app/stress_test/main.cpp @@ -0,0 +1,133 @@ +// main.cpp + +#include +#include +#include + +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; +} diff --git a/src/tests/servers/app/stress_test/run b/src/tests/servers/app/stress_test/run new file mode 100755 index 0000000000..2bbf1fa292 --- /dev/null +++ b/src/tests/servers/app/stress_test/run @@ -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 +