diff --git a/FBSnapshotTestCase.xcodeproj/project.pbxproj b/FBSnapshotTestCase.xcodeproj/project.pbxproj index d7dd88d..f3f58ef 100644 --- a/FBSnapshotTestCase.xcodeproj/project.pbxproj +++ b/FBSnapshotTestCase.xcodeproj/project.pbxproj @@ -24,6 +24,8 @@ B32447DC1AB78B5E00B1D6FF /* square_with_text.png in Resources */ = {isa = PBXBuildFile; fileRef = B32447D91AB78B5E00B1D6FF /* square_with_text.png */; }; B32447DD1AB78B5E00B1D6FF /* square-copy.png in Resources */ = {isa = PBXBuildFile; fileRef = B32447DA1AB78B5E00B1D6FF /* square-copy.png */; }; B32447DE1AB78B5E00B1D6FF /* square.png in Resources */ = {isa = PBXBuildFile; fileRef = B32447DB1AB78B5E00B1D6FF /* square.png */; }; + BC45D5211C2AEFCE007C72F3 /* UIApplication+StrictKeyWindow.h in Headers */ = {isa = PBXBuildFile; fileRef = BC45D51F1C2AEFCE007C72F3 /* UIApplication+StrictKeyWindow.h */; }; + BC45D5221C2AEFCE007C72F3 /* UIApplication+StrictKeyWindow.m in Sources */ = {isa = PBXBuildFile; fileRef = BC45D5201C2AEFCE007C72F3 /* UIApplication+StrictKeyWindow.m */; }; E5C2CD621B1F399A00669887 /* square_with_pixel.png in Resources */ = {isa = PBXBuildFile; fileRef = E5C2CD611B1F399A00669887 /* square_with_pixel.png */; }; F0D698F51B204E120005CAC9 /* SwiftSupport.swift in Sources */ = {isa = PBXBuildFile; fileRef = F0D698F41B204E120005CAC9 /* SwiftSupport.swift */; }; /* End PBXBuildFile section */ @@ -59,6 +61,8 @@ B32447D91AB78B5E00B1D6FF /* square_with_text.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = square_with_text.png; sourceTree = ""; }; B32447DA1AB78B5E00B1D6FF /* square-copy.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "square-copy.png"; sourceTree = ""; }; B32447DB1AB78B5E00B1D6FF /* square.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = square.png; sourceTree = ""; }; + BC45D51F1C2AEFCE007C72F3 /* UIApplication+StrictKeyWindow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIApplication+StrictKeyWindow.h"; sourceTree = ""; }; + BC45D5201C2AEFCE007C72F3 /* UIApplication+StrictKeyWindow.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIApplication+StrictKeyWindow.m"; sourceTree = ""; }; E5C2CD611B1F399A00669887 /* square_with_pixel.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = square_with_pixel.png; sourceTree = ""; }; F0D698F41B204E120005CAC9 /* SwiftSupport.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwiftSupport.swift; sourceTree = ""; }; /* End PBXFileReference section */ @@ -91,6 +95,8 @@ 133564131B59C3F500A4E4BF /* UIImage+Diff.m */, 133564141B59C3F500A4E4BF /* UIImage+Snapshot.h */, 133564151B59C3F500A4E4BF /* UIImage+Snapshot.m */, + BC45D51F1C2AEFCE007C72F3 /* UIApplication+StrictKeyWindow.h */, + BC45D5201C2AEFCE007C72F3 /* UIApplication+StrictKeyWindow.m */, ); path = Categories; sourceTree = ""; @@ -167,6 +173,7 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( + BC45D5211C2AEFCE007C72F3 /* UIApplication+StrictKeyWindow.h in Headers */, B31988281AB7849400B0A900 /* FBSnapshotTestCase.h in Headers */, 13CBB39D1AEE013900B6ADBA /* FBSnapshotTestCasePlatform.h in Headers */, B319882A1AB7849400B0A900 /* FBSnapshotTestController.h in Headers */, @@ -279,6 +286,7 @@ buildActionMask = 2147483647; files = ( 133564171B59C3F500A4E4BF /* UIImage+Compare.m in Sources */, + BC45D5221C2AEFCE007C72F3 /* UIApplication+StrictKeyWindow.m in Sources */, B31988291AB7849400B0A900 /* FBSnapshotTestCase.m in Sources */, 133564191B59C3F500A4E4BF /* UIImage+Diff.m in Sources */, 1335641B1B59C3F500A4E4BF /* UIImage+Snapshot.m in Sources */, diff --git a/FBSnapshotTestCase/Categories/UIApplication+StrictKeyWindow.h b/FBSnapshotTestCase/Categories/UIApplication+StrictKeyWindow.h new file mode 100644 index 0000000..eefe11b --- /dev/null +++ b/FBSnapshotTestCase/Categories/UIApplication+StrictKeyWindow.h @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2015, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + */ + +#import + +@interface UIApplication (StrictKeyWindow) + +/** + @return The receiver's @c keyWindow. Raises an assertion if @c nil. + */ +- (UIWindow *)fb_strictKeyWindow; + +@end diff --git a/FBSnapshotTestCase/Categories/UIApplication+StrictKeyWindow.m b/FBSnapshotTestCase/Categories/UIApplication+StrictKeyWindow.m new file mode 100644 index 0000000..0f7a0c2 --- /dev/null +++ b/FBSnapshotTestCase/Categories/UIApplication+StrictKeyWindow.m @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2015, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + */ + +#import + +@implementation UIApplication (StrictKeyWindow) + +- (UIWindow *)fb_strictKeyWindow +{ + UIWindow *keyWindow = [UIApplication sharedApplication].keyWindow; + if (!keyWindow) { + [NSException raise:@"FBSnapshotTestCaseNilKeyWindowException" + format:@"Snapshot tests must be hosted by an application with a key window. Please ensure your test" + " host sets up a key window at launch (either via storyboards or programmatically) and doesn't" + " do anything to remove it while snapshot tests are running."]; + } + return keyWindow; +} + +@end diff --git a/FBSnapshotTestCase/Categories/UIImage+Snapshot.m b/FBSnapshotTestCase/Categories/UIImage+Snapshot.m index 47fbca8..0b8b934 100644 --- a/FBSnapshotTestCase/Categories/UIImage+Snapshot.m +++ b/FBSnapshotTestCase/Categories/UIImage+Snapshot.m @@ -9,6 +9,7 @@ */ #import +#import @implementation UIImage (Snapshot) @@ -41,22 +42,31 @@ + (UIImage *)fb_imageForView:(UIView *)view { CGRect bounds = view.bounds; NSAssert1(CGRectGetWidth(bounds), @"Zero width for view %@", view); - NSAssert1(CGRectGetHeight(bounds), @"Zero height for view %@", view); + NSAssert1(CGRectGetHeight(bounds), @"Zero height for view %@", view); // If the input view is already a UIWindow, then just use that. Otherwise wrap in a window. UIWindow *window = [view isKindOfClass:[UIWindow class]] ? (UIWindow *)view : view.window; - if (window == nil) { - window = [[UIWindow alloc] initWithFrame:bounds]; + BOOL removeFromSuperview = NO; + if (!window) { + window = [[UIApplication sharedApplication] fb_strictKeyWindow]; + } + + if (!view.window) { [window addSubview:view]; - [window makeKeyAndVisible]; + removeFromSuperview = YES; } - + UIGraphicsBeginImageContextWithOptions(bounds.size, NO, 0); [view layoutIfNeeded]; [view drawViewHierarchyInRect:view.bounds afterScreenUpdates:YES]; UIImage *snapshot = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); + + if (removeFromSuperview) { + [view removeFromSuperview]; + } + return snapshot; } diff --git a/FBSnapshotTestCase/FBSnapshotTestCase.h b/FBSnapshotTestCase/FBSnapshotTestCase.h index 851cbd6..159a724 100644 --- a/FBSnapshotTestCase/FBSnapshotTestCase.h +++ b/FBSnapshotTestCase/FBSnapshotTestCase.h @@ -49,7 +49,7 @@ /** Similar to our much-loved XCTAssert() macros. Use this to perform your test. No need to write an explanation, though. @param layer The layer to snapshot - @param identifier An optional identifier, used is there are multiple snapshot tests in a given -test method. + @param identifier An optional identifier, used if there are multiple snapshot tests in a given -test method. @param suffixes An NSOrderedSet of strings for the different suffixes @param tolerance The percentage of pixels that can differ and still count as an 'identical' layer */ diff --git a/FBSnapshotTestCase/FBSnapshotTestCasePlatform.m b/FBSnapshotTestCase/FBSnapshotTestCasePlatform.m index 4f6fb01..d8709d8 100644 --- a/FBSnapshotTestCase/FBSnapshotTestCasePlatform.m +++ b/FBSnapshotTestCase/FBSnapshotTestCasePlatform.m @@ -9,6 +9,7 @@ */ #import +#import #import BOOL FBSnapshotTestCaseIs64Bit(void) @@ -34,7 +35,8 @@ BOOL FBSnapshotTestCaseIs64Bit(void) NSString *FBDeviceAgnosticNormalizedFileName(NSString *fileName) { UIDevice *device = [UIDevice currentDevice]; - CGSize screenSize = [[UIApplication sharedApplication] keyWindow].bounds.size; + UIWindow *keyWindow = [[UIApplication sharedApplication] fb_strictKeyWindow]; + CGSize screenSize = keyWindow.bounds.size; NSString *os = device.systemVersion; fileName = [NSString stringWithFormat:@"%@_%@%@_%.0fx%.0f", fileName, device.model, os, screenSize.width, screenSize.height]; diff --git a/FBSnapshotTestCaseDemo/FBSnapshotTestCaseDemo.xcodeproj/project.pbxproj b/FBSnapshotTestCaseDemo/FBSnapshotTestCaseDemo.xcodeproj/project.pbxproj index 03ae469..240ba6b 100644 --- a/FBSnapshotTestCaseDemo/FBSnapshotTestCaseDemo.xcodeproj/project.pbxproj +++ b/FBSnapshotTestCaseDemo/FBSnapshotTestCaseDemo.xcodeproj/project.pbxproj @@ -13,6 +13,8 @@ B30449351AB795230067C75D /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = B304492C1AB795230067C75D /* InfoPlist.strings */; }; B30449361AB795230067C75D /* FBAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = B304492F1AB795230067C75D /* FBAppDelegate.m */; }; B30449391AB795230067C75D /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = B30449341AB795230067C75D /* Images.xcassets */; }; + BC97FF051C17E4C900FA40E3 /* FBSnapshotTestCaseDeviceAgnosticTests.m in Sources */ = {isa = PBXBuildFile; fileRef = BC97FF041C17E4C900FA40E3 /* FBSnapshotTestCaseDeviceAgnosticTests.m */; }; + BCF12A251C396B2600789343 /* Launch Screen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = BCF12A241C396B2600789343 /* Launch Screen.storyboard */; }; F02D88451B1F246300BFBC1D /* FBSnapshotTestCaseSwiftTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F02D88441B1F246300BFBC1D /* FBSnapshotTestCaseSwiftTests.swift */; }; /* End PBXBuildFile section */ @@ -30,7 +32,6 @@ 42711825EC840732F7632DB1 /* Pods-FBSnapshotTestCaseDemoTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-FBSnapshotTestCaseDemoTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-FBSnapshotTestCaseDemoTests/Pods-FBSnapshotTestCaseDemoTests.release.xcconfig"; sourceTree = ""; }; 89032B249B2E1256F91C7504 /* Pods-FBSnapshotTestCaseDemoTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-FBSnapshotTestCaseDemoTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-FBSnapshotTestCaseDemoTests/Pods-FBSnapshotTestCaseDemoTests.debug.xcconfig"; sourceTree = ""; }; B30449021AB794320067C75D /* FBSnapshotTestCaseDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = FBSnapshotTestCaseDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; - B30449061AB794320067C75D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; B30449071AB794320067C75D /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; B304491B1AB794320067C75D /* FBSnapshotTestCaseDemoTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = FBSnapshotTestCaseDemoTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; B30449201AB794320067C75D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; @@ -41,6 +42,8 @@ B30449321AB795230067C75D /* FBSnapshotTestCaseDemo-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "FBSnapshotTestCaseDemo-Info.plist"; sourceTree = ""; }; B30449331AB795230067C75D /* FBSnapshotTestCaseDemo-Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "FBSnapshotTestCaseDemo-Prefix.pch"; sourceTree = ""; }; B30449341AB795230067C75D /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; + BC97FF041C17E4C900FA40E3 /* FBSnapshotTestCaseDeviceAgnosticTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FBSnapshotTestCaseDeviceAgnosticTests.m; sourceTree = ""; }; + BCF12A241C396B2600789343 /* Launch Screen.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = "Launch Screen.storyboard"; sourceTree = ""; }; F02D88441B1F246300BFBC1D /* FBSnapshotTestCaseSwiftTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FBSnapshotTestCaseSwiftTests.swift; sourceTree = ""; }; F2F94786ED7FC097D31026B6 /* Pods_FBSnapshotTestCaseDemoTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_FBSnapshotTestCaseDemoTests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXFileReference section */ @@ -105,6 +108,7 @@ B30449331AB795230067C75D /* FBSnapshotTestCaseDemo-Prefix.pch */, B30449341AB795230067C75D /* Images.xcassets */, B30449051AB794320067C75D /* Supporting Files */, + BCF12A241C396B2600789343 /* Launch Screen.storyboard */, ); path = FBSnapshotTestCaseDemo; sourceTree = ""; @@ -112,7 +116,6 @@ B30449051AB794320067C75D /* Supporting Files */ = { isa = PBXGroup; children = ( - B30449061AB794320067C75D /* Info.plist */, B30449071AB794320067C75D /* main.m */, ); name = "Supporting Files"; @@ -122,6 +125,7 @@ isa = PBXGroup; children = ( B30449211AB794320067C75D /* FBSnapshotTestCaseDemoTests.m */, + BC97FF041C17E4C900FA40E3 /* FBSnapshotTestCaseDeviceAgnosticTests.m */, F02D88441B1F246300BFBC1D /* FBSnapshotTestCaseSwiftTests.swift */, B304491F1AB794320067C75D /* Supporting Files */, ); @@ -236,6 +240,7 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + BCF12A251C396B2600789343 /* Launch Screen.storyboard in Resources */, B30449391AB795230067C75D /* Images.xcassets in Resources */, B30449351AB795230067C75D /* InfoPlist.strings in Resources */, ); @@ -313,6 +318,7 @@ buildActionMask = 2147483647; files = ( B30449221AB794320067C75D /* FBSnapshotTestCaseDemoTests.m in Sources */, + BC97FF051C17E4C900FA40E3 /* FBSnapshotTestCaseDeviceAgnosticTests.m in Sources */, F02D88451B1F246300BFBC1D /* FBSnapshotTestCaseSwiftTests.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -421,6 +427,7 @@ isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = "Brand Assets"; INFOPLIST_FILE = "FBSnapshotTestCaseDemo/FBSnapshotTestCaseDemo-Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -431,6 +438,7 @@ isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = "Brand Assets"; INFOPLIST_FILE = "FBSnapshotTestCaseDemo/FBSnapshotTestCaseDemo-Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_NAME = "$(TARGET_NAME)"; diff --git a/FBSnapshotTestCaseDemo/FBSnapshotTestCaseDemo.xcodeproj/xcshareddata/xcschemes/FBSnapshotTestCaseDemo.xcscheme b/FBSnapshotTestCaseDemo/FBSnapshotTestCaseDemo.xcodeproj/xcshareddata/xcschemes/FBSnapshotTestCaseDemo.xcscheme index f98c32f..657d47f 100644 --- a/FBSnapshotTestCaseDemo/FBSnapshotTestCaseDemo.xcodeproj/xcshareddata/xcschemes/FBSnapshotTestCaseDemo.xcscheme +++ b/FBSnapshotTestCaseDemo/FBSnapshotTestCaseDemo.xcodeproj/xcshareddata/xcschemes/FBSnapshotTestCaseDemo.xcscheme @@ -37,10 +37,10 @@ + shouldUseLaunchSchemeArgsEnv = "YES"> @@ -62,15 +62,18 @@ ReferencedContainer = "container:FBSnapshotTestCaseDemo.xcodeproj"> + + @@ -93,10 +96,10 @@ diff --git a/FBSnapshotTestCaseDemo/FBSnapshotTestCaseDemo/FBSnapshotTestCaseDemo-Info.plist b/FBSnapshotTestCaseDemo/FBSnapshotTestCaseDemo/FBSnapshotTestCaseDemo-Info.plist index 8baa86a..f8f0e8d 100644 --- a/FBSnapshotTestCaseDemo/FBSnapshotTestCaseDemo/FBSnapshotTestCaseDemo-Info.plist +++ b/FBSnapshotTestCaseDemo/FBSnapshotTestCaseDemo/FBSnapshotTestCaseDemo-Info.plist @@ -24,10 +24,14 @@ 1.0 LSRequiresIPhoneOS + UILaunchStoryboardName + Launch Screen UIRequiredDeviceCapabilities armv7 + UIRequiresFullScreen + UISupportedInterfaceOrientations UIInterfaceOrientationPortrait diff --git a/FBSnapshotTestCaseDemo/FBSnapshotTestCaseDemo/Images.xcassets/AppIcon.appiconset/Contents.json b/FBSnapshotTestCaseDemo/FBSnapshotTestCaseDemo/Images.xcassets/AppIcon.appiconset/Contents.json index 33ec0bc..118c98f 100644 --- a/FBSnapshotTestCaseDemo/FBSnapshotTestCaseDemo/Images.xcassets/AppIcon.appiconset/Contents.json +++ b/FBSnapshotTestCaseDemo/FBSnapshotTestCaseDemo/Images.xcassets/AppIcon.appiconset/Contents.json @@ -5,11 +5,21 @@ "size" : "29x29", "scale" : "2x" }, + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "3x" + }, { "idiom" : "iphone", "size" : "40x40", "scale" : "2x" }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "3x" + }, { "idiom" : "iphone", "size" : "60x60", diff --git a/FBSnapshotTestCaseDemo/FBSnapshotTestCaseDemo/Images.xcassets/Brand Assets.launchimage/Contents.json b/FBSnapshotTestCaseDemo/FBSnapshotTestCaseDemo/Images.xcassets/Brand Assets.launchimage/Contents.json new file mode 100644 index 0000000..a0ad363 --- /dev/null +++ b/FBSnapshotTestCaseDemo/FBSnapshotTestCaseDemo/Images.xcassets/Brand Assets.launchimage/Contents.json @@ -0,0 +1,36 @@ +{ + "images" : [ + { + "orientation" : "portrait", + "idiom" : "ipad", + "extent" : "full-screen", + "minimum-system-version" : "7.0", + "scale" : "1x" + }, + { + "orientation" : "landscape", + "idiom" : "ipad", + "extent" : "full-screen", + "minimum-system-version" : "7.0", + "scale" : "1x" + }, + { + "orientation" : "portrait", + "idiom" : "ipad", + "extent" : "full-screen", + "minimum-system-version" : "7.0", + "scale" : "2x" + }, + { + "orientation" : "landscape", + "idiom" : "ipad", + "extent" : "full-screen", + "minimum-system-version" : "7.0", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/FBSnapshotTestCaseDemo/FBSnapshotTestCaseDemo/Images.xcassets/Contents.json b/FBSnapshotTestCaseDemo/FBSnapshotTestCaseDemo/Images.xcassets/Contents.json new file mode 100644 index 0000000..da4a164 --- /dev/null +++ b/FBSnapshotTestCaseDemo/FBSnapshotTestCaseDemo/Images.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/FBSnapshotTestCaseDemo/FBSnapshotTestCaseDemo/Images.xcassets/LaunchImage.launchimage/Contents.json b/FBSnapshotTestCaseDemo/FBSnapshotTestCaseDemo/Images.xcassets/LaunchImage.launchimage/Contents.json index c79ebd3..3dd8aa5 100644 --- a/FBSnapshotTestCaseDemo/FBSnapshotTestCaseDemo/Images.xcassets/LaunchImage.launchimage/Contents.json +++ b/FBSnapshotTestCaseDemo/FBSnapshotTestCaseDemo/Images.xcassets/LaunchImage.launchimage/Contents.json @@ -1,5 +1,29 @@ { "images" : [ + { + "orientation" : "portrait", + "idiom" : "iphone", + "extent" : "full-screen", + "minimum-system-version" : "8.0", + "subtype" : "736h", + "scale" : "3x" + }, + { + "orientation" : "landscape", + "idiom" : "iphone", + "extent" : "full-screen", + "minimum-system-version" : "8.0", + "subtype" : "736h", + "scale" : "3x" + }, + { + "orientation" : "portrait", + "idiom" : "iphone", + "extent" : "full-screen", + "minimum-system-version" : "8.0", + "subtype" : "667h", + "scale" : "2x" + }, { "orientation" : "portrait", "idiom" : "iphone", @@ -10,9 +34,104 @@ { "orientation" : "portrait", "idiom" : "iphone", + "extent" : "full-screen", + "minimum-system-version" : "7.0", "subtype" : "retina4", + "scale" : "2x" + }, + { + "orientation" : "portrait", + "idiom" : "ipad", "extent" : "full-screen", "minimum-system-version" : "7.0", + "scale" : "1x" + }, + { + "orientation" : "landscape", + "idiom" : "ipad", + "extent" : "full-screen", + "minimum-system-version" : "7.0", + "scale" : "1x" + }, + { + "orientation" : "portrait", + "idiom" : "ipad", + "extent" : "full-screen", + "minimum-system-version" : "7.0", + "scale" : "2x" + }, + { + "orientation" : "landscape", + "idiom" : "ipad", + "extent" : "full-screen", + "minimum-system-version" : "7.0", + "scale" : "2x" + }, + { + "orientation" : "portrait", + "idiom" : "iphone", + "extent" : "full-screen", + "scale" : "1x" + }, + { + "orientation" : "portrait", + "idiom" : "iphone", + "extent" : "full-screen", + "scale" : "2x" + }, + { + "orientation" : "portrait", + "idiom" : "iphone", + "extent" : "full-screen", + "subtype" : "retina4", + "scale" : "2x" + }, + { + "orientation" : "portrait", + "idiom" : "ipad", + "extent" : "to-status-bar", + "scale" : "1x" + }, + { + "orientation" : "portrait", + "idiom" : "ipad", + "extent" : "full-screen", + "scale" : "1x" + }, + { + "orientation" : "landscape", + "idiom" : "ipad", + "extent" : "to-status-bar", + "scale" : "1x" + }, + { + "orientation" : "landscape", + "idiom" : "ipad", + "extent" : "full-screen", + "scale" : "1x" + }, + { + "orientation" : "portrait", + "idiom" : "ipad", + "extent" : "to-status-bar", + "scale" : "2x" + }, + { + "orientation" : "portrait", + "idiom" : "ipad", + "extent" : "full-screen", + "scale" : "2x" + }, + { + "orientation" : "landscape", + "idiom" : "ipad", + "extent" : "to-status-bar", + "scale" : "2x" + }, + { + "orientation" : "landscape", + "idiom" : "ipad", + "extent" : "full-screen", "scale" : "2x" } ], diff --git a/FBSnapshotTestCaseDemo/FBSnapshotTestCaseDemo/Launch Screen.storyboard b/FBSnapshotTestCaseDemo/FBSnapshotTestCaseDemo/Launch Screen.storyboard new file mode 100644 index 0000000..ecfa0f0 --- /dev/null +++ b/FBSnapshotTestCaseDemo/FBSnapshotTestCaseDemo/Launch Screen.storyboard @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/FBSnapshotTestCaseDemo/FBSnapshotTestCaseDemoTests/FBSnapshotTestCaseDeviceAgnosticTests.m b/FBSnapshotTestCaseDemo/FBSnapshotTestCaseDemoTests/FBSnapshotTestCaseDeviceAgnosticTests.m new file mode 100644 index 0000000..5623bad --- /dev/null +++ b/FBSnapshotTestCaseDemo/FBSnapshotTestCaseDemoTests/FBSnapshotTestCaseDeviceAgnosticTests.m @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2013, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + */ + +#import + +@interface FBSnapshotTestCaseDeviceAgnosticTests : FBSnapshotTestCase + +@end + +@implementation FBSnapshotTestCaseDeviceAgnosticTests + +- (void)setUp +{ + [super setUp]; + self.deviceAgnostic = YES; + self.recordMode = NO; +} + +- (void)testSuccessfulComparisonOfDeviceAgnosticReferenceImages +{ + UIView *redView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 40, 40)]; + redView.backgroundColor = [UIColor redColor]; + FBSnapshotVerifyView(redView, nil); + FBSnapshotVerifyLayer(redView.layer, nil); +} + +@end diff --git a/FBSnapshotTestCaseDemo/FBSnapshotTestCaseDemoTests/ReferenceImages_32/FBSnapshotTestCaseDeviceAgnosticTests/testSuccessfulComparisonOfDeviceAgnosticReferenceImages_iPhone9_0_320x480@2x.png b/FBSnapshotTestCaseDemo/FBSnapshotTestCaseDemoTests/ReferenceImages_32/FBSnapshotTestCaseDeviceAgnosticTests/testSuccessfulComparisonOfDeviceAgnosticReferenceImages_iPhone9_0_320x480@2x.png new file mode 100644 index 0000000..91d8099 Binary files /dev/null and b/FBSnapshotTestCaseDemo/FBSnapshotTestCaseDemoTests/ReferenceImages_32/FBSnapshotTestCaseDeviceAgnosticTests/testSuccessfulComparisonOfDeviceAgnosticReferenceImages_iPhone9_0_320x480@2x.png differ diff --git a/FBSnapshotTestCaseDemo/FBSnapshotTestCaseDemoTests/ReferenceImages_64/FBSnapshotTestCaseDeviceAgnosticTests/testSuccessfulComparisonOfDeviceAgnosticReferenceImages_iPhone9_0_375x667@2x.png b/FBSnapshotTestCaseDemo/FBSnapshotTestCaseDemoTests/ReferenceImages_64/FBSnapshotTestCaseDeviceAgnosticTests/testSuccessfulComparisonOfDeviceAgnosticReferenceImages_iPhone9_0_375x667@2x.png new file mode 100644 index 0000000..91d8099 Binary files /dev/null and b/FBSnapshotTestCaseDemo/FBSnapshotTestCaseDemoTests/ReferenceImages_64/FBSnapshotTestCaseDeviceAgnosticTests/testSuccessfulComparisonOfDeviceAgnosticReferenceImages_iPhone9_0_375x667@2x.png differ