diff --git a/.travis.yml b/.travis.yml index 1f50e82..e8acbf6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,2 +1,4 @@ language: objective-c osx_image: xcode7.1 + +script: xctool -project MobilePlayer.xcodeproj -scheme MobilePlayer clean build CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO diff --git a/MobilePlayer.podspec b/MobilePlayer.podspec index 6ab8f1c..342e96e 100755 --- a/MobilePlayer.podspec +++ b/MobilePlayer.podspec @@ -1,13 +1,12 @@ Pod::Spec.new do |s| s.name = "MobilePlayer" - s.version = "1.0.1" + s.version = "1.0.2" s.summary = "A powerful and completely customizable media player for iOS." s.homepage = "https://github.com/mobileplayer/mobileplayer-ios" s.license = 'CC' s.author = { "Barış Şencan" => "baris.sncn@gmail.com", "Toygar Dündaralp" => "tdundaralp@gmail.com", - "Cem Olcay" => "ccemolcay@gmail.com", - "Şahin Boydaş" => "sahinboydas@gmail.com" } + "Cem Olcay" => "ccemolcay@gmail.com" } s.source = { :git => "https://github.com/mobileplayer/mobileplayer-ios.git", :tag => s.version.to_s } s.platform = :ios, '8.0' s.requires_arc = true diff --git a/MobilePlayer.xcodeproj/project.pbxproj b/MobilePlayer.xcodeproj/project.pbxproj index 8421dba..9ced2d2 100644 --- a/MobilePlayer.xcodeproj/project.pbxproj +++ b/MobilePlayer.xcodeproj/project.pbxproj @@ -81,17 +81,12 @@ 5FF829671C168E4700EF50C4 /* ProgConfigExampleViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5FF829661C168E4700EF50C4 /* ProgConfigExampleViewController.swift */; }; 5FF829691C16924400EF50C4 /* MovielalaPlayer.json in Resources */ = {isa = PBXBuildFile; fileRef = 5FF829681C16924400EF50C4 /* MovielalaPlayer.json */; }; C308B3C01B150F7600CB1515 /* MobilePlayerConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = C308B3BE1B150F7600CB1515 /* MobilePlayerConfig.swift */; }; - C35497A31B70007500FDDBFF /* SkinTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C35497A21B70007500FDDBFF /* SkinTests.swift */; }; - C38833C91B266C2500918C94 /* Skin.json in Resources */ = {isa = PBXBuildFile; fileRef = C38833C81B266C2500918C94 /* Skin.json */; }; - C39C749F1B75400700E6CD21 /* KIF.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C39C749E1B75400700E6CD21 /* KIF.framework */; }; - C3A406AD1B27A8DE00D1833D /* YoutubeTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3A406AC1B27A8DE00D1833D /* YoutubeTests.swift */; }; C3A406AF1B27AA8C00D1833D /* UIColor+Hex.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3A406AE1B27AA8C00D1833D /* UIColor+Hex.swift */; }; C3A406B01B27AA9500D1833D /* UIColor+Hex.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3A406AE1B27AA8C00D1833D /* UIColor+Hex.swift */; }; CE554D551AFE6CCD00DAC7E9 /* MobilePlayer.h in Headers */ = {isa = PBXBuildFile; fileRef = CE554D541AFE6CCD00DAC7E9 /* MobilePlayer.h */; settings = {ATTRIBUTES = (Public, ); }; }; CE554D5B1AFE6CCD00DAC7E9 /* MobilePlayer.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CE554D4F1AFE6CCD00DAC7E9 /* MobilePlayer.framework */; }; CE554D731AFE6EBB00DAC7E9 /* MobilePlayerOverlayViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE554D6E1AFE6EBB00DAC7E9 /* MobilePlayerOverlayViewController.swift */; }; CE554D741AFE6EBB00DAC7E9 /* MobilePlayerViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE554D6F1AFE6EBB00DAC7E9 /* MobilePlayerViewController.swift */; }; - EEA04B28926490156EB2A4F1 /* Pods_MobilePlayerTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 505CCD80FF878F8F17EC4627 /* Pods_MobilePlayerTests.framework */; settings = {ATTRIBUTES = (Weak, ); }; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -222,10 +217,8 @@ 6CCEC38BCAA197BDB85EEE44 /* Pods-MobilePlayer.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-MobilePlayer.release.xcconfig"; path = "Pods/Target Support Files/Pods-MobilePlayer/Pods-MobilePlayer.release.xcconfig"; sourceTree = ""; }; AAC564F266BFE6E6667728D5 /* Pods-MobilePlayer.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-MobilePlayer.debug.xcconfig"; path = "Pods/Target Support Files/Pods-MobilePlayer/Pods-MobilePlayer.debug.xcconfig"; sourceTree = ""; }; C308B3BE1B150F7600CB1515 /* MobilePlayerConfig.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MobilePlayerConfig.swift; sourceTree = ""; }; - C35497A21B70007500FDDBFF /* SkinTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SkinTests.swift; sourceTree = ""; }; C38833C81B266C2500918C94 /* Skin.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = Skin.json; sourceTree = ""; }; C39C749E1B75400700E6CD21 /* KIF.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = KIF.framework; path = "Pods/../build/Debug-iphoneos/KIF.framework"; sourceTree = ""; }; - C3A406AC1B27A8DE00D1833D /* YoutubeTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = YoutubeTests.swift; sourceTree = ""; }; C3A406AE1B27AA8C00D1833D /* UIColor+Hex.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIColor+Hex.swift"; sourceTree = ""; }; C3ADD7B61B6C327E00E82C3B /* SnapKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SnapKit.framework; path = "Pods/../build/Debug-iphoneos/Pods-MobilePlayerExample/SnapKit.framework"; sourceTree = ""; }; CE554D4F1AFE6CCD00DAC7E9 /* MobilePlayer.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = MobilePlayer.framework; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -276,9 +269,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - C39C749F1B75400700E6CD21 /* KIF.framework in Frameworks */, CE554D5B1AFE6CCD00DAC7E9 /* MobilePlayer.framework in Frameworks */, - EEA04B28926490156EB2A4F1 /* Pods_MobilePlayerTests.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -501,8 +492,6 @@ CE554D5E1AFE6CCD00DAC7E9 /* MobilePlayerTests */ = { isa = PBXGroup; children = ( - C3A406AC1B27A8DE00D1833D /* YoutubeTests.swift */, - C35497A21B70007500FDDBFF /* SkinTests.swift */, CE554D5F1AFE6CCD00DAC7E9 /* Supporting Files */, ); path = MobilePlayerTests; @@ -853,8 +842,6 @@ buildActionMask = 2147483647; files = ( C3A406B01B27AA9500D1833D /* UIColor+Hex.swift in Sources */, - C35497A31B70007500FDDBFF /* SkinTests.swift in Sources */, - C3A406AD1B27A8DE00D1833D /* YoutubeTests.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1117,7 +1104,6 @@ }; CE554D691AFE6CCD00DAC7E9 /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 0A3D625F8D46F7B3823A9927 /* Pods-MobilePlayerTests.debug.xcconfig */; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; FRAMEWORK_SEARCH_PATHS = ( @@ -1140,7 +1126,6 @@ }; CE554D6A1AFE6CCD00DAC7E9 /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 460022C3A2D4FC80A1D57D18 /* Pods-MobilePlayerTests.release.xcconfig */; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; FRAMEWORK_SEARCH_PATHS = ( diff --git a/MobilePlayer/Supporting Files/Info.plist b/MobilePlayer/Supporting Files/Info.plist index 7a84553..9645e5d 100644 --- a/MobilePlayer/Supporting Files/Info.plist +++ b/MobilePlayer/Supporting Files/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 1.0.1 + 1.0.2 CFBundleSignature ???? CFBundleVersion diff --git a/MobilePlayerTests/SkinTests.swift b/MobilePlayerTests/SkinTests.swift deleted file mode 100644 index 1c47c93..0000000 --- a/MobilePlayerTests/SkinTests.swift +++ /dev/null @@ -1,326 +0,0 @@ -// -// SkinTests.swift -// MobilePlayer -// -// Created by Toygar Dündaralp on 8/3/15. -// Copyright (c) 2015 MovieLaLa. All rights reserved. -// - -import UIKit -import XCTest -import MobilePlayer - -class SkinTests: XCTestCase { - - override func setUp() { - super.setUp() - } - - // controlbar tests - - func testPlayPauseButton() { - let fileURL = NSBundle(forClass: SkinTests.self).URLForResource("Skin", withExtension:"json")! - let skin = SkinParser.parseConfigFromURL(fileURL) - if let skinDictionary = skin?.skinDictionary as [String: AnyObject]? { - if let controlbar = skinDictionary["controlbar"] as? [[String: AnyObject]] { - if let order = controlbar[0]["order"] as? Int { - XCTAssertEqual(order, 0, "order not valid!") - } - if let playButtonTintColor = controlbar[0]["playTintColor"] as? String { - XCTAssertEqual(playButtonTintColor, "#ffffff", "play button tint color not valid!") - } - if let playImage = controlbar[0]["playImage"] as? String { - XCTAssertEqual(playImage, "MLPlayButton", "play image not valid!") - } - if let pauseImage = controlbar[0]["pauseImage"] as? String { - XCTAssertEqual(pauseImage, "MLPauseButton", "pause image not valid!") - } - if let pauseTintColor = controlbar[0]["pauseTintColor"] as? String { - XCTAssertEqual(pauseTintColor, "#ffffff", "pause tint color not valid!") - } - if let type = controlbar[0]["type"] as? String { - XCTAssertEqual(type, "button", "type not valid!") - } - if let subType = controlbar[0]["subType"] as? String { - XCTAssertEqual(subType, "play", "subType not valid!") - } - } - } - } - - func testTimeLabel() { - let fileURL = NSBundle(forClass: SkinTests.self).URLForResource("Skin", withExtension:"json")! - let skin = SkinParser.parseConfigFromURL(fileURL) - if let skinDictionary = skin?.skinDictionary as [String: AnyObject]? { - if let controlbar = skinDictionary["controlbar"] as? [[String: AnyObject]] { - if let order = controlbar[1]["order"] as? Int { - XCTAssertEqual(order, 1, "order not valid!") - } - if let textFont = controlbar[1]["textFont"] as? String { - XCTAssertEqual(textFont, "HelveticaNeue", "textfont not valid!") - } - if let textFontSize = controlbar[1]["textFontSize"] as? Int { - XCTAssertEqual(textFontSize, 15, "textFontSize not valid!") - } - if let textColor = controlbar[1]["textColor"] as? String { - XCTAssertEqual(textColor, "#ffffff", "textColor not valid!") - } - if let type = controlbar[1]["type"] as? String { - XCTAssertEqual(type, "label", "type not valid!") - } - if let subType = controlbar[1]["subType"] as? String { - XCTAssertEqual(subType, "time", "subType not valid!") - } - } - } - } - - func testSeperator(){ - let fileURL = NSBundle(forClass: SkinTests.self).URLForResource("Skin", withExtension:"json")! - let skin = SkinParser.parseConfigFromURL(fileURL) - if let skinDictionary = skin?.skinDictionary as [String: AnyObject]? { - if let controlbar = skinDictionary["controlbar"] as? [[String: AnyObject]] { - if let order = controlbar[2]["order"] as? Int { - XCTAssertEqual(order, 2, "order not valid!") - } - if let type = controlbar[2]["type"] as? String { - XCTAssertEqual(type, "view", "type not valid!") - } - if let subType = controlbar[2]["subType"] as? String { - XCTAssertEqual(subType, "seperator", "subType not valid!") - } - } - } - } - - func testTimeSlider(){ - let fileURL = NSBundle(forClass: SkinTests.self).URLForResource("Skin", withExtension:"json")! - let skin = SkinParser.parseConfigFromURL(fileURL) - if let skinDictionary = skin?.skinDictionary as [String: AnyObject]? { - if let controlbar = skinDictionary["controlbar"] as? [[String: AnyObject]] { - if let order = controlbar[3]["order"] as? Int { - XCTAssertEqual(order, 3, "order not valid!") - } - if let type = controlbar[3]["type"] as? String { - XCTAssertEqual(type, "view", "type not valid!") - } - if let subType = controlbar[3]["subType"] as? String { - XCTAssertEqual(subType, "timeSlider", "subType not valid!") - } - if let radius = controlbar[3]["radius"] as? Int { - XCTAssertEqual(radius, 5, "subType not valid!") - } - if let railHeight = controlbar[3]["railHeight"] as? Int { - XCTAssertEqual(railHeight, 10, "railHeight not valid!") - } - if let thumbRadius = controlbar[3]["thumbRadius"] as? Float { - XCTAssertEqual(thumbRadius, 12.5, "thumbRadius not valid!") - } - if let thumbHeight = controlbar[3]["thumbHeight"] as? Int { - XCTAssertEqual(thumbHeight, 25, "thumbHeight not valid!") - } - if let thumbWidth = controlbar[3]["thumbWidth"] as? Int { - XCTAssertEqual(thumbWidth, 25, "thumbWidth not valid!") - } - if let thumbBorder = controlbar[3]["thumbBorder"] as? Int { - XCTAssertEqual(thumbBorder, 0, "thumbBorder not valid!") - } - if let railTintColor = controlbar[3]["railTintColor"] as? String { - XCTAssertEqual(railTintColor, "#cccccc", "railTintColor not valid!") - } - if let bufferTintColor = controlbar[3]["bufferTintColor"] as? String { - XCTAssertEqual(bufferTintColor, "#9e9b9a", "bufferTintColor not valid!") - } - if let progressTintColor = controlbar[3]["progressTintColor"] as? String { - XCTAssertEqual(progressTintColor, "#ae3f1c", "progressTintColor not valid!") - } - if let thumbTintColor = controlbar[3]["thumbTintColor"] as? String { - XCTAssertEqual(thumbTintColor, "#e54918", "thumbTintColor not valid!") - } - } - } - } - - func testSeperatorTwo(){ - let fileURL = NSBundle(forClass: SkinTests.self).URLForResource("Skin", withExtension:"json")! - let skin = SkinParser.parseConfigFromURL(fileURL) - if let skinDictionary = skin?.skinDictionary as [String: AnyObject]? { - if let controlbar = skinDictionary["controlbar"] as? [[String: AnyObject]] { - if let order = controlbar[4]["order"] as? Int { - XCTAssertEqual(order, 4, "order not valid!") - } - if let type = controlbar[4]["type"] as? String { - XCTAssertEqual(type, "view", "type not valid!") - } - if let subType = controlbar[4]["subType"] as? String { - XCTAssertEqual(subType, "seperator", "subType not valid!") - } - } - } - } - - func testRemainingLabel(){ - let fileURL = NSBundle(forClass: SkinTests.self).URLForResource("Skin", withExtension:"json")! - let skin = SkinParser.parseConfigFromURL(fileURL) - if let skinDictionary = skin?.skinDictionary as [String: AnyObject]? { - if let controlbar = skinDictionary["controlbar"] as? [[String: AnyObject]] { - if let order = controlbar[5]["order"] as? Int { - XCTAssertEqual(order, 5, "order not valid!") - } - if let type = controlbar[5]["type"] as? String { - XCTAssertEqual(type, "label", "type not valid!") - } - if let subType = controlbar[5]["subType"] as? String { - XCTAssertEqual(subType, "remaining", "subType not valid!") - } - if let textFont = controlbar[5]["textFont"] as? String { - XCTAssertEqual(textFont, "HelveticaNeue", "textFont not valid!") - } - if let textFontSize = controlbar[5]["textFontSize"] as? Int { - XCTAssertEqual(textFontSize, 15, "textFontSize not valid!") - } - if let textColor = controlbar[5]["textColor"] as? String { - XCTAssertEqual(textColor, "#ffffff", "textColor not valid!") - } - } - } - } - - func testDurationLabel(){ - let fileURL = NSBundle(forClass: SkinTests.self).URLForResource("Skin", withExtension:"json")! - let skin = SkinParser.parseConfigFromURL(fileURL) - if let skinDictionary = skin?.skinDictionary as [String: AnyObject]? { - if let controlbar = skinDictionary["controlbar"] as? [[String: AnyObject]] { - if let order = controlbar[6]["order"] as? Int { - XCTAssertEqual(order, 6, "order not valid!") - } - if let type = controlbar[6]["type"] as? String { - XCTAssertEqual(type, "label", "type not valid!") - } - if let subType = controlbar[6]["subType"] as? String { - XCTAssertEqual(subType, "duration", "subType not valid!") - } - if let textFont = controlbar[6]["textFont"] as? String { - XCTAssertEqual(textFont, "HelveticaNeue", "textFont not valid!") - } - if let textFontSize = controlbar[6]["textFontSize"] as? Int { - XCTAssertEqual(textFontSize, 15, "textFontSize not valid!") - } - if let textColor = controlbar[6]["textColor"] as? String { - XCTAssertEqual(textColor, "#ffffff", "textColor not valid!") - } - } - } - } - - func testVolumeView(){ - let fileURL = NSBundle(forClass: SkinTests.self).URLForResource("Skin", withExtension:"json")! - let skin = SkinParser.parseConfigFromURL(fileURL) - if let skinDictionary = skin?.skinDictionary as [String: AnyObject]? { - if let controlbar = skinDictionary["controlbar"] as? [[String: AnyObject]] { - if let order = controlbar[7]["order"] as? Int { - XCTAssertEqual(order, 7, "order not valid!") - } - if let type = controlbar[7]["type"] as? String { - XCTAssertEqual(type, "button", "type not valid!") - } - if let subType = controlbar[7]["subType"] as? String { - XCTAssertEqual(subType, "volume", "subType not valid!") - } - if let railTintColor = controlbar[7]["railTintColor"] as? String { - XCTAssertEqual(railTintColor, "#cccccc", "railTintColor not valid!") - } - if let progressTintColor = controlbar[7]["progressTintColor"] as? String { - XCTAssertEqual(progressTintColor, "#0000ff", "progressTintColor not valid!") - } - if let thumbTintColor = controlbar[7]["thumbTintColor"] as? String { - XCTAssertEqual(thumbTintColor, "#c5c5c5", "thumbTintColor not valid!") - } - if let image = controlbar[7]["image"] as? String { - XCTAssertEqual(image, "MLVolumeButton", "image not valid!") - } - if let backgroundColor = controlbar[7]["backgroundColor"] as? String { - XCTAssertEqual(backgroundColor, "#ffffff", "backgroundColor not valid!") - } - } - } - } - - // header tests - - func testCloseButton(){ - let fileURL = NSBundle(forClass: SkinTests.self).URLForResource("Skin", withExtension:"json")! - let skin = SkinParser.parseConfigFromURL(fileURL) - if let skinDictionary = skin?.skinDictionary as [String: AnyObject]? { - if let controlbar = skinDictionary["header"] as? [[String: AnyObject]] { - if let order = controlbar[0]["order"] as? Int { - XCTAssertEqual(order, 0, "order not valid!") - } - if let image = controlbar[0]["image"] as? String { - XCTAssertEqual(image, "MLCloseButton", "image not valid!") - } - if let type = controlbar[0]["type"] as? String { - XCTAssertEqual(type, "button", "type not valid!") - } - if let subType = controlbar[0]["subType"] as? String { - XCTAssertEqual(subType, "close", "subType not valid!") - } - if let tintColor = controlbar[0]["tintColor"] as? String { - XCTAssertEqual(tintColor, "#ffffff", "tintColor not valid!") - } - } - } - } - - func testTitleLabel(){ - let fileURL = NSBundle(forClass: SkinTests.self).URLForResource("Skin", withExtension:"json")! - let skin = SkinParser.parseConfigFromURL(fileURL) - if let skinDictionary = skin?.skinDictionary as [String: AnyObject]? { - if let controlbar = skinDictionary["header"] as? [[String: AnyObject]] { - if let order = controlbar[1]["order"] as? Int { - XCTAssertEqual(order, 1, "order not valid!") - } - if let textFont = controlbar[1]["textFont"] as? String { - XCTAssertEqual(textFont, "HelveticaNeue", "textFont not valid!") - } - if let textSize = controlbar[1]["textSize"] as? Int { - XCTAssertEqual(textSize, 16, "textSize not valid!") - } - if let type = controlbar[1]["type"] as? String { - XCTAssertEqual(type, "label", "type not valid!") - } - if let subType = controlbar[1]["subType"] as? String { - XCTAssertEqual(subType, "title", "subType not valid!") - } - if let tintColor = controlbar[1]["tintColor"] as? String { - XCTAssertEqual(tintColor, "#ffffff", "tintColor not valid!") - } - } - } - } - - func testShareButton(){ - let fileURL = NSBundle(forClass: SkinTests.self).URLForResource("Skin", withExtension:"json")! - let skin = SkinParser.parseConfigFromURL(fileURL) - if let skinDictionary = skin?.skinDictionary as [String: AnyObject]? { - if let controlbar = skinDictionary["header"] as? [[String: AnyObject]] { - if let order = controlbar[2]["order"] as? Int { - XCTAssertEqual(order, 2, "order not valid!") - } - if let image = controlbar[2]["image"] as? String { - XCTAssertEqual(image, "MLShareButton", "image not valid!") - } - if let type = controlbar[2]["type"] as? String { - XCTAssertEqual(type, "button", "type not valid!") - } - if let subType = controlbar[2]["subType"] as? String { - XCTAssertEqual(subType, "share", "subType not valid!") - } - if let tintColor = controlbar[2]["tintColor"] as? String { - XCTAssertEqual(tintColor, "#ffffff", "tintColor not valid!") - } - } - } - } - -} diff --git a/MobilePlayerTests/YoutubeTests.swift b/MobilePlayerTests/YoutubeTests.swift deleted file mode 100644 index 03ca447..0000000 --- a/MobilePlayerTests/YoutubeTests.swift +++ /dev/null @@ -1,95 +0,0 @@ -// -// YoutubeTests.swift -// MobilePlayer -// -// Created by Toygar Dündaralp on 09/06/15. -// Copyright (c) 2015 MovieLaLa. All rights reserved. -// - -import UIKit -import XCTest -import MobilePlayer - -class YoutubeTests: XCTestCase { - - override func setUp() { - super.setUp() - } - - func testStringByDecodingURLFormat() { - let originalString = "https://www.youtube.com/watch?v=XUFpdwbfqqQ+XUFpdwbfqqQ" - let testString = "https://www.youtube.com/watch?v=XUFpdwbfqqQ XUFpdwbfqqQ" - let comparsionString = originalString.stringByDecodingURLFormat() - XCTAssertNotNil(comparsionString, "comparsionString is nil") - XCTAssertEqual(comparsionString, testString, "String decoding failed") - } - - func testDictionaryFromQueryStringComponents() { - let sampleLink = "https://www.youtube.com/watch?v=o0jJiB2Ygpg&list=RDo0jJiB2Ygpg" - let dictionary = sampleLink.dictionaryFromQueryStringComponents() as [String:AnyObject] - XCTAssertNotNil(dictionary["list"], "url dictionary parse error") - if let list = dictionary["list"] as? String { - XCTAssertEqual(list, "RDo0jJiB2Ygpg", "list not equal value") - } - if let link = dictionary["https://www.youtube.com/watch?v="] as? String { - XCTAssertEqual(link, "o0jJiB2Ygpg", "link not equal value") - } - } - - func testYoutubeIDFromYoutubeURL() { - let sampleLink = NSURL(string: "http://www.youtube.com/watch?v=1hZ98an9wjo")! - XCTAssertNotNil(Youtube.youtubeIDFromYoutubeURL(sampleLink), "Youtube ID is nil") - if let youtubeID = Youtube.youtubeIDFromYoutubeURL(sampleLink) { - XCTAssertEqual(youtubeID, "1hZ98an9wjo", "Youtube ID not same") - } - } - - func testH264videosWithYoutubeURL() { - let sampleLink = NSURL(string: "http://www.youtube.com/watch?v=1hZ98an9wjo")! - if let videoComponents = Youtube.h264videosWithYoutubeID("1hZ98an9wjo") { - XCTAssertNotNil(videoComponents, "video component is nil") - if let itag = videoComponents["itag"] as? String { - XCTAssertEqual(itag, "22", "itag not equal") - } - if let quality = videoComponents["quality"] as? String { - XCTAssertEqual(quality, "hd720", "quality not equal") - } - if let fallback_host = videoComponents["fallback_host"] as? String { - XCTAssertEqual(fallback_host, "tc.v7.cache1.googlevideo.com", "fallback_host not equal") - } - if let type = videoComponents["type"] as? String { - XCTAssertEqual(type, "video/mp4; codecs=\"avc1.64001F, mp4a.40.2\"", "type not equal") - } - } - } - - func testh264videosWithYoutubeURLBlock() { - if let videoURL = NSURL(string: "http://www.youtube.com/watch?v=1hZ98an9wjo") { - Youtube.h264videosWithYoutubeURL(videoURL, completion: { (videoInfo, error) -> Void in - XCTAssertNotNil(videoInfo, "video dictionary is nil") - if let info = videoInfo as [String:AnyObject]? { - if let itag = info["itag"] as? String { - XCTAssertEqual(itag, "22", "itag not equal") - } - if let quality = info["quality"] as? String { - XCTAssertEqual(quality, "hd720", "quality not equal") - } - if let fallback_host = info["fallback_host"] as? String { - XCTAssertEqual(fallback_host, "tc.v7.cache1.googlevideo.com", "fallback_host not equal") - } - if let type = info["type"] as? String { - XCTAssertEqual(type, "video/mp4; codecs=\"avc1.64001F, mp4a.40.2\"", "type not equal") - } - } - }) - } - if let liveVideoURL = NSURL(string: "https://www.youtube.com/watch?v=E3DEih8_6O8"){ - Youtube.h264videosWithYoutubeURL(liveVideoURL, completion: { (videoInfo, error) -> Void in - XCTAssertNotNil(videoInfo, "video dictionary is nil") - if let info = videoInfo as [String:AnyObject]? { - XCTAssertNotNil(info["url"], "live stream url is nil") - } - }) - } - } -}