Skip to content

Commit c2cbd61

Browse files
committed
Add the travis-CI script and simple test case
1 parent b670034 commit c2cbd61

11 files changed

Lines changed: 248 additions & 57 deletions

File tree

.travis.yml

Lines changed: 44 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,46 @@
1-
# references:
2-
# * https://www.objc.io/issues/6-build-tools/travis-ci/
3-
# * https://github.com/supermarin/xcpretty#usage
4-
5-
osx_image: xcode7.3
61
language: objective-c
7-
# cache: cocoapods
8-
# podfile: Example/Podfile
9-
# before_install:
10-
# - gem install cocoapods # Since Travis is not always on latest version
11-
# - pod install --project-directory=Example
2+
osx_image: xcode9.4
3+
4+
env:
5+
global:
6+
- LC_CTYPE=en_US.UTF-8
7+
- LANG=en_US.UTF-8
8+
9+
addons:
10+
ssh_known_hosts: github.com
11+
12+
notifications:
13+
email: false
14+
15+
before_install:
16+
- env
17+
- locale
18+
- gem install cocoapods --no-rdoc --no-ri --no-document --quiet
19+
- gem install xcpretty --no-rdoc --no-ri --no-document --quiet
20+
- pod --version
21+
- pod setup --silent > /dev/null
22+
- pod repo update --silent
23+
- xcpretty --version
24+
- xcodebuild -version
25+
- xcodebuild -showsdks
26+
1227
script:
13-
- set -o pipefail && xcodebuild test -enableCodeCoverage YES -workspace Example/SDWebImageLinkPlugin.xcworkspace -scheme SDWebImageLinkPlugin-Example -sdk iphonesimulator9.3 ONLY_ACTIVE_ARCH=NO | xcpretty
14-
- pod lib lint
28+
- set -o pipefail
29+
30+
- echo Check if the library described by the podspec can be built
31+
- pod lib lint --allow-warnings
32+
33+
- echo Build example
34+
- pod install --project-directory=Example
35+
- xcodebuild build -workspace Example/SDWebImageLinkPlugin.xcworkspace -scheme SDWebImageLinkPlugin-Example -sdk iphonesimulator -destination 'name=iPhone 8' ONLY_ACTIVE_ARCH=NO | xcpretty -c
36+
37+
- echo Clean DerivedData
38+
- mkdir DerivedData
39+
- rm -rf ~/Library/Developer/Xcode/DerivedData
40+
41+
- echo Run the tests
42+
- xcodebuild test -workspace Example/SDWebImageLinkPlugin.xcworkspace -scheme 'SDWebImageLinkPlugin_Tests' -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 8' -configuration Debug | xcpretty -c
43+
- mv ~/Library/Developer/Xcode/DerivedData/ ./DerivedData/iOS
44+
45+
after_success:
46+
- bash <(curl -s https://codecov.io/bash) -D './DerivedData/iOS' -J '^SDWebImageLinkPlugin$' -F 'iOS'

Example/Podfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ target 'SDWebImageLinkPlugin_Example' do
66

77
target 'SDWebImageLinkPlugin_Tests' do
88
inherit! :search_paths
9-
10-
9+
pod 'Expecta'
1110
end
1211
end
1312

Example/Podfile.lock

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,29 @@
11
PODS:
2+
- Expecta (1.0.6)
23
- SDWebImage (5.3.1):
34
- SDWebImage/Core (= 5.3.1)
45
- SDWebImage/Core (5.3.1)
56
- SDWebImageLinkPlugin (0.1.0):
67
- SDWebImage (~> 5.0)
78

89
DEPENDENCIES:
10+
- Expecta
911
- SDWebImageLinkPlugin (from `../`)
1012

1113
SPEC REPOS:
1214
trunk:
15+
- Expecta
1316
- SDWebImage
1417

1518
EXTERNAL SOURCES:
1619
SDWebImageLinkPlugin:
1720
:path: "../"
1821

1922
SPEC CHECKSUMS:
23+
Expecta: 3b6bd90a64b9a1dcb0b70aa0e10a7f8f631667d5
2024
SDWebImage: 7137d57385fb632129838c1e6ab9528a22c666cc
21-
SDWebImageLinkPlugin: ea390a828e8c0da400a4d113fbef334fab2b26d1
25+
SDWebImageLinkPlugin: f77eb1f3ef322a2cb331ecf62cf78444529de597
2226

23-
PODFILE CHECKSUM: 74a62a3e72a34ed61a73510a4231db8d0408fcbe
27+
PODFILE CHECKSUM: 74e009387008b3c98728da0575236586673f1fec
2428

2529
COCOAPODS: 1.8.4

Example/SDWebImageLinkPlugin.xcodeproj/project.pbxproj

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
3253E1152387EAC5007ACAD8 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 3253E1142387EAC5007ACAD8 /* Assets.xcassets */; };
1313
3253E1182387EAC5007ACAD8 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 3253E1162387EAC5007ACAD8 /* Main.storyboard */; };
1414
3253E11B2387EAC5007ACAD8 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 3253E11A2387EAC5007ACAD8 /* main.m */; };
15+
32BE73912389924600AFBDDC /* SDLinkPluginTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 32BE738F2389924600AFBDDC /* SDLinkPluginTests.m */; };
16+
32BE73922389924600AFBDDC /* SDTestCase.m in Sources */ = {isa = PBXBuildFile; fileRef = 32BE73902389924600AFBDDC /* SDTestCase.m */; };
1517
356F339F2E31974F1AC0A558 /* Pods_SDWebImageLinkPlugin_Example.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6E4D6B07E67D3523A930F04D /* Pods_SDWebImageLinkPlugin_Example.framework */; };
1618
6003F58E195388D20070C39A /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6003F58D195388D20070C39A /* Foundation.framework */; };
1719
6003F590195388D20070C39A /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6003F58F195388D20070C39A /* CoreGraphics.framework */; };
@@ -25,7 +27,6 @@
2527
6003F5B1195388D20070C39A /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6003F58D195388D20070C39A /* Foundation.framework */; };
2628
6003F5B2195388D20070C39A /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6003F591195388D20070C39A /* UIKit.framework */; };
2729
6003F5BA195388D20070C39A /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 6003F5B8195388D20070C39A /* InfoPlist.strings */; };
28-
6003F5BC195388D20070C39A /* Tests.m in Sources */ = {isa = PBXBuildFile; fileRef = 6003F5BB195388D20070C39A /* Tests.m */; };
2930
71719F9F1E33DC2100824A3D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 71719F9D1E33DC2100824A3D /* LaunchScreen.storyboard */; };
3031
873B8AEB1B1F5CCA007FD442 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 873B8AEA1B1F5CCA007FD442 /* Main.storyboard */; };
3132
B989383922F630505442228C /* Pods_SDWebImageLinkPlugin_Example_macOS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 23347A87D45A8E975727A81F /* Pods_SDWebImageLinkPlugin_Example_macOS.framework */; };
@@ -57,6 +58,9 @@
5758
3253E11A2387EAC5007ACAD8 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
5859
3253E11C2387EAC5007ACAD8 /* SDWebImageLinkPlugin_Example_macOS.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = SDWebImageLinkPlugin_Example_macOS.entitlements; sourceTree = "<group>"; };
5960
3292A76B23898BA4001C7C82 /* SDWebImageLinkPlugin_Example.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = SDWebImageLinkPlugin_Example.entitlements; sourceTree = "<group>"; };
61+
32BE738E2389924600AFBDDC /* SDTestCase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDTestCase.h; sourceTree = "<group>"; };
62+
32BE738F2389924600AFBDDC /* SDLinkPluginTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDLinkPluginTests.m; sourceTree = "<group>"; };
63+
32BE73902389924600AFBDDC /* SDTestCase.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDTestCase.m; sourceTree = "<group>"; };
6064
54D9FFA9DF3619FBB4B10600 /* SDWebImageLinkPlugin.podspec */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = SDWebImageLinkPlugin.podspec; path = ../SDWebImageLinkPlugin.podspec; sourceTree = "<group>"; };
6165
6003F58A195388D20070C39A /* SDWebImageLinkPlugin_Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SDWebImageLinkPlugin_Example.app; sourceTree = BUILT_PRODUCTS_DIR; };
6266
6003F58D195388D20070C39A /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
@@ -75,7 +79,6 @@
7579
6003F5AF195388D20070C39A /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; };
7680
6003F5B7195388D20070C39A /* Tests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Tests-Info.plist"; sourceTree = "<group>"; };
7781
6003F5B9195388D20070C39A /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
78-
6003F5BB195388D20070C39A /* Tests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Tests.m; sourceTree = "<group>"; };
7982
606FC2411953D9B200FFA9A0 /* Tests-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Tests-Prefix.pch"; sourceTree = "<group>"; };
8083
6E4D6B07E67D3523A930F04D /* Pods_SDWebImageLinkPlugin_Example.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_SDWebImageLinkPlugin_Example.framework; sourceTree = BUILT_PRODUCTS_DIR; };
8184
71719F9E1E33DC2100824A3D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
@@ -220,7 +223,9 @@
220223
6003F5B5195388D20070C39A /* Tests */ = {
221224
isa = PBXGroup;
222225
children = (
223-
6003F5BB195388D20070C39A /* Tests.m */,
226+
32BE738F2389924600AFBDDC /* SDLinkPluginTests.m */,
227+
32BE738E2389924600AFBDDC /* SDTestCase.h */,
228+
32BE73902389924600AFBDDC /* SDTestCase.m */,
224229
6003F5B6195388D20070C39A /* Supporting Files */,
225230
);
226231
path = Tests;
@@ -295,6 +300,7 @@
295300
6003F5AA195388D20070C39A /* Sources */,
296301
6003F5AB195388D20070C39A /* Frameworks */,
297302
6003F5AC195388D20070C39A /* Resources */,
303+
2E3AE7681B2B62E38CFC32CE /* [CP] Embed Pods Frameworks */,
298304
);
299305
buildRules = (
300306
);
@@ -381,6 +387,24 @@
381387
/* End PBXResourcesBuildPhase section */
382388

