Skip to content
This repository has been archived by the owner on Jan 14, 2021. It is now read-only.

Commit

Permalink
Merge branch '1.1-development'
Browse files Browse the repository at this point in the history
* 1.1-development:
  Remove Travis build (Swift is not working yet)
  Update file comments
  Add Travis build status
  Update README.md with new title
  Rename swift-gif to SwiftGif
  Add .travis.yml
  Add testAnimatedImageWithSource()
  Add test.gif, testDelayForImageAtIndex()
  Fix typo in test functions
  Add tests for greatest common divisor
  Remove  CoreData stuff from AppDelegate.swift
  Remove xcdatamodel
  Add test template
  Remove TODO comment
  • Loading branch information
bahlo committed Jun 11, 2014
2 parents 0986a36 + 0a7564a commit 057a25d
Show file tree
Hide file tree
Showing 22 changed files with 266 additions and 351 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
language: swift

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# swift-gif
# SwiftGif

A small `UIImage` extension with gif support.

Expand Down

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "14C34DA6194769CD00F68707"
BuildableName = "swift-gif.app"
BlueprintName = "swift-gif"
ReferencedContainer = "container:swift-gif.xcodeproj">
BlueprintIdentifier = "1448EB6A19491D2000D54654"
BuildableName = "SwiftGif.app"
BlueprintName = "SwiftGif"
ReferencedContainer = "container:SwiftGif.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
Expand All @@ -32,20 +32,20 @@
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "14C34DB6194769CD00F68707"
BuildableName = "swift-gifTests.xctest"
BlueprintName = "swift-gifTests"
ReferencedContainer = "container:swift-gif.xcodeproj">
BlueprintIdentifier = "1448EB7719491D2100D54654"
BuildableName = "SwiftGifTests.xctest"
BlueprintName = "SwiftGifTests"
ReferencedContainer = "container:SwiftGif.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "14C34DA6194769CD00F68707"
BuildableName = "swift-gif.app"
BlueprintName = "swift-gif"
ReferencedContainer = "container:swift-gif.xcodeproj">
BlueprintIdentifier = "1448EB6A19491D2000D54654"
BuildableName = "SwiftGif.app"
BlueprintName = "SwiftGif"
ReferencedContainer = "container:SwiftGif.xcodeproj">
</BuildableReference>
</MacroExpansion>
</TestAction>
Expand All @@ -61,10 +61,10 @@
<BuildableProductRunnable>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "14C34DA6194769CD00F68707"
BuildableName = "swift-gif.app"
BlueprintName = "swift-gif"
ReferencedContainer = "container:swift-gif.xcodeproj">
BlueprintIdentifier = "1448EB6A19491D2000D54654"
BuildableName = "SwiftGif.app"
BlueprintName = "SwiftGif"
ReferencedContainer = "container:SwiftGif.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
Expand All @@ -79,10 +79,10 @@
<BuildableProductRunnable>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "14C34DA6194769CD00F68707"
BuildableName = "swift-gif.app"
BlueprintName = "swift-gif"
ReferencedContainer = "container:swift-gif.xcodeproj">
BlueprintIdentifier = "1448EB6A19491D2000D54654"
BuildableName = "SwiftGif.app"
BlueprintName = "SwiftGif"
ReferencedContainer = "container:SwiftGif.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@
<dict>
<key>SchemeUserState</key>
<dict>
<key>swift-gif.xcscheme</key>
<key>SwiftGif.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
<key>SuppressBuildableAutocreation</key>
<dict>
<key>14C34DA6194769CD00F68707</key>
<key>1448EB6A19491D2000D54654</key>
<dict>
<key>primary</key>
<true/>
</dict>
<key>14C34DB6194769CD00F68707</key>
<key>1448EB7719491D2100D54654</key>
<dict>
<key>primary</key>
<true/>
Expand Down
50 changes: 50 additions & 0 deletions SwiftGif/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
//
// AppDelegate.swift
// SwiftGif
//
// Created by Arne Bahlo on 10.06.14.
// Copyright (c) 2014 Arne Bahlo. All rights reserved.
//

