Travis CI-support and iOS8 push notifications

//FREEBIE
This commit is contained in:
Frederic Jacobs 2014-08-05 05:44:43 +02:00
parent 0d7e2d2f20
commit 9240a095ae
12 changed files with 165 additions and 11 deletions

View File

@ -1,4 +1,5 @@
language: objective-c
cache: cocoapods
script: xcodebuild test -workspace Signal.xcworkspace -scheme Signal -sdk iphonesimulator ONLY_ACTIVE_ARCH=YES
xcode_sdk: iphonesimulator7.1
install: true
xcode_workspace: Signal.xcworkspace
xcode_scheme: Signal

View File

@ -1113,6 +1113,7 @@
B621B06F198C69A100D36C3D /* zh_TW */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = zh_TW; path = Localizable.strings; sourceTree = "<group>"; };
B624C4E5198FD2830009264A /* whisperFake.cer */ = {isa = PBXFileReference; lastKnownFileType = file; name = whisperFake.cer; path = Signal/test/whisperFake.cer; sourceTree = SOURCE_ROOT; };
B657DDC91911A40500F45B0C /* Signal.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = Signal.entitlements; sourceTree = "<group>"; };
B661C211198EE2EA00548CA1 /* iOSVersions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = iOSVersions.h; path = src/environment/iOSVersions.h; sourceTree = "<group>"; };
B67ADDC21989FF8700E1A773 /* CallServerRequestsManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CallServerRequestsManager.h; sourceTree = "<group>"; };
B67ADDC31989FF8700E1A773 /* CallServerRequestsManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CallServerRequestsManager.m; sourceTree = "<group>"; };
B67EBF5C19194AC60084CCFD /* Settings.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; name = Settings.bundle; path = SettingsBundle/Settings.bundle; sourceTree = SOURCE_ROOT; };
@ -2878,6 +2879,7 @@
D221A099169C9E5E00537ABF /* main.m */,
D221A095169C9E5E00537ABF /* Signal-Info.plist */,
D221A09B169C9E5E00537ABF /* Signal-Prefix.pch */,
B661C211198EE2EA00548CA1 /* iOSVersions.h */,
E1C407C117F0C246007BEE65 /* whisperReal.cer */,
B624C4E5198FD2830009264A /* whisperFake.cer */,
);

View File

@ -15,4 +15,5 @@
static const int ddLogLevel = LOG_LEVEL_ERROR;
#endif
#import "iOSVersions.h"
#endif

View File

