Browse Source

IOSAD-207 Create and configure PEPObjCAdapterTypesTests_iOS.

IOSAD-207
David Alarcon 1 year ago
parent
commit
f627bd640b
10 changed files with 794 additions and 4 deletions
  1. +163
    -2
      Subprojects/PEPObjCAdapterTypes/PEPObjCAdapterTypes.xcodeproj/project.pbxproj
  2. +52
    -0
      Subprojects/PEPObjCAdapterTypes/PEPObjCAdapterTypes.xcodeproj/xcshareddata/xcschemes/PEPObjCAdapterTypesTests_iOS.xcscheme
  3. +22
    -0
      Subprojects/PEPObjCAdapterTypes/PEPObjCAdapterTypesTests_iOS/Info.plist
  4. +81
    -0
      Subprojects/PEPObjCAdapterTypes/PEPObjCAdapterTypesTests_iOS/PEPAttachment+SecureCodingTest.m
  5. +95
    -0
      Subprojects/PEPObjCAdapterTypes/PEPObjCAdapterTypesTests_iOS/PEPIdentity+SecureCodingTest.m
  6. +67
    -0
      Subprojects/PEPObjCAdapterTypes/PEPObjCAdapterTypesTests_iOS/PEPLanguage+SecureCodingTest.m
  7. +197
    -0
      Subprojects/PEPObjCAdapterTypes/PEPObjCAdapterTypesTests_iOS/PEPMessage+SecureCodingTest.m
  8. +23
    -0
      Subprojects/PEPObjCAdapterTypes/PEPObjCAdapterTypesTests_iOS/TestUtils/PEPTypesTestUtil.h
  9. +92
    -0
      Subprojects/PEPObjCAdapterTypes/PEPObjCAdapterTypesTests_iOS/TestUtils/PEPTypesTestUtil.m
  10. +2
    -2
      pEpObjCAdapter.xcodeproj/xcshareddata/xcschemes/PEPObjCAdapterTypes_iOS.xcscheme

+ 163
- 2
Subprojects/PEPObjCAdapterTypes/PEPObjCAdapterTypes.xcodeproj/project.pbxproj View File

