diff options
author | Damiano Galassi <[email protected]> | 2017-01-01 11:57:30 +0100 |
---|---|---|
committer | Damiano Galassi <[email protected]> | 2017-01-01 11:57:30 +0100 |
commit | ed40e7a024e54f4b9ccd04f3c57a73701272b66c (patch) | |
tree | 1a26e2dec7a863cbd391166aafb2b14d87badd68 /macosx | |
parent | 6e6507c64c72294c6478c7fa06ca1f7dad0d17d7 (diff) |
MacGui: fix the tests, an external file is required to run them now.
Diffstat (limited to 'macosx')
-rw-r--r-- | macosx/HandBrake.xcodeproj/project.pbxproj | 6 | ||||
-rw-r--r-- | macosx/HandBrakeKitTests/HBJobTests.m | 47 | ||||
-rw-r--r-- | macosx/HandBrakeKitTests/HBJobUndoTests.m | 25 | ||||
-rw-r--r-- | macosx/HandBrakeKitTests/HBMockTitle.h | 12 | ||||
-rw-r--r-- | macosx/HandBrakeKitTests/HBMockTitle.m | 167 |
5 files changed, 58 insertions, 199 deletions
diff --git a/macosx/HandBrake.xcodeproj/project.pbxproj b/macosx/HandBrake.xcodeproj/project.pbxproj index 786c4e4a0..d9c8abdf0 100644 --- a/macosx/HandBrake.xcodeproj/project.pbxproj +++ b/macosx/HandBrake.xcodeproj/project.pbxproj @@ -223,7 +223,6 @@ A9DC6C56196F0517002AE6B4 /* Subtitles.xib in Resources */ = {isa = PBXBuildFile; fileRef = A9DC6C54196F0517002AE6B4 /* Subtitles.xib */; }; A9DF49271C884C4E008AC14A /* HBJobTests.m in Sources */ = {isa = PBXBuildFile; fileRef = A9DF49221C884C4E008AC14A /* HBJobTests.m */; }; A9DF49281C884C4E008AC14A /* HBJobUndoTests.m in Sources */ = {isa = PBXBuildFile; fileRef = A9DF49231C884C4E008AC14A /* HBJobUndoTests.m */; }; - A9DF49291C884C4E008AC14A /* HBMockTitle.m in Sources */ = {isa = PBXBuildFile; fileRef = A9DF49251C884C4E008AC14A /* HBMockTitle.m */; }; A9DF492A1C884C4E008AC14A /* HBPresetsTests.m in Sources */ = {isa = PBXBuildFile; fileRef = A9DF49261C884C4E008AC14A /* HBPresetsTests.m */; }; A9E1467B16BC2ABD00C307BC /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A9E1467A16BC2ABD00C307BC /* QuartzCore.framework */; }; A9E1468016BC2AD800C307BC /* NextTemplate.pdf in Resources */ = {isa = PBXBuildFile; fileRef = A9E1467C16BC2AD800C307BC /* NextTemplate.pdf */; }; @@ -546,8 +545,6 @@ A9DEC87E1A23DF6F00C79B48 /* HBJob.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HBJob.m; sourceTree = "<group>"; }; A9DF49221C884C4E008AC14A /* HBJobTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HBJobTests.m; sourceTree = "<group>"; }; A9DF49231C884C4E008AC14A /* HBJobUndoTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HBJobUndoTests.m; sourceTree = "<group>"; }; - A9DF49241C884C4E008AC14A /* HBMockTitle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HBMockTitle.h; sourceTree = "<group>"; }; - A9DF49251C884C4E008AC14A /* HBMockTitle.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HBMockTitle.m; sourceTree = "<group>"; }; A9DF49261C884C4E008AC14A /* HBPresetsTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HBPresetsTests.m; sourceTree = "<group>"; }; A9E1467A16BC2ABD00C307BC /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = /System/Library/Frameworks/QuartzCore.framework; sourceTree = "<absolute>"; }; A9E1467C16BC2AD800C307BC /* NextTemplate.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = NextTemplate.pdf; sourceTree = "<group>"; }; @@ -1065,8 +1062,6 @@ children = ( A9DF49221C884C4E008AC14A /* HBJobTests.m */, A9DF49231C884C4E008AC14A /* HBJobUndoTests.m */, - A9DF49241C884C4E008AC14A /* HBMockTitle.h */, - A9DF49251C884C4E008AC14A /* HBMockTitle.m */, A9DF49261C884C4E008AC14A /* HBPresetsTests.m */, A94A98F41C858EFB004BA9BA /* HBDictTests.m */, A9736F141C7DA5FE008F1D18 /* Info.plist */, @@ -1573,7 +1568,6 @@ files = ( A94A98F51C858EFB004BA9BA /* HBDictTests.m in Sources */, A9DF49271C884C4E008AC14A /* HBJobTests.m in Sources */, - A9DF49291C884C4E008AC14A /* HBMockTitle.m in Sources */, A9DF49281C884C4E008AC14A /* HBJobUndoTests.m in Sources */, A9DF492A1C884C4E008AC14A /* HBPresetsTests.m in Sources */, ); diff --git a/macosx/HandBrakeKitTests/HBJobTests.m b/macosx/HandBrakeKitTests/HBJobTests.m index 55726deea..dba18e35d 100644 --- a/macosx/HandBrakeKitTests/HBJobTests.m +++ b/macosx/HandBrakeKitTests/HBJobTests.m @@ -7,7 +7,8 @@ #import <Cocoa/Cocoa.h> #import <XCTest/XCTest.h> -#import "HBMockTitle.h" +#import "HBCore.h" +#import "HBTitle.h" #import "HBJob.h" #import "HBPicture.h" #import "HBJob+UIAdditions.h" @@ -18,8 +19,11 @@ @interface HBJobTests : XCTestCase @property (nonatomic, readonly) HBPresetsManager *manager; - @property (nonatomic, readwrite) HBPreset *preset; + +@property (nonatomic, readwrite) dispatch_queue_t queue; +@property (nonatomic, readwrite) HBCore *core; + @property (nonatomic, readwrite) HBTitle *title; @property (nonatomic, readwrite) HBJob *job; @@ -36,7 +40,21 @@ self.preset = self.manager.defaultPreset; - self.title = [[HBMockTitle alloc] init]; + NSURL *sampleURL = [NSURL fileURLWithPath:@"test.mp4"]; + + self.queue = dispatch_queue_create("fr.handbrake.testQueue", DISPATCH_QUEUE_SERIAL); + dispatch_semaphore_t sem = dispatch_semaphore_create(0); + + self.core = [[HBCore alloc] initWithLogLevel:1 queue:self.queue]; + [self.core scanURL:sampleURL titleIndex:0 previews:1 minDuration:0 progressHandler:^(HBState state, HBProgress progress, NSString * _Nonnull info) { + + } completionHandler:^(HBCoreResult result) { + dispatch_semaphore_signal(sem); + }]; + + dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER); + + self.title = self.core.titles.firstObject; self.job = [[HBJob alloc] initWithTitle:self.title andPreset:self.preset]; self.job.destURL = [NSURL fileURLWithPath:@"/Dest.mp4"]; @@ -51,29 +69,32 @@ { HBJob *job = [[HBJob alloc] init]; - XCTAssert(job, @"Pass"); + XCTAssertNotNil(job, @"Pass"); } - (void)testApplyPreset { - HBMockTitle *title = [[HBMockTitle alloc] init]; HBPreset *preset = self.manager.defaultPreset; - HBJob *job = [[HBJob alloc] initWithTitle:title andPreset:preset]; - job.destURL = [NSURL fileURLWithPath:@"/Dest.mp4"]; + XCTAssertNotNil(self.title); + + HBJob *job = [[HBJob alloc] initWithTitle:self.title andPreset:preset]; + XCTAssertNotNil(self.job); + + job.destURL = [NSURL fileURLWithPath:@"/Dest.mp4"]; [job applyPreset:preset]; } - (void)testAudio { - XCTAssertGreaterThan(self.job.audio.tracks.count, 1); + XCTAssertEqual(self.job.audio.tracks.count, 1); } - (void)testPictureSize { - XCTAssertEqual(self.job.picture.width, 1254); - XCTAssertEqual(self.job.picture.height, 678); + XCTAssertEqual(self.job.picture.width, 1280); + XCTAssertEqual(self.job.picture.height, 720); } - (void)testAutoCrop @@ -83,6 +104,9 @@ - (void)testAutoCropValues { + XCTAssertNotNil(self.title); + XCTAssertNotNil(self.job); + XCTAssertEqual(self.title.autoCropTop, self.job.picture.cropTop); XCTAssertEqual(self.title.autoCropBottom, self.job.picture.cropBottom); XCTAssertEqual(self.title.autoCropLeft, self.job.picture.cropLeft); @@ -103,12 +127,13 @@ preset[@"PicturePARHeight"] = @45; HBJob *job = [self.job copy]; + job.title = self.job.title; [job applyPreset:preset]; XCTAssertEqual(job.picture.width, 720); XCTAssertEqual(job.picture.height, 576); - XCTAssertEqual(job.picture.displayWidth, 1064); + XCTAssertEqual(job.picture.displayWidth, 1024); } @end diff --git a/macosx/HandBrakeKitTests/HBJobUndoTests.m b/macosx/HandBrakeKitTests/HBJobUndoTests.m index bff23198e..afee23cae 100644 --- a/macosx/HandBrakeKitTests/HBJobUndoTests.m +++ b/macosx/HandBrakeKitTests/HBJobUndoTests.m @@ -6,7 +6,8 @@ #import <XCTest/XCTest.h> -#import "HBMockTitle.h" +#import "HBCore.h" +#import "HBTitle.h" #import "HBJob.h" #import "HBChapter.h" #import "HBAudioTrack.h" @@ -18,8 +19,11 @@ @interface HBJobUndoTests : XCTestCase @property (nonatomic, readonly) HBPresetsManager *manager; - @property (nonatomic, readwrite) HBPreset *preset; + +@property (nonatomic, readwrite) dispatch_queue_t queue; +@property (nonatomic, readwrite) HBCore *core; + @property (nonatomic, readwrite) HBTitle *title; @property (nonatomic, readwrite) HBJob *job; @property (nonatomic, readwrite) HBJob *modifiedJob; @@ -37,7 +41,21 @@ self.preset = self.manager.defaultPreset; - self.title = [[HBMockTitle alloc] init]; + NSURL *sampleURL = [NSURL fileURLWithPath:@"test.mp4"]; + + self.queue = dispatch_queue_create("fr.handbrake.testQueue", DISPATCH_QUEUE_SERIAL); + dispatch_semaphore_t sem = dispatch_semaphore_create(0); + + self.core = [[HBCore alloc] initWithLogLevel:1 queue:self.queue]; + [self.core scanURL:sampleURL titleIndex:0 previews:1 minDuration:0 progressHandler:^(HBState state, HBProgress progress, NSString * _Nonnull info) { + + } completionHandler:^(HBCoreResult result) { + dispatch_semaphore_signal(sem); + }]; + + dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER); + + self.title = self.core.titles.firstObject; self.job = [[HBJob alloc] initWithTitle:self.title andPreset:self.preset]; self.job.destURL = [NSURL fileURLWithPath:@"/Dest.mp4"]; @@ -46,6 +64,7 @@ undoManager.groupsByEvent = NO; self.modifiedJob = [self.job copy]; + self.modifiedJob.title = self.job.title; self.modifiedJob.undo = undoManager; [self.manager.root enumerateObjectsUsingBlock:^(HBPreset * _Nonnull obj, NSIndexPath * _Nonnull idx, BOOL * _Nonnull stop) diff --git a/macosx/HandBrakeKitTests/HBMockTitle.h b/macosx/HandBrakeKitTests/HBMockTitle.h deleted file mode 100644 index e83a13ad2..000000000 --- a/macosx/HandBrakeKitTests/HBMockTitle.h +++ /dev/null @@ -1,12 +0,0 @@ -/* HBMockTitle - - This file is part of the HandBrake source code. - Homepage: <http://handbrake.fr/>. - It may be used under the terms of the GNU General Public License. */ - -#import <Foundation/Foundation.h> -#import "HBTitle.h" - -@interface HBMockTitle : HBTitle - -@end diff --git a/macosx/HandBrakeKitTests/HBMockTitle.m b/macosx/HandBrakeKitTests/HBMockTitle.m deleted file mode 100644 index 217f56bfc..000000000 --- a/macosx/HandBrakeKitTests/HBMockTitle.m +++ /dev/null @@ -1,167 +0,0 @@ -/* HBMockTitle - - This file is part of the HandBrake source code. - Homepage: <http://handbrake.fr/>. - It may be used under the terms of the GNU General Public License. */ - -#import "HBMockTitle.h" -#import "HBChapter.h" - -extern NSString *keyAudioTrackIndex; -extern NSString *keyAudioTrackName; -extern NSString *keyAudioInputBitrate; -extern NSString *keyAudioInputSampleRate; -extern NSString *keyAudioInputCodec; -extern NSString *keyAudioInputCodecParam; -extern NSString *keyAudioInputChannelLayout; -extern NSString *keyAudioTrackLanguageIsoCode; - -extern NSString *keySubTrackName; -extern NSString *keySubTrackLanguageIsoCode; -extern NSString *keySubTrackType; - -@implementation HBMockTitle - -- (instancetype)init -{ - self = [super init]; - return self; -} - -- (NSString *)name -{ - return @"Test.mkv"; -} - -- (BOOL)isStream -{ - return YES; -} - -- (NSString *)description -{ - return @"Test Title"; -} - -- (NSURL *)url -{ - return [NSURL fileURLWithPath:@"/Test.mkv"]; -} - -- (int)index -{ - return 1; -} - -- (int)angles -{ - return 1; -} - -- (int)duration -{ - return 60; -} - -- (int)frames -{ - return 60 * 25; -} - -- (NSString *)timeCode -{ - return @"00:01:00"; -} - -- (int)width -{ - return 1280; -} - -- (int)height -{ - return 720; -} - -- (int)parWidth -{ - return 1; -} - -- (int)parHeight -{ - return 1; -} - -- (int)autoCropTop -{ - return 20; -} - -- (int)autoCropBottom -{ - return 22; -} - -- (int)autoCropLeft -{ - return 12; -} - -- (int)autoCropRight -{ - return 15; -} - -- (NSArray *)audioTracks -{ - NSMutableArray *tracks = [NSMutableArray array]; - [tracks addObject: @{keyAudioTrackIndex: @1, - keyAudioTrackName: [NSString stringWithFormat: @"%d: %s", 0, "English"], - keyAudioInputBitrate: @104, - keyAudioInputSampleRate: @48000, - keyAudioInputCodec: @65536, - keyAudioInputCodecParam: @86018, - keyAudioInputChannelLayout: @3, - keyAudioTrackLanguageIsoCode: @"eng"}]; - - [tracks addObject: @{keyAudioTrackIndex: @2, - keyAudioTrackName: [NSString stringWithFormat: @"%d: %s", 1, "Italian"], - keyAudioInputBitrate: @104, - keyAudioInputSampleRate: @48000, - keyAudioInputCodec: @65536, - keyAudioInputCodecParam: @86018, - keyAudioInputChannelLayout: @3, - keyAudioTrackLanguageIsoCode: @"ita"}]; - return [tracks copy]; -} - -- (NSArray *)subtitlesTracks -{ - NSMutableArray *tracks = [NSMutableArray array]; - NSString *nativeLanguage = @"English"; - - // create a dictionary of source subtitle information to store in our array - [tracks addObject:@{keySubTrackName: [NSString stringWithFormat:@"%d: %@ (%@) (%@)", 0, nativeLanguage, @"Bitmap", @"VobSub"], - keySubTrackType: @0, - keySubTrackLanguageIsoCode: @"eng"}]; - - return [tracks copy]; -} - -- (NSArray<HBChapter *> *)chapters -{ - NSMutableArray *chapters = [NSMutableArray array]; - - for (int i = 0; i < 10; i++) - { - NSString *title = [NSString stringWithFormat:@"Chapter %d", i + 1]; - [chapters addObject:[[HBChapter alloc] initWithTitle:title - index:i + 1 - duration:100]]; - } - return [chapters copy]; -} - - -@end |