]> granicus.if.org Git - handbrake/commitdiff
MacGui: fix the tests, an external file is required to run them now.
authorDamiano Galassi <damiog@gmail.com>
Sun, 1 Jan 2017 10:57:30 +0000 (11:57 +0100)
committerDamiano Galassi <damiog@gmail.com>
Sun, 1 Jan 2017 10:57:30 +0000 (11:57 +0100)
macosx/HandBrake.xcodeproj/project.pbxproj
macosx/HandBrakeKitTests/HBJobTests.m
macosx/HandBrakeKitTests/HBJobUndoTests.m
macosx/HandBrakeKitTests/HBMockTitle.h [deleted file]
macosx/HandBrakeKitTests/HBMockTitle.m [deleted file]

index 786c4e4a09a39845121bb3239c76aecc74076de8..d9c8abdf09732bee2e8239108994194cd80e52a9 100644 (file)
                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 */; };
                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>"; };
                        children = (
                                A9DF49221C884C4E008AC14A /* HBJobTests.m */,
                                A9DF49231C884C4E008AC14A /* HBJobUndoTests.m */,
-                               A9DF49241C884C4E008AC14A /* HBMockTitle.h */,
-                               A9DF49251C884C4E008AC14A /* HBMockTitle.m */,
                                A9DF49261C884C4E008AC14A /* HBPresetsTests.m */,
                                A94A98F41C858EFB004BA9BA /* HBDictTests.m */,
                                A9736F141C7DA5FE008F1D18 /* Info.plist */,
                        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 */,
                        );
index 55726deea562a5b4f06e3f4e5ec764ce861c2fd1..dba18e35dda5ebe74f15e4544ba791e70fbefe98 100644 (file)
@@ -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"
 @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;
 
 
     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"];
 {
     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
 
 - (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);
     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
index bff23198e55f171ccfb73e753676d5c4ba8b4767..afee23cae523a4752b9920cd89b0c88d2397b4d1 100644 (file)
@@ -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"
 @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;
 
     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 (file)
index e83a13a..0000000
+++ /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 (file)
index 217f56b..0000000
+++ /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