forked from TestingWithFrank/Shelley
/
SYParentsTests.m
46 lines (34 loc) · 1.3 KB
/
SYParentsTests.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
//
// SYParentsTests.m
// Shelley
//
// Created by Pete Hodgson on 7/22/11.
// Copyright 2011 ThoughtWorks. All rights reserved.
//
#import "SYParentsTests.h"
#import "SYParents.h"
@implementation SYParentsTests
- (void)testReturnsAllAncestors {
UIView *view = [[[UIView alloc] init] autorelease];
UIView *viewA = [[[UIView alloc] init] autorelease];
UIView *viewAA = [[[UIButton alloc] init] autorelease];
UIView *viewAB = [[[UIView alloc] init] autorelease];
UIView *viewABA = [[[UIView alloc] init] autorelease];
UIView *viewB = [[[UIButton alloc] init] autorelease];
UIView *viewBA = [[[UIView alloc] init] autorelease];
UIView *viewC = [[[UIView alloc] init] autorelease];
[view addSubview:viewA];
[viewA addSubview:viewAA];
[viewA addSubview:viewAB];
[viewAB addSubview:viewABA];
[view addSubview:viewB];
[viewB addSubview:viewBA];
[view addSubview:viewC];
SYParents *filter = [[[SYParents alloc] init]autorelease];
NSArray *filteredViews = [filter applyToView:viewABA];
STAssertEquals((NSUInteger)3, [filteredViews count], nil);
[self assertArray:filteredViews containsObject:viewAB];
[self assertArray:filteredViews containsObject:viewA];
[self assertArray:filteredViews containsObject:view];
}
@end