Added test for BWindow::FindView(BPoint).

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28495 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus 2008-11-04 14:47:18 +00:00
parent a5a4ec57c5
commit 5ae0bbaad0
4 changed files with 120 additions and 0 deletions

View File

@ -173,6 +173,7 @@ SubInclude HAIKU_TOP src tests servers app draw_after_children ;
SubInclude HAIKU_TOP src tests servers app drawing_debugger ;
SubInclude HAIKU_TOP src tests servers app drawing_modes ;
SubInclude HAIKU_TOP src tests servers app event_mask ;
SubInclude HAIKU_TOP src tests servers app find_view ;
SubInclude HAIKU_TOP src tests servers app following ;
SubInclude HAIKU_TOP src tests servers app idle_test ;
SubInclude HAIKU_TOP src tests servers app lagging_get_mouse ;

View File

@ -0,0 +1,83 @@
/*
* Copyright 2008, Stephan Aßmus <superstippi@gmx.de>
* Distributed under the terms of the MIT License.
*/
#include <Application.h>
#include <Window.h>
#include <View.h>
#include <stdio.h>
class View : public BView {
public:
View(BRect rect, const char* name, uint32 followMode,
uint8 red, uint8 green, uint8 blue)
: BView(rect, name, followMode, 0)
{
SetViewColor(red, green, blue);
}
};
class TestView : public View {
public:
TestView(BRect rect, const char* name, uint32 followMode,
uint8 red, uint8 green, uint8 blue)
: View(rect, name, followMode, red, green, blue)
{
SetEventMask(B_POINTER_EVENTS, B_NO_POINTER_HISTORY);
}
virtual void MouseMoved(BPoint where, uint32 transit,
const BMessage* dragMessage)
{
ConvertToScreen(&where);
where -= Window()->Frame().LeftTop();
BView* view = Window()->FindView(where);
printf("View at (%.1f, %.1f): %s\n", where.x, where.y,
view ? view->Name() : "NULL");
}
};
// #pragma mark -
int
main(int argc, char **argv)
{
BApplication app("application/x-vnd.haiku-find_view");
BWindow* window = new BWindow(BRect(100, 100, 400, 400),
"ViewTransit-Test", B_TITLED_WINDOW,
B_ASYNCHRONOUS_CONTROLS | B_QUIT_ON_WINDOW_CLOSE);
// TestView
BRect frame = window->Bounds();
View* testView = new TestView(frame, "Test View", B_FOLLOW_ALL, 255, 0, 0);
window->AddChild(testView);
// View 1
frame.InsetBy(20, 20);
frame.right /= 2;
View* view1 = new View(frame, "View 1",
B_FOLLOW_TOP_BOTTOM | B_FOLLOW_RIGHT, 0, 255, 0);
testView->AddChild(view1);
// View 2
frame.left = frame.right + 1;
frame.right = window->Bounds().right - 20;
View* view2 = new View(frame, "View 2",
B_FOLLOW_TOP_BOTTOM | B_FOLLOW_RIGHT, 0, 0, 255);
testView->AddChild(view2);
view2->Hide();
window->Show();
app.Run();
return 0;
}

View File

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

View File

@ -0,0 +1,18 @@
#!/bin/sh
../../../../../generated/tests/libbe_test/x86/apps/run_haiku_registrar || exit
if test -f ../../../../../generated/tests/libbe_test/x86/apps/haiku_app_server; then
../../../../../generated/tests/libbe_test/x86/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/libbe_test/x86/apps/FindView; then
../../../../../generated/tests/libbe_test/x86/apps/FindView
else
echo "You need to \"TARGET_PLATFORM=libbe_test jam install-test-apps\" first."
fi