Skip to content

Commit b890e2a

Browse files
committed
Merge pull request #35 from adjust/unit
Unit tests
2 parents 96d8366 + f40cd39 commit b890e2a

23 files changed

+1903
-4
lines changed

Adjust.xcodeproj/project.pbxproj

Lines changed: 568 additions & 0 deletions
Large diffs are not rendered by default.

Adjust.xcodeproj/project.xcworkspace/contents.xcworkspacedata

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Adjust/AIAdditions/NSData+AIAdditions.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ - (NSString *)aiEncodeBase64 {
1919
char * strResult;
2020

2121
// Get the Raw Data length and ensure we actually have data
22-
int intLength = self.length;
22+
NSUInteger intLength = self.length;
2323
if (intLength == 0) return nil;
2424

2525
// Setup the String-based Result placeholder and pointer within that placeholder

Adjust/AIAdditions/NSString+AIAdditions.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ - (NSString *)aiQuote {
3030
- (NSString *)aiMd5 {
3131
const char *cStr = [self UTF8String];
3232
unsigned char digest[16];
33-
CC_MD5(cStr, strlen(cStr), digest);
33+
CC_MD5(cStr, (CC_LONG)strlen(cStr), digest);
3434

3535
NSMutableString *output = [NSMutableString stringWithCapacity:CC_MD5_DIGEST_LENGTH * 2];
3636
for(int i = 0; i < CC_MD5_DIGEST_LENGTH; i++) {
@@ -43,7 +43,7 @@ - (NSString *)aiSha1 {
4343
const char *cstr = [self cStringUsingEncoding:NSUTF8StringEncoding];
4444
NSData *data = [NSData dataWithBytes:cstr length:self.length];
4545
uint8_t digest[CC_SHA1_DIGEST_LENGTH];
46-
CC_SHA1(data.bytes, data.length, digest);
46+
CC_SHA1(data.bytes, (CC_LONG)data.length, digest);
4747

4848
NSMutableString* output = [NSMutableString stringWithCapacity:CC_SHA1_DIGEST_LENGTH * 2];
4949
for(int i = 0; i < CC_SHA1_DIGEST_LENGTH; i++) {

Adjust/AIUtil.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ + (void)excludeFromBackup:(NSString *)path {
9090
}
9191
} else { // iOS 5.0 and higher
9292
// First try and remove the extended attribute if it is present
93-
int result = getxattr(filePath, attrName, NULL, sizeof(u_int8_t), 0, 0);
93+
ssize_t result = getxattr(filePath, attrName, NULL, sizeof(u_int8_t), 0, 0);
9494
if (result != -1) {
9595
// The attribute exists, we need to remove it
9696
int removeResult = removexattr(filePath, attrName, 0);
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//
2+
// AIActivityHandlerMock.h
3+
// Adjust
4+
//
5+
// Created by Pedro Filipe on 11/02/14.
6+
// Copyright (c) 2014 adeven. All rights reserved.
7+
//
8+
9+
#import "AIActivityHandler.h"
10+
11+
@interface AIActivityHandlerMock : NSObject <AIActivityHandler>
12+
13+
@end
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
//
2+
// AIActivityHandlerMock.m
3+
// Adjust
4+
//
5+
// Created by Pedro Filipe on 11/02/14.
6+
// Copyright (c) 2014 adeven. All rights reserved.
7+
//
8+
9+
#import "AIActivityHandlerMock.h"
10+
#import "AILoggerMock.h"
11+
#import "AIAdjustFactory.h"
12+
13+
static NSString * const prefix = @"AIActivityHandler ";
14+
15+
@interface AIActivityHandlerMock()
16+
17+
@property (nonatomic, strong) AILoggerMock *loggerMock;
18+
19+
@end
20+
21+
@implementation AIActivityHandlerMock
22+
23+
@synthesize environment;
24+
@synthesize bufferEvents;
25+
@synthesize trackMacMd5;
26+
@synthesize delegate;
27+
28+
- (id)initWithAppToken:(NSString *)yourAppToken {
29+
self = [super init];
30+
if (self == nil) return nil;
31+
32+
self.loggerMock = (AILoggerMock *) [AIAdjustFactory logger];
33+
34+
[self.loggerMock test:[prefix stringByAppendingFormat:@"initWithAppToken yourAppToken:%@", yourAppToken]];
35+
36+
return self;
37+
}
38+
39+
- (void)setSdkPrefix:(NSString *)sdkPrefix {
40+
[self.loggerMock test:[prefix stringByAppendingFormat:@"setSdkPrefix sdkPrefix:%@", sdkPrefix]];
41+
}
42+
43+
- (void)trackSubsessionStart {
44+
[self.loggerMock test:[prefix stringByAppendingFormat:@"trackSubsessionStart"]];
45+
}
46+
- (void)trackSubsessionEnd {
47+
[self.loggerMock test:[prefix stringByAppendingFormat:@"trackSubsessionEnd"]];
48+
}
49+
50+
- (void)trackEvent:(NSString *)eventToken
51+
withParameters:(NSDictionary *)parameters {
52+
[self.loggerMock test:[prefix stringByAppendingFormat:@"trackEvent eventToken:%@ parameters:%@", eventToken, parameters]];
53+
}
54+
55+
- (void)trackRevenue:(double)amount
56+
forEvent:(NSString *)eventToken
57+
withParameters:(NSDictionary *)parameters {
58+
[self.loggerMock test:[prefix stringByAppendingFormat:@"trackRevenue amount:%f eventToken:%@ parameters:%@", amount, eventToken, parameters]];
59+
}
60+
61+
- (void)finishedTrackingWithResponse:(AIResponseData *)response {
62+
[self.loggerMock test:[prefix stringByAppendingFormat:@"finishedTrackingWithResponse response:%@", response]];
63+
}
64+
65+
66+
67+
@end

0 commit comments

Comments
 (0)