Commit 7734b081 authored by Mike JS. Choi's avatar Mike JS. Choi Committed by Carola Nitz

Tests: VLCLibrary

parent 12a1b0af
......@@ -218,6 +218,8 @@
CAA03D2520C8DE7B001764DA /* CoreMedia.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CAA03D2420C8DE7A001764DA /* CoreMedia.framework */; };
CAA9F00320D254AB00CDBB2C /* VLCTimeTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = CAA9F00120D254A600CDBB2C /* VLCTimeTest.swift */; };
CAA9F00420D254AC00CDBB2C /* VLCTimeTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = CAA9F00120D254A600CDBB2C /* VLCTimeTest.swift */; };
CABEDAB821095242005FED09 /* VLCLibraryTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = CABEDAB721095242005FED09 /* VLCLibraryTest.swift */; };
CABEDAB921095242005FED09 /* VLCLibraryTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = CABEDAB721095242005FED09 /* VLCLibraryTest.swift */; };
CABF4D4120D8DBA900FCCE29 /* VLCMediaTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = CABF4D4020D8DBA900FCCE29 /* VLCMediaTest.swift */; };
CABF4D4220D8DBA900FCCE29 /* VLCMediaTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = CABF4D4020D8DBA900FCCE29 /* VLCMediaTest.swift */; };
CABCBAE220EB0B080040E2F5 /* VLCAudioTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = CABCBADD20EB0B080040E2F5 /* VLCAudioTest.swift */; };
......@@ -479,6 +481,7 @@
CAA9EFFE20D2549300CDBB2C /* TVVLCKitTests-Bridging-Header.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "TVVLCKitTests-Bridging-Header.h"; sourceTree = "<group>"; };
CAA9EFFF20D2549300CDBB2C /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
CAA9F00120D254A600CDBB2C /* VLCTimeTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = VLCTimeTest.swift; sourceTree = "<group>"; };
CABEDAB721095242005FED09 /* VLCLibraryTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = VLCLibraryTest.swift; sourceTree = "<group>"; };
CABF4D4020D8DBA900FCCE29 /* VLCMediaTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VLCMediaTest.swift; sourceTree = "<group>"; };
CABCBADD20EB0B080040E2F5 /* VLCAudioTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = VLCAudioTest.swift; sourceTree = "<group>"; };
D2AAC07E0554694100DB518D /* libMobileVLCKit.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libMobileVLCKit.a; sourceTree = BUILT_PRODUCTS_DIR; };
......@@ -908,6 +911,7 @@
isa = PBXGroup;
children = (
CABCBADD20EB0B080040E2F5 /* VLCAudioTest.swift */,
CABEDAB721095242005FED09 /* VLCLibraryTest.swift */,
CAA9F00120D254A600CDBB2C /* VLCTimeTest.swift */,
CABF4D4020D8DBA900FCCE29 /* VLCMediaTest.swift */,
);
......@@ -1329,6 +1333,7 @@
CA7BC89120F4419E00C86820 /* XCTestHelper.swift in Sources */,
CAA9F00320D254AB00CDBB2C /* VLCTimeTest.swift in Sources */,
CABCBAE220EB0B080040E2F5 /* VLCAudioTest.swift in Sources */,
CABEDAB821095242005FED09 /* VLCLibraryTest.swift in Sources */,
CA1E134E21087D750066F32F /* Video.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
......@@ -1341,6 +1346,7 @@
CA7BC89520F441B500C86820 /* XCTestHelper.swift in Sources */,
CAA9F00420D254AC00CDBB2C /* VLCTimeTest.swift in Sources */,
CABCBAE320EB0B080040E2F5 /* VLCAudioTest.swift in Sources */,
CABEDAB921095242005FED09 /* VLCLibraryTest.swift in Sources */,
CA1E134F21087D750066F32F /* Video.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
......
/*****************************************************************************
* VLCLibraryTest.swift
*****************************************************************************
* Copyright (C) 2018 VLC authors and VideoLAN
* $Id$
*
* Authors: Mike JS. Choi <mkchoi212 # icloud.com>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
import XCTest
class VLCLibraryTest: XCTestCase {
let paramKey = "VLCParams"
override func setUp() {
super.setUp()
UserDefaults.standard.removeObject(forKey: paramKey)
}
func testSharedLibrary() {
XCTAssertNotNil(VLCLibrary.shared())
XCTAssertNotNil(VLCLibrary.shared().instance)
}
func testInitWithOptions() throws {
let customLibrary1 = try XCTAssertNotNilAndUnwrap(VLCLibrary(options: ["--verbose=1", "--avi-index=1"]))
assertDefaultParameters()
XCTAssertNotNil(customLibrary1.instance)
UserDefaults.standard.removeObject(forKey: paramKey)
let customLibrary2 = try XCTAssertNotNilAndUnwrap(VLCLibrary(options: []))
assertDefaultParameters()
XCTAssertNotNil(customLibrary2.instance)
}
func testInit() {
let library = VLCLibrary()
XCTAssertNotNil(library.instance)
assertDefaultParameters()
}
func testDebugLoggingLevel() throws {
let library = try XCTAssertNotNilAndUnwrap(VLCLibrary.shared())
XCTAssertEqual(library.debugLoggingLevel, 0)
let tests: [(input: Int32, expected: Int32)] = [
(0, 0),
(3, 3),
(4, 4),
(100, 0),
(-10, 0)
]
for (input, expected) in tests {
library.debugLoggingLevel = input
XCTAssertEqual(library.debugLoggingLevel, expected)
}
}
func testDebugLogging() throws {
let library = try XCTAssertNotNilAndUnwrap(VLCLibrary.shared())
XCTAssertFalse(library.debugLogging)
library.debugLogging = true
XCTAssertTrue(library.debugLogging)
library.debugLogging = false
XCTAssertFalse(library.debugLogging)
}
func testLibraryDescription() throws {
let library = try XCTAssertNotNilAndUnwrap(VLCLibrary.shared())
let warn: (String) -> (String) = { desirable in
return "Should hold a string of form \"\(desirable)\""
}
XCTAssertFalse(library.version.isEmpty, warn("3.0.4 Vetinari"))
XCTAssertFalse(library.compiler.isEmpty, warn("InstalledDir: /Applications/Xcode.app/..."))
XCTAssertFalse(library.changeset.isEmpty, warn("3.0.3-1-108-g7039639e6b"))
}
}
extension VLCLibraryTest {
func assertDefaultParameters() {
let expected = [
"--play-and-pause",
"--no-color",
"--no-video-title-show",
"--verbose=4",
"--no-sout-keep",
"--vout=macosx",
"--text-renderer=freetype",
"--extraintf=macosx_dialog_provider",
"--audio-resampler=soxr"
]
let defaultParams = UserDefaults.standard.object(forKey: paramKey)
#if os(macOS)
XCTAssertEqual(defaultParams as? [String], expected)
#else
XCTAssertNil(defaultParams)
#endif
}
}
......@@ -102,6 +102,7 @@
CA23EBCC20BDF07700C0D635 /* VLCTimeTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = CA23EBCB20BDF07700C0D635 /* VLCTimeTest.swift */; };
CA766ED620E9E53E009B3F3F /* VLCAudioTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = CA766ED520E9E53E009B3F3F /* VLCAudioTest.swift */; };
CA7BC8B720F4424100C86820 /* XCTestHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = CA7BC8B020F4424100C86820 /* XCTestHelper.swift */; };
CABEDABB2109525B005FED09 /* VLCLibraryTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = CABEDABA2109525B005FED09 /* VLCLibraryTest.swift */; };
CABF4D5420D8E31700FCCE29 /* VLCMediaTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = CABF4D5320D8E31700FCCE29 /* VLCMediaTest.swift */; };
/* End PBXBuildFile section */
......@@ -221,6 +222,7 @@
CA23EBCB20BDF07700C0D635 /* VLCTimeTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = VLCTimeTest.swift; sourceTree = "<group>"; };
CA766ED520E9E53E009B3F3F /* VLCAudioTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VLCAudioTest.swift; sourceTree = "<group>"; };
CA7BC8B020F4424100C86820 /* XCTestHelper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = XCTestHelper.swift; sourceTree = "<group>"; };
CABEDABA2109525B005FED09 /* VLCLibraryTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = VLCLibraryTest.swift; sourceTree = "<group>"; };
CABF4D5320D8E31700FCCE29 /* VLCMediaTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = VLCMediaTest.swift; sourceTree = "<group>"; };
CCEC5B73114D9BE800D34AAB /* deprecated.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = deprecated.h; path = libvlc/vlc/include/vlc/deprecated.h; sourceTree = SOURCE_ROOT; };
CCEC5B74114D9BE800D34AAB /* libvlc_events.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = libvlc_events.h; path = libvlc/vlc/include/vlc/libvlc_events.h; sourceTree = SOURCE_ROOT; };
......@@ -528,6 +530,7 @@
CA23EBC720BDF03400C0D635 /* Sources */ = {
isa = PBXGroup;
children = (
CABEDABA2109525B005FED09 /* VLCLibraryTest.swift */,
CABF4D5320D8E31700FCCE29 /* VLCMediaTest.swift */,
CA766ED520E9E53E009B3F3F /* VLCAudioTest.swift */,
CA23EBCB20BDF07700C0D635 /* VLCTimeTest.swift */,
......@@ -833,6 +836,7 @@
CABF4D5420D8E31700FCCE29 /* VLCMediaTest.swift in Sources */,
CA23EBCC20BDF07700C0D635 /* VLCTimeTest.swift in Sources */,
CA766ED620E9E53E009B3F3F /* VLCAudioTest.swift in Sources */,
CABEDABB2109525B005FED09 /* VLCLibraryTest.swift in Sources */,
CA7BC8B720F4424100C86820 /* XCTestHelper.swift in Sources */,
CA1E133021087CD60066F32F /* Video.swift in Sources */,
);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment