Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TIMOB-25522] iOS: Add "navigationWindow" property to Ti.UI.Window, add unit-tests for all nav-window API's #9608

Merged
merged 31 commits into from
May 21, 2018
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
c4580dc
[TIMOB-25522] Add "navigationWindow" property to window
hansemannn Nov 16, 2017
385b500
Merge branch 'master' into TIMOB-25522
sgtcoolguy Nov 29, 2017
dd57fe3
Address review-comments
hansemannn Nov 29, 2017
b23d132
Rename ti.ui.window.test.js to ti.ui.ios.navigationwindow.addontest.js
hansemannn Nov 29, 2017
0fc6eba
[TIMOB-25522] Add unit-tests for all navigation-window properties
hansemannn Nov 29, 2017
1cfcf13
Update ti.ui.ios.navigationwindow.addontest.js
hansemannn Nov 29, 2017
d061097
Merge branch 'master' into TIMOB-25522
hansemannn Nov 29, 2017
ead8877
Merge branch 'master' into TIMOB-25522
sgtcoolguy Nov 29, 2017
25db46e
Attempt to fix crash
hansemannn Nov 29, 2017
9825ea2
Merge branch 'master' into TIMOB-25522
ssjsamir Jan 16, 2018
e1cdf2e
Merge branch 'master' into TIMOB-25522
hansemannn Feb 16, 2018
78b5534
Merge branch 'master' into TIMOB-25522
vijaysingh-axway Apr 16, 2018
ab810d8
Merge branch 'master' into TIMOB-25522
hansemannn May 15, 2018
1f4ffac
Update Window.yml
hansemannn May 15, 2018
9495cb5
Update ti.ui.ios.navigationwindow.addontest.js
hansemannn May 15, 2018
3819ed4
Update ti.ui.ios.navigationwindow.addontest.js
hansemannn May 15, 2018
2166687
Update ti.ui.ios.navigationwindow.addontest.js
hansemannn May 15, 2018
b737dc7
Merge branch 'master' into TIMOB-25522
hansemannn May 15, 2018
20742cb
Merge branch 'master' into TIMOB-25522
hansemannn May 15, 2018
38a908d
Update ti.ui.ios.navigationwindow.addontest.js
hansemannn May 15, 2018
596dfa6
Merge branch 'master' into TIMOB-25522
hansemannn May 15, 2018
4504492
Merge branch 'master' into TIMOB-25522
ssjsamir May 17, 2018
7940c50
Update Window.yml
hansemannn May 17, 2018
96e6da6
Merge branch 'master' into TIMOB-25522
ssjsamir May 18, 2018
796be79
Merge branch 'master' into TIMOB-25522
ssjsamir May 18, 2018
3ce3aab
Update ti.ui.ios.navigationwindow.addontest.js
hansemannn May 18, 2018
449f895
Merge branch 'master' into TIMOB-25522
hansemannn May 18, 2018
c246609
Merge branch 'master' into TIMOB-25522
hansemannn May 18, 2018
71dd096
Update ti.ui.ios.navigationwindow.addontest.js
hansemannn May 19, 2018
49de1f5
Merge branch 'master' into TIMOB-25522
hansemannn May 21, 2018
f4f9711
Merge branch 'master' into TIMOB-25522
hansemannn May 21, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions apidoc/Titanium/UI/Window.yml
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,16 @@ properties:
osver: {ios: {min: "7.0"}}
platforms: [iphone,ipad]

- name: navigationWindow
summary: The <Titanium.UI.iOS.NavigationWindow> instance hosting this window.
description: |
Returns the navigation window that hosts this window. Returns `null` if the window is not
hosted by a navigation window.
since: "7.1.0"
type: Titanium.UI.iOS.NavigationWindow
permission: read-only
platforms: [iphone, ipad]

- name: opacity
summary: The opacity from 0.0-1.0.
description: |
Expand Down
16 changes: 16 additions & 0 deletions iphone/Classes/TiWindowProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
#import "TiUIWindow.h"
#import "TiUIWindowProxy.h"

#ifdef USE_TI_UIIOSNAVIGATIONWINDOW
#import "TiUIiOSNavWindowProxy.h"
#endif

