Add an app server test for stack&tile

Should help with debugging #8569.
This commit is contained in:
Adrien Destugues 2014-10-29 19:35:04 +01:00
parent dfb13a8716
commit afc5d438a7
3 changed files with 132 additions and 0 deletions

View File

@ -244,6 +244,7 @@ SubInclude HAIKU_TOP src tests servers app resize_limits ;
SubInclude HAIKU_TOP src tests servers app scrollbar ;
SubInclude HAIKU_TOP src tests servers app scrolling ;
SubInclude HAIKU_TOP src tests servers app shape_test ;
SubInclude HAIKU_TOP src tests servers app stacktile ;
SubInclude HAIKU_TOP src tests servers app statusbar ;
SubInclude HAIKU_TOP src tests servers app stress_test ;
SubInclude HAIKU_TOP src tests servers app textview ;

View File

@ -0,0 +1,19 @@
SubDir HAIKU_TOP src tests servers app stacktile ;
SetSubDirSupportedPlatformsBeOSCompatible ;
AddSubDirSupportedPlatforms libbe_test ;
UseHeaders [ FDirName $(HAIKU_TOP) os app ] ;
UseHeaders [ FDirName $(HAIKU_TOP) os interface ] ;
UsePrivateHeaders interface ;
Application StackTileTest :
main.cpp
: [ TargetLibstdc++ ] be
;
if ( $(TARGET_PLATFORM) = libbe_test ) {
HaikuInstall install-test-apps : $(HAIKU_APP_TEST_DIR) : StackTileTest
: tests!apps ;
}

View File

@ -0,0 +1,112 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <Application.h>
#include <OS.h>
#include <Window.h>
#include <WindowStack.h>
static BRect* sFrames = NULL;
static uint32 sNumFrames = 0;
class TestApp : public BApplication {
public:
TestApp(uint32 numWindows);
virtual ~TestApp();
private:
void _CreateFrames(uint32 numWindows);
int32 _WindowCreator();
static int32 _ThreadStarter(void* data);
private:
uint32 fFrameNum;
uint32 fNumWindows;
uint32 fMaxWindows;
};
class TestWindow : public BWindow {
public:
TestWindow(BRect frame);
virtual ~TestWindow();
virtual void DispatchMessage(BMessage* message, BHandler* handler);
};
TestApp::TestApp(uint32 numWindows)
:
BApplication("application/x.vnd-Haiku.stack-tile"),
fNumWindows(0),
fMaxWindows(numWindows)
{
_CreateFrames(numWindows);
}
TestApp::~TestApp()
{
delete[] sFrames;
}
void
TestApp::_CreateFrames(uint32 numWindows)
{
BWindowStack* stack = NULL;
while (fNumWindows < fMaxWindows) {
if (fFrameNum >= sNumFrames)
fFrameNum = 0;
BWindow* window = new TestWindow(BRect(20, 20, 300, 200));
if (!stack) stack = new BWindowStack(window);
else stack->AddWindow(window);
window->Show();
fNumWindows++;
}
}
TestWindow::TestWindow(BRect frame)
:
BWindow(frame, "Test", B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS)
{
}
TestWindow::~TestWindow()
{
}
void
TestWindow::DispatchMessage(BMessage* message, BHandler* handler)
{
BWindow::DispatchMessage(message, handler);
int a = rand();
char buf[32];
sprintf(buf, "%d", a);
SetTitle(buf);
}
int
main(int argc, char** argv)
{
uint32 numWindows = 2;
if (argc > 1)
numWindows = atoi(argv[1]);
TestApp app(numWindows);
app.Run();
return 0;
}