Author: laplace Date: 2010-07-30 11:12:57 +0200 (Fri, 30 Jul 2010) New Revision: 37818 Changeset: http://dev.haiku-os.org/changeset/37818 Modified: haiku/trunk/src/tests/kits/interface/flatten_picture/PictureTestCases.cpp Log: * Added testDrawScaledPicture which exposes a bug drawing a scaled picture at an offset. The offset needs to be scaled too, but isn't right now. * Fixed testDrawLargeBitmap. The bounds were negative. * Added testFontRotation. Works fine. Modified: haiku/trunk/src/tests/kits/interface/flatten_picture/PictureTestCases.cpp =================================================================== --- haiku/trunk/src/tests/kits/interface/flatten_picture/PictureTestCases.cpp 2010-07-30 02:28:17 UTC (rev 37817) +++ haiku/trunk/src/tests/kits/interface/flatten_picture/PictureTestCases.cpp 2010-07-30 09:12:57 UTC (rev 37818) @@ -8,6 +8,8 @@ #include "PictureTestCases.h" +#include <stdio.h> + static const rgb_color kBlack = {0, 0, 0}; static const rgb_color kWhite = {255, 255, 255}; static const rgb_color kRed = {255, 0, 0}; @@ -292,6 +294,23 @@ delete picture; } +static void testDrawScaledPicture(BView* view, BRect frame) +{ + view->BeginPicture(new BPicture()); + view->FillRect(BRect(0, 0, 15, 15)); + BPicture* picture = view->EndPicture(); + + // first unscaled at left, top + view->DrawPicture(picture, BPoint(2, 2)); + + // draw scaled at middle top + view->SetScale(0.5); + // the drawing offset must be scaled too! + view->DrawPicture(picture, BPoint(frame.Width(), 2)); + + delete picture; +} + static void testLineArray(BView *view, BRect frame) { frame.InsetBy(2, 2); @@ -373,8 +392,8 @@ static void testDrawLargeBitmap(BView *view, BRect frame) { BRect bounds(frame); bounds.OffsetTo(0, 0); - bounds.left = 1024; - bounds.bottom = 767; + bounds.right *= 4; + bounds.bottom *= 4; BBitmap bitmap(bounds, B_RGBA32); fillBitmap(bitmap); frame.InsetBy(2, 2); @@ -724,6 +743,19 @@ view->FillRect(frame, B_SOLID_HIGH); } +static void testFontRotation(BView* view, BRect frame) +{ + BFont font; + view->GetFont(&font); + + font.SetRotation(90); + view->SetFont(&font, B_FONT_ROTATION); + view->DrawString("This is a test!", BPoint(frame.Width() / 2, frame.bottom - 3)); + + view->GetFont(&font); + if (font.Rotation() != 90.0) + fprintf(stderr, "Error: Rotation is %f but should be 90.0\n", font.Rotation()); +} // TODO // - blending mode @@ -762,6 +794,7 @@ { "Test Record And Play Picture", testRecordAndPlayPicture }, { "Test Record And Play Picture With Offset", testRecordAndPlayPictureWithOffset }, { "Test AppendToPicture", testAppendToPicture }, + { "Test Draw Scaled Picture", testDrawScaledPicture }, { "Test LineArray", testLineArray }, { "Test InvertRect", testInvertRect }, { "Test DrawBitmap", testDrawBitmap }, @@ -790,6 +823,7 @@ { "Test SetFontFamilyAndStyle", testSetFontFamilyAndStyle }, { "Test SetDrawingMode", testSetDrawingMode }, { "Test PushPopState", testPushPopState }, + { "Test FontRotation", testFontRotation }, { NULL, NULL } };