This repository has been archived by the owner on Jan 10, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add methods to get image from UI/NSView
- Loading branch information
Reda Lemeden
committed
Nov 16, 2015
1 parent
708b45a
commit a181d34
Showing
7 changed files
with
84 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import AppKit.NSImage | ||
import Verbena | ||
import XCTest | ||
|
||
class NSImageWithViewTests: XCTestCase { | ||
var image: NSImage! | ||
|
||
override func setUp() { | ||
super.setUp() | ||
|
||
let view = NSView(frame: CGRect(x: 0, y: 0, width: 100, height: 100)) | ||
view.wantsLayer = true | ||
view.layer?.backgroundColor = NSColor.redColor().CGColor | ||
image = NSImage.imageWithView(view) | ||
} | ||
|
||
func testImageIsDrawnInContext() { | ||
XCTAssertEqual(image.size.width, 100) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import UIKit.UIImage | ||
import Verbena | ||
import XCTest | ||
|
||
class UIImageWithViewTests: XCTestCase { | ||
var image: UIImage! | ||
|
||
override func setUp() { | ||
super.setUp() | ||
|
||
let view = UIView(frame: CGRect(x: 0, y: 0, width: 100, height: 100)) | ||
view.backgroundColor = UIColor.redColor() | ||
image = UIImage.imageWithView(view) | ||
} | ||
|
||
func testImageIsDrawnInContext() { | ||
XCTAssertEqual(image.size.width, 100) | ||
} | ||
|
||
func testImageIgnoresAlpha() { | ||
XCTAssertFalse(imageHasAlpha(image)) | ||
} | ||
} |