diff --git a/MobilePlayer.xcodeproj/project.pbxproj b/MobilePlayer.xcodeproj/project.pbxproj index 0351109..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 */; }; @@ -97,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; }; @@ -120,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 = ""; }; @@ -188,6 +188,14 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 5F4FDFD51BC6EB2F00EF50C4 /* ConfigTests */ = { + isa = PBXGroup; + children = ( + 5F4FDFD61BC6EB6200EF50C4 /* LabelConfigTests.swift */, + ); + name = ConfigTests; + sourceTree = ""; + }; 5F7CFC251BA22A3100EF50C4 /* Views */ = { isa = PBXGroup; children = ( @@ -349,7 +357,7 @@ isa = PBXGroup; children = ( C3A406AC1B27A8DE00D1833D /* YoutubeParserTests.swift */, - C35497A21B70007500FDDBFF /* SkinTests.swift */, + 5F4FDFD51BC6EB2F00EF50C4 /* ConfigTests */, C38BEEA51B72DBD1009E4F64 /* PlayerStateTest.swift */, CE554D5F1AFE6CCD00DAC7E9 /* Supporting Files */, ); @@ -620,8 +628,8 @@ buildActionMask = 2147483647; files = ( C3A406B01B27AA9500D1833D /* UIColor+Hex.swift in Sources */, - C35497A31B70007500FDDBFF /* SkinTests.swift in Sources */, C38BEEA61B72DBD1009E4F64 /* PlayerStateTest.swift in Sources */, + 5F4FDFD71BC6EB6200EF50C4 /* LabelConfigTests.swift in Sources */, C3A406AD1B27A8DE00D1833D /* YoutubeParserTests.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/MobilePlayerTests/ConfigTests/LabelConfigTests.swift b/MobilePlayerTests/ConfigTests/LabelConfigTests.swift new file mode 100644 index 0000000..2997650 --- /dev/null +++ b/MobilePlayerTests/ConfigTests/LabelConfigTests.swift @@ -0,0 +1,47 @@ +// +// 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 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 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(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!") - } - } - } - } - -}