383389
/* Begin PBXShellScriptBuildPhase section */
390+
2E3AE7681B2B62E38CFC32CE /* [CP] Embed Pods Frameworks */ = {
391+
isa = PBXShellScriptBuildPhase;
392+
buildActionMask = 2147483647;
393+
files = (
394+
);
395+
inputPaths = (
396+
"${PODS_ROOT}/Target Support Files/Pods-SDWebImageLinkPlugin_Tests/Pods-SDWebImageLinkPlugin_Tests-frameworks.sh",
397+
"${BUILT_PRODUCTS_DIR}/Expecta/Expecta.framework",
398+
);
399+
name = "[CP] Embed Pods Frameworks";
400+
outputPaths = (
401+
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Expecta.framework",
402+
);
403+
runOnlyForDeploymentPostprocessing = 0;
404+
shellPath = /bin/sh;
405+
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-SDWebImageLinkPlugin_Tests/Pods-SDWebImageLinkPlugin_Tests-frameworks.sh\"\n";
406+
showEnvVarsInLog = 0;
407+
};
384408
46001664ABC81FA7E132B906 /* [CP] Embed Pods Frameworks */ = {
385409
isa = PBXShellScriptBuildPhase;
386410
buildActionMask = 2147483647;
@@ -514,7 +538,8 @@
514538
isa = PBXSourcesBuildPhase;
515539
buildActionMask = 2147483647;
516540
files = (
517-
6003F5BC195388D20070C39A /* Tests.m in Sources */,
541+
32BE73922389924600AFBDDC /* SDTestCase.m in Sources */,
542+
32BE73912389924600AFBDDC /* SDLinkPluginTests.m in Sources */,
518543
);
519544
runOnlyForDeploymentPostprocessing = 0;
520545
};
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Scheme
3+
LastUpgradeVersion = "1120"
4+
version = "1.3">
5+
<BuildAction
6+
parallelizeBuildables = "YES"
7+
buildImplicitDependencies = "YES">
8+
</BuildAction>
9+
<TestAction
10+
buildConfiguration = "Debug"
11+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
12+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
13+
shouldUseLaunchSchemeArgsEnv = "YES"
14+
codeCoverageEnabled = "YES">
15+
<Testables>
16+
<TestableReference
17+
skipped = "NO">
18+
<BuildableReference
19+
BuildableIdentifier = "primary"
20+
BlueprintIdentifier = "6003F5AD195388D20070C39A"
21+
BuildableName = "SDWebImageLinkPlugin_Tests.xctest"
22+
BlueprintName = "SDWebImageLinkPlugin_Tests"
23+
ReferencedContainer = "container:SDWebImageLinkPlugin.xcodeproj">
24+
</BuildableReference>
25+
</TestableReference>
26+
</Testables>
27+
</TestAction>
28+
<LaunchAction
29+
buildConfiguration = "Debug"
30+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
31+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
32+
launchStyle = "0"
33+
useCustomWorkingDirectory = "NO"
34+
ignoresPersistentStateOnLaunch = "NO"
35+
debugDocumentVersioning = "YES"
36+
debugServiceExtension = "internal"
37+
allowLocationSimulation = "YES">
38+
</LaunchAction>
39+
<ProfileAction
40+
buildConfiguration = "Release"
41+
shouldUseLaunchSchemeArgsEnv = "YES"
42+
savedToolIdentifier = ""
43+
useCustomWorkingDirectory = "NO"
44+
debugDocumentVersioning = "YES">
45+
</ProfileAction>
46+
<AnalyzeAction
47+
buildConfiguration = "Debug">
48+
</AnalyzeAction>
49+
<ArchiveAction
50+
buildConfiguration = "Release"
51+
revealArchiveInOrganizer = "YES">
52+
</ArchiveAction>
53+
</Scheme>