@ -70,10 +70,10 @@ static unsigned char DH3K_PRIME[]={
return [Environment environmentWithLogging:[DiscardingLog discardingLog]
andErrorNoter:^(id error, id relatedInfo, bool causedTermination) {}
andServerPort:31337
andMasterServerHostName:@"testing.whispersystems.org"
andDefaultRelayName:@"testing"
andMasterServerHostName:@"master.whispersystems.org"
andDefaultRelayName:@"relay"
andRelayServerHostNameSuffix:@"whispersystems.org"
andCertificate:[Certificate certificateFromResourcePath:@"whisperReal" ofType:@"der"]
andCertificate:[Certificate certificateFromResourcePath:@"whisperReal" ofType:@"cer"]
andCurrentRegionCodeForPhoneNumbers:@"US"
andSupportedKeyAgreementProtocols:[self supportedKeyAgreementProtocols]
andPhoneManager:nil

View File

@ -0,0 +1,96 @@
//
// iOSVersions.h
// Signal
//
// Created by Frederic Jacobs on 03/08/14.
// Copyright (c) 2014 Open Whisper Systems. All rights reserved.
//
#import <Foundation/Foundation.h>
#include <Availability.h>
// Source: https://github.com/carlj/CJAMacros/blob/master/CJAMacros/CJAMacros.h
/**
Runtime check for the current version Nummer.
checks ( CURRENT_VERSION_NUMBR == GIVEN_VERSION_NUMBER)
@_gVersion - the given Version Number. aka (_iOS_7_0 or NSFoundationVersionNumber_iOS_7_0 and so on)
*/
#define SYSTEM_VERSION_EQUAL_TO(_gVersion) ( floor(NSFoundationVersionNumber) == _gVersion )
/**
Runtime check for the current version Nummer.
checks CURRENT_VERSION_NUMBER > GIVEN_VERSION_NUMBER
@_gVersion - the given Version Number. aka (_iOS_7_0 or NSFoundationVersionNumber_iOS_7_0 and so on)
*/
#define SYSTEM_VERSION_GREATER_THAN(_gVersion) ( floor(NSFoundationVersionNumber) > _gVersion )
/**
Runtime check for the current version Nummer.
checks CURRENT_VERSION_NUMBER >= GIVEN_VERSION_NUMBER
@_gVersion - the given Version Number. aka (_iOS_7_0 or NSFoundationVersionNumber_iOS_7_0 and so on)
*/
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(_gVersion) ( floor(NSFoundationVersionNumber) >= _gVersion )
/**
Runtime check for the current version Nummer.
checks CURRENT_VERSION_NUMBER < GIVEN_VERSION_NUMBER
@_gVersion - the given Version Number. aka (_iOS_7_0 or NSFoundationVersionNumber_iOS_7_0 and so on)
*/
#define SYSTEM_VERSION_LESS_THAN(_gVersion) ( floor(NSFoundationVersionNumber) < _gVersion )
/**
Runtime check for the current version Nummer.
checks CURRENT_VERSION_NUMBER <= GIVEN_VERSION_NUMBER
@_gVersion - the given Version Number. aka (_iOS_7_0 or NSFoundationVersionNumber_iOS_7_0 and so on)
*/
#define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(_gVersion) ( floor(NSFoundationVersionNumber) <= _gVersion )
//If the symbol for iOS 7 isnt defined, define it.
#ifndef NSFoundationVersionNumber_iOS_7_0
#define NSFoundationVersionNumber_iOS_7_0 1047.00 //extracted from iOS 7 Header
#endif
#ifdef NSFoundationVersionNumber_iOS_7_0
#define _iOS_7_0 NSFoundationVersionNumber_iOS_7_0
#endif
//If the symbol for iOS 7.1 isnt defined, define it.
#ifndef NSFoundationVersionNumber_iOS_7_1
#define NSFoundationVersionNumber_iOS_7_1 1047.25 //extracted from iOS 8 Header
#endif
#ifdef NSFoundationVersionNumber_iOS_7_1
#define _iOS_7_1 NSFoundationVersionNumber_iOS_7_1
#endif
//If the symbol for iOS 8 isnt defined, define it.
#ifndef NSFoundationVersionNumber_iOS_8_0
#define NSFoundationVersionNumber_iOS_8_0 1134.10 //extracted with NSLog(@"%f", NSFoundationVersionNumber)
#endif
#ifdef NSFoundationVersionNumber_iOS_8_0
#define _iOS_8_0 NSFoundationVersionNumber_iOS_8_0
#endif
/**
Add a Singelton implementation to the .m File
*/
#define MacrosSingletonImplemantion \
+ (instancetype)sharedInstance { \
\
static dispatch_once_t onceToken; \
static id sharedInstance = nil; \
dispatch_once(&onceToken, ^{ \
sharedInstance = [self.class new]; \
}); \
\
return sharedInstance; \
}
#define CJAMacrosSingletonInterface + (instancetype)sharedInstance;

View File

@ -34,9 +34,7 @@
UIRemoteNotificationType notificationTypes = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];
BOOL needsPushSettingChangeAlert = NO;
// enhancement: do custom message depending on the setting?
if (notificationTypes == UIRemoteNotificationTypeNone) {
needsPushSettingChangeAlert = YES;
} else if (notificationTypes == UIRemoteNotificationTypeBadge) {
@ -60,7 +58,7 @@
[self askForPushRegistration];
}
}
}
- (void)askForPushRegistrationWithSuccess:(void (^)())success failure:(void (^)())failure{
@ -70,7 +68,38 @@
}
- (void)askForPushRegistration{
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeBadge)];
if(SYSTEM_VERSION_LESS_THAN(_iOS_8_0)){
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeBadge)];
} else{
#if __IPHONE_OS_VERSION_MAX_ALLOWED > __IPHONE_7_1
UIMutableUserNotificationAction *action_accept = [[UIMutableUserNotificationAction alloc]init];
action_accept.identifier = @"Signal_Call_Accept";
action_accept.title = @"Pick up";
action_accept.activationMode = UIUserNotificationActivationModeForeground;
action_accept.destructive = YES;
action_accept.authenticationRequired = NO;
UIMutableUserNotificationAction *action_decline = [[UIMutableUserNotificationAction alloc]init];
action_decline.identifier = @"Signal_Call_Decline";
action_decline.title = @"Pick up";
action_decline.activationMode = UIUserNotificationActivationModeForeground;
action_decline.destructive = YES;
action_decline.authenticationRequired = NO;
UIMutableUserNotificationCategory *callCategory = [[UIMutableUserNotificationCategory alloc] init];
callCategory.identifier = @"Signal_IncomingCall";
[callCategory setActions:@[action_accept, action_decline] forContext:UIUserNotificationActionContextDefault];
NSSet *categories = [NSSet setWithObject:callCategory];
[[UIApplication sharedApplication] registerForRemoteNotifications];
[[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIRemoteNotificationTypeAlert|UIRemoteNotificationTypeBadge|UIRemoteNotificationTypeSound) categories:categories]];
#endif
}
self.retries = 3;
}
@ -114,4 +143,6 @@
}
}
@end

