Explorar o código

Merge pull request #580 from alvesjtiago/bar-chart-tests

Bar chart tests
Daniel Cohen Gindi %!s(int64=9) %!d(string=hai) anos
pai
achega
3f88894f31

+ 1 - 1
Charts/Cartfile.resolved

@@ -1 +1 @@
-github "facebook/ios-snapshot-test-case" "2.0.5"
+github "facebook/ios-snapshot-test-case" "2.0.7"

+ 8 - 4
Charts/Carthage/Checkouts/ios-snapshot-test-case/CHANGELOG.md

@@ -2,6 +2,14 @@
 
 
 All notable changes to this project will be documented in this file.
 All notable changes to this project will be documented in this file.
 
 
+## 2.0.7
+
+  - Change FBSnapshotTestController from private to public (#129)
+
+## 2.0.6
+
+  - Added modulemap and podspec fixes to build with Xcode 7.1 (#127)
+
 ## 2.0.5
 ## 2.0.5
 
 
   - Swift 2.0 (#111, #120) (Thanks to @pietbrauer and @grantjk)
   - Swift 2.0 (#111, #120) (Thanks to @pietbrauer and @grantjk)
@@ -33,14 +41,10 @@ All notable changes to this project will be documented in this file.
 
 
 ## 1.8.1
 ## 1.8.1
 
 
-### Fixed
-
   - Prevent mangling of C function names when compiled with a C++ compiler. (#79)
   - Prevent mangling of C function names when compiled with a C++ compiler. (#79)
 
 
 ## 1.8.0
 ## 1.8.0
 
 
-### Changed
-
   - The default directories for snapshots images are now **ReferenceImages_32** (32bit) and **ReferenceImages_64** (64bit) and the suffix depends on the architecture when the test is running. (#77) 
   - The default directories for snapshots images are now **ReferenceImages_32** (32bit) and **ReferenceImages_64** (64bit) and the suffix depends on the architecture when the test is running. (#77) 
   	- If a test fails for a given suffix, it will try to load and compare all other suffixes before failing.
   	- If a test fails for a given suffix, it will try to load and compare all other suffixes before failing.
   - Added assertion on setRecordMode. (#76)
   - Added assertion on setRecordMode. (#76)

+ 6 - 5
Charts/Carthage/Checkouts/ios-snapshot-test-case/FBSnapshotTestCase.podspec

@@ -1,6 +1,6 @@
 Pod::Spec.new do |s|
 Pod::Spec.new do |s|
   s.name         = "FBSnapshotTestCase"
   s.name         = "FBSnapshotTestCase"
-  s.version      = "2.0.5"
+  s.version      = "2.0.7"
   s.summary      = "Snapshot view unit tests for iOS"
   s.summary      = "Snapshot view unit tests for iOS"
   s.description  = <<-DESC
   s.description  = <<-DESC
                     A "snapshot test case" takes a configured UIView or CALayer
                     A "snapshot test case" takes a configured UIView or CALayer
@@ -16,13 +16,14 @@ Pod::Spec.new do |s|
                      :tag => s.version.to_s }
                      :tag => s.version.to_s }
   s.platform     = :ios, '7.0'
   s.platform     = :ios, '7.0'
   s.requires_arc = true
   s.requires_arc = true
-  s.framework    = 'XCTest'
+  s.frameworks    = 'XCTest','UIKit','Foundation','QuartzCore'
   s.pod_target_xcconfig = { 'ENABLE_BITCODE' => 'NO' }
   s.pod_target_xcconfig = { 'ENABLE_BITCODE' => 'NO' }
-  s.public_header_files = ['FBSnapshotTestCase/FBSnapshotTestCase.h', 'FBSnapshotTestCase/FBSnapshotTestCasePlatform.h']
-  s.private_header_files = ['FBSnapshotTestCase/FBSnapshotTestController.h', 'FBSnapshotTestCase/UIImage+Compare.h', 'FBSnapshotTestCase/UIImage+Diff.h']
   s.default_subspecs = 'SwiftSupport'
   s.default_subspecs = 'SwiftSupport'
+  s.module_map = 'FBSnapshotTestCase.modulemap'
   s.subspec 'Core' do |cs|
   s.subspec 'Core' do |cs|
-    cs.source_files = 'FBSnapshotTestCase/**/*.{h,m}'
+    cs.source_files = 'FBSnapshotTestCase/**/*.{h,m}', 'FBSnapshotTestCase/*.{h,m}'
+    cs.public_header_files = 'FBSnapshotTestCase/FBSnapshotTestCase.h','FBSnapshotTestCase/FBSnapshotTestCasePlatform.h','FBSnapshotTestCase/FBSnapshotTestController.h'
+    cs.private_header_files = 'FBSnapshotTestCase/Categories/UIImage+Compare.h','FBSnapshotTestCase/Categories/UIImage+Diff.h','FBSnapshotTestCase/Categories/UIImage+Snapshot.h'
   end
   end
   s.subspec 'SwiftSupport' do |cs|
   s.subspec 'SwiftSupport' do |cs|
     cs.dependency 'FBSnapshotTestCase/Core'
     cs.dependency 'FBSnapshotTestCase/Core'

+ 5 - 5
Charts/Carthage/Checkouts/ios-snapshot-test-case/FBSnapshotTestCaseDemo/Podfile.lock

@@ -1,8 +1,8 @@
 PODS:
 PODS:
-  - FBSnapshotTestCase (2.0.5):
-    - FBSnapshotTestCase/SwiftSupport (= 2.0.5)
-  - FBSnapshotTestCase/Core (2.0.5)
-  - FBSnapshotTestCase/SwiftSupport (2.0.5):
+  - FBSnapshotTestCase (2.0.6):
+    - FBSnapshotTestCase/SwiftSupport (= 2.0.6)
+  - FBSnapshotTestCase/Core (2.0.6)
+  - FBSnapshotTestCase/SwiftSupport (2.0.6):
     - FBSnapshotTestCase/Core
     - FBSnapshotTestCase/Core
 
 
 DEPENDENCIES:
 DEPENDENCIES:
@@ -13,6 +13,6 @@ EXTERNAL SOURCES:
     :path: ".."
     :path: ".."
 
 
 SPEC CHECKSUMS:
 SPEC CHECKSUMS:
-  FBSnapshotTestCase: 6917deb01d0556dd544536f9eb34e0cf26f904d5
+  FBSnapshotTestCase: f53793e19b2782f2948e8597b03ec2bb5aedf5cd
 
 
 COCOAPODS: 0.39.0
 COCOAPODS: 0.39.0

+ 4 - 0
Charts/Charts.xcodeproj/project.pbxproj

@@ -194,6 +194,7 @@
 		A52C5C8D1BAC5D1200594CDD /* ChartTransformerHorizontalBarChart.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5BB6EC1C1ACC28AB006E9C25 /* ChartTransformerHorizontalBarChart.swift */; };
 		A52C5C8D1BAC5D1200594CDD /* ChartTransformerHorizontalBarChart.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5BB6EC1C1ACC28AB006E9C25 /* ChartTransformerHorizontalBarChart.swift */; };
 		A52C5C8E1BAC5D1200594CDD /* ChartUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5BA8EC7C1A9D151C00CE82E1 /* ChartUtils.swift */; };
 		A52C5C8E1BAC5D1200594CDD /* ChartUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5BA8EC7C1A9D151C00CE82E1 /* ChartUtils.swift */; };
 		A52C5C8F1BAC5D1200594CDD /* ChartViewPortHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5BD8F06C1AB897D500566E05 /* ChartViewPortHandler.swift */; };
 		A52C5C8F1BAC5D1200594CDD /* ChartViewPortHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5BD8F06C1AB897D500566E05 /* ChartViewPortHandler.swift */; };
+		DDC77DC61C0A991A00C27BCF /* BarChartTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDC77DC51C0A991A00C27BCF /* BarChartTests.swift */; };
 /* End PBXBuildFile section */
 /* End PBXBuildFile section */
 
 
 /* Begin PBXContainerItemProxy section */
 /* Begin PBXContainerItemProxy section */
@@ -319,6 +320,7 @@
 		5BD4C57B1BCDBF6C00462351 /* ScatterChartDataProvider.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ScatterChartDataProvider.swift; sourceTree = "<group>"; };
 		5BD4C57B1BCDBF6C00462351 /* ScatterChartDataProvider.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ScatterChartDataProvider.swift; sourceTree = "<group>"; };
 		5BD8F06C1AB897D500566E05 /* ChartViewPortHandler.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ChartViewPortHandler.swift; sourceTree = "<group>"; };
 		5BD8F06C1AB897D500566E05 /* ChartViewPortHandler.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ChartViewPortHandler.swift; sourceTree = "<group>"; };
 		A52C5C371BAC5CA400594CDD /* Charts.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Charts.framework; sourceTree = BUILT_PRODUCTS_DIR; };
 		A52C5C371BAC5CA400594CDD /* Charts.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Charts.framework; sourceTree = BUILT_PRODUCTS_DIR; };
+		DDC77DC51C0A991A00C27BCF /* BarChartTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BarChartTests.swift; sourceTree = "<group>"; };
 /* End PBXFileReference section */
 /* End PBXFileReference section */
 
 
 /* Begin PBXFrameworksBuildPhase section */
 /* Begin PBXFrameworksBuildPhase section */
@@ -350,6 +352,7 @@
 		06AEE7A31BDC3F8B009875AE /* ChartsTests */ = {
 		06AEE7A31BDC3F8B009875AE /* ChartsTests */ = {
 			isa = PBXGroup;
 			isa = PBXGroup;
 			children = (
 			children = (
+				DDC77DC51C0A991A00C27BCF /* BarChartTests.swift */,
 				06AEE7AD1BDC3FC6009875AE /* LineChartTests.swift */,
 				06AEE7AD1BDC3FC6009875AE /* LineChartTests.swift */,
 				06AEE7A61BDC3F8B009875AE /* Info.plist */,
 				06AEE7A61BDC3F8B009875AE /* Info.plist */,
 			);
 			);
@@ -719,6 +722,7 @@
 			isa = PBXSourcesBuildPhase;
 			isa = PBXSourcesBuildPhase;
 			buildActionMask = 2147483647;
 			buildActionMask = 2147483647;
 			files = (
 			files = (
+				DDC77DC61C0A991A00C27BCF /* BarChartTests.swift in Sources */,
 				06AEE7AE1BDC3FC6009875AE /* LineChartTests.swift in Sources */,
 				06AEE7AE1BDC3FC6009875AE /* LineChartTests.swift in Sources */,
 			);
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 			runOnlyForDeploymentPostprocessing = 0;

+ 78 - 0
Charts/ChartsTests/BarChartTests.swift

@@ -0,0 +1,78 @@
+import XCTest
+import FBSnapshotTestCase
+@testable import Charts
+
+class BarChartTests: FBSnapshotTestCase
+{
+    
+    var chart: BarChartView!
+    var dataSet: BarChartDataSet!
+    
+    override func setUp()
+    {
+        super.setUp()
+        
+        // Set to `true` to re-capture all snapshots
+        self.recordMode = false
+        
+        // Sample data
+        let values: [Double] = [8, 104, 81, 93, 52, 44, 97, 101, 75, 28,
+            76, 25, 20, 13, 52, 44, 57, 23, 45, 91,
+            99, 14, 84, 48, 40, 71, 106, 41, 45, 61]
+        
+        var entries: [ChartDataEntry] = Array()
+        var xValues: [String] = Array()
+        
+        for (i, value) in values.enumerate()
+        {
+            entries.append(BarChartDataEntry.init(value: value, xIndex: i))
+            xValues.append("\(i)")
+        }
+        
+        dataSet = BarChartDataSet(yVals: entries, label: "Bar chart unit test data")
+        
+        chart = BarChartView(frame: CGRectMake(0, 0, 480, 350))
+        chart.data = BarChartData(xVals: xValues, 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)
+    }
+    
+    func testHidesValues()
+    {
+        dataSet.drawValuesEnabled = false
+        FBSnapshotVerifyView(chart)
+    }
+    
+    func testHideLeftAxis()
+    {
+        chart.leftAxis.drawAxisLineEnabled = false
+        FBSnapshotVerifyView(chart)
+    }
+    
+    func testHideRightAxis()
+    {
+        chart.rightAxis.drawAxisLineEnabled = false
+        FBSnapshotVerifyView(chart)
+    }
+    
+    func testHideLeftAxisGridlines()
+    {
+        chart.leftAxis.drawGridLinesEnabled = false
+        FBSnapshotVerifyView(chart)
+    }
+    
+    func testHideRightAxisGridlines()
+    {
+        chart.rightAxis.drawGridLinesEnabled = false
+        FBSnapshotVerifyView(chart)
+    }
+}

BIN=BIN
Charts/ChartsTests/ReferenceImages_64/ChartsTests.BarChartTests/testDefaultValues@2x.png


BIN=BIN
Charts/ChartsTests/ReferenceImages_64/ChartsTests.BarChartTests/testHideLeftAxis@2x.png


BIN=BIN
Charts/ChartsTests/ReferenceImages_64/ChartsTests.BarChartTests/testHideLeftAxisGridlines@2x.png


BIN=BIN
Charts/ChartsTests/ReferenceImages_64/ChartsTests.BarChartTests/testHideRightAxis@2x.png


BIN=BIN
Charts/ChartsTests/ReferenceImages_64/ChartsTests.BarChartTests/testHideRightAxisGridlines@2x.png


BIN=BIN
Charts/ChartsTests/ReferenceImages_64/ChartsTests.BarChartTests/testHidesValues@2x.png