This repository has been archived by the owner on Dec 5, 2019. It is now read-only.
forked from twitter-archive/twui
/
VELTUIViewTests.m
95 lines (69 loc) · 2.64 KB
/
VELTUIViewTests.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
//
// VELTUIViewTests.m
// TwUI
//
// Created by Justin Spahr-Summers on 15.01.12.
// Copyright (c) 2012 Bitswift. All rights reserved.
//
#import "VELTUIViewTests.h"
#import <TwUI/TUIKit.h>
#import <Cocoa/Cocoa.h>
@interface VELTUIViewTests ()
@property (nonatomic, strong) VELWindow *window;
@end
@implementation VELTUIViewTests
@synthesize window = m_window;
- (void)setUp {
self.window = [[VELWindow alloc] initWithContentRect:CGRectMake(100, 100, 500, 500)];
}
- (void)tearDown {
self.window = nil;
}
- (void)testInitialization {
VELTUIView *view = [[VELTUIView alloc] init];
STAssertNotNil(view, @"");
}
- (void)testSettingAsRootView {
self.window.rootView = [[VELTUIView alloc] init];
}
- (void)testResponderChain {
VELTUIView *hostView = [[VELTUIView alloc] init];
TUIScrollView *scrollView = [[TUIScrollView alloc] initWithFrame:CGRectZero];
hostView.guestView = scrollView;
STAssertEquals(scrollView.nextResponder, hostView, @"");
}
- (void)testConformsToVELBridgedView {
STAssertTrue([VELTUIView conformsToProtocol:@protocol(VELBridgedView)], @"");
VELTUIView *view = [[VELTUIView alloc] init];
STAssertTrue([view conformsToProtocol:@protocol(VELBridgedView)], @"");
}
- (void)testConformsToVELHostView {
STAssertTrue([VELTUIView conformsToProtocol:@protocol(VELHostView)], @"");
VELTUIView *view = [[VELTUIView alloc] init];
STAssertTrue([view conformsToProtocol:@protocol(VELHostView)], @"");
}
- (void)testAncestorNSVelvetView {
VELTUIView *view = [[VELTUIView alloc] initWithFrame:CGRectZero];
[self.window.rootView addSubview:view];
STAssertEquals(view.ancestorNSVelvetView, self.window.contentView, @"");
}
- (void)testDescendantViewAtPoint {
VELTUIView *hostView = [[VELTUIView alloc] init];
self.window.rootView = hostView;
hostView.guestView = [[TUIView alloc] initWithFrame:CGRectZero];
TUIView *view = [[TUIView alloc] initWithFrame:CGRectMake(50, 30, 100, 150)];
[hostView.guestView addSubview:view];
CGPoint guestSubviewPoint = CGPointMake(51, 31);
STAssertEquals([hostView descendantViewAtPoint:guestSubviewPoint], view, @"");
CGPoint guestViewPoint = CGPointMake(49, 29);
STAssertEquals([hostView descendantViewAtPoint:guestViewPoint], hostView.guestView, @"");
CGPoint outsidePoint = CGPointMake(49, 1000);
STAssertNil([hostView descendantViewAtPoint:outsidePoint], @"");
}
- (void)testGuestView {
VELTUIView *hostView = [[VELTUIView alloc] init];
TUIScrollView *scrollView = [[TUIScrollView alloc] initWithFrame:CGRectZero];
hostView.guestView = scrollView;
STAssertEquals(hostView.guestView, scrollView, @"");
}
@end