-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathSSTestsHelper.m
More file actions
53 lines (41 loc) · 1.4 KB
/
SSTestsHelper.m
File metadata and controls
53 lines (41 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
//
// SSTestsHelper.m
// SSDynamicTextExample
//
// Created by Remigiusz Herba on 17/09/15.
// Copyright (c) 2015 Splinesoft. All rights reserved.
//
#import "SSTestsHelper.h"
#import <OCMock/OCMock.h>
NSString * const SSTestFontName = @"Avenir-Roman";
CGFloat const SSTestFontSize = 14.f;
CGFloat const SSTestFontSizeDifferenceForSizeExtraExtraLarge = 2.f;
static id applicationMock;
static id bundleMock;
@implementation SSTestsHelper
+ (void)startMockingPreferredContentSizeCategory:(NSString *)contentSizeCategory {
if (applicationMock) {
[self stopMockingPreferredContentSizeCategory];
}
applicationMock = OCMPartialMock([UIApplication sharedApplication]);
OCMStub([applicationMock preferredContentSizeCategory]).andReturn(contentSizeCategory);
}
+ (void)stopMockingPreferredContentSizeCategory {
[applicationMock stopMocking];
applicationMock = nil;
}
+ (void)postContentSizeChangeNotification {
[[NSNotificationCenter defaultCenter] postNotificationName:UIContentSizeCategoryDidChangeNotification object:nil];
}
+ (void)startMockingBundleDictionary:(NSDictionary *)dictionary {
if (bundleMock) {
[self stopMockingBundleDictionary];
}
bundleMock = OCMPartialMock([NSBundle mainBundle]);
OCMStub([bundleMock infoDictionary]).andReturn(dictionary);
}
+ (void)stopMockingBundleDictionary {
[bundleMock stopMocking];
bundleMock = nil;
}
@end