Skip to content

Commit ff83132

Browse files
committed
Add InsetTests
1 parent 3ecb767 commit ff83132

File tree

2 files changed

+85
-0
lines changed

2 files changed

+85
-0
lines changed

FlexLayout.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@
9999
EF0E61762C1A811100DF30F6 /* YGNodeStyle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = EF0E612C2C1A811100DF30F6 /* YGNodeStyle.cpp */; };
100100
EF0E61772C1A811100DF30F6 /* YGPixelGrid.cpp in Sources */ = {isa = PBXBuildFile; fileRef = EF0E612D2C1A811100DF30F6 /* YGPixelGrid.cpp */; };
101101
EF0E61782C1A811100DF30F6 /* YGValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = EF0E612E2C1A811100DF30F6 /* YGValue.cpp */; };
102+
EF5445402C1D607100BF4A33 /* InsetTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = EF54453F2C1D607100BF4A33 /* InsetTests.swift */; };
102103
/* End PBXBuildFile section */
103104

104105
/* Begin PBXContainerItemProxy section */
@@ -223,6 +224,7 @@
223224
EF0E612C2C1A811100DF30F6 /* YGNodeStyle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = YGNodeStyle.cpp; sourceTree = "<group>"; };
224225
EF0E612D2C1A811100DF30F6 /* YGPixelGrid.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = YGPixelGrid.cpp; sourceTree = "<group>"; };
225226
EF0E612E2C1A811100DF30F6 /* YGValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = YGValue.cpp; sourceTree = "<group>"; };
227+
EF54453F2C1D607100BF4A33 /* InsetTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InsetTests.swift; sourceTree = "<group>"; };
226228
/* End PBXFileReference section */
227229

228230
/* Begin PBXFrameworksBuildPhase section */
@@ -310,6 +312,7 @@
310312
711F2EE32ACC727000DDDD67 /* FlexLayoutTests.swift */,
311313
711F2EE42ACC727000DDDD67 /* MarginTests.swift */,
312314
711F2EE52ACC727000DDDD67 /* JustifyContentTests.swift */,
315+
EF54453F2C1D607100BF4A33 /* InsetTests.swift */,
313316
);
314317
path = FlexLayoutTests;
315318
sourceTree = "<group>";
@@ -717,6 +720,7 @@
717720
711F2EE82ACC727000DDDD67 /* PaddingTests.swift in Sources */,
718721
711F2EE62ACC727000DDDD67 /* AbsolutionPositionContentTests.swift in Sources */,
719722
711F2EEB2ACC727000DDDD67 /* JustifyContentTests.swift in Sources */,
723+
EF5445402C1D607100BF4A33 /* InsetTests.swift in Sources */,
720724
711F2EE72ACC727000DDDD67 /* WidthSizeContentTests.swift in Sources */,
721725
);
722726
runOnlyForDeploymentPostprocessing = 0;
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
2+
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
3+
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
4+
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
5+
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
6+
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
7+
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
8+
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
9+
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
10+
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
11+
// POSSIBILITY OF SUCH DAMAGE.
12+
13+
import FlexLayout
14+
import XCTest
15+
16+
final class InsetTests: XCTestCase {
17+
18+
var viewController: UIViewController!
19+
var rootFlexContainer: UIView!
20+
var aView: UIView!
21+
22+
override func setUp() {
23+
super.setUp()
24+
25+
viewController = UIViewController()
26+
27+
rootFlexContainer = UIView()
28+
rootFlexContainer.frame = CGRect(x: 0, y: 0, width: 400, height: 400)
29+
viewController.view.addSubview(rootFlexContainer)
30+
31+
aView = UIView()
32+
}
33+
34+
func test_adjust_the_aView_size_and_relative_position_with_left() {
35+
rootFlexContainer.flex.define { flex in
36+
flex.addItem(aView).position(.relative).grow(1).left(10)
37+
}
38+
rootFlexContainer.flex.layout()
39+
XCTAssertEqual(aView.frame, CGRect(x: 10.0, y: 0.0, width: 400.0, height: 400.0))
40+
}
41+
42+
func test_adjust_the_aView_size_and_relative_position_with_top() {
43+
rootFlexContainer.flex.define { flex in
44+
flex.addItem(aView).position(.relative).grow(1).top(10)
45+
}
46+
rootFlexContainer.flex.layout()
47+
XCTAssertEqual(aView.frame, CGRect(x: 0.0, y: 10.0, width: 400.0, height: 400.0))
48+
}
49+
50+
func test_adjust_the_aView_size_and_relative_position_with_right() {
51+
rootFlexContainer.flex.define { flex in
52+
flex.addItem(aView).position(.relative).grow(1).right(10)
53+
}
54+
rootFlexContainer.flex.layout()
55+
XCTAssertEqual(aView.frame, CGRect(x: -10.0, y: 0.0, width: 400.0, height: 400.0))
56+
}
57+
58+
func test_adjust_the_aView_size_and_relative_position_with_bottom() {
59+
rootFlexContainer.flex.define { flex in
60+
flex.addItem(aView).position(.relative).grow(1).bottom(10)
61+
}
62+
rootFlexContainer.flex.layout()
63+
XCTAssertEqual(aView.frame, CGRect(x: 0.0, y: -10.0, width: 400.0, height: 400.0))
64+
}
65+
66+
func test_adjust_the_aView_size_and_relative_position_with_horizontally() {
67+
rootFlexContainer.flex.define { flex in
68+
flex.addItem(aView).position(.relative).grow(1).horizontally(10)
69+
}
70+
rootFlexContainer.flex.layout()
71+
XCTAssertEqual(aView.frame, CGRect(x: 10.0, y: 0.0, width: 400.0, height: 400.0))
72+
}
73+
74+
func test_adjust_the_aView_size_and_relative_position_with_vertically() {
75+
rootFlexContainer.flex.define { flex in
76+
flex.addItem(aView).position(.relative).grow(1).vertically(10)
77+
}
78+
rootFlexContainer.flex.layout()
79+
XCTAssertEqual(aView.frame, CGRect(x: 0.0, y: 10.0, width: 400.0, height: 400.0))
80+
}
81+
}

0 commit comments

Comments
 (0)