Skip to content

Commit

Permalink
Fix test failures. add a new extension to only use 64bit arch. This i…
Browse files Browse the repository at this point in the history
…s the companion commit that only has code change regards fixing test failures.
  • Loading branch information
liuxuan30 committed Apr 11, 2019
1 parent 27c5611 commit ba86bf7
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 39 deletions.
52 changes: 26 additions & 26 deletions Tests/Charts/BarChartTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -84,23 +84,23 @@ class BarChartTests: FBSnapshotTestCase
let dataEntries = setupDefaultValuesDataEntries()
let dataSet = setupDefaultDataSet(chartDataEntries: dataEntries)
let chart = setupDefaultChart(dataSets: [dataSet])
FBSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance)
ChartsSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance)
}

func testZeroValues()
{
let dataEntries = setupZeroValuesDataEntries()
let dataSet = setupDefaultDataSet(chartDataEntries: dataEntries)
let chart = setupDefaultChart(dataSets: [dataSet])
FBSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance)
ChartsSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance)
}

func testPositiveValues()
{
let dataEntries = setupPositiveValuesDataEntries()
let dataSet = setupDefaultDataSet(chartDataEntries: dataEntries)
let chart = setupDefaultChart(dataSets: [dataSet])
FBSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance)
ChartsSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance)
}

func testPositiveValuesWithCustomAxisMaximum()
Expand All @@ -110,7 +110,7 @@ class BarChartTests: FBSnapshotTestCase
let chart = setupDefaultChart(dataSets: [dataSet])
chart.leftAxis.axisMaximum = 50
chart.notifyDataSetChanged()
FBSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance)
ChartsSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance)
}

func testPositiveValuesWithCustomAxisMaximum2()
Expand All @@ -120,7 +120,7 @@ class BarChartTests: FBSnapshotTestCase
let chart = setupDefaultChart(dataSets: [dataSet])
chart.leftAxis.axisMaximum = -10
chart.notifyDataSetChanged()
FBSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance)
ChartsSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance)
}

func testPositiveValuesWithCustomAxisMinimum()
Expand All @@ -130,7 +130,7 @@ class BarChartTests: FBSnapshotTestCase
let chart = setupDefaultChart(dataSets: [dataSet])
chart.leftAxis.axisMinimum = 50
chart.notifyDataSetChanged()
FBSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance)
ChartsSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance)
}

func testPositiveValuesWithCustomAxisMinimum2()
Expand All @@ -140,7 +140,7 @@ class BarChartTests: FBSnapshotTestCase
let chart = setupDefaultChart(dataSets: [dataSet])
chart.leftAxis.axisMinimum = 110
chart.notifyDataSetChanged()
FBSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance)
ChartsSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance)
}

func testPositiveValuesWithCustomAxisMaximumAndCustomAxisMaximum()
Expand All @@ -152,15 +152,15 @@ class BarChartTests: FBSnapshotTestCase
chart.leftAxis.axisMaximum = 200
chart.leftAxis.axisMinimum = -10
chart.notifyDataSetChanged()
FBSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance)
ChartsSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance)
}

func testNegativeValues()
{
let dataEntries = setupNegativeValuesDataEntries()
let dataSet = setupDefaultDataSet(chartDataEntries: dataEntries)
let chart = setupDefaultChart(dataSets: [dataSet])
FBSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance)
ChartsSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance)
}

func testNegativeValuesWithCustomAxisMaximum()
Expand All @@ -170,7 +170,7 @@ class BarChartTests: FBSnapshotTestCase
let chart = setupDefaultChart(dataSets: [dataSet])
chart.leftAxis.axisMaximum = 10
chart.notifyDataSetChanged()
FBSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance)
ChartsSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance)
}

func testNegativeValuesWithCustomAxisMaximum2()
Expand All @@ -180,7 +180,7 @@ class BarChartTests: FBSnapshotTestCase
let chart = setupDefaultChart(dataSets: [dataSet])
chart.leftAxis.axisMaximum = -150
chart.notifyDataSetChanged()
FBSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance)
ChartsSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance)
}


Expand All @@ -191,7 +191,7 @@ class BarChartTests: FBSnapshotTestCase
let chart = setupDefaultChart(dataSets: [dataSet])
chart.leftAxis.axisMinimum = -200
chart.notifyDataSetChanged()
FBSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance)
ChartsSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance)
}

func testNegativeValuesWithCustomAxisMinimum2()
Expand All @@ -201,7 +201,7 @@ class BarChartTests: FBSnapshotTestCase
let chart = setupDefaultChart(dataSets: [dataSet])
chart.leftAxis.axisMinimum = 10
chart.notifyDataSetChanged()
FBSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance)
ChartsSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance)
}

func testNegativeValuesWithCustomAxisMaximumAndCustomAxisMaximum()
Expand All @@ -213,7 +213,7 @@ class BarChartTests: FBSnapshotTestCase
chart.leftAxis.axisMaximum = 10
chart.leftAxis.axisMinimum = -200
chart.notifyDataSetChanged()
FBSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance)
ChartsSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance)
}

func testHidesValues()
Expand All @@ -223,7 +223,7 @@ class BarChartTests: FBSnapshotTestCase
let chart = setupDefaultChart(dataSets: [dataSet])
dataSet.drawValuesEnabled = false
chart.notifyDataSetChanged()
FBSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance)
ChartsSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance)
}

func testHideLeftAxis()
Expand All @@ -233,7 +233,7 @@ class BarChartTests: FBSnapshotTestCase
let chart = setupDefaultChart(dataSets: [dataSet])
chart.leftAxis.enabled = false
chart.notifyDataSetChanged()
FBSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance)
ChartsSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance)
}

