Commit 4a806265 authored by Mike JS. Choi's avatar Mike JS. Choi Committed by Carola Nitz

Tests: Add tests for VLCAudio, setPassthrough, VolumeDown, VolumeUp and SetVolume

parent ca81ecdd
......@@ -194,6 +194,8 @@
CAA9F00420D254AC00CDBB2C /* VLCTimeTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = CAA9F00120D254A600CDBB2C /* VLCTimeTest.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 */; };
CABCBAE320EB0B080040E2F5 /* VLCAudioTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = CABCBADD20EB0B080040E2F5 /* VLCAudioTest.swift */; };
CABF4D4520D8DCDD00FCCE29 /* libMobileVLCKit.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D2AAC07E0554694100DB518D /* libMobileVLCKit.a */; };
CABF4D4620D8DD1B00FCCE29 /* libc++.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 7D797FC31DF41F9100AD93ED /* libc++.tbd */; };
CABF4D4720D8DD2000FCCE29 /* libbz2.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 7D24C2B51EC0A3390047E700 /* libbz2.tbd */; };
......@@ -439,6 +441,7 @@
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>"; };
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; };
/* End PBXFileReference section */
......@@ -820,6 +823,7 @@
CAA9F00020D254A600CDBB2C /* Sources */ = {
isa = PBXGroup;
children = (
CABCBADD20EB0B080040E2F5 /* VLCAudioTest.swift */,
CAA9F00120D254A600CDBB2C /* VLCTimeTest.swift */,
CABF4D4020D8DBA900FCCE29 /* VLCMediaTest.swift */,
);
......@@ -1185,6 +1189,7 @@
CABF4D4120D8DBA900FCCE29 /* VLCMediaTest.swift in Sources */,
CA7BC89120F4419E00C86820 /* XCTestHelper.swift in Sources */,
CAA9F00320D254AB00CDBB2C /* VLCTimeTest.swift in Sources */,
CABCBAE220EB0B080040E2F5 /* VLCAudioTest.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -1195,6 +1200,7 @@
CABF4D4220D8DBA900FCCE29 /* VLCMediaTest.swift in Sources */,
CA7BC89520F441B500C86820 /* XCTestHelper.swift in Sources */,
CAA9F00420D254AC00CDBB2C /* VLCTimeTest.swift in Sources */,
CABCBAE320EB0B080040E2F5 /* VLCAudioTest.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......
/*****************************************************************************
* VLCAudioTest.swift
*****************************************************************************
* Copyright (C) 2018 Mike JS. Choi
* 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 VLCAudioTest: XCTestCase {
let step = 6
let min: Int32 = 0
let max: Int32 = 200
func testPassThrough() throws {
let player = VLCMediaPlayer()
let audio = try XCTAssertNotNilAndUnwrap(player.audio)
XCTAssertFalse(audio.passthrough)
audio.passthrough = true
XCTAssertTrue(audio.passthrough)
audio.passthrough = false
XCTAssertFalse(audio.passthrough)
}
func testVolumeDown() throws {
let player = VLCMediaPlayer()
let audio = try XCTAssertNotNilAndUnwrap(player.audio)
audio.volume = max
XCTAssertEqual(audio.volume, max)
let tests: [(repeatCount: Int, expected: Int32)] = [
(10, 140),
(5, 110),
(0, 110),
(15, 20),
(100, min)
]
for (repeatCount, expected) in tests {
(0..<repeatCount).forEach { _ in audio.volumeDown() }
XCTAssertEqual(audio.volume, expected)
}
}
func testVolumeUp() throws {
let player = VLCMediaPlayer()
let audio = try XCTAssertNotNilAndUnwrap(player.audio)
audio.volume = min
XCTAssertEqual(audio.volume, 0)
let tests: [(repeatCount: Int, expected: Int32)] = [
(5, 30),
(10, 90),
(10, 150),
(0, 150),
(100, max)
]
for (repeatCount, expected) in tests {
(0..<repeatCount).forEach { _ in audio.volumeUp() }
XCTAssertEqual(audio.volume, expected)
}
}
func testSetVolume() throws {
let player = VLCMediaPlayer()
let audio = try XCTAssertNotNilAndUnwrap(player.audio)
let tests: [(target: Int32, expected: Int32)] = [
(min, min),
(min - 100, min),
(50, 50),
(100, 100),
(max, max),
(max + 100, max)
]
for (target, expected) in tests {
audio.volume = target
XCTAssertEqual(audio.volume, expected)
}
}
}
......@@ -87,6 +87,7 @@
7DEBDAD9203C561D000A7D2F /* vlc.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = CCEC5B7E114D9BE800D34AAB /* vlc.h */; };
CA23EBC120BDF02700C0D635 /* VLCKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7DC28D7F20194117002D05C4 /* VLCKit.framework */; };
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 */; };
CABF4D5420D8E31700FCCE29 /* VLCMediaTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = CABF4D5320D8E31700FCCE29 /* VLCMediaTest.swift */; };
/* End PBXBuildFile section */
......@@ -192,6 +193,7 @@
CA23EBC020BDF02700C0D635 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
CA23EBCA20BDF07700C0D635 /* VLCKitTests-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "VLCKitTests-Bridging-Header.h"; sourceTree = "<group>"; };
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>"; };
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; };
......@@ -457,6 +459,7 @@
isa = PBXGroup;
children = (
CABF4D5320D8E31700FCCE29 /* VLCMediaTest.swift */,
CA766ED520E9E53E009B3F3F /* VLCAudioTest.swift */,
CA23EBCB20BDF07700C0D635 /* VLCTimeTest.swift */,
);
path = Sources;
......@@ -728,6 +731,7 @@
files = (
CABF4D5420D8E31700FCCE29 /* VLCMediaTest.swift in Sources */,
CA23EBCC20BDF07700C0D635 /* VLCTimeTest.swift in Sources */,
CA766ED620E9E53E009B3F3F /* VLCAudioTest.swift in Sources */,
CA7BC8B720F4424100C86820 /* XCTestHelper.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
......
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