Video.swift 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*****************************************************************************
  2. * Video.swift
  3. *****************************************************************************
  4. * Copyright (C) 2018 Mike JS. Choi
  5. * Copyright (C) 2018 VLC authors and VideoLAN
  6. * $Id$
  7. *
  8. * Authors: Mike JS. Choi <mkchoi212 # icloud.com>
  9. *
  10. * This program is free software; you can redistribute it and/or modify it
  11. * under the terms of the GNU Lesser General Public License as published by
  12. * the Free Software Foundation; either version 2.1 of the License, or
  13. * (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU Lesser General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU Lesser General Public License
  21. * along with this program; if not, write to the Free Software Foundation,
  22. * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  23. *****************************************************************************/
  24. import XCTest
  25. struct Video {
  26. let name: String
  27. let type: String
  28. let meta: [String:String]
  29. #if os(OSX)
  30. let bundle = Bundle(identifier: "org.videolan.VLCKitTests")!
  31. #elseif os(iOS)
  32. let bundle = Bundle(identifier: "org.videolan.MobileVLCKitTests") != nil ? Bundle(identifier: "org.videolan.MobileVLCKitTests")! : Bundle(identifier: "org.videolan.DynamicMobileVLCKitTests")!
  33. #elseif os(tvOS)
  34. let bundle = Bundle(identifier: "org.videolan.TVVLCKitTests")!
  35. #endif
  36. static let standards = [Video.test1, Video.test2, Video.test3, Video.test4]
  37. static let test1 = Video(
  38. name: "bird",
  39. type: "m4v",
  40. meta: ["title": "bird.m4v", "date": "2017", "trackNumber": "1", "genre": "Chill", "description": "Bird looking into the abiss"]
  41. )
  42. static let test2 = Video(
  43. name: "bunny",
  44. type: "avi",
  45. meta: ["title": "bunny.avi", "genre": "Nature", "description": "Cute bunny looking for something"]
  46. )
  47. static let test3 = Video(
  48. name: "salmon",
  49. type: "mp4",
  50. meta: ["title": "salmon.mp4", "date": "2016", "trackNumber": "2", "genre": "Lake", "description": "Salmon trying to swim upstream"]
  51. )
  52. static let test4 = Video(
  53. name: "sea_lions",
  54. type: "mov",
  55. meta: ["title": "sea_lions.mov", "description": "Tanning sea lions", "genre": "Nature"]
  56. )
  57. static let invalid = Video(
  58. name: "invalid",
  59. type: "foo",
  60. meta: [:]
  61. )
  62. var media: VLCMedia {
  63. return VLCMedia(path: path)
  64. }
  65. var path: String {
  66. if type == "foo" {
  67. return title
  68. }
  69. let path = bundle.path(forResource: name, ofType: type)
  70. return path!
  71. }
  72. var url: URL {
  73. let url = bundle.url(forResource: name, withExtension: type)
  74. XCTAssertNotNil(url)
  75. return url!
  76. }
  77. var title: String {
  78. return "\(name).\(type)"
  79. }
  80. }