-
-
Notifications
You must be signed in to change notification settings - Fork 6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
80 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import XCTest | ||
import FBSnapshotTestCase | ||
@testable import Charts | ||
|
||
class PieChartTests: FBSnapshotTestCase | ||
{ | ||
|
||
var chart: PieChartView! | ||
var dataSet: PieChartDataSet! | ||
|
||
override func setUp() | ||
{ | ||
super.setUp() | ||
|
||
// Set to `true` to re-capture all snapshots | ||
self.recordMode = false | ||
|
||
// Sample data | ||
let values: [Double] = [11, 33, 81, 52, 97, 101, 75] | ||
|
||
var entries: [PieChartDataEntry] = Array() | ||
|
||
for value in values | ||
{ | ||
entries.append(PieChartDataEntry(value: value, icon: UIImage(named: "icon", in: Bundle(for: self.classForCoder), compatibleWith: nil))) | ||
} | ||
|
||
dataSet = PieChartDataSet(values: entries, label: "First unit test data") | ||
dataSet.drawIconsEnabled = false | ||
dataSet.iconsOffset = CGPoint(x: 0, y: 20.0) | ||
|
||
dataSet.colors = ChartColorTemplates.vordiplom() | ||
+ ChartColorTemplates.joyful() | ||
+ ChartColorTemplates.colorful() | ||
+ ChartColorTemplates.liberty() | ||
+ ChartColorTemplates.pastel() | ||
+ [UIColor(red: 51/255, green: 181/255, blue: 229/255, alpha: 1)] | ||
|
||
chart = PieChartView(frame: CGRect(x: 0, y: 0, width: 480, height: 350)) | ||
chart.backgroundColor = NSUIColor.clear | ||
chart.centerText = "PieChart Unit Test" | ||
chart.data = PieChartData(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, identifier: Snapshot.identifier(UIScreen.main.bounds.size), tolerance: Snapshot.tolerance) | ||
} | ||
|
||
func testHidesValues() | ||
{ | ||
dataSet.drawValuesEnabled = false | ||
FBSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), tolerance: Snapshot.tolerance) | ||
} | ||
|
||
func testDrawIcons() | ||
{ | ||
dataSet.drawIconsEnabled = true | ||
FBSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), tolerance: Snapshot.tolerance) | ||
} | ||
|
||
func testHideCenterLabel() | ||
{ | ||
chart.drawCenterTextEnabled = false | ||
FBSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), tolerance: Snapshot.tolerance) | ||
} | ||
} | ||
|
||
|
||
|
Binary file added
BIN
+56.2 KB
...nceImages_64/ChartsTests.PieChartTests/testDefaultValues_iOS_375.0_667.0@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+56.2 KB
...eImages_64/ChartsTests.PieChartTests/testDrawCenterLabel_iOS_375.0_667.0@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+65.7 KB
...ferenceImages_64/ChartsTests.PieChartTests/testDrawIcons_iOS_375.0_667.0@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+53.5 KB
...eImages_64/ChartsTests.PieChartTests/testHideCenterLabel_iOS_375.0_667.0@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+49 KB
...renceImages_64/ChartsTests.PieChartTests/testHidesValues_iOS_375.0_667.0@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.