diff --git a/Images.xcassets/memory/Contents.json b/Images.xcassets/memory/Contents.json new file mode 100644 index 0000000..da4a164 --- /dev/null +++ b/Images.xcassets/memory/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Images.xcassets/memory/m_1gb.imageset/Contents.json b/Images.xcassets/memory/m_1gb.imageset/Contents.json new file mode 100644 index 0000000..2365dc5 --- /dev/null +++ b/Images.xcassets/memory/m_1gb.imageset/Contents.json @@ -0,0 +1,41 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "image.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "blue.png", + "memory" : "1GB", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "image@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "blue@2x.png", + "memory" : "1GB", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "image@3x.png", + "scale" : "3x" + }, + { + "idiom" : "universal", + "filename" : "blue@3x.png", + "memory" : "1GB", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Images.xcassets/memory/m_1gb.imageset/blue.png b/Images.xcassets/memory/m_1gb.imageset/blue.png new file mode 100644 index 0000000..d540418 Binary files /dev/null and b/Images.xcassets/memory/m_1gb.imageset/blue.png differ diff --git a/Images.xcassets/memory/m_1gb.imageset/blue@2x.png b/Images.xcassets/memory/m_1gb.imageset/blue@2x.png new file mode 100644 index 0000000..03291ba Binary files /dev/null and b/Images.xcassets/memory/m_1gb.imageset/blue@2x.png differ diff --git a/Images.xcassets/memory/m_1gb.imageset/blue@3x.png b/Images.xcassets/memory/m_1gb.imageset/blue@3x.png new file mode 100644 index 0000000..e7deb63 Binary files /dev/null and b/Images.xcassets/memory/m_1gb.imageset/blue@3x.png differ diff --git a/Images.xcassets/memory/m_1gb.imageset/image.png b/Images.xcassets/memory/m_1gb.imageset/image.png new file mode 100644 index 0000000..8ffa9d4 Binary files /dev/null and b/Images.xcassets/memory/m_1gb.imageset/image.png differ diff --git a/Images.xcassets/memory/m_1gb.imageset/image@2x.png b/Images.xcassets/memory/m_1gb.imageset/image@2x.png new file mode 100644 index 0000000..61df295 Binary files /dev/null and b/Images.xcassets/memory/m_1gb.imageset/image@2x.png differ diff --git a/Images.xcassets/memory/m_1gb.imageset/image@3x.png b/Images.xcassets/memory/m_1gb.imageset/image@3x.png new file mode 100644 index 0000000..83dae6e Binary files /dev/null and b/Images.xcassets/memory/m_1gb.imageset/image@3x.png differ diff --git a/Images.xcassets/memory/m_2gb.imageset/Contents.json b/Images.xcassets/memory/m_2gb.imageset/Contents.json new file mode 100644 index 0000000..6f58749 --- /dev/null +++ b/Images.xcassets/memory/m_2gb.imageset/Contents.json @@ -0,0 +1,41 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "blue.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "cyan.png", + "memory" : "2GB", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "blue@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "cyan@2x.png", + "memory" : "2GB", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "blue@3x.png", + "scale" : "3x" + }, + { + "idiom" : "universal", + "filename" : "cyan@3x.png", + "memory" : "2GB", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Images.xcassets/memory/m_2gb.imageset/blue.png b/Images.xcassets/memory/m_2gb.imageset/blue.png new file mode 100644 index 0000000..d540418 Binary files /dev/null and b/Images.xcassets/memory/m_2gb.imageset/blue.png differ diff --git a/Images.xcassets/memory/m_2gb.imageset/blue@2x.png b/Images.xcassets/memory/m_2gb.imageset/blue@2x.png new file mode 100644 index 0000000..03291ba Binary files /dev/null and b/Images.xcassets/memory/m_2gb.imageset/blue@2x.png differ diff --git a/Images.xcassets/memory/m_2gb.imageset/blue@3x.png b/Images.xcassets/memory/m_2gb.imageset/blue@3x.png new file mode 100644 index 0000000..e7deb63 Binary files /dev/null and b/Images.xcassets/memory/m_2gb.imageset/blue@3x.png differ diff --git a/Images.xcassets/memory/m_2gb.imageset/cyan.png b/Images.xcassets/memory/m_2gb.imageset/cyan.png new file mode 100644 index 0000000..4ad4b63 Binary files /dev/null and b/Images.xcassets/memory/m_2gb.imageset/cyan.png differ diff --git a/Images.xcassets/memory/m_2gb.imageset/cyan@2x.png b/Images.xcassets/memory/m_2gb.imageset/cyan@2x.png new file mode 100644 index 0000000..700c912 Binary files /dev/null and b/Images.xcassets/memory/m_2gb.imageset/cyan@2x.png differ diff --git a/Images.xcassets/memory/m_2gb.imageset/cyan@3x.png b/Images.xcassets/memory/m_2gb.imageset/cyan@3x.png new file mode 100644 index 0000000..b44da9a Binary files /dev/null and b/Images.xcassets/memory/m_2gb.imageset/cyan@3x.png differ diff --git a/Images.xcassets/memory/m_4gb.imageset/Contents.json b/Images.xcassets/memory/m_4gb.imageset/Contents.json new file mode 100644 index 0000000..06b989a --- /dev/null +++ b/Images.xcassets/memory/m_4gb.imageset/Contents.json @@ -0,0 +1,41 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "cyan.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "green.png", + "memory" : "4GB", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "cyan@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "green@2x.png", + "memory" : "4GB", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "cyan@3x.png", + "scale" : "3x" + }, + { + "idiom" : "universal", + "filename" : "green@3x.png", + "memory" : "4GB", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Images.xcassets/memory/m_4gb.imageset/cyan.png b/Images.xcassets/memory/m_4gb.imageset/cyan.png new file mode 100644 index 0000000..4ad4b63 Binary files /dev/null and b/Images.xcassets/memory/m_4gb.imageset/cyan.png differ diff --git a/Images.xcassets/memory/m_4gb.imageset/cyan@2x.png b/Images.xcassets/memory/m_4gb.imageset/cyan@2x.png new file mode 100644 index 0000000..700c912 Binary files /dev/null and b/Images.xcassets/memory/m_4gb.imageset/cyan@2x.png differ diff --git a/Images.xcassets/memory/m_4gb.imageset/cyan@3x.png b/Images.xcassets/memory/m_4gb.imageset/cyan@3x.png new file mode 100644 index 0000000..b44da9a Binary files /dev/null and b/Images.xcassets/memory/m_4gb.imageset/cyan@3x.png differ diff --git a/Images.xcassets/memory/m_4gb.imageset/green.png b/Images.xcassets/memory/m_4gb.imageset/green.png new file mode 100644 index 0000000..645826c Binary files /dev/null and b/Images.xcassets/memory/m_4gb.imageset/green.png differ diff --git a/Images.xcassets/memory/m_4gb.imageset/green@2x.png b/Images.xcassets/memory/m_4gb.imageset/green@2x.png new file mode 100644 index 0000000..d88a747 Binary files /dev/null and b/Images.xcassets/memory/m_4gb.imageset/green@2x.png differ diff --git a/Images.xcassets/memory/m_4gb.imageset/green@3x.png b/Images.xcassets/memory/m_4gb.imageset/green@3x.png new file mode 100644 index 0000000..0c4df1a Binary files /dev/null and b/Images.xcassets/memory/m_4gb.imageset/green@3x.png differ diff --git a/Images.xcassets/memory/m_no.imageset/Contents.json b/Images.xcassets/memory/m_no.imageset/Contents.json new file mode 100644 index 0000000..7bbf089 --- /dev/null +++ b/Images.xcassets/memory/m_no.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "green.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "green@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "green@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Images.xcassets/memory/m_no.imageset/green.png b/Images.xcassets/memory/m_no.imageset/green.png new file mode 100644 index 0000000..645826c Binary files /dev/null and b/Images.xcassets/memory/m_no.imageset/green.png differ diff --git a/Images.xcassets/memory/m_no.imageset/green@2x.png b/Images.xcassets/memory/m_no.imageset/green@2x.png new file mode 100644 index 0000000..d88a747 Binary files /dev/null and b/Images.xcassets/memory/m_no.imageset/green@2x.png differ diff --git a/Images.xcassets/memory/m_no.imageset/green@3x.png b/Images.xcassets/memory/m_no.imageset/green@3x.png new file mode 100644 index 0000000..0c4df1a Binary files /dev/null and b/Images.xcassets/memory/m_no.imageset/green@3x.png differ diff --git a/README.md b/README.md index d0b49b1..29675e9 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ Support Mac, iOS and AppleWatch assets. Can extract PNG and PDF files. | 4 inch iPhone | ✔ | | Size classes | ✔ | | Slicing | ✔ | -| Memory class | ✘ | +| Memory class | ✔ | | Graphics class | ✔ | | Data | ✘ | | PDF | ✘ | diff --git a/Templates.xcassets/colors/cyan.imageset/Contents.json b/Templates.xcassets/colors/cyan.imageset/Contents.json index c7edc5c..1a810ad 100644 --- a/Templates.xcassets/colors/cyan.imageset/Contents.json +++ b/Templates.xcassets/colors/cyan.imageset/Contents.json @@ -2,18 +2,18 @@ "images" : [ { "idiom" : "universal", - "scale" : "1x", - "filename" : "cyan.png" + "filename" : "cyan.png", + "scale" : "1x" }, { "idiom" : "universal", - "scale" : "2x", - "filename" : "cyan@2x.png" + "filename" : "cyan@2x.png", + "scale" : "2x" }, { "idiom" : "universal", - "scale" : "3x", - "filename" : "cyan@3x.png" + "filename" : "cyan@3x.png", + "scale" : "3x" } ], "info" : { diff --git a/acextract.xcodeproj/project.pbxproj b/acextract.xcodeproj/project.pbxproj index d0fef21..4c1128e 100644 --- a/acextract.xcodeproj/project.pbxproj +++ b/acextract.xcodeproj/project.pbxproj @@ -46,6 +46,7 @@ 96A84A5D1D0DF0D500B79D25 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 96A84A5B1D0DF0D500B79D25 /* Main.storyboard */; }; 96A84A5F1D0DF0D500B79D25 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 96A84A5E1D0DF0D500B79D25 /* Assets.xcassets */; }; 96A84A661D0DF0EF00B79D25 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 9625C14A1A48C24A00EE5162 /* Images.xcassets */; }; + 96CB28C51D29411C003B94BB /* MemoryClassTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96CB28C41D29411C003B94BB /* MemoryClassTests.swift */; }; 96D010831D173194000553B1 /* CorrectnessTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96D010821D173194000553B1 /* CorrectnessTests.swift */; }; 96E36DDB1D2472CB00985687 /* GraphicalClassTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96E36DDA1D2472CB00985687 /* GraphicalClassTests.swift */; }; 96E9F6AA1D0DD320001588FF /* AssetsCatalogTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96E9F6A91D0DD320001588FF /* AssetsCatalogTests.swift */; }; @@ -170,6 +171,7 @@ 96A84A5C1D0DF0D500B79D25 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 96A84A5E1D0DF0D500B79D25 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 96A84A601D0DF0D500B79D25 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 96CB28C41D29411C003B94BB /* MemoryClassTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MemoryClassTests.swift; sourceTree = ""; }; 96D010821D173194000553B1 /* CorrectnessTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CorrectnessTests.swift; sourceTree = ""; }; 96E36DDA1D2472CB00985687 /* GraphicalClassTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GraphicalClassTests.swift; sourceTree = ""; }; 96E9F6A71D0DD31F001588FF /* acextractTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = acextractTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -400,6 +402,7 @@ 96D010821D173194000553B1 /* CorrectnessTests.swift */, 96F446651D15DB6F00F30964 /* DeviceTests.swift */, 96E36DDA1D2472CB00985687 /* GraphicalClassTests.swift */, + 96CB28C41D29411C003B94BB /* MemoryClassTests.swift */, 96F52BFB1D1FFB89006CAD7B /* SizeClassTests.swift */, 9666CE241D21B363009C9402 /* SlicesTests.swift */, 9669A6351D20332D0037654D /* TemplateRenderingTests.swift */, @@ -779,6 +782,7 @@ 9673B97A1D205CE900F3C684 /* AlignmentTests.swift in Sources */, 96D010831D173194000553B1 /* CorrectnessTests.swift in Sources */, 9666CE251D21B363009C9402 /* SlicesTests.swift in Sources */, + 96CB28C51D29411C003B94BB /* MemoryClassTests.swift in Sources */, 961427121D1F1186005831AA /* Assets.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/acextract/CoreUI.h b/acextract/CoreUI.h index 9be41db..685a055 100644 --- a/acextract/CoreUI.h +++ b/acextract/CoreUI.h @@ -83,12 +83,19 @@ typedef NS_ENUM(NSInteger, CUIGraphicalClass) { CUIGraphicalClassMetal3v1 = 3, }; +typedef NS_ENUM(NSInteger, CUIMemoryClass) { + CUIMemoryClassDefault = 0, + CUIMemoryClassMemory1GB = 1, + CUIMemoryClassMemory2GB = 2, + CUIMemoryClassMemory4GB = 3, +}; + @class CUIRenditionSliceInformation; @interface CUIRenditionKey : NSObject - (CUIGraphicalClass)themeGraphicsClass; -- (long long)themeMemoryClass; +- (CUIMemoryClass)themeMemoryClass; @end @@ -182,7 +189,7 @@ typedef NS_ENUM(NSInteger, CUIGraphicalClass) { - (nonnull CUIRenditionKey *)baseKey; - (CUIGraphicalClass)graphicsClass; -- (long long)memoryClass; +- (CUIMemoryClass)memoryClass; @end diff --git a/acextract/CoreUI_Swift.swift b/acextract/CoreUI_Swift.swift index 17f0201..c25865e 100644 --- a/acextract/CoreUI_Swift.swift +++ b/acextract/CoreUI_Swift.swift @@ -293,6 +293,40 @@ extension CUIGraphicalClass: CustomStringConvertible { } } +// MARK: CUIMemoryClass +extension CUIMemoryClass: NameStringConvertible { + var name: String { + switch self { + case .Default: return "" + case .Memory1GB: return "1gb" + case .Memory2GB: return "2gb" + case .Memory4GB: return "4gb" + } + } +} + +extension CUIMemoryClass: ValueCorrectness, IncorrectValueAssertion { + var correct: Bool { + switch self { + case .Default: return rawValue == Default.rawValue + case .Memory1GB: return rawValue == Memory1GB.rawValue + case .Memory2GB: return rawValue == Memory2GB.rawValue + case .Memory4GB: return rawValue == Memory4GB.rawValue + } + } +} + +extension CUIMemoryClass: CustomStringConvertible { + public var description: String { + switch self { + case .Default: return "default" + case .Memory1GB: return "1GB" + case .Memory2GB: return "2GB" + case .Memory4GB: return "4GB" + } + } +} + // MARK: CUINamedImage extension CUINamedImage { var acScale: ScaleFactor { @@ -324,6 +358,9 @@ extension CUINamedImage { // Graphical class let graphics = self.graphicsClass().name + // Memory class + let memory = self.memoryClass().name + // Size class suffix let sizeClassSuffix = acSizeClassString @@ -339,6 +376,6 @@ extension CUINamedImage { // File extension let fileExtension = acFileExtension - return "\(self.name)\(graphics)\(sizeClassSuffix)\(subtype)\(scale)\(idiom).\(fileExtension)" + return "\(self.name)\(graphics)\(memory)\(sizeClassSuffix)\(subtype)\(scale)\(idiom).\(fileExtension)" } } diff --git a/acextract/PrintInformationOperation.swift b/acextract/PrintInformationOperation.swift index 391fb68..9bdd58b 100644 --- a/acextract/PrintInformationOperation.swift +++ b/acextract/PrintInformationOperation.swift @@ -73,6 +73,7 @@ extension CUIRenderMode: InformationPrintable { } extension CUIResizingMode: InformationPrintable { } extension CUIImageType: InformationPrintable { } extension CUIGraphicalClass: InformationPrintable { } +extension CUIMemoryClass: InformationPrintable { } // MARK: - PrintInformationOperation struct PrintInformationOperation: Operation { @@ -176,7 +177,7 @@ struct PrintInformationOperation: Operation { // renditionKey() -> CUIRenditionKey // printProperty("rendition key", value: namedImage.renditionKey()) namedImage.renditionKey().themeGraphicsClass().printWithLabel("rendition key graphical class") - printProperty("rendition key memory class", value: namedImage.renditionKey().themeMemoryClass()) + namedImage.renditionKey().themeMemoryClass().printWithLabel("rendition key memory class") // _rendition() -> CUIThemeRendition printProperty("rendition name", value: namedImage._rendition().name()) @@ -202,8 +203,8 @@ struct PrintInformationOperation: Operation { printProperty("scale", value: namedImage.acScale.informationName) namedImage.sizeClassHorizontal().printWithLabel("size vlass horizontal") namedImage.sizeClassVertical().printWithLabel("size vlass vertical") - namedImage.graphicsClass().printWithLabel("graphics Class") - printProperty("memory Class", value: namedImage.memoryClass()) + namedImage.graphicsClass().printWithLabel("graphics class") + namedImage.memoryClass().printWithLabel("memory class") printProperty("opacity", value: namedImage.opacity) printProperty("size", value: namedImage.size) printProperty("blend mode", value: namedImage.blendMode) @@ -220,8 +221,7 @@ struct PrintInformationOperation: Operation { // baseKey -> CUIRenditionKey // printProperty("base key", value: namedImage.baseKey()) - printProperty("base key graphical class", value: namedImage.baseKey().themeGraphicsClass()) - printProperty("base key memory class", value: namedImage.baseKey().themeMemoryClass()) - + namedImage.baseKey().themeGraphicsClass().printWithLabel("base key graphical class") + namedImage.baseKey().themeMemoryClass().printWithLabel("base key memory class") } } diff --git a/acextractTests/MemoryClassTests.swift b/acextractTests/MemoryClassTests.swift new file mode 100644 index 0000000..433aef7 --- /dev/null +++ b/acextractTests/MemoryClassTests.swift @@ -0,0 +1,267 @@ +// +// MemoryClassTests.swift +// acextract +// +// Created by Bartosz Janda on 03.07.2016. +// Copyright © 2016 Bartosz Janda. All rights reserved. +// + +import XCTest + +class MemoryClassTests: XCTestCase { + // MARK: Memory class + func testNone() { + let imageSet = assetsContainer.iOS.imageSet(withName: "m_no") + let images = imageSet.namedImages + XCTAssertEqual(images.count, 3) + + // Default 1x + if let image = images.filter({ return $0.scale == 1.0 }).first { + XCTAssertEqual(image.memoryClass(), CUIMemoryClass.Default) + XCTAssertEqual(image.baseKey().themeMemoryClass(), CUIMemoryClass.Default) + XCTAssertEqual(image.renditionKey().themeMemoryClass(), CUIMemoryClass.Default) + XCTAssertEqual(image.acImageName, "m_no.png") + XCTAssertNotNil(image._rendition().unslicedImage()) + } else { + XCTFail("Cannot find image") + } + + // Default 2x + if let image = images.filter({ return $0.scale == 2.0 }).first { + XCTAssertEqual(image.memoryClass(), CUIMemoryClass.Default) + XCTAssertEqual(image.baseKey().themeMemoryClass(), CUIMemoryClass.Default) + XCTAssertEqual(image.renditionKey().themeMemoryClass(), CUIMemoryClass.Default) + XCTAssertEqual(image.acImageName, "m_no@2x.png") + XCTAssertNotNil(image._rendition().unslicedImage()) + } else { + XCTFail("Cannot find image") + } + + // Default 3x + if let image = images.filter({ return $0.scale == 3.0 }).first { + XCTAssertEqual(image.memoryClass(), CUIMemoryClass.Default) + XCTAssertEqual(image.baseKey().themeMemoryClass(), CUIMemoryClass.Default) + XCTAssertEqual(image.renditionKey().themeMemoryClass(), CUIMemoryClass.Default) + XCTAssertEqual(image.acImageName, "m_no@3x.png") + XCTAssertNotNil(image._rendition().unslicedImage()) + } else { + XCTFail("Cannot find image") + } + } + + func test1GB() { + let imageSet = assetsContainer.iOS.imageSet(withName: "m_1gb") + let images = imageSet.namedImages + XCTAssertEqual(images.count, 6) + + // Default 1x + if let image = images.filter({ return $0.scale == 1.0 && $0.memoryClass() == .Default }).first { + XCTAssertEqual(image.memoryClass(), CUIMemoryClass.Default) + XCTAssertEqual(image.baseKey().themeMemoryClass(), CUIMemoryClass.Default) + XCTAssertEqual(image.renditionKey().themeMemoryClass(), CUIMemoryClass.Default) + XCTAssertEqual(image.acImageName, "m_1gb.png") + XCTAssertNotNil(image._rendition().unslicedImage()) + } else { + XCTFail("Cannot find image") + } + + // Default 2x + if let image = images.filter({ return $0.scale == 2.0 && $0.memoryClass() == .Default }).first { + XCTAssertEqual(image.memoryClass(), CUIMemoryClass.Default) + XCTAssertEqual(image.baseKey().themeMemoryClass(), CUIMemoryClass.Default) + XCTAssertEqual(image.renditionKey().themeMemoryClass(), CUIMemoryClass.Default) + XCTAssertEqual(image.acImageName, "m_1gb@2x.png") + XCTAssertNotNil(image._rendition().unslicedImage()) + } else { + XCTFail("Cannot find image") + } + + // Default 3x + if let image = images.filter({ return $0.scale == 3.0 && $0.memoryClass() == .Default }).first { + XCTAssertEqual(image.memoryClass(), CUIMemoryClass.Default) + XCTAssertEqual(image.baseKey().themeMemoryClass(), CUIMemoryClass.Default) + XCTAssertEqual(image.renditionKey().themeMemoryClass(), CUIMemoryClass.Default) + XCTAssertEqual(image.acImageName, "m_1gb@3x.png") + XCTAssertNotNil(image._rendition().unslicedImage()) + } else { + XCTFail("Cannot find image") + } + + // 1GB 1x + if let image = images.filter({ return $0.scale == 1.0 && $0.memoryClass() == .Memory1GB }).first { + XCTAssertEqual(image.memoryClass(), CUIMemoryClass.Memory1GB) + XCTAssertEqual(image.baseKey().themeMemoryClass(), CUIMemoryClass.Memory1GB) + XCTAssertEqual(image.renditionKey().themeMemoryClass(), CUIMemoryClass.Memory1GB) + XCTAssertEqual(image.acImageName, "m_1gb1gb.png") + XCTAssertNotNil(image._rendition().unslicedImage()) + } else { + XCTFail("Cannot find image") + } + + // 1GB 2x + if let image = images.filter({ return $0.scale == 2.0 && $0.memoryClass() == .Memory1GB }).first { + XCTAssertEqual(image.memoryClass(), CUIMemoryClass.Memory1GB) + XCTAssertEqual(image.baseKey().themeMemoryClass(), CUIMemoryClass.Memory1GB) + XCTAssertEqual(image.renditionKey().themeMemoryClass(), CUIMemoryClass.Memory1GB) + XCTAssertEqual(image.acImageName, "m_1gb1gb@2x.png") + XCTAssertNotNil(image._rendition().unslicedImage()) + } else { + XCTFail("Cannot find image") + } + + // 1GB 3x + if let image = images.filter({ return $0.scale == 3.0 && $0.memoryClass() == .Memory1GB }).first { + XCTAssertEqual(image.memoryClass(), CUIMemoryClass.Memory1GB) + XCTAssertEqual(image.baseKey().themeMemoryClass(), CUIMemoryClass.Memory1GB) + XCTAssertEqual(image.renditionKey().themeMemoryClass(), CUIMemoryClass.Memory1GB) + XCTAssertEqual(image.acImageName, "m_1gb1gb@3x.png") + XCTAssertNotNil(image._rendition().unslicedImage()) + } else { + XCTFail("Cannot find image") + } + } + + func test2GB() { + let imageSet = assetsContainer.iOS.imageSet(withName: "m_2gb") + let images = imageSet.namedImages + XCTAssertEqual(images.count, 6) + + // Default 1x + if let image = images.filter({ return $0.scale == 1.0 && $0.memoryClass() == .Default }).first { + XCTAssertEqual(image.memoryClass(), CUIMemoryClass.Default) + XCTAssertEqual(image.baseKey().themeMemoryClass(), CUIMemoryClass.Default) + XCTAssertEqual(image.renditionKey().themeMemoryClass(), CUIMemoryClass.Default) + XCTAssertEqual(image.acImageName, "m_2gb.png") + XCTAssertNotNil(image._rendition().unslicedImage()) + } else { + XCTFail("Cannot find image") + } + + // Default 2x + if let image = images.filter({ return $0.scale == 2.0 && $0.memoryClass() == .Default }).first { + XCTAssertEqual(image.memoryClass(), CUIMemoryClass.Default) + XCTAssertEqual(image.baseKey().themeMemoryClass(), CUIMemoryClass.Default) + XCTAssertEqual(image.renditionKey().themeMemoryClass(), CUIMemoryClass.Default) + XCTAssertEqual(image.acImageName, "m_2gb@2x.png") + XCTAssertNotNil(image._rendition().unslicedImage()) + } else { + XCTFail("Cannot find image") + } + + // Default 3x + if let image = images.filter({ return $0.scale == 3.0 && $0.memoryClass() == .Default }).first { + XCTAssertEqual(image.memoryClass(), CUIMemoryClass.Default) + XCTAssertEqual(image.baseKey().themeMemoryClass(), CUIMemoryClass.Default) + XCTAssertEqual(image.renditionKey().themeMemoryClass(), CUIMemoryClass.Default) + XCTAssertEqual(image.acImageName, "m_2gb@3x.png") + XCTAssertNotNil(image._rendition().unslicedImage()) + } else { + XCTFail("Cannot find image") + } + + // 2GB 1x + if let image = images.filter({ return $0.scale == 1.0 && $0.memoryClass() == .Memory2GB }).first { + XCTAssertEqual(image.memoryClass(), CUIMemoryClass.Memory2GB) + XCTAssertEqual(image.baseKey().themeMemoryClass(), CUIMemoryClass.Memory2GB) + XCTAssertEqual(image.renditionKey().themeMemoryClass(), CUIMemoryClass.Memory2GB) + XCTAssertEqual(image.acImageName, "m_2gb2gb.png") + XCTAssertNotNil(image._rendition().unslicedImage()) + } else { + XCTFail("Cannot find image") + } + + // 2GB 2x + if let image = images.filter({ return $0.scale == 2.0 && $0.memoryClass() == .Memory2GB }).first { + XCTAssertEqual(image.memoryClass(), CUIMemoryClass.Memory2GB) + XCTAssertEqual(image.baseKey().themeMemoryClass(), CUIMemoryClass.Memory2GB) + XCTAssertEqual(image.renditionKey().themeMemoryClass(), CUIMemoryClass.Memory2GB) + XCTAssertEqual(image.acImageName, "m_2gb2gb@2x.png") + XCTAssertNotNil(image._rendition().unslicedImage()) + } else { + XCTFail("Cannot find image") + } + + // 2GB 3x + if let image = images.filter({ return $0.scale == 3.0 && $0.memoryClass() == .Memory2GB }).first { + XCTAssertEqual(image.memoryClass(), CUIMemoryClass.Memory2GB) + XCTAssertEqual(image.baseKey().themeMemoryClass(), CUIMemoryClass.Memory2GB) + XCTAssertEqual(image.renditionKey().themeMemoryClass(), CUIMemoryClass.Memory2GB) + XCTAssertEqual(image.acImageName, "m_2gb2gb@3x.png") + XCTAssertNotNil(image._rendition().unslicedImage()) + } else { + XCTFail("Cannot find image") + } + } + + func test4GB() { + let imageSet = assetsContainer.iOS.imageSet(withName: "m_4gb") + let images = imageSet.namedImages + XCTAssertEqual(images.count, 6) + + // Default 1x + if let image = images.filter({ return $0.scale == 1.0 && $0.memoryClass() == .Default }).first { + XCTAssertEqual(image.memoryClass(), CUIMemoryClass.Default) + XCTAssertEqual(image.baseKey().themeMemoryClass(), CUIMemoryClass.Default) + XCTAssertEqual(image.renditionKey().themeMemoryClass(), CUIMemoryClass.Default) + XCTAssertEqual(image.acImageName, "m_4gb.png") + XCTAssertNotNil(image._rendition().unslicedImage()) + } else { + XCTFail("Cannot find image") + } + + // Default 2x + if let image = images.filter({ return $0.scale == 2.0 && $0.memoryClass() == .Default }).first { + XCTAssertEqual(image.memoryClass(), CUIMemoryClass.Default) + XCTAssertEqual(image.baseKey().themeMemoryClass(), CUIMemoryClass.Default) + XCTAssertEqual(image.renditionKey().themeMemoryClass(), CUIMemoryClass.Default) + XCTAssertEqual(image.acImageName, "m_4gb@2x.png") + XCTAssertNotNil(image._rendition().unslicedImage()) + } else { + XCTFail("Cannot find image") + } + + // Default 3x + if let image = images.filter({ return $0.scale == 3.0 && $0.memoryClass() == .Default }).first { + XCTAssertEqual(image.memoryClass(), CUIMemoryClass.Default) + XCTAssertEqual(image.baseKey().themeMemoryClass(), CUIMemoryClass.Default) + XCTAssertEqual(image.renditionKey().themeMemoryClass(), CUIMemoryClass.Default) + XCTAssertEqual(image.acImageName, "m_4gb@3x.png") + XCTAssertNotNil(image._rendition().unslicedImage()) + } else { + XCTFail("Cannot find image") + } + + // 4GB 1x + if let image = images.filter({ return $0.scale == 1.0 && $0.memoryClass() == .Memory4GB }).first { + XCTAssertEqual(image.memoryClass(), CUIMemoryClass.Memory4GB) + XCTAssertEqual(image.baseKey().themeMemoryClass(), CUIMemoryClass.Memory4GB) + XCTAssertEqual(image.renditionKey().themeMemoryClass(), CUIMemoryClass.Memory4GB) + XCTAssertEqual(image.acImageName, "m_4gb4gb.png") + XCTAssertNotNil(image._rendition().unslicedImage()) + } else { + XCTFail("Cannot find image") + } + + // 4GB 2x + if let image = images.filter({ return $0.scale == 2.0 && $0.memoryClass() == .Memory4GB }).first { + XCTAssertEqual(image.memoryClass(), CUIMemoryClass.Memory4GB) + XCTAssertEqual(image.baseKey().themeMemoryClass(), CUIMemoryClass.Memory4GB) + XCTAssertEqual(image.renditionKey().themeMemoryClass(), CUIMemoryClass.Memory4GB) + XCTAssertEqual(image.acImageName, "m_4gb4gb@2x.png") + XCTAssertNotNil(image._rendition().unslicedImage()) + } else { + XCTFail("Cannot find image") + } + + // 4GB 3x + if let image = images.filter({ return $0.scale == 3.0 && $0.memoryClass() == .Memory4GB }).first { + XCTAssertEqual(image.memoryClass(), CUIMemoryClass.Memory4GB) + XCTAssertEqual(image.baseKey().themeMemoryClass(), CUIMemoryClass.Memory4GB) + XCTAssertEqual(image.renditionKey().themeMemoryClass(), CUIMemoryClass.Memory4GB) + XCTAssertEqual(image.acImageName, "m_4gb4gb@3x.png") + XCTAssertNotNil(image._rendition().unslicedImage()) + } else { + XCTFail("Cannot find image") + } + } +} diff --git a/acextractTests/data/assets.car b/acextractTests/data/assets.car index 279ad7c..b5beb5d 100644 Binary files a/acextractTests/data/assets.car and b/acextractTests/data/assets.car differ diff --git a/acextractTests/data/assets_ios.car b/acextractTests/data/assets_ios.car index 279ad7c..b5beb5d 100644 Binary files a/acextractTests/data/assets_ios.car and b/acextractTests/data/assets_ios.car differ diff --git a/acextractTests/data/assets_ipad.car b/acextractTests/data/assets_ipad.car index b4a4e8f..907559e 100644 Binary files a/acextractTests/data/assets_ipad.car and b/acextractTests/data/assets_ipad.car differ diff --git a/acextractTests/data/assets_iphone.car b/acextractTests/data/assets_iphone.car index 5b7d9c0..0f781c3 100644 Binary files a/acextractTests/data/assets_iphone.car and b/acextractTests/data/assets_iphone.car differ diff --git a/acextractTests/data/assets_mac.car b/acextractTests/data/assets_mac.car index 0ba8b4d..3400646 100644 Binary files a/acextractTests/data/assets_mac.car and b/acextractTests/data/assets_mac.car differ diff --git a/acextractTests/data/assets_tv.car b/acextractTests/data/assets_tv.car index 48f2b57..e267e25 100644 Binary files a/acextractTests/data/assets_tv.car and b/acextractTests/data/assets_tv.car differ diff --git a/acextractTests/data/assets_watch.car b/acextractTests/data/assets_watch.car index 1bd3269..1c3b953 100644 Binary files a/acextractTests/data/assets_watch.car and b/acextractTests/data/assets_watch.car differ