PageRenderTime 4ms CodeModel.GetById 2ms app.highlight 0ms RepoModel.GetById 1ms app.codeStats 0ms

/Tests/AppKit/CPTabViewTest.j

http://github.com/cacaodev/cappuccino
Unknown | 96 lines | 74 code | 22 blank | 0 comment | 0 complexity | 79a8ac940bbd010bfb2e82cdb7d986d7 MD5 | raw file
 1@import <Foundation/Foundation.j>
 2@import <AppKit/AppKit.j>
 3
 4
 5
 6@implementation CPTabView (TEST)
 7
 8- (CPSegmentedControl)tabs
 9{
10    return _tabs;
11}
12
13- (CPBox)box
14{
15    return _box;
16}
17
18@end
19
20
21@implementation CPTabViewTest : OJTestCase
22{
23    CPTabView       _tabView;
24    CPTabViewItem   _tabItem1;
25    CPTabViewItem   _tabItem2;
26}
27
28- (void)setUp
29{
30    _tabView = [[CPTabView alloc] initWithFrame:CGRectMake(0, 0, 800, 600)];
31
32    _tabItem1 = [[CPTabViewItem alloc] initWithIdentifier:@"id1"];
33    [_tabItem1 setLabel:@"Item A"];
34    [_tabItem1 setView:[[CPView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)]]
35
36    _tabItem2 = [[CPTabViewItem alloc] initWithIdentifier:@"id2"];
37    [_tabItem2 setLabel:@"Item B"];
38    [_tabItem2 setView:[[CPView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)]]
39
40    [_tabView addTabViewItem:_tabItem1];
41    [_tabView addTabViewItem:_tabItem2];
42}
43
44- (void)testCreate
45{
46    [self assertNotNull:_tabView];
47
48}
49
50- (void)testMiddle
51{
52    var tabs = [_tabView tabs];
53    [self assert:([_tabView frameSize].width / 2)  equals:CGRectGetMidX([tabs frame])];
54}
55
56- (void)testMiddleAfterMoveFrame
57{
58    var tabs = [_tabView tabs];
59    [_tabView setFrame:CGRectMake(10, 100, 1000, 200)];
60    // Perform this manually for the sake of the unit test.
61    [_tabView layoutIfNeeded];
62    [self assert:([_tabView frameSize].width / 2)  equals:CGRectGetMidX([tabs frame])];
63}
64
65- (void)testMiddleAfterMoveBound
66{
67    var tabs = [_tabView tabs];
68    [_tabView setBounds:CGRectMake(100, 100, 20, 300)];
69    // Perform this manually for the sake of the unit test.
70    [_tabView layoutIfNeeded];
71    [self assert:([tabs boundsSize].width / 2)  equals:CGRectGetMidX([tabs bounds])];
72}
73
74- (void)testBoxHeight
75{
76    var box = [_tabView box],
77        tabs = [_tabView tabs];
78
79    [_tabView setFrame:CGRectMake(0, 0, 800, 800)];
80    // Perform this manually for the sake of the unit test.
81    [_tabView layoutIfNeeded];
82    [self assert:[box frameSize].height  equals:800 - [tabs frameSize].height / 2];
83}
84
85- (void)testTabViewGetsSetOnViewItem
86{
87    [self assert:[_tabItem1 tabView] equals:_tabView];
88}
89
90- (void)testTabViewGetsRemoveOnViewItem
91{
92    [_tabView removeTabViewItem:_tabItem1];
93    [self assertNull:[_tabItem1 tabView]];
94}
95
96@end