From bb04734fe17aa693f8f25b74cf1f31153000d6ab Mon Sep 17 00:00:00 2001 From: ericwa Date: Fri, 8 Jul 2011 18:21:43 +0000 Subject: [PATCH] * Tests/gui/NSView/NSView_autoresize_and_rounding.m: Add some more test cases for when the view's width is 0 git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@33488 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 5 ++ .../NSView/NSView_autoresize_and_rounding.m | 56 ++++++++++++++++++- 2 files changed, 60 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index bc8c8c3a5..1cc0c691b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-07-08 Eric Wasylishen + + * Tests/gui/NSView/NSView_autoresize_and_rounding.m: Add some more + test cases for when the view's width is 0 + 2011-07-07 Eric Wasylishen * Headers/AppKit/NSView.h: diff --git a/Tests/gui/NSView/NSView_autoresize_and_rounding.m b/Tests/gui/NSView/NSView_autoresize_and_rounding.m index 1bae4f074..d024e0511 100755 --- a/Tests/gui/NSView/NSView_autoresize_and_rounding.m +++ b/Tests/gui/NSView/NSView_autoresize_and_rounding.m @@ -92,8 +92,62 @@ int main(int argc, char **argv) passed = CHECK(view1, NSMakeRect(100,0,50,25)) && passed; [window setContentSize: NSMakeSize(100, 100)]; - pass(passed,"NSView autoresizing works"); + + /** + * Corner case tests, involving widths of 0, etc. + */ + + // Test that a view with a width of 0 can be expanded + // if it only has NSViewWidthSizable + + passed = 1; + [view1 setFrame: NSMakeRect(50,0,0,25)]; + [view1 setAutoresizingMask: NSViewWidthSizable]; + [window setContentSize: NSMakeSize(133, 100)]; + passed = CHECK(view1, NSMakeRect(50,0,33,25)) && passed; + [window setContentSize: NSMakeSize(100, 100)]; + + // Test that if NSViewWidthSizable | NSViewMinXMargin is set, + // and the view has width of 0, extra space is given to the margin + // not the width + + [view1 setFrame: NSMakeRect(50,0,0,35)]; + [view1 setAutoresizingMask: NSViewWidthSizable | NSViewMinXMargin]; + [window setContentSize: NSMakeSize(133, 100)]; + passed = CHECK(view1, NSMakeRect(83,0,0,35)) && passed; + [window setContentSize: NSMakeSize(100, 100)]; + + // Test a {0, 0} sized window with NSViewWidthSizable | NSViewHeightSizable + + [window setContentSize: NSMakeSize(0,0)]; + [view1 setFrame: NSMakeRect(0,0,0,0)]; + [view1 setAutoresizingMask: NSViewWidthSizable | NSViewHeightSizable]; + [window setContentSize: NSMakeSize(4,4)]; + passed = CHECK(view1, NSMakeRect(0,0,4,4)) && passed; + [window setContentSize: NSMakeSize(100, 100)]; + + // Test a {0, 0} sized window with NSMinXMargin | NSViewWidthSizable + + [window setContentSize: NSMakeSize(0,0)]; + [view1 setFrame: NSMakeRect(0,0,0,0)]; + [view1 setAutoresizingMask: NSViewMinXMargin | NSViewWidthSizable]; + [window setContentSize: NSMakeSize(6,6)]; + passed = CHECK(view1, NSMakeRect(3,0,3,0)) && passed; + [window setContentSize: NSMakeSize(100, 100)]; + + // Test a {0, 0} sized window with all autoresizing flags set on the view + + [window setContentSize: NSMakeSize(0,0)]; + [view1 setFrame: NSMakeRect(0,0,0,0)]; + [view1 setAutoresizingMask: NSViewMinXMargin | NSViewWidthSizable | NSViewMaxXMargin | + NSViewMinYMargin | NSViewHeightSizable | NSViewMaxYMargin]; + [window setContentSize: NSMakeSize(9,9)]; + passed = CHECK(view1, NSMakeRect(3,3,3,3)) && passed; + [window setContentSize: NSMakeSize(100, 100)]; + + pass(passed,"NSView autoresizing corner cases work"); + /** * Rounding test