Skip to content

Commit e108da5

Browse files
committed
Bar chart tests
Bar chart tests included mimicking previous line chart tests. Updated ios-snapshot-test-case to 2.0.7 version. Bar chart tests included: - default chart - hide values - hide left axis - hide right axis - hide left axis gridlines - hide right axis gridlines
1 parent f68e007 commit e108da5

File tree

12 files changed

+102
-15
lines changed

12 files changed

+102
-15
lines changed

Charts/Cartfile.resolved

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
github "facebook/ios-snapshot-test-case" "2.0.5"
1+
github "facebook/ios-snapshot-test-case" "2.0.7"

Charts/Carthage/Checkouts/ios-snapshot-test-case/CHANGELOG.md

+8-4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22

33
All notable changes to this project will be documented in this file.
44

5+
## 2.0.7
6+
7+
- Change FBSnapshotTestController from private to public (#129)
8+
9+
## 2.0.6
10+
11+
- Added modulemap and podspec fixes to build with Xcode 7.1 (#127)
12+
513
## 2.0.5
614

715
- Swift 2.0 (#111, #120) (Thanks to @pietbrauer and @grantjk)
@@ -33,14 +41,10 @@ All notable changes to this project will be documented in this file.
3341

3442
## 1.8.1
3543

36-
### Fixed
37-
3844
- Prevent mangling of C function names when compiled with a C++ compiler. (#79)
3945

4046
## 1.8.0
4147

42-
### Changed
43-
4448
- The default directories for snapshots images are now **ReferenceImages_32** (32bit) and **ReferenceImages_64** (64bit) and the suffix depends on the architecture when the test is running. (#77)
4549
- If a test fails for a given suffix, it will try to load and compare all other suffixes before failing.
4650
- Added assertion on setRecordMode. (#76)

Charts/Carthage/Checkouts/ios-snapshot-test-case/FBSnapshotTestCase.podspec

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "FBSnapshotTestCase"
3-
s.version = "2.0.5"
3+
s.version = "2.0.7"
44
s.summary = "Snapshot view unit tests for iOS"
55
s.description = <<-DESC
66
A "snapshot test case" takes a configured UIView or CALayer
@@ -16,13 +16,14 @@ Pod::Spec.new do |s|
1616
:tag => s.version.to_s }
1717
s.platform = :ios, '7.0'
1818
s.requires_arc = true
19-
s.framework = 'XCTest'
19+
s.frameworks = 'XCTest','UIKit','Foundation','QuartzCore'
2020
s.pod_target_xcconfig = { 'ENABLE_BITCODE' => 'NO' }
21-
s.public_header_files = ['FBSnapshotTestCase/FBSnapshotTestCase.h', 'FBSnapshotTestCase/FBSnapshotTestCasePlatform.h']
22-
s.private_header_files = ['FBSnapshotTestCase/FBSnapshotTestController.h', 'FBSnapshotTestCase/UIImage+Compare.h', 'FBSnapshotTestCase/UIImage+Diff.h']
2321
s.default_subspecs = 'SwiftSupport'
22+
s.module_map = 'FBSnapshotTestCase.modulemap'
2423
s.subspec 'Core' do |cs|
25-
cs.source_files = 'FBSnapshotTestCase/**/*.{h,m}'
24+
cs.source_files = 'FBSnapshotTestCase/**/*.{h,m}', 'FBSnapshotTestCase/*.{h,m}'
25+
cs.public_header_files = 'FBSnapshotTestCase/FBSnapshotTestCase.h','FBSnapshotTestCase/FBSnapshotTestCasePlatform.h','FBSnapshotTestCase/FBSnapshotTestController.h'
26+
cs.private_header_files = 'FBSnapshotTestCase/Categories/UIImage+Compare.h','FBSnapshotTestCase/Categories/UIImage+Diff.h','FBSnapshotTestCase/Categories/UIImage+Snapshot.h'
2627
end
2728
s.subspec 'SwiftSupport' do |cs|
2829
cs.dependency 'FBSnapshotTestCase/Core'
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
PODS:
2-
- FBSnapshotTestCase (2.0.5):
3-
- FBSnapshotTestCase/SwiftSupport (= 2.0.5)
4-
- FBSnapshotTestCase/Core (2.0.5)
5-
- FBSnapshotTestCase/SwiftSupport (2.0.5):
2+
- FBSnapshotTestCase (2.0.6):
3+
- FBSnapshotTestCase/SwiftSupport (= 2.0.6)
4+
- FBSnapshotTestCase/Core (2.0.6)
5+
- FBSnapshotTestCase/SwiftSupport (2.0.6):
66
- FBSnapshotTestCase/Core
77

88
DEPENDENCIES:
@@ -13,6 +13,6 @@ EXTERNAL SOURCES:
1313
:path: ".."
1414

1515
SPEC CHECKSUMS:
16-
FBSnapshotTestCase: 6917deb01d0556dd544536f9eb34e0cf26f904d5
16+
FBSnapshotTestCase: f53793e19b2782f2948e8597b03ec2bb5aedf5cd
1717

1818
COCOAPODS: 0.39.0

Charts/Charts.xcodeproj/project.pbxproj

+4
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@
194194
A52C5C8D1BAC5D1200594CDD /* ChartTransformerHorizontalBarChart.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5BB6EC1C1ACC28AB006E9C25 /* ChartTransformerHorizontalBarChart.swift */; };
195195
A52C5C8E1BAC5D1200594CDD /* ChartUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5BA8EC7C1A9D151C00CE82E1 /* ChartUtils.swift */; };
196196
A52C5C8F1BAC5D1200594CDD /* ChartViewPortHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5BD8F06C1AB897D500566E05 /* ChartViewPortHandler.swift */; };
197+
DDC77DC61C0A991A00C27BCF /* BarChartTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDC77DC51C0A991A00C27BCF /* BarChartTests.swift */; };
197198
/* End PBXBuildFile section */
198199

199200
/* Begin PBXContainerItemProxy section */
@@ -319,6 +320,7 @@
319320
5BD4C57B1BCDBF6C00462351 /* ScatterChartDataProvider.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ScatterChartDataProvider.swift; sourceTree = "<group>"; };
320321
5BD8F06C1AB897D500566E05 /* ChartViewPortHandler.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ChartViewPortHandler.swift; sourceTree = "<group>"; };
321322
A52C5C371BAC5CA400594CDD /* Charts.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Charts.framework; sourceTree = BUILT_PRODUCTS_DIR; };
323+
DDC77DC51C0A991A00C27BCF /* BarChartTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BarChartTests.swift; sourceTree = "<group>"; };
322324
/* End PBXFileReference section */
323325

324326
/* Begin PBXFrameworksBuildPhase section */
@@ -350,6 +352,7 @@
350352
06AEE7A31BDC3F8B009875AE /* ChartsTests */ = {
351353
isa = PBXGroup;
352354
children = (
355+
DDC77DC51C0A991A00C27BCF /* BarChartTests.swift */,
353356
06AEE7AD1BDC3FC6009875AE /* LineChartTests.swift */,
354357
06AEE7A61BDC3F8B009875AE /* Info.plist */,
355358
);
@@ -719,6 +722,7 @@
719722
isa = PBXSourcesBuildPhase;
720723
buildActionMask = 2147483647;
721724
files = (
725+
DDC77DC61C0A991A00C27BCF /* BarChartTests.swift in Sources */,
722726
06AEE7AE1BDC3FC6009875AE /* LineChartTests.swift in Sources */,
723727
);
724728
runOnlyForDeploymentPostprocessing = 0;
+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
import XCTest
2+
import FBSnapshotTestCase
3+
@testable import Charts
4+
5+
class BarChartTests: FBSnapshotTestCase
6+
{
7+
8+
var chart: BarChartView!
9+
var dataSet: BarChartDataSet!
10+
11+
override func setUp()
12+
{
13+
super.setUp()
14+
15+
// Set to `true` to re-capture all snapshots
16+
self.recordMode = false
17+
18+
// Sample data
19+
let values: [Double] = [8, 104, 81, 93, 52, 44, 97, 101, 75, 28,
20+
76, 25, 20, 13, 52, 44, 57, 23, 45, 91,
21+
99, 14, 84, 48, 40, 71, 106, 41, 45, 61]
22+
23+
var entries: [ChartDataEntry] = Array()
24+
var xValues: [String] = Array()
25+
26+
for (i, value) in values.enumerate()
27+
{
28+
entries.append(BarChartDataEntry.init(value: value, xIndex: i))
29+
xValues.append("\(i)")
30+
}
31+
32+
dataSet = BarChartDataSet(yVals: entries, label: "Bar chart unit test data")
33+
34+
chart = BarChartView(frame: CGRectMake(0, 0, 480, 350))
35+
chart.data = BarChartData(xVals: xValues, dataSet: dataSet)
36+
}
37+
38+
override func tearDown()
39+
{
40+
// Put teardown code here. This method is called after the invocation of each test method in the class.
41+
super.tearDown()
42+
}
43+
44+
func testDefaultValues()
45+
{
46+
FBSnapshotVerifyView(chart)
47+
}
48+
49+
func testHidesValues()
50+
{
51+
dataSet.drawValuesEnabled = false
52+
FBSnapshotVerifyView(chart)
53+
}
54+
55+
func testHideLeftAxis()
56+
{
57+
chart.leftAxis.drawAxisLineEnabled = false
58+
FBSnapshotVerifyView(chart)
59+
}
60+
61+
func testHideRightAxis()
62+
{
63+
chart.rightAxis.drawAxisLineEnabled = false
64+
FBSnapshotVerifyView(chart)
65+
}
66+
67+
func testHideLeftAxisGridlines()
68+
{
69+
chart.leftAxis.drawGridLinesEnabled = false
70+
FBSnapshotVerifyView(chart)
71+
}
72+
73+
func testHideRightAxisGridlines()
74+
{
75+
chart.rightAxis.drawGridLinesEnabled = false
76+
FBSnapshotVerifyView(chart)
77+
}
78+
}
Loading
Loading
Loading
Loading
Loading
Loading

0 commit comments

Comments
 (0)