Skip to content

Commit

Permalink
Merge branch '8_3_X' into TIMOB-27352_83X
Browse files Browse the repository at this point in the history
  • Loading branch information
garymathews committed Aug 29, 2019
2 parents 64f391c + a54986f commit f6a172d
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 8 deletions.
27 changes: 22 additions & 5 deletions iphone/TitaniumKit/TitaniumKit/Sources/API/APIModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,22 @@ - (bool)isNSBoolean:(id)object
- (void)logMessage:(id)args severity:(NSString *)severity
{
if (args == nil) {
args = @[ @"null" ];
args = @[ [NSNull null] ];
} else if (!([args isKindOfClass:[NSArray class]])) {
args = @[ args ];
}
// If the arg is an NSNumber wrapping a BOOL we should print the string equivalent for the boolean!
NSMutableArray *newArray = [NSMutableArray array];
[args enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
if ([obj isKindOfClass:[JSValue class]]) {
obj = ((JSValue *)obj).toObject;
}
if ([self isNSBoolean:obj]) {
[newArray addObject:[NSString stringWithFormat:[obj boolValue] ? @"true" : @"false"]];
} else {
[newArray addObject:obj];
obj = [obj boolValue] ? @"true" : @"false";
} else if (obj == nil) {
obj = [NSNull null];
}
[newArray addObject:obj];
}];
NSLog(@"[%@] %@", [severity uppercaseString], [newArray componentsJoinedByString:@" "]);
}
Expand All @@ -49,26 +53,32 @@ - (id)transform:(id)arg

- (void)debug:(id)args
{
args = [JSContext currentArguments] ?: args;

[self logMessage:args severity:@"debug"];
}

- (void)info:(id)args
{
args = [JSContext currentArguments] ?: args;
[self logMessage:args severity:@"info"];
}

- (void)warn:(id)args
{
args = [JSContext currentArguments] ?: args;
[self logMessage:args severity:@"warn"];
}

- (void)error:(NSArray *)args
{
args = [JSContext currentArguments] ?: args;
[self logMessage:args severity:@"error"];
}

- (void)trace:(id)args
{
args = [JSContext currentArguments] ?: args;
[self logMessage:args severity:@"trace"];
}

Expand All @@ -84,17 +94,24 @@ - (void)timestamp:(id)args

- (void)notice:(id)args
{
args = [JSContext currentArguments] ?: args;
[self logMessage:args severity:@"info"];
}

- (void)critical:(id)args
{
args = [JSContext currentArguments] ?: args;
[self logMessage:args severity:@"error"];
}

- (void)log:(id)level withMessage:(id)args
{
if (args == nil) {
if ([JSContext currentArguments].count > 0) {
NSMutableArray *array = [NSMutableArray arrayWithArray:[JSContext currentArguments]];
[array removeObjectAtIndex:0];
args = array;
}
if (args == nil || ([args isKindOfClass:[NSArray class]] && [args count] == 0)) {
[self logMessage:level severity:@"info"];
} else {
[self logMessage:args severity:level];
Expand Down
1 change: 1 addition & 0 deletions iphone/TitaniumKit/TitaniumKit/Sources/API/KrollBridge.m
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,7 @@ - (void)didStartNewContext:(KrollContext *)kroll
@"Network",
@"Stream",
@"UI",
@"WatchSession",
@"XML" ];
for (NSString *name in legacyModuleNames) {
// We must generate the block and copy it to put it into heap or else every instance of the block shares
Expand Down
2 changes: 1 addition & 1 deletion iphone/cli/commands/_build.js
Original file line number Diff line number Diff line change
Expand Up @@ -6370,7 +6370,7 @@ iOSBuilder.prototype.removeFiles = function removeFiles(next) {
}, this);

// remove invalid architectures from TitaniumKit.framework for App Store distributions
if (this.target === 'dist-appstore') {
if (this.target === 'dist-appstore' || this.target === 'dist-adhoc') {
this.logger.info(__('Removing invalid architectures from TitaniumKit.framework'));

const titaniumKitPath = path.join(this.buildDir, 'Frameworks', 'TitaniumKit.framework', 'TitaniumKit');
Expand Down
5 changes: 3 additions & 2 deletions iphone/cli/commands/_buildModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -518,8 +518,8 @@ iOSModuleBuilder.prototype.createUniversalBinary = function createUniversalBinar

// Frameworks are handled differently. Based on https://gist.github.com/cromandini/1a9c4aeab27ca84f5d79
if (this.isFramework) {
const simFramework = args[0];
const deviceFramework = args[1];
const simFramework = args[1];
const deviceFramework = args[0];
const basename = path.basename(simFramework); // Same for sim and dist
const universalFrameworkDir = path.join(this.projectDir, 'build', 'universal');
const universalFrameworkFile = path.join(universalFrameworkDir, basename);
Expand Down Expand Up @@ -750,6 +750,7 @@ iOSModuleBuilder.prototype.packageModule = function packageModule(next) {

this.logger.info(__('Writing module zip: %s', moduleZipFullPath));
dest.finalize();
// eslint-disable-next-line no-useless-catch
} catch (ex) {
throw ex;
} finally {
Expand Down
64 changes: 64 additions & 0 deletions tests/Resources/ti.watchsession.addontest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
* Appcelerator Titanium Mobile
* Copyright (c) 2017 Axway, Inc. All Rights Reserved.
* Licensed under the terms of the Apache Public License
* Please see the LICENSE included with this distribution for details.
*/
/* eslint-env mocha */
/* eslint no-unused-expressions: "off" */
'use strict';
var should = require('./utilities/assertions');

describe.ios('Titanium.WatchSession', function () {

it('apiName', function () {
var watchSession = Ti.WatchSession;
should(watchSession).have.readOnlyProperty('apiName').which.is.a.String;
should(watchSession.apiName).be.eql('Ti.WatchSession');
});

// constants
it('ACTIVATION_STATE_NOT_ACTIVATED', function () {
should(Ti.WatchSession).have.constant('ACTIVATION_STATE_NOT_ACTIVATED').which.is.a.Number;
});

it('ACTIVATION_STATE_INACTIVE', function () {
should(Ti.WatchSession).have.constant('ACTIVATION_STATE_INACTIVE').which.is.a.Number;
});

it('ACTIVATION_STATE_ACTIVATED', function () {
should(Ti.WatchSession).have.constant('ACTIVATION_STATE_ACTIVATED').which.is.a.Number;
});

it('#isSupported', function () {
should(Ti.WatchSession.isSupported).be.a.Boolean;
});

it('#isPaired', function () {
should(Ti.WatchSession.isPaired).be.a.Boolean;
});

it('#isWatchAppInstalled', function () {
should(Ti.WatchSession.isWatchAppInstalled).be.a.Boolean;
});

it('#isComplicationEnabled', function () {
should(Ti.WatchSession.isComplicationEnabled).be.a.Boolean;
});

it('#isReachable', function () {
should(Ti.WatchSession.isReachable).be.a.Boolean;
});

it('#isActivated', function () {
should(Ti.WatchSession.isActivated).be.a.Boolean;
});

it('#hasContentPending', function () {
should(Ti.WatchSession.hasContentPending).be.a.Boolean;
});

it('#remainingComplicationUserInfoTransfers', function () {
should(Ti.WatchSession.remainingComplicationUserInfoTransfers).be.a.Number;
});
});

0 comments on commit f6a172d

Please sign in to comment.