Example/SDWebImageLinkPlugin_Example macOS/AppDelegate.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
//
88

99
#import "AppDelegate.h"
10+
#import <SDWebImage/SDWebImage.h>
11+
#import <SDWebImageLinkPlugin/SDWebImageLinkPlugin.h>
1012

1113
@interface AppDelegate ()
1214

@@ -16,6 +18,8 @@ @implementation AppDelegate
1618

1719
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
1820
// Insert code here to initialize your application
21+
[SDImageLoadersManager.sharedManager addLoader:SDImageLinkLoader.sharedLoader];
22+
SDWebImageManager.defaultImageLoader = SDImageLoadersManager.sharedManager;
1923
}
2024

2125

Example/SDWebImageLinkPlugin_Example macOS/ViewController.m

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ @implementation ViewController
2222

2323
- (void)viewDidLoad {
2424
[super viewDidLoad];
25-
[SDImageLoadersManager.sharedManager addLoader:SDImageLinkLoader.sharedLoader];
26-
SDWebImageManager.defaultImageLoader = SDImageLoadersManager.sharedManager;
2725

2826
NSURL *url1 = [NSURL URLWithString:@"https://www.apple.com/mac/"];
2927
NSURL *url2 = [NSURL URLWithString:@"https://webkit.org/"];

Example/Tests/SDLinkPluginTests.m

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*
2+
* This file is part of the SDWebImagePhotosPlugin package.
3+
*
4+
* For the full copyright and license information, please view the LICENSE
5+
* file that was distributed with this source code.
6+
*/
7+
8+
#import "SDTestCase.h"
9+
10+
@interface SDPhotosPluginTests : SDTestCase
11+
12+
@end
13+
14+
@implementation SDPhotosPluginTests
15+
16+
+ (void)setUp {
17+
[SDImageLoadersManager.sharedManager addLoader:SDImageLinkLoader.sharedLoader];
18+
SDWebImageManager.defaultImageLoader = SDImageLoadersManager.sharedManager;
19+
}
20+
21+
- (void)testUIImageViewSetImageWithURL {
22+
XCTestExpectation *expectation = [self expectationWithDescription:@"UIImageView setImageWithURL"];
23+
NSURL *linkURL = [NSURL URLWithString:@"https://www.apple.com/"];
24+
25+
UIImageView *imageView = [[UIImageView alloc] init];
26+
[imageView sd_setImageWithURL:linkURL
27+
placeholderImage:nil
28+
options:SDWebImageFromLoaderOnly
29+
context:nil
30+
progress:nil
31+
completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
32+
expect(image).toNot.beNil();
33+
expect(error).to.beNil();
34+
expect(linkURL).to.equal(imageURL);
35+
expect(imageView.image).to.equal(image);
36+
[expectation fulfill];
37+
}];
38+
[self waitForExpectationsWithTimeout:kAsyncTestTimeout handler:nil];
39+
}
40+
41+
- (void)testLPLinkViewSetImageWithURL {
42+
XCTestExpectation *expectation = [self expectationWithDescription:@"LPLinkView setImageWithURL"];
43+
NSURL *linkURL = [NSURL URLWithString:@"https://www.apple.com/"];
44+
45+
NSURL *emptyURL = nil;
46+
LPLinkView *linkView = [[LPLinkView alloc] initWithURL:emptyURL];
47+
[linkView sd_setImageWithURL:linkURL
48+
placeholderImage:nil
49+
options:SDWebImageFromLoaderOnly
50+
context:nil
51+
progress:nil
52+
completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
53+
LPLinkMetadata *metadata = imageURL.sd_linkMetadata;
54+
expect(metadata).toNot.beNil();
55+
expect(image).toNot.beNil();
56+
expect(error).to.beNil();
57+
expect(linkURL).to.equal(imageURL);
58+
expect(metadata.originalURL).equal(linkURL);
59+
[expectation fulfill];
60+
}];
61+
[self waitForExpectationsWithTimeout:kAsyncTestTimeout handler:nil];
62+
}
63+
64+
@end

