Skip to content

Commit

Permalink
Merge pull request #934 from Microsoft/develop
Browse files Browse the repository at this point in the history
Release 1.3.1
  • Loading branch information
jaeklim authored Feb 14, 2018
2 parents a4ce362 + 7558d69 commit f44ba55
Show file tree
Hide file tree
Showing 65 changed files with 1,705 additions and 1,021 deletions.
2 changes: 1 addition & 1 deletion AppCenter.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'AppCenter'
s.version = '1.3.0'
s.version = '1.3.1'

s.summary = 'Visual Studio App Center is your continuous integration, delivery and learning solution for iOS and macOS apps.'
s.description = <<-DESC
Expand Down
6 changes: 6 additions & 0 deletions AppCenter/AppCenter.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,8 @@
38E1B67A1DDE3FDF000EFED1 /* MSAppCenterPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 38E1B6791DDE3FDF000EFED1 /* MSAppCenterPrivate.h */; };
38F1944E1DADB93100D3E0FE /* MSHttpSenderPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 38F1944D1DADB93100D3E0FE /* MSHttpSenderPrivate.h */; };
38FD798F1EB7B0B800DE2FB3 /* MSAppCenter.h in Headers */ = {isa = PBXBuildFile; fileRef = 6E0401551D1C9AAA0051BCFA /* MSAppCenter.h */; settings = {ATTRIBUTES = (Public, ); }; };
58603633B718B7A2702C23CB /* MSAbstractLogTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 58603EA088552D6FBB8EBE6C /* MSAbstractLogTests.m */; };
58603867BA3B4B1CB87D0E5D /* MSAbstractLogTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 58603EA088552D6FBB8EBE6C /* MSAbstractLogTests.m */; };
5C7877921EA0CFF3002263CC /* MSLogDBStorageTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5C7877911EA0CFF3002263CC /* MSLogDBStorageTests.m */; };
6E0401571D1C9AAA0051BCFA /* MSAppCenter.m in Sources */ = {isa = PBXBuildFile; fileRef = 6E0401561D1C9AAA0051BCFA /* MSAppCenter.m */; };
6E04016B1D1C9E1F0051BCFA /* MSConstants.h in Headers */ = {isa = PBXBuildFile; fileRef = 6E04013F1D1C99AC0051BCFA /* MSConstants.h */; settings = {ATTRIBUTES = (Public, ); }; };
Expand Down Expand Up @@ -661,6 +663,7 @@
38C633C81FDF163D005F40C9 /* MSAppDelegateUtil.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MSAppDelegateUtil.h; sourceTree = "<group>"; };
38E1B6791DDE3FDF000EFED1 /* MSAppCenterPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MSAppCenterPrivate.h; sourceTree = "<group>"; };
38F1944D1DADB93100D3E0FE /* MSHttpSenderPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MSHttpSenderPrivate.h; sourceTree = "<group>"; };
58603EA088552D6FBB8EBE6C /* MSAbstractLogTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MSAbstractLogTests.m; sourceTree = "<group>"; };
5C7877911EA0CFF3002263CC /* MSLogDBStorageTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MSLogDBStorageTests.m; sourceTree = "<group>"; };
6E0401031D1C98220051BCFA /* libAppCenter.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libAppCenter.a; sourceTree = BUILT_PRODUCTS_DIR; };
6E04013F1D1C99AC0051BCFA /* MSConstants.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MSConstants.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1137,6 +1140,7 @@
6E2395831D22EF5F00E543C8 /* Frameworks */,
04A140AB1ECE7F6F001CEE94 /* Support */,
6E363AEF1D2C84D60079043D /* Util */,
58603EA088552D6FBB8EBE6C /* MSAbstractLogTests.m */,
);
path = AppCenterTests;
sourceTree = "<group>";
Expand Down Expand Up @@ -1849,6 +1853,7 @@
046AEAEB1ECA562A00CBE511 /* MSMockLog.m in Sources */,
049378421FE4914D000ADBAF /* MSSessionContextTests.m in Sources */,
046AEAEC1ECA562A00CBE511 /* MSChannelGroupDefaultTests.m in Sources */,
58603633B718B7A2702C23CB /* MSAbstractLogTests.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -1971,6 +1976,7 @@
E88D17061D35B6B500A5EA57 /* MSMockLog.m in Sources */,
049378411FE4914B000ADBAF /* MSSessionContextTests.m in Sources */,
6E48A5A71D383893006E8B5F /* MSChannelGroupDefaultTests.m in Sources */,
58603867BA3B4B1CB87D0E5D /* MSAbstractLogTests.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
10 changes: 5 additions & 5 deletions AppCenter/AppCenter/Internals/Channel/MSChannelUnitDefault.m
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,9 @@ - (void)flushQueue {

// Optimization. If the current log level is greater than MSLogLevelDebug, we can skip it.
if ([MSAppCenter logLevel] <= MSLogLevelDebug) {
unsigned long count = [container.logs count];
for (unsigned long i = 0; i < count; i++) {
MSLogDebug([MSAppCenter logTag], @"Sending %lu/%lu log, group Id: %@, batch Id: %@, session Id: %@, payload:\n%@",
NSUInteger count = [container.logs count];
for (NSUInteger i = 0; i < count; i++) {
MSLogDebug([MSAppCenter logTag], @"Sending %tu/%tu log, group Id: %@, batch Id: %@, session Id: %@, payload:\n%@",
(i + 1), count, self.configuration.groupId, batchId, container.logs[i].sid,
[(MSAbstractLog *)container.logs[i] serializeLogWithPrettyPrinting:YES]);
}
Expand Down Expand Up @@ -220,8 +220,8 @@ - (void)flushQueue {

// Failure.
else {
MSLogError([MSAppCenter logTag], @"Log(s) sent with failure, batch Id:%@, status code:%lu",
senderBatchId, (unsigned long)statusCode);
MSLogError([MSAppCenter logTag], @"Log(s) sent with failure, batch Id:%@, status code:%tu",
senderBatchId, statusCode);

// Notify delegates.
[self
Expand Down
8 changes: 8 additions & 0 deletions AppCenter/AppCenter/Internals/Model/MSAbstractLog.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#import "MSUtility+Date.h"

static NSString *const kMSSid = @"sid";
static NSString *const kMSDistributionGroupId = @"distributionGroupId";
static NSString *const kMSTimestamp = @"timestamp";
static NSString *const kMSDevice = @"device";
static NSString *const kMSType = @"type";
Expand All @@ -14,6 +15,7 @@ @implementation MSAbstractLog
@synthesize type = _type;
@synthesize timestamp = _timestamp;
@synthesize sid = _sid;
@synthesize distributionGroupId = _distributionGroupId;
@synthesize device = _device;

- (NSMutableDictionary *)serializeToDictionary {
Expand All @@ -28,6 +30,9 @@ - (NSMutableDictionary *)serializeToDictionary {
if (self.sid) {
dict[kMSSid] = self.sid;
}
if (self.distributionGroupId) {
dict[kMSDistributionGroupId] = self.distributionGroupId;
}
if (self.device) {
dict[kMSDevice] = [self.device serializeToDictionary];
}
Expand All @@ -46,6 +51,7 @@ - (BOOL)isEqual:(id)object {
return ((!self.type && !log.type) || [self.type isEqualToString:log.type]) &&
((!self.timestamp && !log.timestamp) || [self.timestamp isEqualToDate:log.timestamp]) &&
((!self.sid && !log.sid) || [self.sid isEqualToString:log.sid]) &&
((!self.distributionGroupId && !log.distributionGroupId) || [self.distributionGroupId isEqualToString:log.distributionGroupId]) &&
((!self.device && !log.device) || [self.device isEqual:log.device]);
}

Expand All @@ -57,6 +63,7 @@ - (instancetype)initWithCoder:(NSCoder *)coder {
_type = [coder decodeObjectForKey:kMSType];
_timestamp = [coder decodeObjectForKey:kMSTimestamp];
_sid = [coder decodeObjectForKey:kMSSid];
_distributionGroupId = [coder decodeObjectForKey:kMSDistributionGroupId];
_device = [coder decodeObjectForKey:kMSDevice];
}
return self;
Expand All @@ -66,6 +73,7 @@ - (void)encodeWithCoder:(NSCoder *)coder {
[coder encodeObject:self.type forKey:kMSType];
[coder encodeObject:self.timestamp forKey:kMSTimestamp];
[coder encodeObject:self.sid forKey:kMSSid];
[coder encodeObject:self.distributionGroupId forKey:kMSDistributionGroupId];
[coder encodeObject:self.device forKey:kMSDevice];
}

Expand Down
5 changes: 5 additions & 0 deletions AppCenter/AppCenter/Internals/Model/MSLog.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@
*/
@property(nonatomic, copy) NSString *sid;

