mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 11:40:48 +00:00
Import testsuite
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@32225 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
03bc4d79d6
commit
251b1edd94
23 changed files with 1991 additions and 0 deletions
82
Tests/gui/NSView/scrollRectToVisible.m
Normal file
82
Tests/gui/NSView/scrollRectToVisible.m
Normal file
|
@ -0,0 +1,82 @@
|
|||
/*
|
||||
copyright 2004 Alexander Malmberg <alexander@malmberg.org>
|
||||
*/
|
||||
|
||||
#include "Testing.h"
|
||||
|
||||
#include <Foundation/NSAutoreleasePool.h>
|
||||
#include <Foundation/NSGeometry.h>
|
||||
#include <AppKit/NSClipView.h>
|
||||
|
||||
#define TEST(r,s) \
|
||||
if (!NSEqualRects([v visibleRect],r)) \
|
||||
{ \
|
||||
printf("%s: got %s, expected %s\n", \
|
||||
s, \
|
||||
[NSStringFromRect([v visibleRect]) lossyCString], \
|
||||
[NSStringFromRect(r) lossyCString]); \
|
||||
pass(0,s); \
|
||||
} \
|
||||
else \
|
||||
pass(1,s);
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
CREATE_AUTORELEASE_POOL(arp);
|
||||
NSClipView *cv=[[NSClipView alloc] initWithFrame: NSMakeRect(0,0,10,10)];
|
||||
NSView *v=[[NSView alloc] initWithFrame: NSMakeRect(0,0,100,100)];
|
||||
[cv setDocumentView: v];
|
||||
|
||||
/* Initial position. */
|
||||
TEST(NSMakeRect(0,0,10,10),"1")
|
||||
|
||||
/* Basic scrolling. */
|
||||
[v scrollRectToVisible: NSMakeRect(50,50,10,10)];
|
||||
TEST(NSMakeRect(50,50,10,10),"2");
|
||||
|
||||
/* No scrolling necessary. */
|
||||
[v scrollRectToVisible: NSMakeRect(55,55,5,5)];
|
||||
TEST(NSMakeRect(50,50,10,10),"3");
|
||||
|
||||
/* No scrolling necessary. */
|
||||
[v scrollRectToVisible: NSMakeRect(50,50,5,5)];
|
||||
TEST(NSMakeRect(50,50,10,10),"4");
|
||||
|
||||
/* No scrolling necessary. */
|
||||
[v scrollRectToVisible: NSMakeRect(52,52,5,5)];
|
||||
TEST(NSMakeRect(50,50,10,10),"5");
|
||||
|
||||
/* Minimal scrolling means that the "small-coordinate" corner should be
|
||||
visible. */
|
||||
[v scrollRectToVisible: NSMakeRect(80,80,20,20)];
|
||||
TEST(NSMakeRect(80,80,10,10),"6");
|
||||
|
||||
/* And in this case, the "large-coordinate" corner. */
|
||||
[v scrollRectToVisible: NSMakeRect(0,0,20,20)];
|
||||
TEST(NSMakeRect(10,10,10,10),"7");
|
||||
|
||||
/* If the visible rect is inside the target rect, no scrolling should
|
||||
occur. */
|
||||
[v scrollRectToVisible: NSMakeRect(5,5,20,20)];
|
||||
TEST(NSMakeRect(10,10,10,10),"8");
|
||||
|
||||
/* Nor for a target rect on the edge of the visible rect. */
|
||||
[v scrollRectToVisible: NSMakeRect(10,10,20,20)];
|
||||
TEST(NSMakeRect(10,10,10,10),"9");
|
||||
|
||||
/* Repeating the call shouldn't cause any scrolling. */
|
||||
[v scrollRectToVisible: NSMakeRect(10,10,20,20)];
|
||||
TEST(NSMakeRect(10,10,10,10),"10");
|
||||
|
||||
/* Minimal scrolling and partial overlap. */
|
||||
[v scrollRectToVisible: NSMakeRect(7,7,5,5)];
|
||||
TEST(NSMakeRect(7,7,10,10),"11");
|
||||
|
||||
[v scrollRectToVisible: NSMakeRect(15,15,5,5)];
|
||||
TEST(NSMakeRect(10,10,10,10),"12");
|
||||
|
||||
DESTROY(arp);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue