Add an app server test for stack&tile
Should help with debugging #8569.
This commit is contained in:
parent
dfb13a8716
commit
afc5d438a7
@ -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 ;
|
||||
|
19
src/tests/servers/app/stacktile/Jamfile
Normal file
19
src/tests/servers/app/stacktile/Jamfile
Normal 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 ;
|
||||
}
|
||||
|
112
src/tests/servers/app/stacktile/main.cpp
Normal file
112
src/tests/servers/app/stacktile/main.cpp
Normal 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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user