Skip to content

Commit

Permalink
updated unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
abjurato committed Nov 10, 2016
1 parent fbba515 commit 56a8712
Show file tree
Hide file tree
Showing 53 changed files with 55 additions and 6 deletions.
4 changes: 4 additions & 0 deletions Charts.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@
06B3C0F81D99F85400B1DF43 /* LineChartTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06B3C0F41D99F85400B1DF43 /* LineChartTests.swift */; };
06B3C0F91D99F85400B1DF43 /* ChartsRealmTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06B3C0F61D99F85400B1DF43 /* ChartsRealmTest.swift */; };
5B56A9CD1D905EB300F58178 /* Description.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B56A9CC1D905EB300F58178 /* Description.swift */; };
D8A58A411DCE2EF8007BB012 /* Media.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = D8A58A401DCE2EF8007BB012 /* Media.xcassets */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -337,6 +338,7 @@
06B3C0F41D99F85400B1DF43 /* LineChartTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LineChartTests.swift; sourceTree = "<group>"; };
06B3C0F61D99F85400B1DF43 /* ChartsRealmTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ChartsRealmTest.swift; sourceTree = "<group>"; };
5B56A9CC1D905EB300F58178 /* Description.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Description.swift; sourceTree = "<group>"; };
D8A58A401DCE2EF8007BB012 /* Media.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Media.xcassets; path = Charts/ChartsTests/Media.xcassets; sourceTree = SOURCE_ROOT; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -737,6 +739,7 @@
isa = PBXGroup;
children = (
06B121111D81201C00D14B02 /* Info.plist */,
D8A58A401DCE2EF8007BB012 /* Media.xcassets */,
);
name = "Supporting Files";
sourceTree = "<group>";
Expand Down Expand Up @@ -891,6 +894,7 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
D8A58A411DCE2EF8007BB012 /* Media.xcassets in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
6 changes: 6 additions & 0 deletions Charts/ChartsTests/Media.xcassets/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}
23 changes: 23 additions & 0 deletions Charts/ChartsTests/Media.xcassets/icon.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "star-2.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "star-1.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "star.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
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.
4 changes: 2 additions & 2 deletions Source/Charts/Utils/ChartUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,10 @@ open class ChartUtils
image.draw(in: CGRect(origin: CGPoint(x: 0, y: 0), size: expectedSize))
let scaledImage = NSUIGraphicsGetImageFromCurrentImageContext()
NSUIGraphicsEndImageContext()
scaledImage?.draw(at: drawOffset)
scaledImage?.draw(in: CGRect(origin: point, size: expectedSize))
}
else {
image.draw(at: drawOffset)
image.draw(in: CGRect(origin: point, size: expectedSize))
}

NSUIGraphicsPopContext()
Expand Down
12 changes: 10 additions & 2 deletions Tests/Charts/BarChartTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@ class BarChartTests: FBSnapshotTestCase

for (i, value) in values.enumerated()
{
entries.append(BarChartDataEntry(x: Double(i), y: value))
entries.append(BarChartDataEntry(x: Double(i), y: value, data: UIImage(named: "icon", in: Bundle(for: self.classForCoder), compatibleWith: nil)))
}

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

dataSet.drawIconsEnabled = false
dataSet.iconsOffset = CGSize(width: 0, height: -10.0)

let data = BarChartData(dataSet: dataSet)
data.barWidth = 0.85

Expand Down Expand Up @@ -80,4 +82,10 @@ class BarChartTests: FBSnapshotTestCase
chart.xAxis.drawGridLinesEnabled = false
FBSnapshotVerifyView(chart)
}

func testDrawIcons()
{
dataSet.drawIconsEnabled = true
FBSnapshotVerifyView(chart)
}
}
12 changes: 10 additions & 2 deletions Tests/Charts/LineChartTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@ class LineChartTests: FBSnapshotTestCase

for (i, value) in values.enumerated()
{
entries.append(ChartDataEntry(x: Double(i), y: value))
entries.append(ChartDataEntry(x: Double(i), y: value, data: UIImage(named: "icon", in: Bundle(for: self.classForCoder), compatibleWith: nil)))
}

dataSet = LineChartDataSet(values: entries, label: "First unit test data")

dataSet.drawIconsEnabled = false
dataSet.iconsOffset = CGSize(width: 0, height: 20.0)

chart = LineChartView(frame: CGRect(x: 0, y: 0, width: 480, height: 350))
chart.backgroundColor = NSUIColor.clear
chart.leftAxis.axisMinimum = 0.0
Expand Down Expand Up @@ -70,4 +72,10 @@ class LineChartTests: FBSnapshotTestCase
dataSet.drawCircleHoleEnabled = false
FBSnapshotVerifyView(chart)
}

func testDrawIcons()
{
dataSet.drawIconsEnabled = true
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.
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.
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.
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 56a8712

Please sign in to comment.