View File

@ -8,6 +8,10 @@
@implementation RtpPacketTests
- (void)setUp{
[Environment setCurrent:[Release unitTestEnvironment:@[]]];
}
-(void) testRawDataSimple {
RtpPacket* r = [RtpPacket rtpPacketWithVersion:2
andPadding:0

View File

@ -8,6 +8,11 @@
@end
@implementation SecureStreamTest
-(void)setUp{
[Environment setCurrent:[Release unitTestEnvironment:@[]]];
}
-(void) testPerturbedRoundTrip {
for (int repeat = 0; repeat < 10; repeat++) {
NSData* key = generatePseudoRandomData(16);

View File

@ -9,6 +9,11 @@
@end
@implementation HandshakePacketTest
- (void)setUp{
[Environment setCurrent:[Release unitTestEnvironment:@[]]];
}
-(void) testHelloPacket {
[Environment setCurrent:testEnv];
HashChain* h = [HashChain hashChainWithSeed:[NSData dataWithLength:32]];

View File

@ -22,6 +22,7 @@ bool pm(HandshakePacket* p1, HandshakePacket* p2) {
@implementation ZrtpTest
- (void)setUp{
[Environment setCurrent:[Release unitTestEnvironment:@[]]];
[SGNKeychainUtil generateSignaling];
[Environment setCurrent:testEnv];
}

View File

@ -14,6 +14,10 @@
@implementation LowLatencyConnectorTest
- (void)setUp{
[Environment setCurrent:[Release unitTestEnvironment:@[]]];
}
-(void) testLowLatencyConnect_example {
[Environment setCurrent:testEnvWith(ENVIRONMENT_TESTING_OPTION_ALLOW_NETWORK_STREAM_TO_NON_SECURE_END_POINTS)];

View File

@ -21,6 +21,10 @@
@implementation NetworkStreamTest
- (void)setUp{
[Environment setCurrent:[Release unitTestEnvironment:@[]]];
}
-(void) testReplies {
[Environment setCurrent:testEnvWith(ENVIRONMENT_TESTING_OPTION_ALLOW_NETWORK_STREAM_TO_NON_SECURE_END_POINTS)];