Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding tests #74

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ profile
# you should judge for yourself, the pros and cons are mentioned at:
# http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control?
#
# Pods/
Pods/
4 changes: 4 additions & 0 deletions .slather.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
ci_service: travis_ci
coverage_service: coveralls
xcodeproj: FLAnimatedImageDemo.xcodeproj
source_directory: FLAnimatedImageDemo/FLAnimatedImage
8 changes: 8 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
language: objective-c
before_install:
- export LANG=en_US.UTF-8
- gem install cocoapods xcpretty slather --no-ri --no-rdoc --no-ri --no-rdoc
xcode_workspace: FLAnimatedImageDemo.xcworkspace
xcode_scheme: FLAnimatedImageDemo
xcode_sdk: iphonesimulator
after_success: slather
228 changes: 228 additions & 0 deletions FLAnimatedImageDemo.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0630"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "872EBE6B178B825500B7531B"
BuildableName = "FLAnimatedImageDemo.app"
BlueprintName = "FLAnimatedImageDemo"
ReferencedContainer = "container:FLAnimatedImageDemo.xcodeproj">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "NO"
buildForArchiving = "NO"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "2140C8AB1AE2BA8E00EA93C1"
BuildableName = "FLAnimatedImageDemoTests.xctest"
BlueprintName = "FLAnimatedImageDemoTests"
ReferencedContainer = "container:FLAnimatedImageDemo.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "2140C8AB1AE2BA8E00EA93C1"
BuildableName = "FLAnimatedImageDemoTests.xctest"
BlueprintName = "FLAnimatedImageDemoTests"
ReferencedContainer = "container:FLAnimatedImageDemo.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "872EBE6B178B825500B7531B"
BuildableName = "FLAnimatedImageDemo.app"
BlueprintName = "FLAnimatedImageDemo"
ReferencedContainer = "container:FLAnimatedImageDemo.xcodeproj">
</BuildableReference>
</MacroExpansion>
</TestAction>
<LaunchAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "872EBE6B178B825500B7531B"
BuildableName = "FLAnimatedImageDemo.app"
BlueprintName = "FLAnimatedImageDemo"
ReferencedContainer = "container:FLAnimatedImageDemo.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "872EBE6B178B825500B7531B"
BuildableName = "FLAnimatedImageDemo.app"
BlueprintName = "FLAnimatedImageDemo"
ReferencedContainer = "container:FLAnimatedImageDemo.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
59 changes: 59 additions & 0 deletions FLAnimatedImageDemoTests/FLAnimatedImageTests.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
//
// FLAnimatedImageTests.m
// FLAnimatedImageDemo
//
// Created by Hristo Hristov on 4/18/15.
// Copyright (c) 2015 Flipboard. All rights reserved.
//


#import <Specta/Specta.h>
#import <Expecta/Expecta.h>
#import "FLAnimatedImage.h"

SpecBegin(FLAnimatedImage)

__block NSData *gifData = nil;
before(^{
NSBundle *currentBundle = [NSBundle bundleForClass:[self class]];
NSString *gifPath = [currentBundle pathForResource:@"test" ofType:@"gif"];
gifData = [NSData dataWithContentsOfFile:gifPath];
});

describe(@"initializations", ^{
it(@"should initialize blank object", ^{
FLAnimatedImage *image = [FLAnimatedImage new];
expect(image.data).to.beNil();
expect(image.frameCount).to.equal(0);
});

it(@"should initialize object with gif", ^{

FLAnimatedImage *image = [[FLAnimatedImage alloc] initWithAnimatedGIFData:gifData];
expect(image.data).toNot.beNil();
expect(image.frameCount).to.beGreaterThan(0);

FLAnimatedImage *image2 = [FLAnimatedImage animatedImageWithGIFData:gifData];
expect([image.data isEqualToData:image2.data]);
});

it(@"should return correct size for image", ^{
FLAnimatedImage *image = [[FLAnimatedImage alloc] initWithAnimatedGIFData:gifData];
expect(image.size).to.equal([FLAnimatedImage sizeForImage:image]);
});

it(@"should be nil when passing invalid image data", ^{
NSData *invalidImageData = [@"bytes" dataUsingEncoding:NSUTF8StringEncoding];
FLAnimatedImage *image = [[FLAnimatedImage alloc] initWithAnimatedGIFData:invalidImageData];
expect(image).to.beNil();
});

it(@"should return zero size for invalid class", ^{
CGSize size = [FLAnimatedImage sizeForImage:@"image"];
expect(size).to.equal(size);
});
});