@interface TiWindowProxy (Private)
- (void)openOnUIThread:(id)args;
- (void)closeOnUIThread:(id)args;
Expand Down Expand Up @@ -646,6 +650,18 @@ - (void)showToolbar:(NSArray *)args
}
}

#ifdef USE_TI_UIIOSNAVIGATIONWINDOW
- (TiUIiOSNavWindowProxy *)navigationWindow
{
if (parentController != nil && [parentController isKindOfClass:[TiUIiOSNavWindowProxy class]]) {
return (TiUIiOSNavWindowProxy *)parentController;
}

NSLog(@"[ERROR] Trying to receive a Ti.UI.NavigationWindow instance that does not exist in this context!");
return nil;
}
#endif

- (void)hideToolbar:(NSArray *)args
{
ENSURE_UI_THREAD(hideToolbar, args);
Expand Down
132 changes: 132 additions & 0 deletions tests/Resources/ti.ui.ios.navigationwindow.addontest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
/*
* 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.
*/
/* eslint-env mocha */
/* global Ti */
/* eslint no-unused-expressions: "off" */
'use strict';

var should = require('./utilities/assertions'),
utilities = require('./utilities/utilities');

describe('Titanium.UI.iOS.NavigationWindow', function () {
var win, rootWindow;

this.timeout(5000);

// Create and open a root window for the rest of the below child window tests to use as a parent.
// We're not going to close this window until the end of this test suite.
// Note: Android needs this so that closing the last window won't back us out of the app.
before(function (finish) {
rootWindow = Ti.UI.createWindow();
rootWindow.addEventListener('open', function () {
finish();
});
rootWindow.open();
});

after(function (finish) {
rootWindow.addEventListener('close', function () {
finish();
});
rootWindow.close();
});

afterEach(function () {
if (win) {
win.close();
}
win = null;
});

it.ios('#openWindow', function () {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, you can just do describe.ios at the top to limit all sub-tests to iOS and avoid having to do it.ios on them all.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doing now, thx!

var nav = Ti.UI.iOS.createNavigationWindow({
window: win
});

win = Ti.UI.createWindow();
var subWindow = Ti.UI.createWindow();

win.addEventListener('open', function () {
should(nav.openWindow).be.a.function;
nav.openWindow(subWindow);
});

subWindow.addEventListener('open', function () {
nav.close();
finish();
});

nav.open();
});

it.ios('#closeWindow', function () {
var nav = Ti.UI.iOS.createNavigationWindow({
window: win
});

win = Ti.UI.createWindow();
var subWindow = Ti.UI.createWindow();

win.addEventListener('open', function () {
nav.openWindow(subWindow);
});

subWindow.addEventListener('open', function () {
should(nav.closeWindow).be.a.function;
nav.closeWindow(subWindow);
});

subWindow.addEventListener('close', function () {
finish();
});

nav.open();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is causing a crash/error on each test. I assume you meant to do win.open();?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mhh, nope, we need to open the navigation window. I am wondering if the following won't cause issues already, because we provide a null-object and set a reference later:

var nav = Ti.UI.iOS.createNavigationWindow({
  window: win // will be null at this point
});

win = Ti.UI.createWindow(); // now it's getting it's reference?

Or we declare the var nav; and assign it later?

});

it.ios('#popToRootWindow', function () {
var nav = Ti.UI.iOS.createNavigationWindow({
window: win
});

win = Ti.UI.createWindow();
var subWindow = Ti.UI.createWindow();

win.addEventListener('open', function () {
nav.openWindow(subWindow);
});

subWindow.addEventListener('open', function () {
should(nav.popToRootWindow).be.a.function;
nav.popToRootWindow();
finish();
});

nav.open();
});

it.ios('.navigationWindow', function () {
var nav = Ti.UI.iOS.createNavigationWindow({
window: win
});

win = Ti.UI.createWindow();

win.addEventListener('open', function () {
should(nav).not.be.undefined;
should(win.navigationWindow).not.be.undefined;

should(win.navigationWindow).eql(nav);

should(nav.openWindow).be.a.function;
should(win.navigationWindow.openWindow).be.a.function;
nav.close();
finish();
});

nav.open();
});
});