/**
* Optional distribution group ID value.
*/
@property(nonatomic, copy) NSString *distributionGroupId;

/**
* Device properties associated to this log.
*/
Expand Down
4 changes: 2 additions & 2 deletions AppCenter/AppCenter/Internals/Sender/MSHttpSender.m
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,8 @@ - (void)sendCallAsync:(MSSenderCall *)call {
}
}
}
MSLogVerbose([MSAppCenter logTag], @"HTTP response received with status code=%lu and payload=%@",
(unsigned long)statusCode, payload);
MSLogVerbose([MSAppCenter logTag], @"HTTP response received with status code=%tu and payload=%@",
statusCode, payload);

// Call handles the completion.
if (call) {
Expand Down
2 changes: 1 addition & 1 deletion AppCenter/AppCenter/Internals/Sender/MSSenderCall.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ NS_ASSUME_NONNULL_BEGIN
*/
- (void)sender:(id<MSSender>)sender
callCompletedWithStatus:(NSUInteger)statusCode
data:(NSData *)data
data:(nullable NSData *)data
error:(NSError *)error;

@end
Expand Down
6 changes: 3 additions & 3 deletions AppCenter/AppCenter/Internals/Sender/MSSenderCall.m
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ - (void)startRetryTimerWithStatusCode:(NSUInteger)statusCode {
// Create queue.
self.timerSource = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, DISPATCH_TARGET_QUEUE_DEFAULT);
int64_t delta = NSEC_PER_SEC * [self delayForRetryCount:self.retryCount];
MSLogWarning([MSAppCenter logTag], @"Call attempt #%lu failed with status code: %lu, it will be retried in %.f ms.",
(unsigned long)self.retryCount, (unsigned long)statusCode, round(delta / 1000000));
MSLogWarning([MSAppCenter logTag], @"Call attempt #%tu failed with status code: %tu, it will be retried in %.f ms.",
self.retryCount, statusCode, round(delta / 1000000));
self.retryCount++;
dispatch_source_set_timer(self.timerSource, dispatch_walltime(NULL, delta), 1ull * NSEC_PER_SEC, 1ull * NSEC_PER_SEC);
__weak typeof(self) weakSelf = self;
Expand Down Expand Up @@ -70,7 +70,7 @@ - (void)resetRetry {

- (void)sender:(id<MSSender>)sender
callCompletedWithStatus:(NSUInteger)statusCode
data:(NSData *)data
data:(nullable NSData *)data
error:(NSError *)error {
BOOL internetIsDown = [MSSenderUtil isNoInternetConnectionError:error];
BOOL couldNotEstablishSecureConnection = [MSSenderUtil isSSLConnectionError:error];
Expand Down
2 changes: 1 addition & 1 deletion AppCenter/AppCenter/Internals/Session/MSSessionContext.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ + (instancetype)sharedInstance {
if (!sharedInstance.sessionHistory) {
sharedInstance.sessionHistory = [NSMutableArray<MSSessionHistoryInfo *> new];
}
MSLogDebug([MSAppCenter logTag], @"%lu session(s) in the history.", (unsigned long)[sharedInstance.sessionHistory count]);
MSLogDebug([MSAppCenter logTag], @"%tu session(s) in the history.", [sharedInstance.sessionHistory count]);
sharedInstance.currentSessionInfo =
[[MSSessionHistoryInfo alloc] initWithTimestamp:[NSDate date] andSessionId:nil];
[sharedInstance.sessionHistory addObject:sharedInstance.currentSessionInfo];
Expand Down
11 changes: 11 additions & 0 deletions AppCenter/AppCenter/Internals/Util/MSUtility+Application.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,17 @@ typedef NS_ENUM(NSInteger, MSOpenURLState) {
*/
@interface MSUtility (Application)

/**
* Get the Shared Application from either NSApplication (MacOS) or UIApplication.
*
* @return The shared application.
*/
#if TARGET_OS_OSX
+ (NSApplication *)sharedApp;
#else
+ (UIApplication *)sharedApp;
#endif

/**
* Get the App Delegate.
*
Expand Down
1 change: 1 addition & 0 deletions AppCenter/AppCenter/MSConstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,6 @@ static short const kMSPriorityCount = MSPriorityHigh + 1;
*/
typedef NS_ENUM(NSInteger, MSInitializationPriority) {
MSInitializationPriorityDefault = 500,
MSInitializationPriorityHigh = 750,
MSInitializationPriorityMax = 999
};
174 changes: 174 additions & 0 deletions AppCenter/AppCenterTests/MSAbstractLogTests.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
#import "MSAbstractLogInternal.h"
#import "MSDevice.h"
#import "MSTestFrameworks.h"

@interface MSAbstractLogTests : XCTestCase

@property(nonatomic, strong) MSAbstractLog *sut;

@end

@implementation MSAbstractLogTests

@synthesize sut = _sut;

#pragma mark - Setup

- (void)setUp {
[super setUp];
self.sut = [MSAbstractLog new];
}

#pragma mark - Tests

- (void)testSerializingToDictionaryWorks {

// If
self.sut.type = @"fake";
self.sut.timestamp = [NSDate dateWithTimeIntervalSince1970:0];
self.sut.sid = @"FAKE-SESSION-ID";
self.sut.distributionGroupId = @"FAKE-GROUP-ID";
self.sut.device = [MSDevice new];

// When
NSMutableDictionary *actual = [self.sut serializeToDictionary];

// Then
assertThat(actual, notNilValue());
assertThat(actual[@"type"], equalTo(@"fake"));
assertThat(actual[@"timestamp"], equalTo(@"1970-01-01T00:00:00.000Z"));
assertThat(actual[@"sid"], equalTo(@"FAKE-SESSION-ID"));
assertThat(actual[@"distributionGroupId"], equalTo(@"FAKE-GROUP-ID"));
assertThat(actual[@"device"], equalTo(@{}));
}

- (void)testNSCodingSerializationAndDeserializationWorks {

// If
NSString *type = @"fake";
NSDate *timestamp = [NSDate dateWithTimeIntervalSince1970:0];
NSString *sid = @"FAKE-SESSION-ID";
NSString *distributionGroupId = @"FAKE-GROUP-ID";
MSDevice *device = [MSDevice new];

self.sut.type = type;
self.sut.timestamp = timestamp;
self.sut.sid = sid;
self.sut.distributionGroupId = distributionGroupId;
self.sut.device = device;

// When
NSData *serializedLog = [NSKeyedArchiver archivedDataWithRootObject:self.sut];
id actual = [NSKeyedUnarchiver unarchiveObjectWithData:serializedLog];

// Then
assertThat(actual, notNilValue());
assertThat(actual, instanceOf([MSAbstractLog class]));

MSAbstractLog *actualLog = actual;
assertThat(actualLog.type, equalTo(type));
assertThat(actualLog.timestamp, equalTo(timestamp));
assertThat(actualLog.sid, equalTo(sid));
assertThat(actualLog.distributionGroupId, equalTo(distributionGroupId));
assertThat(actualLog.device, equalTo(device));
}

- (void)testIsValid {

// If
id device = OCMClassMock([MSDevice class]);
OCMStub([device isValid]).andReturn(YES);
self.sut.type = @"fake";
self.sut.timestamp = [NSDate dateWithTimeIntervalSince1970:42];
self.sut.device = device;

// Then
XCTAssertTrue([self.sut isValid]);

// When
self.sut.type = nil;
self.sut.timestamp = [NSDate dateWithTimeIntervalSince1970:42];
self.sut.device = device;

// Then
XCTAssertFalse([self.sut isValid]);

// When
self.sut.type = @"fake";
self.sut.timestamp = nil;
self.sut.device = device;

// Then
XCTAssertFalse([self.sut isValid]);

// When
self.sut.type = @"fake";
self.sut.timestamp = [NSDate dateWithTimeIntervalSince1970:42];
self.sut.device = nil;

// Then
XCTAssertFalse([self.sut isValid]);
}

- (void)testIsEqual {

// If
NSString *type = @"fake";
NSDate *timestamp = [NSDate dateWithTimeIntervalSince1970:0];
NSString *sid = @"FAKE-SESSION-ID";
NSString *distributionGroupId = @"FAKE-GROUP-ID";
MSDevice *device = [MSDevice new];

self.sut.type = type;
self.sut.timestamp = timestamp;
self.sut.sid = sid;
self.sut.distributionGroupId = distributionGroupId;
self.sut.device = device;

// When
NSData *serializedEvent = [NSKeyedArchiver archivedDataWithRootObject:self.sut];
id actual = [NSKeyedUnarchiver unarchiveObjectWithData:serializedEvent];
MSAbstractLog *actualLog = actual;

// Then
XCTAssertTrue([self.sut isEqual:actualLog]);

// When
self.sut.type = @"new-fake";

// Then
XCTAssertFalse([self.sut isEqual:actualLog]);

// When
self.sut.type = @"fake";
self.sut.distributionGroupId = @"FAKE-NEW-GROUP-ID";

// Then
XCTAssertFalse([self.sut isEqual:actualLog]);
}

- (void)testSerializingToJsonWorks {

// If
self.sut.type = @"fake";
self.sut.timestamp = [NSDate dateWithTimeIntervalSince1970:0];
self.sut.sid = @"FAKE-SESSION-ID";
self.sut.distributionGroupId = @"FAKE-GROUP-ID";
self.sut.device = [MSDevice new];

// When
NSString *actual = [self.sut serializeLogWithPrettyPrinting:false];
NSData *actualData = [actual dataUsingEncoding:NSUTF8StringEncoding];
id actualDict = [NSJSONSerialization JSONObjectWithData:actualData options:0 error:nil];

// Then
assertThat(actualDict, instanceOf([NSDictionary class]));
assertThat([actualDict objectForKey:@"type"], equalTo(@"fake"));
assertThat([actualDict objectForKey:@"timestamp"], equalTo(@"1970-01-01T00:00:00.000Z"));
assertThat([actualDict objectForKey:@"sid"], equalTo(@"FAKE-SESSION-ID"));
assertThat([actualDict objectForKey:@"distributionGroupId"], equalTo(@"FAKE-GROUP-ID"));
assertThat([actualDict objectForKey:@"device"], equalTo(@{}));
}

@end

Loading

0 comments on commit f44ba55

Please sign in to comment.