Tests: VLCLibrary #32
Conversation
a108d95
to
e13f1a4
* libvlc will pass it to servers when required by protocol | ||
* \param readableName human-readable application name, e.g. "FooBar player 1.2.3" | ||
* \param readableName Human-readable application name, e.g. "FooBar player 1.2.3" | ||
* \param userAgent HTTP User Agent, e.g. "FooBar/1.2.3 Python/2.6.0" | ||
*/ | ||
- (void)setHumanReadableName:(NSString *)readableName withHTTPUserAgent:(NSString *)userAgent; |
mkchoi212
Jul 27, 2018
Author
Contributor
Not entirely sure how this can be tested...
Not entirely sure how this can be tested...
* \param version application version numbers, e.g. "1.2.3" | ||
* \param icon application icon name, e.g. "foobar" | ||
* \param version Application version numbers, e.g. "1.2.3" | ||
* \param icon Application icon name, e.g. "foobar" | ||
*/ | ||
- (void)setApplicationIdentifier:(NSString *)identifier withVersion:(NSString *)version andApplicationIconName:(NSString *)icon; |
mkchoi212
Jul 27, 2018
Author
Contributor
Same thing here
Same thing here
604bd1d
to
154b692
for option in tests { | ||
let library = try XCTAssertNotNilAndUnwrap(VLCLibrary(options: option)) | ||
XCTAssertNotNil(library.instance) | ||
assertDefaultParameters() |
carolanitz
Aug 6, 2018
•
Member
Wouldn't it be easier to understand and recognize why a test fails if you don't have a for loop and dict but write the params to test inline?
I know it's less code but right now I have to take some time to understand what line corresponds to a failing test if it would fail here. I'm also a bit unsure why we need to assertDefaultParams for : ["--no-video-title-show", "--verbose=4"]. If both of these are defaults it probably makes sense to test it as well with options that are not the default
Wouldn't it be easier to understand and recognize why a test fails if you don't have a for loop and dict but write the params to test inline?
I know it's less code but right now I have to take some time to understand what line corresponds to a failing test if it would fail here. I'm also a bit unsure why we need to assertDefaultParams for : ["--no-video-title-show", "--verbose=4"]. If both of these are defaults it probably makes sense to test it as well with options that are not the default
mkchoi212
Aug 7, 2018
Author
Contributor
There is no way to actually see if the custom options were successfully saved because the options are saved via
_instance = libvlc_new(count, lib_vlc_params);
where _instance
is a void *
.
So I just ended up making two dummy options and checking if the library was initialized successfully.
There is no way to actually see if the custom options were successfully saved because the options are saved via
_instance = libvlc_new(count, lib_vlc_params);
where _instance
is a void *
.
So I just ended up making two dummy options and checking if the library was initialized successfully.
mkchoi212
Aug 7, 2018
Author
Contributor
Maybe I could init a mock libvlc_new(count, lib_vlc_params)
and compare the two instances?? Is there a libvlc_compare_library
method?
Maybe I could init a mock libvlc_new(count, lib_vlc_params)
and compare the two instances?? Is there a libvlc_compare_library
method?
carolanitz
Aug 7, 2018
Member
I don't think there is but you can cast or bridge the void pointer into the correct object :)
I don't think there is but you can cast or bridge the void pointer into the correct object :)
(3, 3), | ||
(4, 4), | ||
(100, 0), | ||
(-10, 0) |
carolanitz
Aug 6, 2018
Member
👍
|
||
XCTAssert(library.version.count > 1) | ||
XCTAssert(library.compiler.count > 1) | ||
XCTAssert(library.changeset.count > 1) |
carolanitz
Aug 6, 2018
Member
What you're testing for here is a bit unclear for me. Those are strings but the way the test is written it looks like you're testing an array. What do you think about testing for a not empty string and providing a message like "compiler should hold the string of the libvlccompiler, e.g. "gcc version 4.2.3 (Ubuntu 4.2.3-2ubuntu6)"? That way if the test fails we know roughly what we expected
What you're testing for here is a bit unclear for me. Those are strings but the way the test is written it looks like you're testing an array. What do you think about testing for a not empty string and providing a message like "compiler should hold the string of the libvlccompiler, e.g. "gcc version 4.2.3 (Ubuntu 4.2.3-2ubuntu6)"? That way if the test fails we know roughly what we expected
mkchoi212
Aug 7, 2018
Author
Contributor
I thought about doing
XCTAssertEqual(library.compiler, "gcc version 4.2.3 (Ubuntu 4.2.3-2ubuntu6))"
but every time the library gets an update, you would have to update the tests as well or else, they would fail. Is this desirable?
I thought about doing
XCTAssertEqual(library.compiler, "gcc version 4.2.3 (Ubuntu 4.2.3-2ubuntu6))"
but every time the library gets an update, you would have to update the tests as well or else, they would fail. Is this desirable?
carolanitz
Aug 7, 2018
Member
I was thinking more along the lines of XCTAssertFalse (library.compiler. isEmpty, "compiler is empty but it should hold a string of the form e.g. "gcc version 4.2.3 (Ubuntu 4.2.3-2ubuntu6)")
I was thinking more along the lines of XCTAssertFalse (library.compiler. isEmpty, "compiler is empty but it should hold a string of the form e.g. "gcc version 4.2.3 (Ubuntu 4.2.3-2ubuntu6)")
let defaultParams = UserDefaults.standard.object(forKey: paramKey) | ||
|
||
#if os(macOS) | ||
XCTAssertEqual(defaultParams as? [String], expected) |
carolanitz
Aug 6, 2018
Member
When is defaultParams ever nil? Does it make sense to make this also not optional?
When is defaultParams ever nil? Does it make sense to make this also not optional?
mkchoi212
Aug 7, 2018
Author
Contributor
defaultParams
is set in VLCLibrary
during an init
. But the user could override it by using the same key by mistake since the parameters are stored in UserDefaults.standard
defaultParams
is set in VLCLibrary
during an init
. But the user could override it by using the same key by mistake since the parameters are stored in UserDefaults.standard
carolanitz
Aug 7, 2018
Member
I'm still confused a bit by this test :D so I overread the nil two lines down for iOS and I thought this test makes sure that the defaultParams are always not nil and set?
I'm still confused a bit by this test :D so I overread the nil two lines down for iOS and I thought this test makes sure that the defaultParams are always not nil and set?
mkchoi212
Aug 10, 2018
•
Author
Contributor
defaultParams
is nill for iOS and tvOS because VLCLibrary.m
DOES NOT set the default parameters in the UserDefaults #if TARGET_OS_IPHONE
. It does save the default params in UserDefaults otherwise.
Line 101
in
ba9d2cd
defaultParams
is nill for iOS and tvOS because VLCLibrary.m
DOES NOT set the default parameters in the UserDefaults #if TARGET_OS_IPHONE
. It does save the default params in UserDefaults otherwise.
Line 101 in ba9d2cd
XCTAssertTrue(library.debugLogging) | ||
|
||
library.debugLogging = false | ||
XCTAssertFalse(library.debugLogging) |
carolanitz
Aug 6, 2018
Member
👍
|
||
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")) |
Needs to be rebased once #30 is merged