This repository has been archived by the owner on Sep 15, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from num42/feature/improvements
Feature/improvements
- Loading branch information
Showing
8 changed files
with
1,362 additions
and
1,220 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
Large diffs are not rendered by default.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -1,75 +1,133 @@ | ||
import XCTest | ||
import Files | ||
import AppIconResizerCore | ||
@testable import AppIconResizerCore | ||
import class Foundation.Bundle | ||
|
||
final class AppIconResizerTests: XCTestCase { | ||
func testCreatingFile() throws { | ||
|
||
// Setup a temporarz test folder that can be used as a sandbox | ||
let fileSystem = FileSystem() | ||
let tempFolder = fileSystem.temporaryFolder | ||
let testFolder = try tempFolder.createSubfolderIfNeeded(withName:"AppIconResizerTests") | ||
|
||
// Empty the test folder to ensure a clean state | ||
try testFolder.empty() | ||
|
||
// Make the temp folder the current working folder | ||
let fileManager = FileManager.default | ||
fileManager.changeCurrentDirectoryPath(testFolder.path) | ||
|
||
// Create an instance of the command line tool | ||
let arguments = [testFolder.path, "Hello.swift"] | ||
let tool = AppIconResizer(arguments:arguments) | ||
|
||
// Try to run tool and look if there is | ||
try tool.run() | ||
XCTAssertNotNil(try? testFolder.file(named: "Hello.swift")) | ||
} | ||
|
||
func testReadingCommand() throws { | ||
|
||
let devices = ["iphone", "ipad", "watch", "marketing", "all"] | ||
try devices.forEach{ device in | ||
let arguments = [device, "testFilePath"] | ||
let tool = AppIconResizer(arguments:arguments) | ||
try tool.run() | ||
} | ||
//NoIdea | ||
} | ||
|
||
func testDeviceSizes() { | ||
XCTAssert( Idiom.all.appIconEntries == Idiom.all.appIconEntries ) | ||
|
||
XCTAssert( | ||
Idiom.iphone.sizes.map { $0.width } == [40, 58, 60, 80, 87, 120, 180] | ||
Idiom.iphone.appIconEntries == [ | ||
AppIconEntry( | ||
size : 20.0, | ||
idiom : "iphone", | ||
scale : 2), | ||
AppIconEntry( | ||
size : 20.0, | ||
idiom : "iphone", | ||
scale : 3), | ||
AppIconEntry( | ||
size : 29.0, | ||
idiom : "iphone", | ||
scale : 2), | ||
AppIconEntry( | ||
size : 29.0, | ||
idiom : "iphone", | ||
scale : 3), | ||
AppIconEntry( | ||
size : 40.0, | ||
idiom : "iphone", | ||
scale : 2), | ||
AppIconEntry( | ||
size : 40.0, | ||
idiom : "iphone", | ||
scale : 3), | ||
AppIconEntry( | ||
size : 60.0, | ||
idiom : "iphone", | ||
scale : 2), | ||
AppIconEntry( | ||
size : 60.0, | ||
idiom : "iphone", | ||
scale : 3) | ||
] | ||
) | ||
|
||
XCTAssert( | ||
Idiom.ipad.sizes.map { $0.width } == [20, 29, 40, 58, 76, 80, 152, 167] | ||
Idiom.ipad.appIconEntries == [ | ||
AppIconEntry( | ||
size : 20.0, | ||
idiom : "ipad", | ||
scale : 1), | ||
AppIconEntry( | ||
size : 20.0, | ||
idiom : "ipad", | ||
scale : 2), | ||
AppIconEntry( | ||
size : 29.0, | ||
idiom : "ipad", | ||
scale : 1), | ||
AppIconEntry( | ||
size : 29.0, | ||
idiom : "ipad", | ||
scale : 2), | ||
AppIconEntry( | ||
size : 40.0, | ||
idiom : "ipad", | ||
scale : 1), | ||
AppIconEntry( | ||
size : 40.0, | ||
idiom : "ipad", | ||
scale : 2), | ||
AppIconEntry( | ||
size : 76.0, | ||
idiom : "ipad", | ||
scale : 1), | ||
AppIconEntry( | ||
size : 76.0, | ||
idiom : "ipad", | ||
scale : 2), | ||
AppIconEntry( | ||
size : 83.5, | ||
idiom : "ipad", | ||
scale : 2) | ||
] | ||
) | ||
|
||
XCTAssert( | ||
Idiom.watch.sizes.map { $0.width } == [48, 55, 58, 80, 87, 88, 100, 172, 196, 216] | ||
Idiom.watch.appIconEntries == [ | ||
AppIconEntry( | ||
size : 24.0, | ||
idiom : "watch", | ||
scale : 2), | ||
AppIconEntry( | ||
size : 27.5, | ||
idiom : "watch", | ||
scale : 2), | ||
AppIconEntry( | ||
size : 29.0, | ||
idiom : "watch", | ||
scale : 2), | ||
AppIconEntry( | ||
size : 29.0, | ||
idiom : "watch", | ||
scale : 3), | ||
AppIconEntry( | ||
size : 40.0, | ||
idiom : "watch", | ||
scale : 2), | ||
AppIconEntry( | ||
size : 44.0, | ||
idiom : "watch", | ||
scale : 2), | ||
AppIconEntry( | ||
size : 50.0, | ||
idiom : "watch", | ||
scale : 2), | ||
AppIconEntry( | ||
size : 86.0, | ||
idiom : "watch", | ||
scale : 2), | ||
AppIconEntry( | ||
size : 98.0, | ||
idiom : "watch", | ||
scale : 2), | ||
AppIconEntry( | ||
size : 108.0, | ||
idiom : "watch", | ||
scale : 2) | ||
] | ||
) | ||
} | ||
|
||
func testCreatedPngs() throws { | ||
let testFolder = try Folder(path: FileManager.default.currentDirectoryPath) | ||
//AppIconResizer.render(device:iphone, ) | ||
XCTAssertNotNil(try? testFolder.file(named: "20.png")) | ||
} | ||
|
||
|
||
/// Returns path to the built products directory. | ||
var productsDirectory: URL { | ||
#if os(macOS) | ||
for bundle in Bundle.allBundles where bundle.bundlePath.hasSuffix(".xctest") { | ||
return bundle.bundleURL.deletingLastPathComponent() | ||
} | ||
fatalError("couldn't find the products directory") | ||
#else | ||
return Bundle.main.bundleURL | ||
#endif | ||
} | ||
|
||
static var allTests = [ | ||
("test", testCreatingFile), | ||
] | ||
} |