From e52455a31fb20cc3da3c1baac403a9b133b5a336 Mon Sep 17 00:00:00 2001 From: ericwa Date: Tue, 1 Nov 2011 17:37:26 +0000 Subject: [PATCH] * Tests/gui/NSView/NSView_autoresize_and_rounding.m: Add centerScanRect test git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@34103 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 5 ++ .../NSView/NSView_autoresize_and_rounding.m | 59 ++++++++++++++----- 2 files changed, 49 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6b02af5ee..5ff43df38 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-11-01 Eric Wasylishen + + * Tests/gui/NSView/NSView_autoresize_and_rounding.m: Add + centerScanRect test + 2011-10-31 Fred Kiefer * Tests/gui/NSSavePanel/setDelegate_reload.m: Switch the save panel to diff --git a/Tests/gui/NSView/NSView_autoresize_and_rounding.m b/Tests/gui/NSView/NSView_autoresize_and_rounding.m index 5058deb14..335b7d051 100755 --- a/Tests/gui/NSView/NSView_autoresize_and_rounding.m +++ b/Tests/gui/NSView/NSView_autoresize_and_rounding.m @@ -13,25 +13,33 @@ #include #include +BOOL rects_almost_equal(NSRect r1, NSRect r2) { + if (fabs(r1.origin.x - r2.origin.x)>0.001 + || fabs(r1.origin.y - r2.origin.y)>0.001 + || fabs(r1.size.width - r2.size.width)>0.001 + || fabs(r1.size.height - r2.size.height)>0.001) + { + printf("(1) expected frame (%g %g)+(%g %g), got (%g %g)+(%g %g)\n", + r2.origin.x, r2.origin.y, r2.size.width, r2.size.height, + r1.origin.x, r1.origin.y, r1.size.width, r1.size.height); + + return NO; + } + else + { + return YES; + } +} + int CHECK(NSView *view, NSRect frame) { - NSRect r; - - r = [view frame]; - if (fabs(r.origin.x - frame.origin.x)>0.001 - || fabs(r.origin.y - frame.origin.y)>0.001 - || fabs(r.size.width - frame.size.width)>0.001 - || fabs(r.size.height - frame.size.height)>0.001) - { - printf("(1) expected frame (%g %g)+(%g %g), got (%g %g)+(%g %g)\n", - frame.origin.x, frame.origin.y, frame.size.width, frame.size.height, - r.origin.x, r.origin.y, r.size.width, r.size.height); - - return 0; - } - return 1; + NSRect r = [view frame]; + return rects_almost_equal(r, frame); } + + + int main(int argc, char **argv) { CREATE_AUTORELEASE_POOL(arp); @@ -194,6 +202,27 @@ int main(int argc, char **argv) pass(passed,"NSView autoresize rounding works"); + // Test centerScanRect + + { + NSView *view2 = [[NSView alloc] initWithFrame: NSMakeRect(0, 0, 100, 100)]; + + PASS(rects_almost_equal([view2 centerScanRect: NSMakeRect(0.5, 0.5, 100, 100)], + NSMakeRect(1, 1, 100, 100)), + "centerScanRect works 1"); + PASS(rects_almost_equal([view2 centerScanRect: NSMakeRect(0.9, 0.9, 99.9, 99.9)], + NSMakeRect(1, 1, 100, 100)), + "centerScanRect works 2"); + PASS(rects_almost_equal([view2 centerScanRect: NSMakeRect(0.9, 0.9, 99.4, 99.4)], + NSMakeRect(1, 1, 99, 99)), + "centerScanRect works 3"); + PASS(rects_almost_equal([view2 centerScanRect: NSMakeRect(0.4, 0.4, 99.4, 99.4)], + NSMakeRect(0, 0, 100, 100)), + "centerScanRect works 4"); + + [view2 release]; + } + DESTROY(arp); return 0; }