SpecEnd

49 changes: 49 additions & 0 deletions FLAnimatedImageDemoTests/FLAnimatedImageViewTests.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
//
// FLAnimatedImageViewTests.m
// FLAnimatedImageDemo
//
// Created by Hristo Hristov on 4/18/15.
// Copyright (c) 2015 Flipboard. All rights reserved.
//

#import <Specta/Specta.h>
#import <Expecta/Expecta.h>
#import "FLAnimatedImage.h"

SpecBegin(FLAnimatedImageView)

__block FLAnimatedImage *animatedImage;
before(^{
NSBundle *currentBundle = [NSBundle bundleForClass:[self class]];
NSString *gifPath = [currentBundle pathForResource:@"test" ofType:@"gif"];
NSData *gifData = [NSData dataWithContentsOfFile:gifPath];
animatedImage = [[FLAnimatedImage alloc] initWithAnimatedGIFData:gifData];
});

describe(@"initialized animated image view", ^{
it(@"should initialize correctly", ^{
FLAnimatedImageView *imageView = [FLAnimatedImageView new];
expect(imageView.animatedImage).to.beNil();

imageView.animatedImage = animatedImage;
expect(imageView.animatedImage).toNot.beNil();

imageView.image = [UIImage new];
expect(imageView.animatedImage).to.beNil();
});

it(@"should start animating image", ^{
UIWindow *window = [UIWindow new];
UIView *view = [UIView new];
[window addSubview:view];
FLAnimatedImageView *imageView = [FLAnimatedImageView new];
imageView.animatedImage = animatedImage;
[view addSubview:imageView];


expect(imageView.currentFrameIndex).after(2).to.beGreaterThan(0);
});
});


SpecEnd
24 changes: 24 additions & 0 deletions FLAnimatedImageDemoTests/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>com.organization.$(PRODUCT_NAME:rfc1034identifier)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
</plist>
Binary file added FLAnimatedImageDemoTests/test.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions Podfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Uncomment this line to define a global platform for your project
# platform :ios, '6.0'

target 'FLAnimatedImageDemo' do

end

target 'FLAnimatedImageDemoTests' do

pod 'Specta'
pod 'Expecta'
pod 'OCMock'

end

16 changes: 16 additions & 0 deletions Podfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
PODS:
- Expecta (0.4.0)
- OCMock (3.1.2)
- Specta (0.5.0)

DEPENDENCIES:
- Expecta
- OCMock
- Specta

SPEC CHECKSUMS:
Expecta: 392a6b5bfb9f4097e47dd8064d9b732079490332
OCMock: a10ea9f0a6e921651f96f78b6faee95ebc813b92
Specta: eb90708ed77569bbda089f8ead10bb99b8e9489e

COCOAPODS: 0.36.3
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
[![Build Status](https://travis-ci.org/Flipboard/FLAnimatedImage.svg)](https://travis-ci.org/Flipboard/FLAnimatedImage) [![Coverage Status](https://coveralls.io/repos/Flipboard/FLAnimatedImage/badge.svg)](https://coveralls.io/r/Flipboard/FLAnimatedImage)

FLAnimatedImage is a performant animated GIF engine for iOS:

- Plays multiple GIFs simultaneously with a playback speed comparable to desktop browsers
Expand Down