Skip to content

Commit

Permalink
feat(add load from contents of file): add load from contents of file …
Browse files Browse the repository at this point in the history
…named

add load from contents of file named
  • Loading branch information
pengyutang125 committed May 9, 2019
1 parent c0da711 commit 05439bb
Show file tree
Hide file tree
Showing 11 changed files with 300 additions and 67 deletions.
3 changes: 3 additions & 0 deletions cokit/Examples/coKitExamples/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@ target 'coKitExamples' do

pod 'cokit', :path => '../../../'
pod 'coobjc', :path => '../../../'
pod 'cocore', :path => '../../../'

end

target 'coKitExamplesTests' do

pod 'cokit', :path => '../../../'
pod 'coobjc', :path => '../../../'
pod 'cocore', :path => '../../../'


pod 'Specta', '~> 1.0'
pod 'Expecta', '~> 1.0' # expecta matchers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
184C4DC221D3183800C94113 /* coKitURLConnectionTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 184C4DC121D3183800C94113 /* coKitURLConnectionTests.m */; };
184C4DC421D3184800C94113 /* coKitURLSession.m in Sources */ = {isa = PBXBuildFile; fileRef = 184C4DC321D3184800C94113 /* coKitURLSession.m */; };
184C4DC621D3185700C94113 /* coKitUserDefaults.m in Sources */ = {isa = PBXBuildFile; fileRef = 184C4DC521D3185700C94113 /* coKitUserDefaults.m */; };
1851C7142283FDA6008342C0 /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = 1851C7112283FDA6008342C0 /* [email protected] */; };
1851C7152283FDA6008342C0 /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = 1851C7122283FDA6008342C0 /* [email protected] */; };
1851C7162283FDA6008342C0 /* home.png in Resources */ = {isa = PBXBuildFile; fileRef = 1851C7132283FDA6008342C0 /* home.png */; };
18C43A3E21D1D4C300D75A9B /* DemoListViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 18C43A3D21D1D4C300D75A9B /* DemoListViewController.m */; };
18C43A4221D1D4E500D75A9B /* AlertDemoViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 18C43A4021D1D4E500D75A9B /* AlertDemoViewController.m */; };
18C43A4321D1D4E500D75A9B /* AlertDemoViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 18C43A4121D1D4E500D75A9B /* AlertDemoViewController.xib */; };
Expand Down Expand Up @@ -76,6 +79,9 @@
184C4DC121D3183800C94113 /* coKitURLConnectionTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = coKitURLConnectionTests.m; sourceTree = "<group>"; };
184C4DC321D3184800C94113 /* coKitURLSession.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = coKitURLSession.m; sourceTree = "<group>"; };
184C4DC521D3185700C94113 /* coKitUserDefaults.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = coKitUserDefaults.m; sourceTree = "<group>"; };
1851C7112283FDA6008342C0 /* [email protected] */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "[email protected]"; sourceTree = "<group>"; };
1851C7122283FDA6008342C0 /* [email protected] */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "[email protected]"; sourceTree = "<group>"; };
1851C7132283FDA6008342C0 /* home.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = home.png; sourceTree = "<group>"; };
18C43A3C21D1D4C300D75A9B /* DemoListViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DemoListViewController.h; sourceTree = "<group>"; };
18C43A3D21D1D4C300D75A9B /* DemoListViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DemoListViewController.m; sourceTree = "<group>"; };
18C43A3F21D1D4E500D75A9B /* AlertDemoViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AlertDemoViewController.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -180,6 +186,9 @@
183F72C421C9E9D10041C32B /* Resources */ = {
isa = PBXGroup;
children = (
1851C7132283FDA6008342C0 /* home.png */,
1851C7122283FDA6008342C0 /* [email protected] */,
1851C7112283FDA6008342C0 /* [email protected] */,
183F72C521C9E9DE0041C32B /* test.json */,
);
path = Resources;
Expand Down Expand Up @@ -217,8 +226,6 @@
183F728A21C8E8890041C32B /* Sources */,
183F728B21C8E8890041C32B /* Frameworks */,
183F728C21C8E8890041C32B /* Resources */,
24A92622A4331EE56ABFE7D5 /* [CP] Embed Pods Frameworks */,
BF68B3A67305FACEED8A7FCA /* [CP] Copy Pods Resources */,
);
buildRules = (
);
Expand All @@ -237,8 +244,6 @@
183F72A221C8E88C0041C32B /* Sources */,
183F72A321C8E88C0041C32B /* Frameworks */,
183F72A421C8E88C0041C32B /* Resources */,
CB2CC9A54B12823E5E21B0EB /* [CP] Embed Pods Frameworks */,
866D6F23B88BC4316C965F2A /* [CP] Copy Pods Resources */,
);
buildRules = (
);
Expand Down Expand Up @@ -294,8 +299,11 @@
files = (
183F729E21C8E88B0041C32B /* LaunchScreen.storyboard in Resources */,
18C43A4821D1D4F500D75A9B /* ImagePickerDemoViewController.xib in Resources */,
1851C7162283FDA6008342C0 /* home.png in Resources */,
183F72C621C9E9DE0041C32B /* test.json in Resources */,
1851C7152283FDA6008342C0 /* [email protected] in Resources */,
183F729B21C8E88B0041C32B /* Assets.xcassets in Resources */,
1851C7142283FDA6008342C0 /* [email protected] in Resources */,
183F729921C8E8890041C32B /* Main.storyboard in Resources */,
18C43A4321D1D4E500D75A9B /* AlertDemoViewController.xib in Resources */,
);
Expand All @@ -317,28 +325,16 @@
files = (
);
inputPaths = (
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
"${PODS_ROOT}/Manifest.lock",
);
name = "[CP] Check Pods Manifest.lock";
outputPaths = (
"$(DERIVED_FILE_DIR)/Pods-coKitExamplesTests-checkManifestLockResult.txt",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
showEnvVarsInLog = 0;
};
24A92622A4331EE56ABFE7D5 /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-coKitExamples/Pods-coKitExamples-frameworks.sh\"\n";
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
66A9FC6F6F04E954F19CFE67 /* [CP] Check Pods Manifest.lock */ = {
Expand All @@ -347,58 +343,16 @@
files = (
);
inputPaths = (
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
"${PODS_ROOT}/Manifest.lock",
);
name = "[CP] Check Pods Manifest.lock";
outputPaths = (
"$(DERIVED_FILE_DIR)/Pods-coKitExamples-checkManifestLockResult.txt",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
showEnvVarsInLog = 0;
};
866D6F23B88BC4316C965F2A /* [CP] Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "[CP] Copy Pods Resources";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-coKitExamplesTests/Pods-coKitExamplesTests-resources.sh\"\n";
showEnvVarsInLog = 0;
};
BF68B3A67305FACEED8A7FCA /* [CP] Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "[CP] Copy Pods Resources";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-coKitExamples/Pods-coKitExamples-resources.sh\"\n";
showEnvVarsInLog = 0;
};
CB2CC9A54B12823E5E21B0EB /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-coKitExamplesTests/Pods-coKitExamplesTests-frameworks.sh\"\n";
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1020"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "183F728D21C8E8890041C32B"
BuildableName = "coKitExamples.app"
BlueprintName = "coKitExamples"
ReferencedContainer = "container:coKitExamples.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 = "183F72A521C8E88C0041C32B"
BuildableName = "coKitExamplesTests.xctest"
BlueprintName = "coKitExamplesTests"
ReferencedContainer = "container:coKitExamples.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "183F728D21C8E8890041C32B"
BuildableName = "coKitExamples.app"
BlueprintName = "coKitExamples"
ReferencedContainer = "container:coKitExamples.xcodeproj">
</BuildableReference>
</MacroExpansion>
<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">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "183F728D21C8E8890041C32B"
BuildableName = "coKitExamples.app"
BlueprintName = "coKitExamples"
ReferencedContainer = "container:coKitExamples.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "183F728D21C8E8890041C32B"
BuildableName = "coKitExamples.app"
BlueprintName = "coKitExamples"
ReferencedContainer = "container:coKitExamples.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</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,56 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1020"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "183F72A521C8E88C0041C32B"
BuildableName = "coKitExamplesTests.xctest"
BlueprintName = "coKitExamplesTests"
ReferencedContainer = "container:coKitExamples.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">
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
// limitations under the License.

#import <XCTest/XCTest.h>
#import <coobjc/coobjc.h>
#import <cokit/UIImage+Coroutine.h>

@interface coKitExamplesTests : XCTestCase

Expand All @@ -37,6 +39,38 @@ - (void)tearDown {
- (void)testExample {
// This is an example of a functional test case.
// Use XCTAssert and related functions to verify your tests produce the correct results.
XCTestExpectation *e = [self expectationWithDescription:@"test"];
co_launch(^{
UIImage *image = await([UIImage async_imageWithContentsOfFileNamed:@"home"]);
NSAssert(image != nil, @"test");

image = await([UIImage async_imageWithContentsOfFileNamed:@"home1"]);
NSAssert(image != nil, @"test1");

image = await([UIImage async_imageWithContentsOfFileNamed:@"home2"]);
NSAssert(image != nil, @"test2");

image = await([UIImage async_imageWithContentsOfFileNamed:@"home.png"]);
NSAssert(image != nil, @"test");

image = await([UIImage async_imageWithContentsOfFileNamed:@"home1.png"]);
NSAssert(image != nil, @"test1");

image = await([UIImage async_imageWithContentsOfFileNamed:@"home2.png"]);
NSAssert(image != nil, @"test2");

image = await([UIImage async_imageWithContentsOfFileNamed:@"[email protected]"]);
NSAssert(image == nil, @"test");

image = await([UIImage async_imageWithContentsOfFileNamed:@"[email protected]"]);
NSAssert(image == nil, @"test1");

image = await([UIImage async_imageWithContentsOfFileNamed:@"[email protected]"]);
NSAssert(image == nil, @"test2");
[e fulfill];
});

[self waitForExpectations:@[e] timeout:10];
}

- (void)testPerformanceExample {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ - (void)testXMLParse{
int testsuiteCount = 0;
int testcaseCount = 0;
while (1) {
item = [parse_generator next];
// item = [parse_generator next];
if (item.itemType == COXMLItemDidStartElement) {
if ([item.elementName isEqualToString:@"testsuites"]) {
testsuitesCount++;
Expand Down
Loading

0 comments on commit 05439bb

Please sign in to comment.