Example/Tests/SDTestCase.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* This file is part of the SDWebImagePhotosPlugin package.
3+
*
4+
* For the full copyright and license information, please view the LICENSE
5+
* file that was distributed with this source code.
6+
*/
7+
8+
#define EXP_SHORTHAND // required by Expecta
9+
10+
11+
#import <XCTest/XCTest.h>
12+
#import <Expecta/Expecta.h>
13+
#import <SDWebImage/SDWebImage.h>
14+
#import <SDWebImageLinkPlugin/SDWebImageLinkPlugin.h>
15+
16+
FOUNDATION_EXPORT const int64_t kAsyncTestTimeout;
17+
FOUNDATION_EXPORT const int64_t kMinDelayNanosecond;
18+
19+
@interface SDTestCase : XCTestCase
20+
21+
- (void)waitForExpectationsWithCommonTimeout;
22+
- (void)waitForExpectationsWithCommonTimeoutUsingHandler:(nullable XCWaitCompletionHandler)handler;
23+
24+
@end

Example/Tests/SDTestCase.m

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* This file is part of the SDWebImagePhotosPlugin package.
3+
*
4+
* For the full copyright and license information, please view the LICENSE
5+
* file that was distributed with this source code.
6+
*/
7+
8+
#import "SDTestCase.h"
9+
10+
const int64_t kAsyncTestTimeout = 5;
11+
const int64_t kMinDelayNanosecond = NSEC_PER_MSEC * 100; // 0.1s
12+
13+
@implementation SDTestCase
14+
15+
- (void)waitForExpectationsWithCommonTimeout {
16+
[self waitForExpectationsWithCommonTimeoutUsingHandler:nil];
17+
}
18+
19+
- (void)waitForExpectationsWithCommonTimeoutUsingHandler:(XCWaitCompletionHandler)handler {
20+
[self waitForExpectationsWithTimeout:kAsyncTestTimeout handler:handler];
21+
}
22+
23+
@end

0 commit comments

Comments
 (0)