@ -54,8 +54,24 @@
4E5758B626833A4E0084F02D /* PEPObjCAdapterTypes_macOS.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 4E57585A268329170084F02D /* PEPObjCAdapterTypes_macOS.h */; };
4E5758B726833A560084F02D /* module.modulemap in CopyFiles */ = {isa = PBXBuildFile; fileRef = 4E5758B4268339450084F02D /* module.modulemap */; };
4E5758BA26833A700084F02D /* libpEpEngine_macOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4E5758B926833A700084F02D /* libpEpEngine_macOS.a */; };
4E5758C426833D140084F02D /* libPEPObjCAdapterTypes_iOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4E575865268329A20084F02D /* libPEPObjCAdapterTypes_iOS.a */; };
4E5758D126833F920084F02D /* PEPAttachment+SecureCodingTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 4E5758CA26833F920084F02D /* PEPAttachment+SecureCodingTest.m */; };
4E5758D226833F920084F02D /* PEPIdentity+SecureCodingTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 4E5758CB26833F920084F02D /* PEPIdentity+SecureCodingTest.m */; };
4E5758D326833F920084F02D /* PEPLanguage+SecureCodingTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 4E5758CC26833F920084F02D /* PEPLanguage+SecureCodingTest.m */; };
4E5758D426833F920084F02D /* PEPMessage+SecureCodingTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 4E5758CD26833F920084F02D /* PEPMessage+SecureCodingTest.m */; };
4E5758D526833F920084F02D /* PEPTypesTestUtil.m in Sources */ = {isa = PBXBuildFile; fileRef = 4E5758D026833F920084F02D /* PEPTypesTestUtil.m */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
4E5758C526833D140084F02D /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 4E575836268328CD0084F02D /* Project object */;
proxyType = 1;
remoteGlobalIDString = 4E575864268329A20084F02D;
remoteInfo = PEPObjCAdapterTypes_iOS;
};
/* End PBXContainerItemProxy section */
/* Begin PBXCopyFilesBuildPhase section */
4E575863268329A20084F02D /* CopyFiles */ = {
isa = PBXCopyFilesBuildPhase;
@ -111,6 +127,14 @@
4E57588826832F2F0084F02D /* PEPIdentity+SecureCoding.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "PEPIdentity+SecureCoding.h"; sourceTree = "<group>"; };
4E5758B4268339450084F02D /* module.modulemap */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.module-map"; path = module.modulemap; sourceTree = "<group>"; };
4E5758B926833A700084F02D /* libpEpEngine_macOS.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; path = libpEpEngine_macOS.a; sourceTree = BUILT_PRODUCTS_DIR; };
4E5758BF26833D140084F02D /* PEPObjCAdapterTypesTests_iOS.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = PEPObjCAdapterTypesTests_iOS.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
4E5758C326833D140084F02D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
4E5758CA26833F920084F02D /* PEPAttachment+SecureCodingTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "PEPAttachment+SecureCodingTest.m"; sourceTree = "<group>"; };
4E5758CB26833F920084F02D /* PEPIdentity+SecureCodingTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "PEPIdentity+SecureCodingTest.m"; sourceTree = "<group>"; };
4E5758CC26833F920084F02D /* PEPLanguage+SecureCodingTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "PEPLanguage+SecureCodingTest.m"; sourceTree = "<group>"; };
4E5758CD26833F920084F02D /* PEPMessage+SecureCodingTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "PEPMessage+SecureCodingTest.m"; sourceTree = "<group>"; };
4E5758CF26833F920084F02D /* PEPTypesTestUtil.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PEPTypesTestUtil.h; sourceTree = "<group>"; };
4E5758D026833F920084F02D /* PEPTypesTestUtil.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PEPTypesTestUtil.m; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@ -129,6 +153,14 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
4E5758BC26833D140084F02D /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
4E5758C426833D140084F02D /* libPEPObjCAdapterTypes_iOS.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
@ -138,6 +170,7 @@
4E575840268328CD0084F02D /* PEPObjCAdapterTypes */,
4E575859268329170084F02D /* PEPObjCAdapterTypes_macOS */,
4E575866268329A20084F02D /* PEPObjCAdapterTypes_iOS */,
4E5758C026833D140084F02D /* PEPObjCAdapterTypesTests_iOS */,
4E57583F268328CD0084F02D /* Products */,
4E5758B826833A700084F02D /* Frameworks */,
);
@ -148,6 +181,7 @@
children = (
4E575858268329170084F02D /* libPEPObjCAdapterTypes_macOS.a */,
4E575865268329A20084F02D /* libPEPObjCAdapterTypes_iOS.a */,
4E5758BF26833D140084F02D /* PEPObjCAdapterTypesTests_iOS.xctest */,
);
name = Products;
sourceTree = "<group>";
@ -240,6 +274,28 @@
name = Frameworks;
sourceTree = "<group>";
};
4E5758C026833D140084F02D /* PEPObjCAdapterTypesTests_iOS */ = {
isa = PBXGroup;
children = (
4E5758CE26833F920084F02D /* TestUtils */,
4E5758CA26833F920084F02D /* PEPAttachment+SecureCodingTest.m */,
4E5758CB26833F920084F02D /* PEPIdentity+SecureCodingTest.m */,
4E5758CC26833F920084F02D /* PEPLanguage+SecureCodingTest.m */,
4E5758CD26833F920084F02D /* PEPMessage+SecureCodingTest.m */,
4E5758C326833D140084F02D /* Info.plist */,
);
path = PEPObjCAdapterTypesTests_iOS;
sourceTree = "<group>";
};
4E5758CE26833F920084F02D /* TestUtils */ = {
isa = PBXGroup;
children = (
4E5758CF26833F920084F02D /* PEPTypesTestUtil.h */,
4E5758D026833F920084F02D /* PEPTypesTestUtil.m */,
);
path = TestUtils;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXHeadersBuildPhase section */
@ -319,6 +375,24 @@
productReference = 4E575865268329A20084F02D /* libPEPObjCAdapterTypes_iOS.a */;
productType = "com.apple.product-type.library.static";
};
4E5758BE26833D140084F02D /* PEPObjCAdapterTypesTests_iOS */ = {
isa = PBXNativeTarget;
buildConfigurationList = 4E5758C726833D140084F02D /* Build configuration list for PBXNativeTarget "PEPObjCAdapterTypesTests_iOS" */;
buildPhases = (
4E5758BB26833D140084F02D /* Sources */,
4E5758BC26833D140084F02D /* Frameworks */,
4E5758BD26833D140084F02D /* Resources */,
);
buildRules = (
);
dependencies = (
4E5758C626833D140084F02D /* PBXTargetDependency */,
);
name = PEPObjCAdapterTypesTests_iOS;
productName = PEPObjCAdapterTypesTests_iOS;
productReference = 4E5758BF26833D140084F02D /* PEPObjCAdapterTypesTests_iOS.xctest */;
productType = "com.apple.product-type.bundle.unit-test";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
@ -333,6 +407,9 @@
4E575864268329A20084F02D = {
CreatedOnToolsVersion = 12.5;
};
4E5758BE26833D140084F02D = {
CreatedOnToolsVersion = 12.5;
};
};
};
buildConfigurationList = 4E575839268328CD0084F02D /* Build configuration list for PBXProject "PEPObjCAdapterTypes" */;
@ -350,10 +427,21 @@
targets = (
4E575857268329170084F02D /* PEPObjCAdapterTypes_macOS */,
4E575864268329A20084F02D /* PEPObjCAdapterTypes_iOS */,
4E5758BE26833D140084F02D /* PEPObjCAdapterTypesTests_iOS */,
);
};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
4E5758BD26833D140084F02D /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
4E575855268329170084F02D /* Sources */ = {
isa = PBXSourcesBuildPhase;
@ -389,8 +477,28 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
4E5758BB26833D140084F02D /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
4E5758D426833F920084F02D /* PEPMessage+SecureCodingTest.m in Sources */,
4E5758D326833F920084F02D /* PEPLanguage+SecureCodingTest.m in Sources */,
4E5758D126833F920084F02D /* PEPAttachment+SecureCodingTest.m in Sources */,
4E5758D526833F920084F02D /* PEPTypesTestUtil.m in Sources */,
4E5758D226833F920084F02D /* PEPIdentity+SecureCodingTest.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXTargetDependency section */
4E5758C626833D140084F02D /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 4E575864268329A20084F02D /* PEPObjCAdapterTypes_iOS */;
targetProxy = 4E5758C526833D140084F02D /* PBXContainerItemProxy */;
};
/* End PBXTargetDependency section */
/* Begin XCBuildConfiguration section */
4E575845268328CD0084F02D /* Debug */ = {
isa = XCBuildConfiguration;
@ -426,7 +534,7 @@
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = dwarf;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
@ -443,8 +551,9 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = "iOS 12.0";
MACOSX_DEPLOYMENT_TARGET = 11.3;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_ENABLE_DEBUG_INFO = YES;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx;
@ -496,6 +605,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = "iOS 12.0";
MACOSX_DEPLOYMENT_TARGET = 11.3;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
@ -554,6 +664,48 @@
};
name = Release;
};
4E5758C826833D140084F02D /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = NQLYU6MGPN;
INFOPLIST_FILE = PEPObjCAdapterTypesTests_iOS/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
OTHER_LDFLAGS = "-ObjC";
PRODUCT_BUNDLE_IDENTIFIER = "pep.foundation.PEPObjCAdapterTypesTests-iOS";
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
};
4E5758C926833D140084F02D /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = NQLYU6MGPN;
INFOPLIST_FILE = PEPObjCAdapterTypesTests_iOS/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
OTHER_LDFLAGS = "-ObjC";
PRODUCT_BUNDLE_IDENTIFIER = "pep.foundation.PEPObjCAdapterTypesTests-iOS";
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
@ -584,6 +736,15 @@
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
4E5758C726833D140084F02D /* Build configuration list for PBXNativeTarget "PEPObjCAdapterTypesTests_iOS" */ = {
isa = XCConfigurationList;
buildConfigurations = (
4E5758C826833D140084F02D /* Debug */,
4E5758C926833D140084F02D /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = 4E575836268328CD0084F02D /* Project object */;


+ 52
- 0
Subprojects/PEPObjCAdapterTypes/PEPObjCAdapterTypes.xcodeproj/xcshareddata/xcschemes/PEPObjCAdapterTypesTests_iOS.xcscheme View File

@ -0,0 +1,52 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1250"
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 = "4E5758BE26833D140084F02D"
BuildableName = "PEPObjCAdapterTypesTests_iOS.xctest"
BlueprintName = "PEPObjCAdapterTypesTests_iOS"
ReferencedContainer = "container:PEPObjCAdapterTypes.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
</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">
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

+ 22
- 0
Subprojects/PEPObjCAdapterTypes/PEPObjCAdapterTypesTests_iOS/Info.plist View File

@ -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>$(DEVELOPMENT_LANGUAGE)</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>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
</plist>

+ 81
- 0
Subprojects/PEPObjCAdapterTypes/PEPObjCAdapterTypesTests_iOS/PEPAttachment+SecureCodingTest.m View File

@ -0,0 +1,81 @@
//
// PEPAttachment_SecureCodingTest.m
// PEPObjCAdapterTypesTests_iOS
//
// Created by David Alarcon on 27/1/21.
// Copyright © 2021 pp. All rights reserved.
//
#import <XCTest/XCTest.h>
#import "PEPTypesTestUtil.h"
#import "PEPAttachment+SecureCoding.h"
@interface PEPAttachment_SecureCodingTest : XCTestCase
@end
@implementation PEPAttachment_SecureCodingTest
- (void)testConformsSecureCodingProtocol {
PEPAttachment *testee = [PEPAttachment new];
XCTAssertTrue([testee conformsToProtocol:@protocol(NSSecureCoding)]);
}
- (void)testSupportsSecureCodingProtocol {
XCTAssertTrue([PEPAttachment supportsSecureCoding]);
}
- (void)testAttachmentData {
PEPAttachment *testee = [PEPTypesTestUtil pEpAttachmentWithAllFieldsFilled];
PEPAttachment *unarchivedTestee = [self archiveAndUnarchiveAttachment:testee];
XCTAssertEqualObjects(testee.data, unarchivedTestee.data);
}
- (void)testAttachmentSize {
PEPAttachment *testee = [PEPTypesTestUtil pEpAttachmentWithAllFieldsFilled];
PEPAttachment *unarchivedTestee = [self archiveAndUnarchiveAttachment:testee];
XCTAssertEqual(testee.size, unarchivedTestee.size);
}
- (void)testAttachmentMimeType {
PEPAttachment *testee = [PEPTypesTestUtil pEpAttachmentWithAllFieldsFilled];
PEPAttachment *unarchivedTestee = [self archiveAndUnarchiveAttachment:testee];
XCTAssertEqualObjects(testee.mimeType, unarchivedTestee.mimeType);
}
- (void)testAttachmentFilename {
PEPAttachment *testee = [PEPTypesTestUtil pEpAttachmentWithAllFieldsFilled];
PEPAttachment *unarchivedTestee = [self archiveAndUnarchiveAttachment:testee];
XCTAssertEqualObjects(testee.filename, unarchivedTestee.filename);
}
- (void)testAttachmentContentDisposition {
PEPAttachment *testee = [PEPTypesTestUtil pEpAttachmentWithAllFieldsFilled];
PEPAttachment *unarchivedTestee = [self archiveAndUnarchiveAttachment:testee];
XCTAssertEqual(testee.contentDisposition, unarchivedTestee.contentDisposition);
}
// MARK: - Helper
- (PEPAttachment *)archiveAndUnarchiveAttachment:(PEPAttachment *)attachment {
NSError *error;
NSData *data = [NSKeyedArchiver archivedDataWithRootObject:attachment
requiringSecureCoding:YES
error:&error];
XCTAssertNotNil(data, "Error archiving pEp attachment.");
PEPAttachment *unarchivedAttachment = [NSKeyedUnarchiver unarchivedObjectOfClass:[PEPAttachment class]
fromData:data
error:&error];
XCTAssertNotNil(unarchivedAttachment, "Error unarchiving pEp attachment.");
return unarchivedAttachment;
}
@end

+ 95
- 0
Subprojects/PEPObjCAdapterTypes/PEPObjCAdapterTypesTests_iOS/PEPIdentity+SecureCodingTest.m View File

@ -0,0 +1,95 @@
//
// PEPIdentity+SecureCodingTest.m
// pEpObjCAdapter
//
// Created by David Alarcon on 27/1/21.
// Copyright © 2021 pp. All rights reserved.
//
#import <XCTest/XCTest.h>
#import "PEPTypesTestUtil.h"
#import "PEPIdentity+SecureCoding.h"
@interface PEPIdentity_SecureCodingTest : XCTestCase
@end
@implementation PEPIdentity_SecureCodingTest
- (void)testConformsSecureCodingProtocol {
PEPIdentity *testee = [PEPIdentity new];
XCTAssertTrue([testee conformsToProtocol:@protocol(NSSecureCoding)]);
}
- (void)testSupportsSecureCodingProtocol {
XCTAssertTrue([PEPIdentity supportsSecureCoding]);
}
- (void)testIdentityAddress {
PEPIdentity *testee = [PEPTypesTestUtil pEpIdentityWithAllFieldsFilled];
PEPIdentity *unarchivedTestee = [self archiveAndUnarchiveIdentity:testee];
XCTAssertEqualObjects(testee.address, unarchivedTestee.address);
}
- (void)testIdentityUserID {
PEPIdentity *testee = [PEPTypesTestUtil pEpIdentityWithAllFieldsFilled];
PEPIdentity *unarchivedTestee = [self archiveAndUnarchiveIdentity:testee];
XCTAssertEqualObjects(testee.userID, unarchivedTestee.userID);
}
- (void)testIdentityFingerprint {
PEPIdentity *testee = [PEPTypesTestUtil pEpIdentityWithAllFieldsFilled];
PEPIdentity *unarchivedTestee = [self archiveAndUnarchiveIdentity:testee];
XCTAssertEqualObjects(testee.fingerPrint, unarchivedTestee.fingerPrint);
}
- (void)testIdentityLanguage {
PEPIdentity *testee = [PEPTypesTestUtil pEpIdentityWithAllFieldsFilled];
PEPIdentity *unarchivedTestee = [self archiveAndUnarchiveIdentity:testee];
XCTAssertEqualObjects(testee.language, unarchivedTestee.language);
}
- (void)testIdentityCommType {
PEPIdentity *testee = [PEPTypesTestUtil pEpIdentityWithAllFieldsFilled];
PEPIdentity *unarchivedTestee = [self archiveAndUnarchiveIdentity:testee];
XCTAssertEqual(testee.commType, unarchivedTestee.commType);
}
- (void)testIdentityIsOwn {
PEPIdentity *testee = [PEPTypesTestUtil pEpIdentityWithAllFieldsFilled];
PEPIdentity *unarchivedTestee = [self archiveAndUnarchiveIdentity:testee];
XCTAssertEqual(testee.isOwn, unarchivedTestee.isOwn);
}
- (void)testIdentityFlags {
PEPIdentity *testee = [PEPTypesTestUtil pEpIdentityWithAllFieldsFilled];
PEPIdentity *unarchivedTestee = [self archiveAndUnarchiveIdentity:testee];
XCTAssertEqual(testee.flags, unarchivedTestee.flags);
}
// MARK: - Helper
- (PEPIdentity *)archiveAndUnarchiveIdentity:(PEPIdentity *)identity {
NSError *error;
NSData *data = [NSKeyedArchiver archivedDataWithRootObject:identity
requiringSecureCoding:YES
error:&error];
XCTAssertNotNil(data, "Error archiving pEp identity.");
PEPIdentity *unarchivedIdentity = [NSKeyedUnarchiver unarchivedObjectOfClass:[PEPIdentity class]
fromData:data
error:&error];
XCTAssertNotNil(unarchivedIdentity, "Error unarchiving pEp identity.");
return unarchivedIdentity;
}
@end

+ 67
- 0
Subprojects/PEPObjCAdapterTypes/PEPObjCAdapterTypesTests_iOS/PEPLanguage+SecureCodingTest.m View File

@ -0,0 +1,67 @@
//
// PEPLanguage+SecureCodingTest.m
// PEPObjCAdapterTypesTests_iOS
//
// Created by David Alarcon on 27/1/21.
// Copyright © 2021 pp. All rights reserved.
//
#import <XCTest/XCTest.h>
#import "PEPTypesTestUtil.h"
#import "PEPLanguage+SecureCoding.h"
@interface PEPLanguage_SecureCodingTest : XCTestCase
@end
@implementation PEPLanguage_SecureCodingTest
- (void)testConformsSecureCodingProtocol {
PEPLanguage *testee = [PEPLanguage new];
XCTAssertTrue([testee conformsToProtocol:@protocol(NSSecureCoding)]);
}
- (void)testSupportsSecureCodingProtocol {
XCTAssertTrue([PEPLanguage supportsSecureCoding]);
}
- (void)testLanguageCode {
PEPLanguage *testee = [PEPTypesTestUtil pEpLanguageWithAllFieldsFilled];
PEPLanguage *unarchivedTestee = [self archiveAndUnarchiveLanguage:testee];
XCTAssertEqualObjects(testee.code, unarchivedTestee.code);
}
- (void)testLanguageName {
PEPLanguage *testee = [PEPTypesTestUtil pEpLanguageWithAllFieldsFilled];
PEPLanguage *unarchivedTestee = [self archiveAndUnarchiveLanguage:testee];
XCTAssertEqualObjects(testee.name, unarchivedTestee.name);
}
- (void)testLanguageSentence {
PEPLanguage *testee = [PEPTypesTestUtil pEpLanguageWithAllFieldsFilled];
PEPLanguage *unarchivedTestee = [self archiveAndUnarchiveLanguage:testee];
XCTAssertEqualObjects(testee.sentence, unarchivedTestee.sentence);
}
// MARK: - Helper
- (PEPLanguage *)archiveAndUnarchiveLanguage:(PEPLanguage *)language {
NSError *error;
NSData *data = [NSKeyedArchiver archivedDataWithRootObject:language
requiringSecureCoding:YES
error:&error];
XCTAssertNotNil(data, "Error archiving pEp language.");
PEPLanguage *unarchivedLanguage = [NSKeyedUnarchiver unarchivedObjectOfClass:[PEPLanguage class]
fromData:data
error:&error];
XCTAssertNotNil(unarchivedLanguage, "Error unarchiving pEp language.");
return unarchivedLanguage;
}
@end

+ 197
- 0
Subprojects/PEPObjCAdapterTypes/PEPObjCAdapterTypesTests_iOS/PEPMessage+SecureCodingTest.m View File

@ -0,0 +1,197 @@
//
// PEPMessage+SecureCodingTest.m
// PEPObjCAdapterTypesTests_iOS
//
// Created by David Alarcon on 27/1/21.
// Copyright © 2021 pp. All rights reserved.
//
#import <XCTest/XCTest.h>
#import "PEPMessage+SecureCoding.h"
#import "PEPTypesTestUtil.h"
#import "PEPIdentity.h"
#import "PEPAttachment.h"
#import "NSObject+Extension.h"
@interface PEPMessage_SecureCodingTest : XCTestCase
@end
@implementation PEPMessage_SecureCodingTest
- (void)testConformsSecureCodingProtocol {
PEPMessage *testee = [PEPMessage new];
XCTAssertTrue([testee conformsToProtocol:@protocol(NSSecureCoding)]);
}
- (void)testSupportsSecureCodingProtocol {
XCTAssertTrue([PEPMessage supportsSecureCoding]);
}
- (void)testMessageMessageID {
PEPMessage *testee = [PEPTypesTestUtil pEpMessageWithAllFieldsFilled];
PEPMessage *unarchivedTestee = [self archiveAndUnarchiveMessage:testee];
XCTAssertEqualObjects(testee.messageID, unarchivedTestee.messageID);
}
- (void)testMessageFrom {
PEPMessage *testee = [PEPTypesTestUtil pEpMessageWithAllFieldsFilled];
PEPMessage *unarchivedTestee = [self archiveAndUnarchiveMessage:testee];
XCTAssertEqualObjects(testee.from, unarchivedTestee.from);
}
- (void)testMessageTo {
PEPMessage *testee = [PEPTypesTestUtil pEpMessageWithAllFieldsFilled];
PEPMessage *unarchivedTestee = [self archiveAndUnarchiveMessage:testee];
XCTAssertEqualObjects(testee.to, unarchivedTestee.to);
}
- (void)testMessageCC {
PEPMessage *testee = [PEPTypesTestUtil pEpMessageWithAllFieldsFilled];
PEPMessage *unarchivedTestee = [self archiveAndUnarchiveMessage:testee];
XCTAssertEqualObjects(testee.cc, unarchivedTestee.cc);
}
- (void)testMessageBCC {
PEPMessage *testee = [PEPTypesTestUtil pEpMessageWithAllFieldsFilled];
PEPMessage *unarchivedTestee = [self archiveAndUnarchiveMessage:testee];
XCTAssertEqualObjects(testee.bcc, unarchivedTestee.bcc);
}
- (void)testMessageShortMessage {
PEPMessage *testee = [PEPTypesTestUtil pEpMessageWithAllFieldsFilled];
PEPMessage *unarchivedTestee = [self archiveAndUnarchiveMessage:testee];
XCTAssertEqualObjects(testee.shortMessage, unarchivedTestee.shortMessage);
}
- (void)testMessageLongMessage {
PEPMessage *testee = [PEPTypesTestUtil pEpMessageWithAllFieldsFilled];
PEPMessage *unarchivedTestee = [self archiveAndUnarchiveMessage:testee];
XCTAssertEqualObjects(testee.longMessage, unarchivedTestee.longMessage);
}
- (void)testMessageLongMessageFormatted {
PEPMessage *testee = [PEPTypesTestUtil pEpMessageWithAllFieldsFilled];
PEPMessage *unarchivedTestee = [self archiveAndUnarchiveMessage:testee];
XCTAssertEqualObjects(testee.longMessageFormatted, unarchivedTestee.longMessageFormatted);
}
- (void)testMessageReplyTo {
PEPMessage *testee = [PEPTypesTestUtil pEpMessageWithAllFieldsFilled];
PEPMessage *unarchivedTestee = [self archiveAndUnarchiveMessage:testee];
XCTAssertEqualObjects(testee.replyTo, unarchivedTestee.replyTo);
}
- (void)testMessageInReplyTo {
PEPMessage *testee = [PEPTypesTestUtil pEpMessageWithAllFieldsFilled];
PEPMessage *unarchivedTestee = [self archiveAndUnarchiveMessage:testee];
XCTAssertEqualObjects(testee.inReplyTo, unarchivedTestee.inReplyTo);
}
- (void)testMessageReferences {
PEPMessage *testee = [PEPTypesTestUtil pEpMessageWithAllFieldsFilled];
PEPMessage *unarchivedTestee = [self archiveAndUnarchiveMessage:testee];
XCTAssertEqualObjects(testee.references, unarchivedTestee.references);
}
- (void)testMessageSentDate {
PEPMessage *testee = [PEPTypesTestUtil pEpMessageWithAllFieldsFilled];
PEPMessage *unarchivedTestee = [self archiveAndUnarchiveMessage:testee];
XCTAssertEqualObjects(testee.sentDate, unarchivedTestee.sentDate);
}
- (void)testMessageReceivedDate {
PEPMessage *testee = [PEPTypesTestUtil pEpMessageWithAllFieldsFilled];
PEPMessage *unarchivedTestee = [self archiveAndUnarchiveMessage:testee];
XCTAssertEqualObjects(testee.receivedDate, unarchivedTestee.receivedDate);
}
- (void)testMessageAttachments {
PEPMessage *testee = [PEPTypesTestUtil pEpMessageWithAllFieldsFilled];
PEPMessage *unarchivedTestee = [self archiveAndUnarchiveMessage:testee];
XCTAssertEqualObjects(testee.attachments, unarchivedTestee.attachments);
}
- (void)testMessageOptionalFields {
PEPMessage *testee = [PEPTypesTestUtil pEpMessageWithAllFieldsFilled];
PEPMessage *unarchivedTestee = [self archiveAndUnarchiveMessage:testee];
XCTAssertEqualObjects(testee.optionalFields, unarchivedTestee.optionalFields);
}
- (void)testMessageKeywords {
PEPMessage *testee = [PEPTypesTestUtil pEpMessageWithAllFieldsFilled];
PEPMessage *unarchivedTestee = [self archiveAndUnarchiveMessage:testee];
XCTAssertEqualObjects(testee.keywords, unarchivedTestee.keywords);
}
- (void)testMessageReceivedBy {
PEPMessage *testee = [PEPTypesTestUtil pEpMessageWithAllFieldsFilled];
PEPMessage *unarchivedTestee = [self archiveAndUnarchiveMessage:testee];
XCTAssertEqualObjects(testee.receivedBy, unarchivedTestee.receivedBy);
}
- (void)testMessageDirection {
PEPMessage *testee = [PEPTypesTestUtil pEpMessageWithAllFieldsFilled];
PEPMessage *unarchivedTestee = [self archiveAndUnarchiveMessage:testee];
XCTAssertEqual(testee.direction, unarchivedTestee.direction);
}
// MARK: - Helper
- (PEPMessage *)archiveAndUnarchiveMessage:(PEPMessage *)message {
NSError *error;
NSData *data = [NSKeyedArchiver archivedDataWithRootObject:message
requiringSecureCoding:YES
error:&error];
XCTAssertNotNil(data, "Error archiving pEp message.");
PEPMessage *unarchivedMessage = [NSKeyedUnarchiver unarchivedObjectOfClass:[PEPMessage class]
fromData:data
error:&error];
XCTAssertNotNil(unarchivedMessage, "Error unarchiving pEp message.");
return unarchivedMessage;
}
@end
@implementation PEPAttachment (Equatable)
- (BOOL)isEqualToPEPAttachment:(PEPAttachment * _Nonnull)attachment {
NSArray *s_keys = @[@"data", @"size", @"mimeType", @"filename", @"contentDisposition"];
return [self isEqualToObject:attachment basedOnKeys:s_keys];
}
- (BOOL)isEqual:(id)object {
if (object == self) {
return YES;
}
if (!object || ![object isKindOfClass:[self class]]) {
return NO;
}
return [self isEqualToPEPAttachment:object];
}
@end

+ 23
- 0
Subprojects/PEPObjCAdapterTypes/PEPObjCAdapterTypesTests_iOS/TestUtils/PEPTypesTestUtil.h View File

@ -0,0 +1,23 @@
//
// PEPTypesTestUtil.h
// PEPObjCAdapterTypesTests_iOS
//
// Created by David Alarcon on 27/1/21.
// Copyright © 2021 pp. All rights reserved.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@class PEPIdentity, PEPAttachment, PEPLanguage, PEPMessage;
@interface PEPTypesTestUtil : NSObject
+ (PEPIdentity *)pEpIdentityWithAllFieldsFilled;
+ (PEPAttachment *)pEpAttachmentWithAllFieldsFilled;
+ (PEPLanguage *)pEpLanguageWithAllFieldsFilled;
+ (PEPMessage *)pEpMessageWithAllFieldsFilled;
@end
NS_ASSUME_NONNULL_END

+ 92
- 0
Subprojects/PEPObjCAdapterTypes/PEPObjCAdapterTypesTests_iOS/TestUtils/PEPTypesTestUtil.m View File

@ -0,0 +1,92 @@
//
// PEPTypesTestUtil.m
// PEPObjCAdapterTypesTests_iOS
//
// Created by David Alarcon on 27/1/21.
// Copyright © 2021 pp. All rights reserved.
//
#import "PEPTypesTestUtil.h"
#import "PEPIdentity.h"
#import "PEPAttachment.h"
#import "PEPLanguage.h"
#import "PEPMessage.h"
@implementation PEPTypesTestUtil
+ (PEPIdentity *)pEpIdentityWithAllFieldsFilled {
PEPIdentity *identity = [PEPIdentity new];
identity.address = @"test@host.com";
identity.userID = @"pEp_own_userId";
identity.fingerPrint = @"184C1DE2D4AB98A2A8BB7F23B0EC5F483B62E19D";
identity.language = @"cat";
identity.commType = PEPCommTypePEP;
identity.isOwn = YES;
identity.flags = PEPIdentityFlagsNotForSync;
return identity;
}
+ (PEPAttachment *)pEpAttachmentWithAllFieldsFilled {
PEPAttachment *attachment = [PEPAttachment new];
attachment.data = [@"attachment" dataUsingEncoding:NSUTF8StringEncoding];
attachment.size = attachment.data.length;
attachment.mimeType = @"text/plain";
attachment.filename = @"attachment.txt";
attachment.contentDisposition = PEPContentDispositionAttachment;
return attachment;
}
+ (PEPLanguage *)pEpLanguageWithAllFieldsFilled {
PEPLanguage *language = [PEPLanguage new];
language.code = @"cat";
language.name = @"Català";
language.sentence = @"Bon profit";
return language;
}
+ (PEPMessage *)pEpMessageWithAllFieldsFilled {
PEPMessage *message = [PEPMessage new];
PEPIdentity *identity = [PEPTypesTestUtil pEpIdentityWithAllFieldsFilled];
PEPAttachment *attachment = [PEPTypesTestUtil pEpAttachmentWithAllFieldsFilled];
message.messageID = [NSString stringWithFormat: @"19980506192030.26456.%@", identity.address];
message.from = identity;
message.to = @[identity];
message.cc = @[identity];
message.bcc = @[identity];
message.shortMessage = @"shortMessage";
message.longMessage = @"longMessage";
message.longMessageFormatted = @"longMessageFormatted";
message.replyTo = @[identity];
message.inReplyTo = @[[NSString stringWithFormat: @"19980507220459.5655.%@", identity.address]];
message.references = @[[NSString stringWithFormat:
@"19980509035615.40087.%@",
identity.address]];
NSDate *yesterday = [NSCalendar.currentCalendar dateByAddingUnit:NSCalendarUnitDay
value:-1 toDate:[NSDate now]
options:NSCalendarWrapComponents];
message.sentDate = yesterday;
message.receivedDate = [NSDate now];
message.attachments = @[attachment];
message.optionalFields = @[@"optionalField"];
message.keywords = @[@"keyword"];
message.receivedBy = identity;
message.direction = PEPMsgDirectionIncoming;
return message;
}
@end

+ 2
- 2
pEpObjCAdapter.xcodeproj/xcshareddata/xcschemes/PEPObjCAdapterTypes_iOS.xcscheme View File

@ -14,7 +14,7 @@
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "15B10796257520B200D06C34"
BlueprintIdentifier = "151606FC257A401000DD42E0"
BuildableName = "libPEPObjCAdapterTypes_iOS.a"
BlueprintName = "PEPObjCAdapterTypes_iOS"
ReferencedContainer = "container:pEpObjCAdapter.xcodeproj">
@ -50,7 +50,7 @@
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "15B10796257520B200D06C34"
BlueprintIdentifier = "151606FC257A401000DD42E0"
BuildableName = "libPEPObjCAdapterTypes_iOS.a"
BlueprintName = "PEPObjCAdapterTypes_iOS"
ReferencedContainer = "container:pEpObjCAdapter.xcodeproj">


Loading…
Cancel
Save