From 5ae0bbaad06ffefc3176fa597e157a708002df7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Tue, 4 Nov 2008 14:47:18 +0000 Subject: [PATCH] Added test for BWindow::FindView(BPoint). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28495 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/tests/servers/app/Jamfile | 1 + src/tests/servers/app/find_view/FindView.cpp | 83 ++++++++++++++++++++ src/tests/servers/app/find_view/Jamfile | 18 +++++ src/tests/servers/app/find_view/run | 18 +++++ 4 files changed, 120 insertions(+) create mode 100644 src/tests/servers/app/find_view/FindView.cpp create mode 100644 src/tests/servers/app/find_view/Jamfile create mode 100755 src/tests/servers/app/find_view/run diff --git a/src/tests/servers/app/Jamfile b/src/tests/servers/app/Jamfile index 1def2c0d16..23817c880d 100644 --- a/src/tests/servers/app/Jamfile +++ b/src/tests/servers/app/Jamfile @@ -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 ; diff --git a/src/tests/servers/app/find_view/FindView.cpp b/src/tests/servers/app/find_view/FindView.cpp new file mode 100644 index 0000000000..f1f83d0a39 --- /dev/null +++ b/src/tests/servers/app/find_view/FindView.cpp @@ -0,0 +1,83 @@ +/* + * Copyright 2008, Stephan Aßmus + * Distributed under the terms of the MIT License. + */ + + +#include +#include +#include + +#include + + +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; +} diff --git a/src/tests/servers/app/find_view/Jamfile b/src/tests/servers/app/find_view/Jamfile new file mode 100644 index 0000000000..59590eff20 --- /dev/null +++ b/src/tests/servers/app/find_view/Jamfile @@ -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 ; +} + diff --git a/src/tests/servers/app/find_view/run b/src/tests/servers/app/find_view/run new file mode 100755 index 0000000000..d7977e1992 --- /dev/null +++ b/src/tests/servers/app/find_view/run @@ -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 +