Skip to content
This repository was archived by the owner on Dec 2, 2020. It is now read-only.

Commit 8bb5f88

Browse files
author
Sam Spencer
committed
New Unit Test for Performance, Fixed a Unit Test
Added a new unit test to measure the performance of the reloadGraph method. Fixed unit tests checking the value of graph dots (whose default value was changed in a recent commit).
1 parent 81fcbd7 commit 8bb5f88

4 files changed

Lines changed: 74 additions & 2 deletions

File tree

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>classNames</key>
6+
<dict>
7+
<key>SimpleLineGraphTests</key>
8+
<dict>
9+
<key>testReloadDataPerformance</key>
10+
<dict>
11+
<key>com.apple.XCTPerformanceMetric_WallClockTime</key>
12+
<dict>
13+
<key>baselineAverage</key>
14+
<real>0.017</real>
15+
<key>baselineIntegrationDisplayName</key>
16+
<string>Local Baseline</string>
17+
</dict>
18+
</dict>
19+
</dict>
20+
</dict>
21+
</dict>
22+
</plist>
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>runDestinationsByUUID</key>
6+
<dict>
7+
<key>2C820550-74B3-4FE2-BBBC-50D038B845C0</key>
8+
<dict>
9+
<key>localComputer</key>
10+
<dict>
11+
<key>busSpeedInMHz</key>
12+
<integer>100</integer>
13+
<key>cpuCount</key>
14+
<integer>1</integer>
15+
<key>cpuKind</key>
16+
<string>Intel Core i5</string>
17+
<key>cpuSpeedInMHz</key>
18+
<integer>2800</integer>
19+
<key>logicalCPUCoresPerPackage</key>
20+
<integer>4</integer>
21+
<key>modelCode</key>
22+
<string>MacBookPro11,1</string>
23+
<key>physicalCPUCoresPerPackage</key>
24+
<integer>2</integer>
25+
<key>platformIdentifier</key>
26+
<string>com.apple.platform.macosx</string>
27+
</dict>
28+
<key>targetArchitecture</key>
29+
<string>x86_64</string>
30+
<key>targetDevice</key>
31+
<dict>
32+
<key>modelCode</key>
33+
<string>iPhone8,1</string>
34+
<key>platformIdentifier</key>
35+
<string>com.apple.platform.iphonesimulator</string>
36+
</dict>
37+
</dict>
38+
</dict>
39+
</dict>
40+
</plist>

Sample Project/SimpleLineChartTests/CustomizationTests.m

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ - (void)setUp {
3838
}
3939

4040
#pragma mark BEMSimpleLineGraph Data Source
41+
4142
- (NSInteger)numberOfPointsInLineGraph:(BEMSimpleLineGraphView * __nonnull)graph {
4243
return numberOfPoints;
4344
}
@@ -59,6 +60,7 @@ - (NSString *)popUpSuffixForlineGraph:(BEMSimpleLineGraphView * __nonnull)graph
5960
}
6061

6162
#pragma mark Tests
63+
6264
- (void)testDotCustomization {
6365
CGFloat sizePoint = 20.0;
6466

@@ -82,7 +84,7 @@ - (void)testDotCustomization {
8284
XCTAssert(dot.bounds.size.height == sizePoint, @"Dots size point has been customized to 20.0");
8385
XCTAssert([dot.Pointcolor isEqual:[UIColor greenColor]], @"Dots color has been set to green");
8486
XCTAssert(dot.absoluteValue == pointValue, @"Dots are expected to have a value equal to the value returned by the data source method 'valueForPointAtIndex:'");
85-
XCTAssert(dot.alpha >= 0.69 && dot.alpha <= 0.71, @"Dots are expected to always be displayed (alpha of 0.7)");
87+
XCTAssert(dot.alpha >= 0.98 && dot.alpha <= 1.0, @"Dots are expected to always be displayed (alpha of 0.7)");
8688
XCTAssert([dot.backgroundColor isEqual:[UIColor clearColor]], @"Dots are expected to have a clearColor background color by default");
8789
}
8890
}

Sample Project/SimpleLineChartTests/SimpleLineChartTests.m

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ - (void)setUp {
4040
}
4141

4242
#pragma mark BEMSimpleLineGraph Data Source
43+
4344
- (NSInteger)numberOfPointsInLineGraph:(BEMSimpleLineGraphView * __nonnull)graph {
4445
return numberOfPoints;
4546
}
@@ -53,6 +54,7 @@ - (NSString *)lineGraph:(nonnull BEMSimpleLineGraphView *)graph labelOnXAxisForI
5354
}
5455

5556
#pragma mark Test Methods
57+
5658
- (void)testInit {
5759
XCTAssertNotNil(self.lineGraph, @"An allocated and initialized BEMSimpleLineGraph should not be nil.");
5860
}
@@ -61,6 +63,12 @@ - (void)testInitWithFrame {
6163
XCTAssertNotNil(self.lineGraph, @"An allocated and initialized BEMSimpleLineGraph should not be nil.");
6264
}
6365

66+
- (void)testReloadDataPerformance {
67+
[self measureBlock:^{
68+
[self.lineGraph reloadGraph];
69+
}];
70+
}
71+
6472
- (void)testGraphValuesForXAxis {
6573
[self.lineGraph reloadGraph];
6674

@@ -101,7 +109,7 @@ - (void)testDrawnPoints {
101109
for (BEMCircle *dot in dots) {
102110
XCTAssert(dot.bounds.size.width == 10.0, @"Dots are expected to have a default width of 10.0");
103111
XCTAssert(dot.bounds.size.height == 10.0, @"Dots are expected to have a default height of 10.0");
104-
XCTAssert([dot.Pointcolor isEqual:[UIColor whiteColor]], @"Dots are expected to be white by default");
112+
XCTAssert([dot.Pointcolor isEqual:[UIColor colorWithWhite:1.0 alpha:0.7]], @"Dots are expected to be white by default");
105113
XCTAssert(dot.absoluteValue == pointValue, @"Dots are expected to have a value equal to the value returned by the data source method 'valueForPointAtIndex:'");
106114
XCTAssert(dot.alpha == 0.0, @"Dots are expected to not be displayed by default (alpha of 0)");
107115
XCTAssert([dot.backgroundColor isEqual:[UIColor clearColor]], @"Dots are expected to have a clearColor background color by default");

0 commit comments

Comments
 (0)