diff --git a/MobilePlayer.xcodeproj/project.pbxproj b/MobilePlayer.xcodeproj/project.pbxproj index b17f9a8..a6de525 100644 --- a/MobilePlayer.xcodeproj/project.pbxproj +++ b/MobilePlayer.xcodeproj/project.pbxproj @@ -8,6 +8,7 @@ /* Begin PBXBuildFile section */ 5F31B7B91BBAE39900EF50C4 /* MobilePlayerNotification.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5F31B7B81BBAE39900EF50C4 /* MobilePlayerNotification.swift */; settings = {ASSET_TAGS = (); }; }; + 5F4FDFD71BC6EB6200EF50C4 /* LabelConfigTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5F4FDFD61BC6EB6200EF50C4 /* LabelConfigTests.swift */; settings = {ASSET_TAGS = (); }; }; 5F6AF3701BA96EF000EF50C4 /* Button.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5F6AF36F1BA96EF000EF50C4 /* Button.swift */; }; 5F749C261BAB2C8900EF50C4 /* Element.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5F749C251BAB2C8900EF50C4 /* Element.swift */; settings = {ASSET_TAGS = (); }; }; 5F7CDF471BBEB6C400EF50C4 /* YoutubeParser.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5F7CDF461BBEB6C400EF50C4 /* YoutubeParser.swift */; settings = {ASSET_TAGS = (); }; }; @@ -29,7 +30,6 @@ 5FD756961BAC4AE700EF50C4 /* WatermarkViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5FD756951BAC4AE700EF50C4 /* WatermarkViewController.swift */; settings = {ASSET_TAGS = (); }; }; C305DED81B21068700DD9632 /* Minimal.json in Resources */ = {isa = PBXBuildFile; fileRef = C305DED71B21068700DD9632 /* Minimal.json */; }; C308B3C01B150F7600CB1515 /* MobilePlayerConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = C308B3BE1B150F7600CB1515 /* MobilePlayerConfig.swift */; }; - C35497A31B70007500FDDBFF /* SkinTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C35497A21B70007500FDDBFF /* SkinTests.swift */; }; C35E68BF1B7D06F700594CE6 /* PlayerViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C35E68BE1B7D06F700594CE6 /* PlayerViewController.swift */; }; C35FDE0F1B3E0918005C55A6 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = CE554D751AFE6EE400DAC7E9 /* Images.xcassets */; }; C361643D1B6725C2000CE00E /* Hulu.json in Resources */ = {isa = PBXBuildFile; fileRef = C361643C1B6725C2000CE00E /* Hulu.json */; }; @@ -38,8 +38,7 @@ C38BEEA61B72DBD1009E4F64 /* PlayerStateTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = C38BEEA51B72DBD1009E4F64 /* PlayerStateTest.swift */; }; C38FA6511B33279600BE17E8 /* ADBannerViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C38FA6501B33279600BE17E8 /* ADBannerViewController.swift */; }; C38FA6531B33530C00BE17E8 /* PreRollViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C38FA6521B33530C00BE17E8 /* PreRollViewController.swift */; }; - C39C749F1B75400700E6CD21 /* KIF.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C39C749E1B75400700E6CD21 /* KIF.framework */; }; - C3A406AD1B27A8DE00D1833D /* YoutubeTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3A406AC1B27A8DE00D1833D /* YoutubeTests.swift */; }; + C3A406AD1B27A8DE00D1833D /* YoutubeParserTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3A406AC1B27A8DE00D1833D /* YoutubeParserTests.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 */; }; C3A9AEDE1B048B5600D0C842 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3A9AEDD1B048B5600D0C842 /* AppDelegate.swift */; }; @@ -53,17 +52,9 @@ CE554D731AFE6EBB00DAC7E9 /* MobilePlayerOverlayViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE554D6E1AFE6EBB00DAC7E9 /* MobilePlayerOverlayViewController.swift */; }; CE554D741AFE6EBB00DAC7E9 /* MobilePlayerViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE554D6F1AFE6EBB00DAC7E9 /* MobilePlayerViewController.swift */; }; CE554D761AFE6EE400DAC7E9 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = CE554D751AFE6EE400DAC7E9 /* Images.xcassets */; }; - EEA04B28926490156EB2A4F1 /* Pods_MobilePlayerTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 505CCD80FF878F8F17EC4627 /* Pods_MobilePlayerTests.framework */; settings = {ATTRIBUTES = (Weak, ); }; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ - C38BEEA71B72E2AD009E4F64 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = CE554D461AFE6CCD00DAC7E9 /* Project object */; - proxyType = 1; - remoteGlobalIDString = C3A9AED81B048B5600D0C842; - remoteInfo = MobilePlayerExample; - }; C3A9AEEE1B048B5700D0C842 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = CE554D461AFE6CCD00DAC7E9 /* Project object */; @@ -106,6 +97,7 @@ 460022C3A2D4FC80A1D57D18 /* Pods-MobilePlayerTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-MobilePlayerTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-MobilePlayerTests/Pods-MobilePlayerTests.release.xcconfig"; sourceTree = ""; }; 505CCD80FF878F8F17EC4627 /* Pods_MobilePlayerTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_MobilePlayerTests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 5F31B7B81BBAE39900EF50C4 /* MobilePlayerNotification.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MobilePlayerNotification.swift; sourceTree = ""; }; + 5F4FDFD61BC6EB6200EF50C4 /* LabelConfigTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = LabelConfigTests.swift; path = ConfigTests/LabelConfigTests.swift; sourceTree = ""; }; 5F6AF36F1BA96EF000EF50C4 /* Button.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Button.swift; path = Views/Button.swift; sourceTree = ""; }; 5F749C251BAB2C8900EF50C4 /* Element.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Element.swift; path = Views/Element.swift; sourceTree = ""; }; 5F7CDF461BBEB6C400EF50C4 /* YoutubeParser.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = YoutubeParser.swift; path = MobilePlayer/Parsers/YoutubeParser.swift; sourceTree = SOURCE_ROOT; }; @@ -129,7 +121,6 @@ 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 = ""; }; C305DED71B21068700DD9632 /* Minimal.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = Minimal.json; 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 = ""; }; C35E68BE1B7D06F700594CE6 /* PlayerViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PlayerViewController.swift; sourceTree = ""; }; C361643C1B6725C2000CE00E /* Hulu.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = Hulu.json; sourceTree = ""; }; C36164401B673D04000CE00E /* Netflix.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = Netflix.json; sourceTree = ""; }; @@ -138,7 +129,7 @@ C38FA6501B33279600BE17E8 /* ADBannerViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ADBannerViewController.swift; sourceTree = ""; }; C38FA6521B33530C00BE17E8 /* PreRollViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PreRollViewController.swift; 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 = ""; }; + C3A406AC1B27A8DE00D1833D /* YoutubeParserTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = YoutubeParserTests.swift; sourceTree = ""; }; C3A406AE1B27AA8C00D1833D /* UIColor+Hex.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIColor+Hex.swift"; sourceTree = ""; }; C3A9AED91B048B5600D0C842 /* MobilePlayerExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = MobilePlayerExample.app; sourceTree = BUILT_PRODUCTS_DIR; }; C3A9AEDC1B048B5600D0C842 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; @@ -190,15 +181,21 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - C39C749F1B75400700E6CD21 /* KIF.framework in Frameworks */, CE554D5B1AFE6CCD00DAC7E9 /* MobilePlayer.framework in Frameworks */, - EEA04B28926490156EB2A4F1 /* Pods_MobilePlayerTests.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 5F4FDFD51BC6EB2F00EF50C4 /* ConfigTests */ = { + isa = PBXGroup; + children = ( + 5F4FDFD61BC6EB6200EF50C4 /* LabelConfigTests.swift */, + ); + name = ConfigTests; + sourceTree = ""; + }; 5F7CFC251BA22A3100EF50C4 /* Views */ = { isa = PBXGroup; children = ( @@ -359,8 +356,8 @@ CE554D5E1AFE6CCD00DAC7E9 /* MobilePlayerTests */ = { isa = PBXGroup; children = ( - C3A406AC1B27A8DE00D1833D /* YoutubeTests.swift */, - C35497A21B70007500FDDBFF /* SkinTests.swift */, + C3A406AC1B27A8DE00D1833D /* YoutubeParserTests.swift */, + 5F4FDFD51BC6EB2F00EF50C4 /* ConfigTests */, C38BEEA51B72DBD1009E4F64 /* PlayerStateTest.swift */, CE554D5F1AFE6CCD00DAC7E9 /* Supporting Files */, ); @@ -474,18 +471,14 @@ isa = PBXNativeTarget; buildConfigurationList = CE554D681AFE6CCD00DAC7E9 /* Build configuration list for PBXNativeTarget "MobilePlayerTests" */; buildPhases = ( - 39BE5A6F582542962733FA2B /* Check Pods Manifest.lock */, CE554D561AFE6CCD00DAC7E9 /* Sources */, CE554D571AFE6CCD00DAC7E9 /* Frameworks */, CE554D581AFE6CCD00DAC7E9 /* Resources */, - F40C37578BF721D3E7447872 /* Embed Pods Frameworks */, - 34FBA218D2E9EFA476A8CB14 /* Copy Pods Resources */, ); buildRules = ( ); dependencies = ( CE554D5D1AFE6CCD00DAC7E9 /* PBXTargetDependency */, - C38BEEA81B72E2AD009E4F64 /* PBXTargetDependency */, ); name = MobilePlayerTests; productName = MobilePlayerTests; @@ -579,54 +572,6 @@ }; /* End PBXResourcesBuildPhase section */ -/* Begin PBXShellScriptBuildPhase section */ - 34FBA218D2E9EFA476A8CB14 /* Copy Pods Resources */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - name = "Copy Pods Resources"; - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-MobilePlayerTests/Pods-MobilePlayerTests-resources.sh\"\n"; - showEnvVarsInLog = 0; - }; - 39BE5A6F582542962733FA2B /* Check Pods Manifest.lock */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - name = "Check Pods Manifest.lock"; - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n"; - showEnvVarsInLog = 0; - }; - F40C37578BF721D3E7447872 /* Embed Pods Frameworks */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - name = "Embed Pods Frameworks"; - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-MobilePlayerTests/Pods-MobilePlayerTests-frameworks.sh\"\n"; - showEnvVarsInLog = 0; - }; -/* End PBXShellScriptBuildPhase section */ - /* Begin PBXSourcesBuildPhase section */ C3A9AED51B048B5600D0C842 /* Sources */ = { isa = PBXSourcesBuildPhase; @@ -683,20 +628,15 @@ buildActionMask = 2147483647; files = ( C3A406B01B27AA9500D1833D /* UIColor+Hex.swift in Sources */, - C35497A31B70007500FDDBFF /* SkinTests.swift in Sources */, C38BEEA61B72DBD1009E4F64 /* PlayerStateTest.swift in Sources */, - C3A406AD1B27A8DE00D1833D /* YoutubeTests.swift in Sources */, + 5F4FDFD71BC6EB6200EF50C4 /* LabelConfigTests.swift in Sources */, + C3A406AD1B27A8DE00D1833D /* YoutubeParserTests.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXSourcesBuildPhase section */ /* Begin PBXTargetDependency section */ - C38BEEA81B72E2AD009E4F64 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = C3A9AED81B048B5600D0C842 /* MobilePlayerExample */; - targetProxy = C38BEEA71B72E2AD009E4F64 /* PBXContainerItemProxy */; - }; C3A9AEEF1B048B5700D0C842 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = C3A9AED81B048B5600D0C842 /* MobilePlayerExample */; diff --git a/MobilePlayer.xcodeproj/xcshareddata/xcschemes/MobilePlayer.xcscheme b/MobilePlayer.xcodeproj/xcshareddata/xcschemes/MobilePlayer.xcscheme index df6ffbc..0c03451 100644 --- a/MobilePlayer.xcodeproj/xcshareddata/xcschemes/MobilePlayer.xcscheme +++ b/MobilePlayer.xcodeproj/xcshareddata/xcschemes/MobilePlayer.xcscheme @@ -40,7 +40,8 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" - shouldUseLaunchSchemeArgsEnv = "YES"> + shouldUseLaunchSchemeArgsEnv = "YES" + codeCoverageEnabled = "YES"> diff --git a/MobilePlayerTests/ConfigTests/LabelConfigTests.swift b/MobilePlayerTests/ConfigTests/LabelConfigTests.swift new file mode 100644 index 0000000..6f485e2 --- /dev/null +++ b/MobilePlayerTests/ConfigTests/LabelConfigTests.swift @@ -0,0 +1,50 @@ +// +// LabelConfigTests.swift +// MobilePlayer +// +// Created by Baris Sencan on 08/10/2015. +// Copyright © 2015 MovieLaLa. All rights reserved. +// + +import UIKit +import XCTest +@testable import MobilePlayer + +private let defaultText: String? = nil +private let text = "lorem ipsum" + +private let font = "Baskerville" + +private let defaultSize = CGFloat(14) +private let defaultTitleSize = CGFloat(16) +private let size = CGFloat(22) + +private let defaultColor = UIColor.whiteColor() +private let colorString = "#fffffff0" +private let color = UIColor(red: 1, green: 1, blue: 1, alpha: 240 / 255) + +class LabelConfigTests: XCTestCase { + let defaultLabelConfig = LabelConfig() + let defaultTitleLabelConfig = LabelConfig(dictionary: ["identifier": "title"]) + let labelConfig = LabelConfig(dictionary: [ + "text": text, + "font": font, + "size": size, + "textColor": colorString]) + + func testText() { + XCTAssert(defaultLabelConfig.text == defaultText, "default text is wrong") + XCTAssert(labelConfig.text == text, "failed to set text") + } + + func testFont() { + XCTAssert(defaultLabelConfig.font == UIFont.systemFontOfSize(defaultSize), "default font is wrong") + XCTAssert(defaultTitleLabelConfig.font == UIFont.systemFontOfSize(defaultTitleSize), "default title font is wrong") + XCTAssert(labelConfig.font == UIFont(name: font, size: size), "failed to set font") + } + + func testTextColor() { + XCTAssert(defaultLabelConfig.textColor == defaultColor, "default text color is wrong") + XCTAssert(labelConfig.textColor == color, "failed to set text color") + } +} 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/YoutubeParserTests.swift b/MobilePlayerTests/YoutubeParserTests.swift new file mode 100644 index 0000000..943c07d --- /dev/null +++ b/MobilePlayerTests/YoutubeParserTests.swift @@ -0,0 +1,61 @@ +// +// YoutubeParserTests.swift +// MobilePlayer +// +// Created by Toygar Dündaralp on 09/06/15. +// Copyright (c) 2015 MovieLaLa. All rights reserved. +// + +import Foundation +import XCTest +@testable import MobilePlayer + +class YoutubeParserTests: XCTestCase { + + func testYoutubeIDFromURL() { + let youtubeID = "rNkjAGNCpeE" + XCTAssert( + youtubeID == YoutubeParser.youtubeIDFromURL(NSURL(string: "https://www.youtube.com/watch?v=\(youtubeID)")!), + "failed to fetch youtube id from url") + } + + func testH264videosWithYoutubeID() { + let fetchExpectation = expectationWithDescription("video information fetching") + + var youtubeVideoInfo: YoutubeVideoInfo? + YoutubeParser.h264videosWithYoutubeID("1hZ98an9wjo") { videoInfo, error in + youtubeVideoInfo = videoInfo + fetchExpectation.fulfill() + } + + waitForExpectationsWithTimeout(5) { error in + XCTAssert(youtubeVideoInfo?.title == "10 Unsolved Mysteries Of The Brain", "video title is wrong") + XCTAssert(youtubeVideoInfo?.isStream == false, "video isStream property is wrong") + XCTAssert( + youtubeVideoInfo?.previewImageURL == "https://i.ytimg.com/vi/1hZ98an9wjo/hqdefault.jpg", + "video preview image url is wrong") + XCTAssert( + NSURL(string: youtubeVideoInfo!.videoURL!)?.host?.containsString("googlevideo.com") == true, + "video url is wrong") + } + } + +// 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") +// } +// } +// } +} 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") - } - }) - } - } -}