-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtests.rb
76 lines (67 loc) · 2.14 KB
/
tests.rb
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
require './vfl2objc.rb'
require 'test/unit'
class VFLTest < Test::Unit::TestCase
def test_basic
input = "|[b1]|"
output = %Q{
frame = b1.frame;
frame.origin.x = 0;
frame.size.width = superview.bounds.size.width - (0) - frame.origin.x;
// You need to set frame.size.height
// You need to set frame.origin.y
b1.frame = frame;
b1.autoresizingMask |= UIViewAutoresizingFlexibleWidth;
// You need to figure out the vertical autoresizing mask
[superview addSubview:b1];
}
assert str2str(input).include? output
end
def test_predefined_size
input = "V:|-x-[itemA(w)]-x2-[itemB]-x3-[itemC(>0)]|"
output = %Q{
frame = itemA.frame;
// You need to set frame.size.width
// You need to set frame.origin.x
frame.origin.y = 0 + x;
frame.size.height = w;
itemA.frame = frame;
// You need to figure out the horizontal autoresizing mask
itemA.autoresizingMask |= UIViewAutoresizingFlexibleBottomMargin;
[superview addSubview:itemA];
frame = itemB.frame;
// You need to set frame.size.width
// You need to set frame.origin.x
frame.origin.y = 0 + x + w + x2;
// You need to set frame.size.height
itemB.frame = frame;
// You need to figure out the horizontal autoresizing mask
itemB.autoresizingMask |= UIViewAutoresizingFlexibleBottomMargin;
[superview addSubview:itemB];
frame = itemC.frame;
// You need to set frame.size.width
// You need to set frame.origin.x
frame.origin.y = CGRectGetMaxY(itemB.frame) + 0 + x3;
frame.size.height = superview.bounds.size.height - (0) - frame.origin.y;
itemC.frame = frame;
// You need to figure out the horizontal autoresizing mask
itemC.autoresizingMask |= UIViewAutoresizingFlexibleHeight;
[superview addSubview:itemC];
}
assert str2str(input).include? output
end
def test_incomplete
input = "[d(40)]"
output = %Q{
frame = d.frame;
frame.size.width = 40;
// You need to set frame.origin.x
// You need to set frame.size.height
// You need to set frame.origin.y
d.frame = frame;
// You need to figure out the horizontal autoresizing mask
// You need to figure out the vertical autoresizing mask
[superview addSubview:d];
}
assert str2str(input).include? output
end
end