Skip to content

Commit c024ac9

Browse files
committedDec 21, 2015
Move sources around again
1 parent ddc2e1c commit c024ac9

31 files changed

+446
-409
lines changed
 

‎Cache-OSX/Cache-OSX.h

-19
This file was deleted.

‎Cache-OSXTests/Cache_OSXTests.swift

-36
This file was deleted.

‎Cache.xcodeproj/project.pbxproj

+369-326
Large diffs are not rendered by default.

‎Cache.xcodeproj/xcshareddata/xcschemes/Cache-OSX.xcscheme ‎Cache.xcodeproj/xcshareddata/xcschemes/Cache-Mac.xcscheme

+9-28
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
buildForAnalyzing = "YES">
1515
<BuildableReference
1616
BuildableIdentifier = "primary"
17-
BlueprintIdentifier = "D5291C401C28226800B702C9"
18-
BuildableName = "Cache-OSX.framework"
19-
BlueprintName = "Cache-OSX"
17+
BlueprintIdentifier = "D5291D5F1C283B5300B702C9"
18+
BuildableName = "Cache-Mac.framework"
19+
BlueprintName = "Cache-Mac"
2020
ReferencedContainer = "container:Cache.xcodeproj">
2121
</BuildableReference>
2222
</BuildActionEntry>
@@ -28,26 +28,7 @@
2828
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
2929
shouldUseLaunchSchemeArgsEnv = "YES">
3030
<Testables>
31-
<TestableReference
32-
skipped = "NO">
33-
<BuildableReference
34-
BuildableIdentifier = "primary"
35-
BlueprintIdentifier = "D5291C491C28226800B702C9"
36-
BuildableName = "Cache-OSX-Tests.xctest"
37-
BlueprintName = "Cache-OSX-Tests"
38-
ReferencedContainer = "container:Cache.xcodeproj">
39-
</BuildableReference>
40-
</TestableReference>
4131
</Testables>
42-
<MacroExpansion>
43-
<BuildableReference
44-
BuildableIdentifier = "primary"
45-
BlueprintIdentifier = "D5291C401C28226800B702C9"
46-
BuildableName = "Cache-OSX.framework"
47-
BlueprintName = "Cache-OSX"
48-
ReferencedContainer = "container:Cache.xcodeproj">
49-
</BuildableReference>
50-
</MacroExpansion>
5132
<AdditionalOptions>
5233
</AdditionalOptions>
5334
</TestAction>
@@ -64,9 +45,9 @@
6445
<MacroExpansion>
6546
<BuildableReference
6647
BuildableIdentifier = "primary"
67-
BlueprintIdentifier = "D5291C401C28226800B702C9"
68-
BuildableName = "Cache-OSX.framework"
69-
BlueprintName = "Cache-OSX"
48+
BlueprintIdentifier = "D5291D5F1C283B5300B702C9"
49+
BuildableName = "Cache-Mac.framework"
50+
BlueprintName = "Cache-Mac"
7051
ReferencedContainer = "container:Cache.xcodeproj">
7152
</BuildableReference>
7253
</MacroExpansion>
@@ -82,9 +63,9 @@
8263
<MacroExpansion>
8364
<BuildableReference
8465
BuildableIdentifier = "primary"
85-
BlueprintIdentifier = "D5291C401C28226800B702C9"
86-
BuildableName = "Cache-OSX.framework"
87-
BlueprintName = "Cache-OSX"
66+
BlueprintIdentifier = "D5291D5F1C283B5300B702C9"
67+
BuildableName = "Cache-Mac.framework"
68+
BlueprintName = "Cache-Mac"
8869
ReferencedContainer = "container:Cache.xcodeproj">
8970
</BuildableReference>
9071
</MacroExpansion>
File renamed without changes.
File renamed without changes.
File renamed without changes.
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import Cocoa
2+
@testable import Cache
3+
4+
extension NSImage {
5+
6+
func isEqualToImage(image: NSImage) -> Bool {
7+
return data.isEqualToData(image.data)
8+
}
9+
10+
var data: NSData {
11+
let representation = TIFFRepresentation!
12+
13+
let imageFileType: NSBitmapImageFileType = hasAlpha
14+
? .NSPNGFileType
15+
: .NSJPEGFileType
16+
17+
return (NSBitmapImageRep(data: representation)?.representationUsingType(imageFileType, properties: [:]))!
18+
}
19+
}
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import Cocoa
2+
3+
struct SpecHelper {
4+
5+
static func image(color: NSColor = NSColor.redColor(), size: NSSize = CGSize(width: 1, height: 1)) -> NSImage {
6+
let image = NSImage(size: size)
7+
image.lockFocus()
8+
color.drawSwatchInRect(NSMakeRect(0, 0, size.width, size.height))
9+
image.unlockFocus()
10+
return image
11+
}
12+
}
File renamed without changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import Quick
2+
import Nimble
3+
@testable import Cache
4+
5+
class NSImageCacheSpec: QuickSpec {
6+
7+
override func spec() {
8+
describe("NSImage+Cache") {
9+
10+
describe("Cachable") {
11+
describe(".decode") {
12+
it("decodes from NSData") {
13+
let image = SpecHelper.image()
14+
let data = image.encode()!
15+
let result = NSImage.decode(data)!
16+
17+
expect(result.isEqualToImage(image)).to(beTrue())
18+
}
19+
}
20+
21+
describe("#encode") {
22+
it("encodes to NSData") {
23+
let image = SpecHelper.image()
24+
let representation = image.TIFFRepresentation!
25+
let imageFileType: NSBitmapImageFileType = image.hasAlpha
26+
? .NSPNGFileType
27+
: .NSJPEGFileType
28+
let data = NSBitmapImageRep(data: representation)!.representationUsingType(imageFileType, properties: [:])
29+
let result = image.encode()!
30+
31+
expect(result).to(equal(data))
32+
}
33+
}
34+
}
35+
}
36+
}
37+
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)
Please sign in to comment.