Skip to content

Commit

Permalink
Merge pull request ChartsOrg#580 from alvesjtiago/bar-chart-tests
Browse files Browse the repository at this point in the history
Bar chart tests
  • Loading branch information
danielgindi committed Nov 29, 2015
2 parents f68e007 + e108da5 commit 3f88894
Show file tree
Hide file tree
Showing 12 changed files with 102 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Charts/Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1 +1 @@
github "facebook/ios-snapshot-test-case" "2.0.5"
github "facebook/ios-snapshot-test-case" "2.0.7"
12 changes: 8 additions & 4 deletions Charts/Carthage/Checkouts/ios-snapshot-test-case/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

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

## 2.0.7

- Change FBSnapshotTestController from private to public (#129)

## 2.0.6

- Added modulemap and podspec fixes to build with Xcode 7.1 (#127)

## 2.0.5

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

## 1.8.1

### Fixed

- Prevent mangling of C function names when compiled with a C++ compiler. (#79)

## 1.8.0

### Changed

- 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)
- If a test fails for a given suffix, it will try to load and compare all other suffixes before failing.
- Added assertion on setRecordMode. (#76)
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "FBSnapshotTestCase"
s.version = "2.0.5"
s.version = "2.0.7"
s.summary = "Snapshot view unit tests for iOS"
s.description = <<-DESC
A "snapshot test case" takes a configured UIView or CALayer
Expand All @@ -16,13 +16,14 @@ Pod::Spec.new do |s|
:tag => s.version.to_s }
s.platform = :ios, '7.0'
s.requires_arc = true
s.framework = 'XCTest'
s.frameworks = 'XCTest','UIKit','Foundation','QuartzCore'
s.pod_target_xcconfig = { 'ENABLE_BITCODE' => 'NO' }
s.public_header_files = ['FBSnapshotTestCase/FBSnapshotTestCase.h', 'FBSnapshotTestCase/FBSnapshotTestCasePlatform.h']
s.private_header_files = ['FBSnapshotTestCase/FBSnapshotTestController.h', 'FBSnapshotTestCase/UIImage+Compare.h', 'FBSnapshotTestCase/UIImage+Diff.h']
s.default_subspecs = 'SwiftSupport'
s.module_map = 'FBSnapshotTestCase.modulemap'
s.subspec 'Core' do |cs|
cs.source_files = 'FBSnapshotTestCase/**/*.{h,m}'
cs.source_files = 'FBSnapshotTestCase/**/*.{h,m}', 'FBSnapshotTestCase/*.{h,m}'
cs.public_header_files = 'FBSnapshotTestCase/FBSnapshotTestCase.h','FBSnapshotTestCase/FBSnapshotTestCasePlatform.h','FBSnapshotTestCase/FBSnapshotTestController.h'
cs.private_header_files = 'FBSnapshotTestCase/Categories/UIImage+Compare.h','FBSnapshotTestCase/Categories/UIImage+Diff.h','FBSnapshotTestCase/Categories/UIImage+Snapshot.h'
end
s.subspec 'SwiftSupport' do |cs|
cs.dependency 'FBSnapshotTestCase/Core'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
PODS:
- FBSnapshotTestCase (2.0.5):
- FBSnapshotTestCase/SwiftSupport (= 2.0.5)
- FBSnapshotTestCase/Core (2.0.5)
- FBSnapshotTestCase/SwiftSupport (2.0.5):
- FBSnapshotTestCase (2.0.6):
- FBSnapshotTestCase/SwiftSupport (= 2.0.6)
- FBSnapshotTestCase/Core (2.0.6)
- FBSnapshotTestCase/SwiftSupport (2.0.6):
- FBSnapshotTestCase/Core

DEPENDENCIES:
Expand All @@ -13,6 +13,6 @@ EXTERNAL SOURCES:
:path: ".."

SPEC CHECKSUMS:
FBSnapshotTestCase: 6917deb01d0556dd544536f9eb34e0cf26f904d5
FBSnapshotTestCase: f53793e19b2782f2948e8597b03ec2bb5aedf5cd

COCOAPODS: 0.39.0
4 changes: 4 additions & 0 deletions Charts/Charts.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@
A52C5C8D1BAC5D1200594CDD /* ChartTransformerHorizontalBarChart.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5BB6EC1C1ACC28AB006E9C25 /* ChartTransformerHorizontalBarChart.swift */; };
A52C5C8E1BAC5D1200594CDD /* ChartUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5BA8EC7C1A9D151C00CE82E1 /* ChartUtils.swift */; };
A52C5C8F1BAC5D1200594CDD /* ChartViewPortHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5BD8F06C1AB897D500566E05 /* ChartViewPortHandler.swift */; };
DDC77DC61C0A991A00C27BCF /* BarChartTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDC77DC51C0A991A00C27BCF /* BarChartTests.swift */; };
/* End PBXBuildFile section */

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

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -350,6 +352,7 @@
06AEE7A31BDC3F8B009875AE /* ChartsTests */ = {
isa = PBXGroup;
children = (
DDC77DC51C0A991A00C27BCF /* BarChartTests.swift */,
06AEE7AD1BDC3FC6009875AE /* LineChartTests.swift */,
06AEE7A61BDC3F8B009875AE /* Info.plist */,
);
Expand Down Expand Up @@ -719,6 +722,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
DDC77DC61C0A991A00C27BCF /* BarChartTests.swift in Sources */,
06AEE7AE1BDC3FC6009875AE /* LineChartTests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
78 changes: 78 additions & 0 deletions Charts/ChartsTests/BarChartTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import XCTest
import FBSnapshotTestCase
@testable import Charts

class BarChartTests: FBSnapshotTestCase
{

var chart: BarChartView!
var dataSet: BarChartDataSet!

override func setUp()
{
super.setUp()

// Set to `true` to re-capture all snapshots
self.recordMode = false

// Sample data
let values: [Double] = [8, 104, 81, 93, 52, 44, 97, 101, 75, 28,
76, 25, 20, 13, 52, 44, 57, 23, 45, 91,
99, 14, 84, 48, 40, 71, 106, 41, 45, 61]

var entries: [ChartDataEntry] = Array()
var xValues: [String] = Array()

for (i, value) in values.enumerate()
{
entries.append(BarChartDataEntry.init(value: value, xIndex: i))
xValues.append("\(i)")
}

dataSet = BarChartDataSet(yVals: entries, label: "Bar chart unit test data")

chart = BarChartView(frame: CGRectMake(0, 0, 480, 350))
chart.data = BarChartData(xVals: xValues, dataSet: dataSet)
}

override func tearDown()
{
// Put teardown code here. This method is called after the invocation of each test method in the class.
super.tearDown()
}

func testDefaultValues()
{
FBSnapshotVerifyView(chart)
}

func testHidesValues()
{
dataSet.drawValuesEnabled = false
FBSnapshotVerifyView(chart)
}

func testHideLeftAxis()
{
chart.leftAxis.drawAxisLineEnabled = false
FBSnapshotVerifyView(chart)
}

func testHideRightAxis()
{
chart.rightAxis.drawAxisLineEnabled = false
FBSnapshotVerifyView(chart)
}

func testHideLeftAxisGridlines()
{
chart.leftAxis.drawGridLinesEnabled = false
FBSnapshotVerifyView(chart)
}

func testHideRightAxisGridlines()
{
chart.rightAxis.drawGridLinesEnabled = false
FBSnapshotVerifyView(chart)
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 3f88894

Please sign in to comment.