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/HandBrakeKitTests/HBJobTests.m | |
parent | 6e6507c64c72294c6478c7fa06ca1f7dad0d17d7 (diff) |
MacGui: fix the tests, an external file is required to run them now.
Diffstat (limited to 'macosx/HandBrakeKitTests/HBJobTests.m')
-rw-r--r-- | macosx/HandBrakeKitTests/HBJobTests.m | 47 |
1 files changed, 36 insertions, 11 deletions
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 |