Skip to content

Commit

Permalink
fix(ios): documentViewer setAnnotation method causing a crash (#12496)
Browse files Browse the repository at this point in the history
Fixes TIMOB-28360
  • Loading branch information
vijaysingh-axway committed Mar 17, 2021
1 parent 27c4f08 commit 55fe1c9
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 1 deletion.
6 changes: 6 additions & 0 deletions apidoc/Titanium/UI/iOS/DocumentViewer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,12 @@ properties:
the API summary.
type: String

- name: annotation
summary: Custom property list information for the target file.
description: |
Use this property to pass information about the document type to the app responsible for opening it.
type: [Dictionary, Array, String, Number, Date]

methods:
- name: hide
summary: Dismisses the document viewer.
Expand Down
7 changes: 6 additions & 1 deletion iphone/Classes/TiUIiOSDocumentViewerProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,12 @@ - (NSString *)apiName

- (void)setAnnotation:(id)args
{
[self controller].annotation = [args objectAtIndex:0];
[self controller].annotation = args;
}

- (id)annotation
{
return [self controller].annotation;
}

- (void)show:(id)args
Expand Down
1 change: 1 addition & 0 deletions tests/Resources/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ function loadTests() {
require('./ti.ui.ios.collisionbehavior.test');
require('./ti.ui.ios.feedbackgenerator.test');
require('./ti.ui.ios.previewcontext.test');
require('./ti.ui.ios.documentviewer.test');
require('./ti.ui.ios.splitwindow.test');
require('./ti.ui.ios.statusbar.test');
require('./ti.ui.ios.stepper.test');
Expand Down
65 changes: 65 additions & 0 deletions tests/Resources/ti.ui.ios.documentviewer.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
* Appcelerator Titanium Mobile
* Copyright (c) 2011-Present by Appcelerator, Inc. All Rights Reserved.
* Licensed under the terms of the Apache Public License
* Please see the LICENSE included with this distribution for details.
*/
/* global OS_VERSION_MAJOR */
/* eslint-env mocha */
/* eslint no-unused-expressions: "off" */
'use strict';
const should = require('./utilities/assertions');
const utilities = require('./utilities/utilities');

const isCI = Ti.App.Properties.getBool('isCI', false);

describe.ios('Titanium.UI.iOS', () => {
it('#createDocumentViewer()', () => {
should(Ti.UI.iOS.createDocumentViewer).be.a.Function();
});
});

describe.ios('Titanium.UI.iOS.DocumentViewer', () => {

let documentViewer;

beforeEach(() => {
documentViewer = Ti.UI.iOS.createDocumentViewer({
url: 'example.html'
});
});

it('.name', function () {
// On macOS < 11, it is failing. https://developer.apple.com/forums/thread/125819
if (isCI && utilities.isMacOS() && OS_VERSION_MAJOR < 11) {
this.skip();
return;
}
documentViewer.annotation = 'annotation';
should(documentViewer.name).eql('example.html');
});

it('.annotation', function () {
// On macOS < 11, it is failing. https://developer.apple.com/forums/thread/125819
if (isCI && utilities.isMacOS() && OS_VERSION_MAJOR < 11) {
this.skip();
return;
}

documentViewer.annotation = 'annotation';
should(documentViewer.annotation).eql('annotation');

documentViewer.annotation = [ 'annotation1', 'annotation2' ];
should(documentViewer.annotation).eql([ 'annotation1', 'annotation2' ]);

documentViewer.annotation = 1;
should(documentViewer.annotation).eql(1);

const date = Date();
documentViewer.annotation = date;
should(documentViewer.annotation).eql(date);

documentViewer.annotation = { key: 'value' };
should(documentViewer.annotation).eql({ key: 'value' });
});
});

0 comments on commit 55fe1c9

Please sign in to comment.