summaryrefslogtreecommitdiffstats
path: root/macosx/HandBrake Tests
diff options
context:
space:
mode:
Diffstat (limited to 'macosx/HandBrake Tests')
-rw-r--r--macosx/HandBrake Tests/HBJobTests.m59
-rw-r--r--macosx/HandBrake Tests/HBMockTitle.h14
-rw-r--r--macosx/HandBrake Tests/HBMockTitle.m182
-rw-r--r--macosx/HandBrake Tests/HBPresetsTests.m14
4 files changed, 258 insertions, 11 deletions
diff --git a/macosx/HandBrake Tests/HBJobTests.m b/macosx/HandBrake Tests/HBJobTests.m
index e12f3ef10..c63fce273 100644
--- a/macosx/HandBrake Tests/HBJobTests.m
+++ b/macosx/HandBrake Tests/HBJobTests.m
@@ -7,7 +7,10 @@
#import <Cocoa/Cocoa.h>
#import <XCTest/XCTest.h>
+#import "HBMockTitle.h"
#import "HBJob.h"
+#import "HBPicture.h"
+#import "HBJob+UIAdditions.h"
#import "HBPresetsManager.h"
#import "HBPreset.h"
@@ -15,28 +18,74 @@
@property (nonatomic, readonly) HBPresetsManager *manager;
+@property (nonatomic, readwrite) HBPreset *preset;
+@property (nonatomic, readwrite) HBTitle *title;
+@property (nonatomic, readwrite) HBJob *job;
+
@end
@implementation HBJobTests
-- (void)setUp {
+- (void)setUp
+{
[super setUp];
_manager = [[HBPresetsManager alloc] init];
[_manager generateBuiltInPresets];
- // Put setup code here. This method is called before the invocation of each test method in the class.
+ self.preset = self.manager.defaultPreset;
+
+ self.title = [[HBMockTitle alloc] init];
+
+ self.job = [[HBJob alloc] initWithTitle:self.title andPreset:self.preset];
+ self.job.destURL = [NSURL fileURLWithPath:@"/Dest.mp4"];
}
-- (void)tearDown {
- // Put teardown code here. This method is called after the invocation of each test method in the class.
+- (void)tearDown
+{
[super tearDown];
}
-- (void)testJobCreation {
+- (void)testJobCreation
+{
HBJob *job = [[HBJob alloc] init];
XCTAssert(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"];
+
+ [job applyPreset:preset];
+}
+
+- (void)testAudio
+{
+ XCTAssertEqual(self.job.audio.tracks.count, 2);
+}
+
+- (void)testPictureSize
+{
+ XCTAssertEqual(self.job.picture.width, 1254);
+ XCTAssertEqual(self.job.picture.height, 678);
+}
+
+- (void)testAutoCrop
+{
+ XCTAssertEqual([self.preset.content[@"PictureAutoCrop"] boolValue], self.job.picture.autocrop);
+}
+
+- (void)testAutoCropValues
+{
+ XCTAssertEqual(self.title.autoCropTop, self.job.picture.cropTop);
+ XCTAssertEqual(self.title.autoCropBottom, self.job.picture.cropBottom);
+ XCTAssertEqual(self.title.autoCropLeft, self.job.picture.cropLeft);
+ XCTAssertEqual(self.title.autoCropRight, self.job.picture.cropRight);
+}
+
@end
diff --git a/macosx/HandBrake Tests/HBMockTitle.h b/macosx/HandBrake Tests/HBMockTitle.h
new file mode 100644
index 000000000..ee1f87a62
--- /dev/null
+++ b/macosx/HandBrake Tests/HBMockTitle.h
@@ -0,0 +1,14 @@
+//
+// HBMockTitle.h
+// HandBrake
+//
+// Created by Damiano Galassi on 30/05/15.
+//
+//
+
+#import <Foundation/Foundation.h>
+#import "HBTitle.h"
+
+@interface HBMockTitle : HBTitle
+
+@end
diff --git a/macosx/HandBrake Tests/HBMockTitle.m b/macosx/HandBrake Tests/HBMockTitle.m
new file mode 100644
index 000000000..0e61bd414
--- /dev/null
+++ b/macosx/HandBrake Tests/HBMockTitle.m
@@ -0,0 +1,182 @@
+//
+// HBMockTitle.m
+// HandBrake
+//
+// Created by Damiano Galassi on 30/05/15.
+//
+//
+
+#import "HBMockTitle.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 *keySubTrackIndex;
+extern NSString *keySubTrackLanguage;
+extern NSString *keySubTrackLanguageIsoCode;
+extern NSString *keySubTrackType;
+
+extern NSString *keySubTrackForced;
+extern NSString *keySubTrackBurned;
+extern NSString *keySubTrackDefault;
+
+extern NSString *keySubTrackSrtOffset;
+extern NSString *keySubTrackSrtFilePath;
+extern NSString *keySubTrackSrtCharCode;
+
+@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", 1, "English"],
+ keyAudioInputBitrate: @104,
+ keyAudioInputSampleRate: @48000,
+ keyAudioInputCodec: @65536,
+ keyAudioInputCodecParam: @86018,
+ keyAudioInputChannelLayout: @3,
+ keyAudioTrackLanguageIsoCode: @"eng"}];
+ return [tracks copy];
+}
+
+- (NSArray *)subtitlesTracks
+{
+ /*if (!_subtitlesTracks)
+ {
+ NSMutableArray *tracks = [NSMutableArray array];
+ hb_subtitle_t *subtitle;
+ hb_list_t *list = self.hb_title->list_subtitle;
+ int count = hb_list_count(list);
+
+ for (int i = 0; i < count; i++)
+ {
+ subtitle = (hb_subtitle_t *) hb_list_item(self.hb_title->list_subtitle, i);
+
+ // Human-readable representation of subtitle->source
+ NSString *bitmapOrText = subtitle->format == PICTURESUB ? @"Bitmap" : @"Text";
+ NSString *subSourceName = @(hb_subsource_name(subtitle->source));
+
+ // Use the native language name if available
+ iso639_lang_t *language = lang_for_code2(subtitle->iso639_2);
+ NSString *nativeLanguage = strlen(language->native_name) ? @(language->native_name) : @(language->eng_name);
+
+ // create a dictionary of source subtitle information to store in our array
+ [tracks addObject:@{keySubTrackName: [NSString stringWithFormat:@"%d: %@ (%@) (%@)", i, nativeLanguage, bitmapOrText, subSourceName],
+ keySubTrackIndex: @(i),
+ keySubTrackType: @(subtitle->source),
+ keySubTrackLanguage: nativeLanguage,
+ keySubTrackLanguageIsoCode: @(subtitle->iso639_2)}];
+ }
+
+ _subtitlesTracks = [tracks copy];
+ }*/
+
+ return nil;
+}
+
+- (NSArray *)chapters
+{
+ return @[@"Chapter 1", @"Chapter 2"];
+}
+
+
+@end
diff --git a/macosx/HandBrake Tests/HBPresetsTests.m b/macosx/HandBrake Tests/HBPresetsTests.m
index aff566911..231f151a4 100644
--- a/macosx/HandBrake Tests/HBPresetsTests.m
+++ b/macosx/HandBrake Tests/HBPresetsTests.m
@@ -18,28 +18,30 @@
- (void)setUp {
[super setUp];
- // Put setup code here. This method is called before the invocation of each test method in the class.
}
-- (void)tearDown {
- // Put teardown code here. This method is called after the invocation of each test method in the class.
+- (void)tearDown
+{
[super tearDown];
}
-- (void)testManagerCreation {
+- (void)testManagerCreation
+{
HBPresetsManager *manager = [[HBPresetsManager alloc] init];
XCTAssert(manager, @"Pass");
}
-- (void)testDefaultPresets {
+- (void)testDefaultPresets
+{
HBPresetsManager *manager = [[HBPresetsManager alloc] init];
[manager generateBuiltInPresets];
XCTAssert(manager.root.children.count > 1, @"Pass");
}
-- (void)testCreationTime {
+- (void)testCreationTime
+{
HBPresetsManager *manager = [[HBPresetsManager alloc] init];
[self measureBlock:^{