hrev47552 adds 4 changesets to branch 'master' old head: c5f7461870dacc72c9556c35f082ec7fdd68d613 new head: 8fa91344458abb5f32303a7a3f9a1ecbd69bf111 overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=8fa9134+%5Ec5f7461 ---------------------------------------------------------------------------- c5ed108: Fix the test_app_server build. 15db992: Simple test harness for app_server tests This was developped for the transformations test, but can be used for other tests too. Extract the relevant classes to a separate file. 1f3acfa: Add a test for radial gradients. * This shows that the radius is ignored and all gradients are drwan with a radius of 100. 8fa9134: Draw radial gradients using the proper radius. [ Adrien Destugues <pulkomandy@xxxxxxxxxxxxx> ] ---------------------------------------------------------------------------- 11 files changed, 364 insertions(+), 204 deletions(-) src/servers/app/drawing/Painter/Painter.cpp | 11 +- src/servers/app/drawing/Painter/Painter.h | 3 +- src/tests/servers/app/Jamfile | 1 + src/tests/servers/app/gradients/Gradients.rdef | 17 ++ src/tests/servers/app/gradients/Jamfile | 21 +++ src/tests/servers/app/gradients/main.cpp | 87 +++++++++ src/tests/servers/app/harness/harness.cpp | 173 ++++++++++++++++++ src/tests/servers/app/harness/harness.h | 50 +++++ src/tests/servers/app/transformation/Jamfile | 3 + src/tests/servers/app/transformation/main.cpp | 201 +-------------------- src/tests/servers/registrar/Jamfile | 1 + ############################################################################ Commit: c5ed1088846835e9183a380df23cdbab0b9f71e7 URL: http://cgit.haiku-os.org/haiku/commit/?id=c5ed108 Author: Adrien Destugues <pulkomandy@xxxxxxxxxxxxx> Date: Wed Jul 23 08:13:58 2014 UTC Fix the test_app_server build. ---------------------------------------------------------------------------- diff --git a/src/tests/servers/registrar/Jamfile b/src/tests/servers/registrar/Jamfile index 9df60f2..1c72fe6 100644 --- a/src/tests/servers/registrar/Jamfile +++ b/src/tests/servers/registrar/Jamfile @@ -85,6 +85,7 @@ Server test_registrar MessageRunnerManager.cpp MessagingService.cpp MIMEManager.cpp + PackageWatchingManager.cpp PriorityMessageQueue.cpp RecentApps.cpp RecentEntries.cpp ############################################################################ Commit: 15db99249ada7b04ea295009cb04eb0e2093f5e5 URL: http://cgit.haiku-os.org/haiku/commit/?id=15db992 Author: Adrien Destugues <pulkomandy@xxxxxxxxxxxxx> Date: Wed Jul 23 08:14:35 2014 UTC Simple test harness for app_server tests This was developped for the transformations test, but can be used for other tests too. Extract the relevant classes to a separate file. ---------------------------------------------------------------------------- diff --git a/src/tests/servers/app/harness/harness.cpp b/src/tests/servers/app/harness/harness.cpp new file mode 100644 index 0000000..8ae7358 --- /dev/null +++ b/src/tests/servers/app/harness/harness.cpp @@ -0,0 +1,173 @@ +/* + * Copyright 2014 Stephan Aßmus <superstippi@xxxxxx> + * All rights reserved. Distributed under the terms of the MIT license. + */ + + +#include "harness.h" + + +#include <Application.h> +#include <Bitmap.h> +#include <LayoutBuilder.h> +#include <Message.h> +#include <PopUpMenu.h> +#include <ScrollView.h> + + +Test::Test(const char* name) + : + fName(name) +{ +} + + +Test::~Test() +{ +} + + +// #pragma mark - TestView + + +class TestView : public BView { +public: + TestView(); + virtual ~TestView(); + + virtual void Draw(BRect updateRect); + + void SetTest(Test* test); + +private: + Test* fTest; +}; + + +TestView::TestView() + : + BView(NULL, B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE), + fTest(NULL) +{ +} + + +TestView::~TestView() +{ +} + + +void +TestView::Draw(BRect updateRect) +{ + if (fTest != NULL) + fTest->Draw(this, updateRect); +} + + +void +TestView::SetTest(Test* test) +{ + fTest = test; + Invalidate(); +} + + +// #pragma mark - TestWindow + + +enum { + MSG_SELECT_TEST = 'stst' +}; + + +TestWindow::TestWindow(const char* title) + : + BWindow(BRect(50.0, 50.0, 450.0, 250.0), title, + B_DOCUMENT_WINDOW, B_ASYNCHRONOUS_CONTROLS | B_QUIT_ON_WINDOW_CLOSE + | B_AUTO_UPDATE_SIZE_LIMITS) +{ + fTestView = new TestView(); + + BScrollView* scrollView = new BScrollView("scroll", fTestView, 0, true, + true); + + fTestSelectionField = new BMenuField("test selection", + "Select test:", new BPopUpMenu("select")); + + BLayoutBuilder::Group<>(this, B_VERTICAL, 0.0f) + .AddGroup(B_HORIZONTAL) + .Add(fTestSelectionField) + .AddGlue() + .SetInsets(B_USE_DEFAULT_SPACING) + .End() + .Add(scrollView) + ; +} + + +TestWindow::~TestWindow() +{ + for (int32 i = fTests.CountItems() - 1; i >= 0; i++) + delete (Test*)fTests.ItemAt(i); +} + + +void +TestWindow::MessageReceived(BMessage* message) +{ + switch (message->what) { + case MSG_SELECT_TEST: + { + int32 index; + if (message->FindInt32("index", &index) == B_OK) + SetToTest(index); + break; + } + + default: + BWindow::MessageReceived(message); + } +} + + +void +TestWindow::AddTest(Test* test) +{ + if (test == NULL || fTests.HasItem(test)) + return; + + if (!fTests.AddItem(test)) { + delete test; + return; + } + + BMessage* message = new BMessage(MSG_SELECT_TEST); + message->AddInt32("index", fTests.CountItems() - 1); + + BMenuItem* item = new BMenuItem(test->Name(), message); + if (!fTestSelectionField->Menu()->AddItem(item)) { + fTests.RemoveItem(fTests.CountItems() - 1); + delete test; + delete item; + return; + } + + if (fTests.CountItems() == 1) + SetToTest(0); +} + + +void +TestWindow::SetToTest(int32 index) +{ + Test* test = (Test*)fTests.ItemAt(index); + if (test == NULL) + return; + + fTestSelectionField->Menu()->ItemAt(index)->SetMarked(true); + + fTestView->SetTest(test); +} + + diff --git a/src/tests/servers/app/harness/harness.h b/src/tests/servers/app/harness/harness.h new file mode 100644 index 0000000..c4901a3 --- /dev/null +++ b/src/tests/servers/app/harness/harness.h @@ -0,0 +1,50 @@ +/* + * Copyright 2014 Stephan Aßmus <superstippi@xxxxxx> + * All rights reserved. Distributed under the terms of the MIT license. + */ + + +#include <List.h> +#include <String.h> +#include <View.h> +#include <Window.h> + + +class BMenuField; +class TestView; + + +class Test { +public: + Test(const char* name); + virtual ~Test(); + + const char* Name() const + { return fName.String(); } + + virtual void Draw(BView* view, BRect updateRect) = 0; + +private: + BString fName; +}; + + +class TestWindow : public BWindow { +public: + TestWindow(const char* title); + virtual ~TestWindow(); + + virtual void MessageReceived(BMessage* message); + + void AddTest(Test* test); + void SetToTest(int32 index); + +private: + TestView* fTestView; + + BMenuField* fTestSelectionField; + + BList fTests; +}; + + diff --git a/src/tests/servers/app/transformation/Jamfile b/src/tests/servers/app/transformation/Jamfile index 86d77ff..e73b557 100644 --- a/src/tests/servers/app/transformation/Jamfile +++ b/src/tests/servers/app/transformation/Jamfile @@ -6,7 +6,10 @@ AddSubDirSupportedPlatforms libbe_test ; UseHeaders [ FDirName os app ] ; UseHeaders [ FDirName os interface ] ; +SEARCH_SOURCE += [ FDirName $(HAIKU_TOP) src tests servers app harness ] ; + SimpleTest Transformation : + harness.cpp main.cpp : be $(TARGET_LIBSUPC++) : Transformation.rdef diff --git a/src/tests/servers/app/transformation/main.cpp b/src/tests/servers/app/transformation/main.cpp index 26e733d..0b3f014 100644 --- a/src/tests/servers/app/transformation/main.cpp +++ b/src/tests/servers/app/transformation/main.cpp @@ -11,51 +11,18 @@ #include <Application.h> #include <Bitmap.h> #include <GradientLinear.h> -#include <LayoutBuilder.h> -#include <List.h> -#include <Message.h> #include <Picture.h> -#include <PopUpMenu.h> #include <Region.h> #include <Resources.h> #include <Roster.h> -#include <ScrollView.h> #include <String.h> #include <StringView.h> -#include <View.h> -#include <Window.h> +#include "harness.h" static const char* kAppSignature = "application/x-vnd.Haiku-Transformation"; -class Test { -public: - Test(const char* name); - virtual ~Test(); - - const char* Name() const - { return fName.String(); } - - virtual void Draw(BView* view, BRect updateRect) = 0; - -private: - BString fName; -}; - - -Test::Test(const char* name) - : - fName(name) -{ -} - - -Test::~Test() -{ -} - - class BitmapTest : public Test { public: BitmapTest(const char* name) @@ -115,170 +82,6 @@ protected: }; - -// #pragma mark - TestView - - -class TestView : public BView { -public: - TestView(); - virtual ~TestView(); - - virtual void Draw(BRect updateRect); - - void SetTest(Test* test); - -private: - Test* fTest; -}; - - -TestView::TestView() - : - BView(NULL, B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE), - fTest(NULL) -{ -} - - -TestView::~TestView() -{ -} - - -void -TestView::Draw(BRect updateRect) -{ - if (fTest != NULL) - fTest->Draw(this, updateRect); -} - - -void -TestView::SetTest(Test* test) -{ - fTest = test; - Invalidate(); -} - - -// #pragma mark - TestWindow - - -enum { - MSG_SELECT_TEST = 'stst' -}; - - -class TestWindow : public BWindow { -public: - TestWindow(); - virtual ~TestWindow(); - - virtual void MessageReceived(BMessage* message); - - void AddTest(Test* test); - void SetToTest(int32 index); - -private: - TestView* fTestView; - - BMenuField* fTestSelectionField; - - BList fTests; -}; - - -TestWindow::TestWindow() - : - BWindow(BRect(50.0, 50.0, 450.0, 250.0), "Transformations Test", - B_DOCUMENT_WINDOW, B_ASYNCHRONOUS_CONTROLS | B_QUIT_ON_WINDOW_CLOSE - | B_AUTO_UPDATE_SIZE_LIMITS) -{ - fTestView = new TestView(); - - BScrollView* scrollView = new BScrollView("scroll", fTestView, 0, true, - true); - - fTestSelectionField = new BMenuField("test selection", - "Select test:", new BPopUpMenu("select")); - - BLayoutBuilder::Group<>(this, B_VERTICAL, 0.0f) - .AddGroup(B_HORIZONTAL) - .Add(fTestSelectionField) - .AddGlue() - .SetInsets(B_USE_DEFAULT_SPACING) - .End() - .Add(scrollView) - ; -} - - -TestWindow::~TestWindow() -{ - for (int32 i = fTests.CountItems() - 1; i >= 0; i++) - delete (Test*)fTests.ItemAt(i); -} - - -void -TestWindow::MessageReceived(BMessage* message) -{ - switch (message->what) { - case MSG_SELECT_TEST: - { - int32 index; - if (message->FindInt32("index", &index) == B_OK) - SetToTest(index); - break; - } - - default: - BWindow::MessageReceived(message); - } -} - - -void -TestWindow::AddTest(Test* test) -{ - if (test == NULL || fTests.HasItem(test)) - return; - - if (!fTests.AddItem(test)) { - delete test; - return; - } - - BMessage* message = new BMessage(MSG_SELECT_TEST); - message->AddInt32("index", fTests.CountItems() - 1); - - BMenuItem* item = new BMenuItem(test->Name(), message); - if (!fTestSelectionField->Menu()->AddItem(item)) { - fTests.RemoveItem(fTests.CountItems() - 1); - delete test; - delete item; - return; - } - - if (fTests.CountItems() == 1) - SetToTest(0); -} - - -void -TestWindow::SetToTest(int32 index) -{ - Test* test = (Test*)fTests.ItemAt(index); - if (test == NULL) - return; - - fTestSelectionField->Menu()->ItemAt(index)->SetMarked(true); - - fTestView->SetTest(test); -} - - // #pragma mark - Test1 @@ -633,7 +436,7 @@ main(int argc, char** argv) { BApplication app(kAppSignature); - TestWindow* window = new TestWindow(); + TestWindow* window = new TestWindow("Transformation tests"); window->AddTest(new RectsTest()); window->AddTest(new BitmapClipTest()); ############################################################################ Commit: 1f3acfaa51fa582ffe550c0d005de74619bac572 URL: http://cgit.haiku-os.org/haiku/commit/?id=1f3acfa Author: Adrien Destugues <pulkomandy@xxxxxxxxxxxxx> Date: Wed Jul 23 08:15:49 2014 UTC Add a test for radial gradients. * This shows that the radius is ignored and all gradients are drwan with a radius of 100. ---------------------------------------------------------------------------- diff --git a/src/tests/servers/app/Jamfile b/src/tests/servers/app/Jamfile index 45426dd..5b64fee 100644 --- a/src/tests/servers/app/Jamfile +++ b/src/tests/servers/app/Jamfile @@ -235,6 +235,7 @@ 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 font_spacing ; +SubInclude HAIKU_TOP src tests servers app gradients ; SubInclude HAIKU_TOP src tests servers app hide_and_show ; 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/gradients/Gradients.rdef b/src/tests/servers/app/gradients/Gradients.rdef new file mode 100644 index 0000000..920ee8a --- /dev/null +++ b/src/tests/servers/app/gradients/Gradients.rdef @@ -0,0 +1,17 @@ + +resource app_signature "application/x-vnd.Haiku-Gradients"; + +resource app_flags B_SINGLE_LAUNCH; + +resource app_version { + major = 1, + middle = 0, + minor = 0, + + variety = B_APPV_ALPHA, + internal = 1, + + short_info = "Gradients", + long_info = "Gradients ©2014 Haiku" +}; + diff --git a/src/tests/servers/app/gradients/Jamfile b/src/tests/servers/app/gradients/Jamfile new file mode 100644 index 0000000..f714acb --- /dev/null +++ b/src/tests/servers/app/gradients/Jamfile @@ -0,0 +1,21 @@ +SubDir HAIKU_TOP src tests servers app gradients ; + +SetSubDirSupportedPlatformsBeOSCompatible ; +AddSubDirSupportedPlatforms libbe_test ; + +UseHeaders [ FDirName os app ] ; +UseHeaders [ FDirName os interface ] ; + +SEARCH_SOURCE += [ FDirName $(HAIKU_TOP) src tests servers app harness ] ; + +SimpleTest Gradients : + harness.cpp + main.cpp + : be $(TARGET_LIBSUPC++) + : Gradients.rdef + ; + +if ( $(TARGET_PLATFORM) = libbe_test ) { + HaikuInstall install-test-apps : $(HAIKU_APP_TEST_DIR) : Gradients + : tests!apps ; +} diff --git a/src/tests/servers/app/gradients/main.cpp b/src/tests/servers/app/gradients/main.cpp new file mode 100644 index 0000000..7f7d6ab --- /dev/null +++ b/src/tests/servers/app/gradients/main.cpp @@ -0,0 +1,87 @@ +/* + * Copyright 2014 Haiku, Inc. + * Distributed under the terms of the MIT license. + * + * Authors: + * Adrien Destugues <pulkomandy@xxxxxxxxxxxxx> + */ + + +#include <algorithm> +#include <stdio.h> +#include <string.h> + +#include <Application.h> +#include <GradientRadial.h> +#include <LayoutBuilder.h> +#include <List.h> +#include <Message.h> +#include <PopUpMenu.h> +#include <Roster.h> +#include <ScrollView.h> +#include <String.h> +#include <StringView.h> +#include <View.h> +#include <Window.h> + +#include "harness.h" + + +static const char* kAppSignature = "application/x-vnd.Haiku-Gradients"; + + +// #pragma mark - Test1 + + +class RadialGradientTest : public Test { +public: + RadialGradientTest() + : + Test("Radial Gradient") + { + } + + virtual void Draw(BView* view, BRect updateRect) + { + // Draws two radial gradients with the same stops and different radiis, + // and their enclosing circles. The gradients and circles should have + // the same size. + BGradientRadial g1(100, 100, 50); + BGradientRadial g2(300, 100, 100); + + g1.AddColor(make_color(0,0,0,255), 0); + g1.AddColor(make_color(255,255,255,255), 255); + + g2.AddColor(make_color(0,0,0,255), 0); + g2.AddColor(make_color(255,255,255,255), 255); + + BRect r1(0, 0, 200, 200); + BRect r2(200, 0, 400, 200); + view->FillRect(r1, g1); + view->FillRect(r2, g2); + + r1.InsetBy(50, 50); + view->StrokeEllipse(r1); + view->StrokeEllipse(r2); + } +}; + + +// #pragma mark - + + +int +main(int argc, char** argv) +{ + BApplication app(kAppSignature); + + TestWindow* window = new TestWindow("Gradient tests"); + + window->AddTest(new RadialGradientTest()); + + window->SetToTest(0); + window->Show(); + + app.Run(); + return 0; +} ############################################################################ Revision: hrev47552 Commit: 8fa91344458abb5f32303a7a3f9a1ecbd69bf111 URL: http://cgit.haiku-os.org/haiku/commit/?id=8fa9134 Author: Adrien Destugues <pulkomandy@xxxxxxxxxxxxx> Date: Wed Jul 23 08:17:41 2014 UTC Draw radial gradients using the proper radius. ---------------------------------------------------------------------------- diff --git a/src/servers/app/drawing/Painter/Painter.cpp b/src/servers/app/drawing/Painter/Painter.cpp index ecc60b5..7156be9 100644 --- a/src/servers/app/drawing/Painter/Painter.cpp +++ b/src/servers/app/drawing/Painter/Painter.cpp @@ -2901,7 +2901,8 @@ Painter::_RasterizePath(VertexSource& path, const BGradient& gradient) const agg::gradient_radial gradientFunction; _CalcRadialGradientTransform(radialGradient.Center(), gradientTransform); - _RasterizePath(path, gradient, gradientFunction, gradientTransform); + _RasterizePath(path, gradient, gradientFunction, gradientTransform, + radialGradient.Radius()); break; } case BGradient::TYPE_RADIAL_FOCUS: @@ -2912,7 +2913,8 @@ Painter::_RasterizePath(VertexSource& path, const BGradient& gradient) const agg::gradient_radial_focus gradientFunction; _CalcRadialGradientTransform(radialGradient.Center(), gradientTransform); - _RasterizePath(path, gradient, gradientFunction, gradientTransform); + _RasterizePath(path, gradient, gradientFunction, gradientTransform, + radialGradient.Radius()); break; } case BGradient::TYPE_DIAMOND: @@ -3087,7 +3089,8 @@ Painter::_MakeGradient(Array& array, const BGradient& gradient) const template<class VertexSource, typename GradientFunction> void Painter::_RasterizePath(VertexSource& path, const BGradient& gradient, - GradientFunction function, agg::trans_affine& gradientTransform) const + GradientFunction function, agg::trans_affine& gradientTransform, + int gradientStop) const { GTRACE("Painter::_RasterizePath\n"); @@ -3106,7 +3109,7 @@ Painter::_RasterizePath(VertexSource& path, const BGradient& gradient, _MakeGradient(colorArray, gradient); span_gradient_type spanGradient(spanInterpolator, function, colorArray, - 0, 100); + 0, gradientStop); renderer_gradient_type gradientRenderer(fBaseRenderer, spanAllocator, spanGradient); diff --git a/src/servers/app/drawing/Painter/Painter.h b/src/servers/app/drawing/Painter/Painter.h index 1d30cec..166de5b 100644 --- a/src/servers/app/drawing/Painter/Painter.h +++ b/src/servers/app/drawing/Painter/Painter.h @@ -349,7 +349,8 @@ private: void _RasterizePath(VertexSource& path, const BGradient& gradient, GradientFunction function, - agg::trans_affine& gradientTransform) const; + agg::trans_affine& gradientTransform, + int gradientStop = 100) const; private: mutable agg::rendering_buffer fBuffer;