func testHideRightAxis()
Expand All @@ -243,7 +243,7 @@ class BarChartTests: FBSnapshotTestCase
let chart = setupDefaultChart(dataSets: [dataSet])
chart.rightAxis.enabled = false
chart.notifyDataSetChanged()
FBSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance)
ChartsSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance)
}

func testInvertedLeftAxis()
Expand All @@ -253,7 +253,7 @@ class BarChartTests: FBSnapshotTestCase
let chart = setupDefaultChart(dataSets: [dataSet])
chart.leftAxis.inverted = true
chart.notifyDataSetChanged()
FBSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance)
ChartsSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance)
}

func testInvertedLeftAxisWithNegativeValues()
Expand All @@ -263,7 +263,7 @@ class BarChartTests: FBSnapshotTestCase
let chart = setupDefaultChart(dataSets: [dataSet])
chart.leftAxis.inverted = true
chart.notifyDataSetChanged()
FBSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance)
ChartsSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance)
}

func testInvertedLeftAxisWithPositiveValues()
Expand All @@ -273,7 +273,7 @@ class BarChartTests: FBSnapshotTestCase
let chart = setupDefaultChart(dataSets: [dataSet])
chart.leftAxis.inverted = true
chart.notifyDataSetChanged()
FBSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance)
ChartsSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance)
}

func testInvertedRightAxis()
Expand All @@ -284,7 +284,7 @@ class BarChartTests: FBSnapshotTestCase
let chart = setupDefaultChart(dataSets: [dataSet])
chart.rightAxis.inverted = true
chart.notifyDataSetChanged()
FBSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance)
ChartsSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance)
}

func testInvertedRightAxisWithNegativeValues()
Expand All @@ -295,7 +295,7 @@ class BarChartTests: FBSnapshotTestCase
let chart = setupDefaultChart(dataSets: [dataSet])
chart.rightAxis.inverted = true
chart.notifyDataSetChanged()
FBSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance)
ChartsSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance)
}

func testInvertedRightAxisWithPositiveValues()
Expand All @@ -306,7 +306,7 @@ class BarChartTests: FBSnapshotTestCase
let chart = setupDefaultChart(dataSets: [dataSet])
chart.rightAxis.inverted = true
chart.notifyDataSetChanged()
FBSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance)
ChartsSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance)
}

func testHideHorizontalGridlines()
Expand All @@ -317,7 +317,7 @@ class BarChartTests: FBSnapshotTestCase
chart.leftAxis.drawGridLinesEnabled = false
chart.rightAxis.drawGridLinesEnabled = false
chart.notifyDataSetChanged()
FBSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance)
ChartsSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance)
}

func testHideVerticalGridlines()
Expand All @@ -327,7 +327,7 @@ class BarChartTests: FBSnapshotTestCase
let chart = setupDefaultChart(dataSets: [dataSet])
chart.xAxis.drawGridLinesEnabled = false
chart.notifyDataSetChanged()
FBSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance)
ChartsSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance)
}

func testDrawIcons()
Expand All @@ -337,6 +337,6 @@ class BarChartTests: FBSnapshotTestCase
let chart = setupDefaultChart(dataSets: [dataSet])
dataSet.drawIconsEnabled = true
chart.notifyDataSetChanged()
FBSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance)
ChartsSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance)
}
}
6 changes: 3 additions & 3 deletions Tests/Charts/CombinedChartTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class CombinedChartTests: FBSnapshotTestCase

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

func testLeftRightAxisDependency()
Expand All @@ -89,7 +89,7 @@ class CombinedChartTests: FBSnapshotTestCase
barDataSet.axisDependency = .right
chart.data?.notifyDataChanged()
chart.notifyDataSetChanged()
FBSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance)
ChartsSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance)
}

func testAllRightAxisDependency()
Expand All @@ -98,7 +98,7 @@ class CombinedChartTests: FBSnapshotTestCase
barDataSet.axisDependency = .right
chart.data?.notifyDataChanged()
chart.notifyDataSetChanged()
FBSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance)
ChartsSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance)
}
}

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, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance)
ChartsSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance)
}

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

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

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

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

func testDrawIcons()
{
dataSet.drawIconsEnabled = true
FBSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance)
ChartsSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance)
}
}
8 changes: 4 additions & 4 deletions Tests/Charts/PieChartTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,24 +50,24 @@ class PieChartTests: FBSnapshotTestCase

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

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

func testDrawIcons()
{
dataSet.drawIconsEnabled = true
FBSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance)
ChartsSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance)
}

func testHideCenterLabel()
{
chart.drawCenterTextEnabled = false
FBSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance)
ChartsSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance)
}
}
9 changes: 9 additions & 0 deletions Tests/Charts/Snapshot.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import CoreGraphics
import FBSnapshotTestCase

public struct Snapshot
{
Expand All @@ -21,3 +22,11 @@ public struct Snapshot
return "\(identifier)_\(size.width)_\(size.height)"
}
}

public extension FBSnapshotTestCase
{
func ChartsSnapshotVerifyView(_ view: UIView, identifier: String = "", suffixes: NSOrderedSet = NSOrderedSet(object: "_64"), perPixelTolerance: CGFloat = 0, overallTolerance: CGFloat = 0, file: StaticString = #file, line: UInt = #line)
{
FBSnapshotVerifyView(view, identifier: identifier, suffixes: suffixes, perPixelTolerance: perPixelTolerance, overallTolerance: overallTolerance, file: file, line: line)
}
}

0 comments on commit ba86bf7

Please sign in to comment.