Created
July 6, 2018 10:11
-
-
Save mkchoi212/e608c9a7332f9bb9cd0c2ed6b615b6c0 to your computer and use it in GitHub Desktop.
This is the ideal testing code to test VLCMedia::parse
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func testLength() { | |
let tests: [(path: String, expected: VLCTime)] = [ | |
("https://youtube.com/some_video_here", VLCTime(int: 12345)), | |
] | |
for (path, expected) in tests { | |
let media = VLCMedia(url: URL(string: path)!) | |
let expection = self.expectation(description: "mediaDidFinishParsing called") | |
let delegate = MockMediaDelegate(parseExpectation: expection) | |
media.delegate = delegate | |
// How can this be mocked? | |
// We should not make any networking calls in the unit test | |
media.parse(withOptions: VLCMediaParsingOptions(VLCMediaParseNetwork)) | |
// Waiting for 5 seconds here is very fragile as well | |
// e.g. tests in VLC-iOS sometimes fail here | |
waitForExpectations(timeout: 5) { err in | |
XCTAssertNil(err) | |
XCTAssertEqual(media.length.intValue, expected.intValue) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment