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

Add unit tests #75

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
language: objective-c
xcode_project: NJKWebViewProgress.xcodeproj
xcode_scheme: NJKWebViewProgressTests
xcode_sdk: iphonesimulator

This file was deleted.

2 changes: 1 addition & 1 deletion DemoApp/DemoApp-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>com.ninjinkun.webviewprogress.${PRODUCT_NAME:rfc1034identifier}</string>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
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
@@ -0,0 +1,80 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0820"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "26A4566C1E6A7921000E2746"
BuildableName = "NJKWebViewProgress.framework"
BlueprintName = "NJKWebViewProgress"
ReferencedContainer = "container:NJKWebViewProgress.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "26A4566C1E6A7921000E2746"
BuildableName = "NJKWebViewProgress.framework"
BlueprintName = "NJKWebViewProgress"
ReferencedContainer = "container:NJKWebViewProgress.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "26A4566C1E6A7921000E2746"
BuildableName = "NJKWebViewProgress.framework"
BlueprintName = "NJKWebViewProgress"
ReferencedContainer = "container:NJKWebViewProgress.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0820"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "NO"
buildForArchiving = "NO"
buildForAnalyzing = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "26E1F3301E6A6F42000FBC08"
BuildableName = "NJKWebViewProgressTests.xctest"
BlueprintName = "NJKWebViewProgressTests"
ReferencedContainer = "container:NJKWebViewProgress.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "26E1F3301E6A6F42000FBC08"
BuildableName = "NJKWebViewProgressTests.xctest"
BlueprintName = "NJKWebViewProgressTests"
ReferencedContainer = "container:NJKWebViewProgress.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "26E1F3301E6A6F42000FBC08"
BuildableName = "NJKWebViewProgressTests.xctest"
BlueprintName = "NJKWebViewProgressTests"
ReferencedContainer = "container:NJKWebViewProgress.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "26E1F3301E6A6F42000FBC08"
BuildableName = "NJKWebViewProgressTests.xctest"
BlueprintName = "NJKWebViewProgressTests"
ReferencedContainer = "container:NJKWebViewProgress.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
24 changes: 24 additions & 0 deletions NJKWebViewProgress/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>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
</plist>
11 changes: 11 additions & 0 deletions NJKWebViewProgress/NJKWebViewProgress-Prefix.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#import <UIKit/UIKit.h>
#import "NJKWebViewProgress.h"
//! Project version number for NJKWebViewProgress.
FOUNDATION_EXPORT double NJKWebViewProgressVersionNumber;

//! Project version string for NJKWebViewProgress.
FOUNDATION_EXPORT const unsigned char NJKWebViewProgressVersionString[];

// In this header, you should import all the public headers of your framework using statements like #import <NJKWebViewProgress/PublicHeader.h>


3 changes: 3 additions & 0 deletions NJKWebViewProgress/NJKWebViewProgress.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
#define njk_weak unsafe_unretained
#endif

FOUNDATION_EXPORT double NJKWebViewProgressVersionNumber;
FOUNDATION_EXPORT const unsigned char NJKWebViewProgressVersionString[];

extern const float NJKInitialProgressValue;
extern const float NJKInteractiveProgressValue;
extern const float NJKFinalProgressValue;
Expand Down
22 changes: 22 additions & 0 deletions NJKWebViewProgressTests/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?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>$(PRODUCT_BUNDLE_IDENTIFIER)</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>CFBundleVersion</key>
<string>1</string>
</dict>
</plist>
70 changes: 70 additions & 0 deletions NJKWebViewProgressTests/NJKWebViewProgressTests.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
//
// NJKWebViewProgressTests.m
//
// Created by Satoshi Aasano on 3/4/17.
// Copyright (c) 2017 Satoshi Asano. All rights reserved.
//

#import <XCTest/XCTest.h>
#import <UIKit/UIKit.h>
#import "NJKWebViewProgress.h"

@interface NJKWebViewProgressTests<NJKWebViewProgressDelegate> : XCTestCase
@property (nonatomic) NJKWebViewProgress *progressProxy;
@property (nonatomic) UIWebView *webView;
@property (nonatomic) float progressValue;
@property (nonatomic) XCTestExpectation *firstExpectation;
@property (nonatomic) XCTestExpectation *intermidiateExpectation;
@property (nonatomic) BOOL intermidiateLoaded;
@property (nonatomic) XCTestExpectation *loadedExpactation;
@end

@implementation NJKWebViewProgressTests

- (void)setUp {
[super setUp];

_webView = [[UIWebView alloc] init];
_progressProxy = [[NJKWebViewProgress alloc] init];
_webView.delegate = _progressProxy;
_progressProxy.webViewProxyDelegate = self;
_progressProxy.progressDelegate = self;
}

- (void)tearDown {
[super tearDown];
}

- (void)testLoadWebPage {
NSURLRequest *req = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:@"https://google.com/"]];
[_webView loadRequest:req];

_firstExpectation = [self expectationWithDescription:@"first"];
_intermidiateExpectation = [self expectationWithDescription:@"interamidiate"];
_loadedExpactation = [self expectationWithDescription:@"loaded"];

[self waitForExpectationsWithTimeout:10 handler:^(NSError * _Nullable error) {

}];
}

#pragma mark - NJKWebViewProgressDelegate

- (void)webViewProgress:(NJKWebViewProgress *)webViewProgress updateProgress:(float)progress {
if (progress <= 0.1) {
[_firstExpectation fulfill];
}

if (progress > 0.1 && progress < 0.9 && !_intermidiateLoaded) {
[_intermidiateExpectation fulfill];
_intermidiateLoaded = YES;
}

if (progress >= 1.0) {
[_loadedExpactation fulfill];
}

_progressValue = progress;
}

@end
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# NJKWebViewProgress

[![Build Status](https://travis-ci.org/ninjinkun/NJKWebViewProgress.svg?branch=master)](https://travis-ci.org/ninjinkun/NJKWebViewProgress)

NJKWebViewProgress is a progress interface library for UIWebView. Currently, UIWebView doesn't have official progress interface. You can implement progress bar for your in-app browser using this module.

<img src="https://raw.github.com/ninjinkun/NJKWebViewProgress/master/DemoApp/Screenshot/screenshot1.png" alt="iOS ScreenShot 1" width="240px" style="width: 240px;" />
Expand Down