Skip to content

Commit

Permalink
fix tests by adding tolerance
Browse files Browse the repository at this point in the history
  • Loading branch information
pmairoldi committed Sep 3, 2017
1 parent 705d9ad commit 1025a30
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 21 deletions.
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
14 changes: 7 additions & 7 deletions Tests/Charts/BarChartTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,43 +49,43 @@ class BarChartTests: FBSnapshotTestCase

func testDefaultValues()
{
FBSnapshotVerifyView(chart)
FBSnapshotVerifyView(chart, tolerance: Snapshot.tolerance)
}

func testHidesValues()
{
dataSet.drawValuesEnabled = false
FBSnapshotVerifyView(chart)
FBSnapshotVerifyView(chart, tolerance: Snapshot.tolerance)
}

func testHideLeftAxis()
{
chart.leftAxis.enabled = false
FBSnapshotVerifyView(chart)
FBSnapshotVerifyView(chart, tolerance: Snapshot.tolerance)
}

func testHideRightAxis()
{
chart.rightAxis.enabled = false
FBSnapshotVerifyView(chart)
FBSnapshotVerifyView(chart, tolerance: Snapshot.tolerance)
}

func testHideHorizontalGridlines()
{
chart.leftAxis.drawGridLinesEnabled = false
chart.rightAxis.drawGridLinesEnabled = false
FBSnapshotVerifyView(chart)
FBSnapshotVerifyView(chart, tolerance: Snapshot.tolerance)
}

func testHideVerticalGridlines()
{
chart.xAxis.drawGridLinesEnabled = false
FBSnapshotVerifyView(chart)
FBSnapshotVerifyView(chart, tolerance: Snapshot.tolerance)
}

func testDrawIcons()
{
dataSet.drawIconsEnabled = true
FBSnapshotVerifyView(chart)
FBSnapshotVerifyView(chart, 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
12 changes: 6 additions & 6 deletions Tests/Charts/LineChartTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,36 +46,36 @@ class LineChartTests: FBSnapshotTestCase

func testDefaultValues()
{
FBSnapshotVerifyView(chart)
FBSnapshotVerifyView(chart, tolerance: Snapshot.tolerance)
}

func testHidesValues()
{
dataSet.drawValuesEnabled = false
FBSnapshotVerifyView(chart)
FBSnapshotVerifyView(chart, tolerance: Snapshot.tolerance)
}

func testDoesntDrawCircles()
{
dataSet.drawCirclesEnabled = false
FBSnapshotVerifyView(chart)
FBSnapshotVerifyView(chart, tolerance: Snapshot.tolerance)
}

func testIsCubic()
{
dataSet.mode = LineChartDataSet.Mode.cubicBezier
FBSnapshotVerifyView(chart)
FBSnapshotVerifyView(chart, tolerance: Snapshot.tolerance)
}

func testDoesntDrawCircleHole()
{
dataSet.drawCircleHoleEnabled = false
FBSnapshotVerifyView(chart)
FBSnapshotVerifyView(chart, tolerance: Snapshot.tolerance)
}

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

public struct Snapshot
{
public static let tolerance: CGFloat = 0.0004
}

0 comments on commit 1025a30

Please sign in to comment.