import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?


func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: NSDictionary?) -> Bool {
self.window = UIWindow(frame: UIScreen.mainScreen().bounds)

self.window!.rootViewController = RootViewController()
self.window!.backgroundColor = UIColor.whiteColor()
self.window!.makeKeyAndVisible()
return true
}

func applicationWillResignActive(application: UIApplication) {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

func applicationDidEnterBackground(application: UIApplication) {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

func applicationWillEnterForeground(application: UIApplication) {
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

func applicationDidBecomeActive(application: UIApplication) {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

func applicationWillTerminate(application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}


}

7 changes: 3 additions & 4 deletions swift-gif/Gif.swift → SwiftGif/Gif.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// Gif.swift
// Gifd
// SwiftGif
//
// Created by Arne Bahlo on 07.06.14.
// Copyright (c) 2014 Arne Bahlo. All rights reserved.
Expand All @@ -9,7 +9,6 @@
import UIKit
import ImageIO

// TODO: Release stuff
extension UIImage {

class func animatedImageWithData(data: NSData) -> UIImage? {
Expand Down Expand Up @@ -46,7 +45,7 @@ extension UIImage {
return delay
}

class func gcdForPair(var a: Int?, var b: Int?) -> Int {
class func gcdForPair(var a: Int?, var _ b: Int?) -> Int {
// Check if one of them is nil
if !a || !b {
if b {
Expand Down Expand Up @@ -87,7 +86,7 @@ extension UIImage {
var gcd = array[0]

for val in array {
gcd = UIImage.gcdForPair(val, b: gcd)
gcd = UIImage.gcdForPair(val, gcd)
}

return gcd
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// RootViewController.swift
// swift-gif
// SwiftGif
//
// Created by Arne Bahlo on 10.06.14.
// Copyright (c) 2014 Arne Bahlo. All rights reserved.
Expand Down
File renamed without changes
File renamed without changes
67 changes: 67 additions & 0 deletions SwiftGifTests/GifTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
//
// GifTests.swift
// SwiftGif
//
// Created by Arne Bahlo on 12.06.14.
// Copyright (c) 2014 Arne Bahlo. All rights reserved.
//

import XCTest
import UIKit
import ImageIO

class GifTests: XCTestCase {

var imageData: NSData?
var source: CGImageSourceRef?

override func setUp() {
super.setUp()

imageData = NSData(contentsOfURL: NSBundle.mainBundle().URLForResource("test", withExtension: "gif"))

let cfImageData = imageData! as CFDataRef
source = CGImageSourceCreateWithData(cfImageData, nil).takeRetainedValue()
}

override func tearDown() {
imageData = nil

super.tearDown()
}

func testGCDForPair() {
let values = (9, 4011)
let result = UIImage.gcdForPair(values.0, values.1)
let expected = 3

XCTAssert(result == expected, "UIImage.gcdForPair(\(values.0), \(values.1)) = \(result), but should be \(expected)")
}

func testGCDForArray() {
let values = [13, 17_381, 169]
let result = UIImage.gcdForArray(values)
let expected = 13

XCTAssert(result == expected, "UIImage.gcdForArray(\(values)) = \(result), but should be \(expected)")
}

func testDelayForImageAtIndex() {
let result = UIImage.delayForImageAtIndex(0, source: source!)
let expected = 0.5

XCTAssert(result == expected, "UIImage.delayForImageAtIndex(0, source) = \(result), but should be \(expected)")
}

func testAnimatedImageWithSource() {
let image = UIImage.animatedImageWithSource(source!)

XCTAssert(image, "UIImage.animatedImageWithSource(source) is nil, but shouldn't")

// Note: There should be 12, because they delay is the same for all
XCTAssert(image!.images.count == 12, "image.images.count = \(image!.images.count), but should be 12")

XCTAssert(image!.duration == 6.0, "image.duration = \(image!.duration), but should be 6.0")
}

}
File renamed without changes.
Binary file added SwiftGifTests/test.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

This file was deleted.

Loading

0 comments on commit 057a25d

Please sign in to comment.