From 48ebd2e954e79c142ff203c70d6c01dda3ea065b Mon Sep 17 00:00:00 2001 From: Antoine Mercadal Date: Tue, 19 Oct 2010 23:46:03 +0200 Subject: [PATCH] add tests for CPTabView --- Tests/AppKit/CPTabViewTest.j | 65 ++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 Tests/AppKit/CPTabViewTest.j diff --git a/Tests/AppKit/CPTabViewTest.j b/Tests/AppKit/CPTabViewTest.j new file mode 100644 index 000000000..3496bf6c0 --- /dev/null +++ b/Tests/AppKit/CPTabViewTest.j @@ -0,0 +1,65 @@ +@import +@import + + + +@implementation CPTabView (TEST) + +- (CPSegmentedControl)tabs +{ + return tabs; +} + +@end + + +@implementation CPTabViewTest : OJTestCase +{ + CPTabView _tableView; + CPTabViewItem _tabItem1; + CPTabViewItem _tabItem2; +} + +- (void)setUp +{ + _tabView = [[CPTabView alloc] initWithFrame:CGRectMake(0, 0, 800, 600)]; + + _tabItem1 = [[CPTabViewItem alloc] initWithIdentifier:@"id1"]; + [_tabItem1 setLabel:@"Item A"]; + [_tabItem1 setView:[[CPView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)]] + + _tabItem2 = [[CPTabViewItem alloc] initWithIdentifier:@"id2"]; + [_tabItem2 setLabel:@"Item B"]; + [_tabItem2 setView:[[CPView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)]] + + [_tabView addTabViewItem:_tabItem1]; + [_tabView addTabViewItem:_tabItem2]; +} + +- (void)testCreate +{ + [self assertNotNull:_tabView]; + +} + +- (void)testMiddle +{ + var tabs = [_tabView tabs]; + [self assert:([_tabView frameSize].width / 2) equals:CPRectGetMidX([tabs frame])]; +} + +- (void)testMiddleAfterMoveFrame +{ + var tabs = [_tabView tabs]; + [_tabView setFrame:CPRectMake(10, 100, 1000, 200)]; + [self assert:([_tabView frameSize].width / 2) equals:CPRectGetMidX([tabs frame])]; +} + +- (void)testMiddleAfterMoveBound +{ + var tabs = [_tabView tabs]; + [_tabView setBounds:CPRectMake(12, 13, 20, 300)]; + [self assert:([_tabView boundsSize].width / 2) equals:CPRectGetMidX([tabs frame])]; +} + +@end \ No newline at end of file