Skip to content

Commit

Permalink
fix tests by adding tolerance and device ids
Browse files Browse the repository at this point in the history
  • Loading branch information
pmairoldi committed Sep 3, 2017
1 parent 705d9ad commit 8a9dafd
Show file tree
Hide file tree
Showing 140 changed files with 43 additions and 26 deletions.
2 changes: 1 addition & 1 deletion Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1 +1 @@
github "facebook/ios-snapshot-test-case" "c1808fb4435ffc3db2203e7623935f39fc31aa8f"
github "facebook/ios-snapshot-test-case" "ed4e6a6e81bfb69a5223156e6c3d389a416cf6e3"
4 changes: 4 additions & 0 deletions Charts.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
05253AFC448C107DEF54C2FE /* CombinedChartRenderer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52265C1B343CCC41AF2300E3 /* CombinedChartRenderer.swift */; };
0529DD51622C8769C1121F90 /* CrossShapeRenderer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 823F7DB281C6C6F069A69605 /* CrossShapeRenderer.swift */; };
0577C2B38BCE4C871F262714 /* AnimatedZoomViewJob.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C2EA58CB336967198D30D20 /* AnimatedZoomViewJob.swift */; };
064989461F5C99C7006E8BB3 /* Snapshot.swift in Sources */ = {isa = PBXBuildFile; fileRef = 064989451F5C99C7006E8BB3 /* Snapshot.swift */; };
0A772AEC08246FEC480673E5 /* PieRadarChartViewBase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A6C9631C69B2D772BBD9232 /* PieRadarChartViewBase.swift */; };
0C52C70C6E6EA09BD7426386 /* RadarChartData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BBB57D6FA41029B08F26D7B /* RadarChartData.swift */; };
0CAF514A280FF6A14E2A1A23 /* CombinedChartView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11EF1FE22549E885C8F40738 /* CombinedChartView.swift */; };
Expand Down Expand Up @@ -164,6 +165,7 @@
0216EDC6A1FE272F4EB19FCF /* ChartDataRendererBase.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ChartDataRendererBase.swift; path = Source/Charts/Renderers/ChartDataRendererBase.swift; sourceTree = "<group>"; };
04F7B9DF1F2D66E7279771D4 /* PieRadarHighlighter.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = PieRadarHighlighter.swift; path = Source/Charts/Highlight/PieRadarHighlighter.swift; sourceTree = "<group>"; };
0619A877C69A95ECCC440A44 /* LineChartView.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = LineChartView.swift; path = Source/Charts/Charts/LineChartView.swift; sourceTree = "<group>"; };
064989451F5C99C7006E8BB3 /* Snapshot.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = Snapshot.swift; path = Tests/Charts/Snapshot.swift; sourceTree = "<group>"; };
0BD9DF16AF59680A3BB49452 /* IAxisValueFormatter.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = IAxisValueFormatter.swift; path = Source/Charts/Formatters/IAxisValueFormatter.swift; sourceTree = "<group>"; };
0DABDBBCCE6B3620C967F04A /* LineChartRenderer.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = LineChartRenderer.swift; path = Source/Charts/Renderers/LineChartRenderer.swift; sourceTree = "<group>"; };
0DDE409E9ECF54D2C146A6F0 /* CombinedChartData.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = CombinedChartData.swift; path = Source/Charts/Data/Implementations/Standard/CombinedChartData.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -510,6 +512,7 @@
5C3F5E1A69EC06E86505F7B1 /* BarChartTests.swift */,
7AB9062A28AAB9469752A954 /* ChartUtilsTests.swift */,
D2E1819D72CD7B6C4A4E8048 /* LineChartTests.swift */,
064989451F5C99C7006E8BB3 /* Snapshot.swift */,
);
name = Charts;
sourceTree = "<group>";
Expand Down Expand Up @@ -933,6 +936,7 @@
3B11556EB7DC034E2FC958E4 /* BarChartTests.swift in Sources */,
8E1192F7A7152E9DA92C56A9 /* ChartUtilsTests.swift in Sources */,
2BF85BEA981B359A65E9BF67 /* LineChartTests.swift in Sources */,
064989461F5C99C7006E8BB3 /* Snapshot.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
2 changes: 0 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,6 @@ def run_xcodebuild(schemes_to_execute, tasks, destination, is_test, xcprety_args
schemes_to_execute.each do |scheme|
xcodebuild type, project_name, scheme, configuration, sdk, device, tasks, xcprety_args
end

sh 'killall Simulator' if is_test
end

def execute(tasks, platform, xcprety_args: '')
Expand Down
16 changes: 8 additions & 8 deletions Tests/Charts/BarChartTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class BarChartTests: FBSnapshotTestCase
super.setUp()

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

// Sample data
let values: [Double] = [8, 104, 81, 93, 52, 44, 97, 101, 75, 28,
Expand Down Expand Up @@ -49,43 +49,43 @@ class BarChartTests: FBSnapshotTestCase

func testDefaultValues()
{
FBSnapshotVerifyView(chart)
FBSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), tolerance: Snapshot.tolerance)
}

func testHidesValues()
{
dataSet.drawValuesEnabled = false
FBSnapshotVerifyView(chart)
FBSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), tolerance: Snapshot.tolerance)
}

func testHideLeftAxis()
{
chart.leftAxis.enabled = false
FBSnapshotVerifyView(chart)
FBSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), tolerance: Snapshot.tolerance)
}

func testHideRightAxis()
{
chart.rightAxis.enabled = false
FBSnapshotVerifyView(chart)
FBSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), tolerance: Snapshot.tolerance)
}

func testHideHorizontalGridlines()
{
chart.leftAxis.drawGridLinesEnabled = false
chart.rightAxis.drawGridLinesEnabled = false
FBSnapshotVerifyView(chart)
FBSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), tolerance: Snapshot.tolerance)
}

func testHideVerticalGridlines()
{
chart.xAxis.drawGridLinesEnabled = false
FBSnapshotVerifyView(chart)
FBSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), tolerance: Snapshot.tolerance)
}

func testDrawIcons()
{
dataSet.drawIconsEnabled = true
FBSnapshotVerifyView(chart)
FBSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), tolerance: Snapshot.tolerance)
}
}
8 changes: 0 additions & 8 deletions Tests/Charts/ChartUtilsTests.swift
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
//
// ChartUtilsTests.swift
// Charts
//
// Created by Pierre-Marc Airoldi on 2016-09-25.
//
//

import XCTest
@testable import Charts

Expand Down
14 changes: 7 additions & 7 deletions Tests/Charts/LineChartTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class LineChartTests: FBSnapshotTestCase
super.setUp()

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

// Sample data
let values: [Double] = [8, 104, 81, 93, 52, 44, 97, 101, 75, 28,
Expand Down Expand Up @@ -46,36 +46,36 @@ class LineChartTests: FBSnapshotTestCase

func testDefaultValues()
{
FBSnapshotVerifyView(chart)
FBSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), tolerance: Snapshot.tolerance)
}

func testHidesValues()
{
dataSet.drawValuesEnabled = false
FBSnapshotVerifyView(chart)
FBSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), tolerance: Snapshot.tolerance)
}

func testDoesntDrawCircles()
{
dataSet.drawCirclesEnabled = false
FBSnapshotVerifyView(chart)
FBSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), tolerance: Snapshot.tolerance)
}

func testIsCubic()
{
dataSet.mode = LineChartDataSet.Mode.cubicBezier
FBSnapshotVerifyView(chart)
FBSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), tolerance: Snapshot.tolerance)
}

func testDoesntDrawCircleHole()
{
dataSet.drawCircleHoleEnabled = false
FBSnapshotVerifyView(chart)
FBSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), tolerance: Snapshot.tolerance)
}

func testDrawIcons()
{
dataSet.drawIconsEnabled = true
FBSnapshotVerifyView(chart)
FBSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), tolerance: Snapshot.tolerance)
}
}
23 changes: 23 additions & 0 deletions Tests/Charts/Snapshot.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import CoreGraphics

public struct Snapshot
{
public static let tolerance: CGFloat = 0.03

public static func identifier(_ size: CGSize) -> String {

let identifier: String

#if os(tvOS)
identifier = "tvOS"
#elseif os(iOS)
identifier = "iOS"
#elseif os(OSX)
identifier = "macOS"
#else
identifier = ""
#endif

return "\(identifier)_\(size.width)_\(size.height)"
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.

0 comments on commit 8a9dafd

Please sign in to comment.