diff --git a/.travis.yml b/.travis.yml
index 1637ea83b..edd73e9d6 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,35 +1,69 @@
+env:
+ global:
+ - DATE=$(date +%Y-%m-%d)
+ - PACKAGE_VERSION=$DATE-$TRAVIS_BUILD_NUMBER
+ - PACKAGE_NAME=tns-core-modules
+ - NODE_VERSION=5.10.1
+ - EMULATOR_API_VER=22
+ - RUNTIMEVERSION=next
+ - AVD_NAME=Arm$EMULATOR_API_VER
+addons:
+ artifacts:
+ paths:
+ - "$HOME/test-run-results$PACKAGE_VERSION.xml"
sudo: required
dist: trusty
language: android
node_js:
- - 4.2.3
+ - 4.2.3
jdk:
- - oraclejdk8
+ - oraclejdk8
android:
- components:
- - platform-tools
- - tools
- - build-tools-23.0.3
- - android-21
- - android-23
- - extra-android-support
- - extra-android-m2repository
- - sys-img-armeabi-v7a-android-21
-
+ components:
+ - platform-tools
+ - tools
+ - build-tools-23.0.3
+ - android-$EMULATOR_API_VER
+ - android-23
+ - extra-android-support
+ - extra-android-m2repository
+ - sys-img-armeabi-v7a-android-$EMULATOR_API_VER
before_script:
- - nvm install 5.10.1
- - npm install -g grunt-cli
- - npm install
- - (cd build/platform-declarations && npm install)
- - echo no | android create avd --force -n Arm21 -t android-21 -b armeabi-v7a -c 12M
- - emulator -avd Arm21 -no-skin -no-audio -no-window &
- - android-wait-for-emulator
+ - nvm install $NODE_VERSION
+ - npm install -g grunt-cli
+ - npm install
+ - "(cd build/platform-declarations && npm install)"
+ - echo no | android create avd --force -n $AVD_NAME -t android-$EMULATOR_API_VER -b
+ armeabi-v7a -c 12M
+ - emulator -avd $AVD_NAME -skin WXGA720 -no-audio -no-window &
+ - android-wait-for-emulator
script:
- - jdk_switcher use oraclejdk8
- - grunt default &&
- (cd build/platform-declarations && grunt) &&
- echo no | npm install nativescript -g > /dev/null &&
- grunt buildOnlyTestsApp --platform=Android --modulesPath=./bin/dist/tns-core-modules-2.0.0.tgz --runtimeVersion=next --emuPId=.*emulator.* --avd=Api21 --showEmu=false > /dev/null &&
- grunt runOnlyTestsApp --platform=Android --modulesPath=./bin/dist/tns-core-modules-2.0.0.tgz --emuPId=.*emulator.* --avd=Api21 --showEmu=false
-
- - node ./build/travis-scripts/check-testrun-broken.js
+ - jdk_switcher use oraclejdk8
+ - grunt default &&
+ FULL_PACKAGE_VERSION=`node -e 'console.log(require("./bin/dist/modules/package.json").version);'` &&
+ (cd build/platform-declarations && grunt) &&
+ echo no | npm install nativescript -g > /dev/null &&
+ grunt buildOnlyTestsApp --platform=Android --modulesPath=./bin/dist/$PACKAGE_NAME-$FULL_PACKAGE_VERSION.tgz --runtimeVersion=$RUNTIMEVERSION --emuPId=.*emulator.* --avd=$AVD_NAME --showEmu=false > /dev/null &&
+ grunt runOnlyTestsApp --platform=Android --modulesPath=./bin/dist/$PACKAGE_NAME-$FULL_PACKAGE_VERSION.tgz --emuPId=.*emulator.* --avd=$AVD_NAME --showEmu=false
+ - node ./build/travis-scripts/check-testrun-broken.js
+ - adb pull /data/data/org.nativescript.TestsApp/files/test-results.xml &&
+ mv test-results.xml ~/test-run-results$PACKAGE_VERSION.xml
+before_deploy:
+ - mv bin/dist/$PACKAGE_NAME-$FULL_PACKAGE_VERSION.tgz ../.deploymentpackage
+ - mv build ../
+ - cd ..
+ - rm -rf NativeScript
+ - tar -zxvf .deploymentpackage
+ - mv package $PACKAGE_NAME
+ - cd $PACKAGE_NAME
+ - rm ../.deploymentpackage
+ - mv ../build ./
+ - node ./build/travis-scripts/add-publishConfig.js next
+deploy:
+ provider: npm
+ email: nativescript@telerik.com
+ on:
+ branch: master
+ skip_cleanup: true
+ api_key:
+ secure: j2gE5jnGSuCFy7s3pDB6Or2j+vhlRYIlSSB1mDI7R5PvpV0kWr8yE1rLnyqeb0pI7WY/36SV/0NZCClJhlrZFvd7QvaP3+55cGX3ijmsDp8WxfQRyHppA9RZuMFujG7swFr/s0RmoYgO9mYNe46lJTX8m0HZeNN2qlAC7LDD3x8=
diff --git a/CrossPlatformModules.csproj b/CrossPlatformModules.csproj
index 88f3c1311..f3bbc4871 100644
--- a/CrossPlatformModules.csproj
+++ b/CrossPlatformModules.csproj
@@ -90,11 +90,16 @@
+
+
+ main-page.xml
+
+
modal-page.xml
@@ -152,8 +157,12 @@
+
+ Designer
+
+
Designer
@@ -2106,6 +2115,7 @@
PreserveNewest
+
@@ -2203,7 +2213,7 @@
False
-
+
\ No newline at end of file
diff --git a/application/application.d.ts b/application/application.d.ts
index 079e2bad9..1a7105d28 100644
--- a/application/application.d.ts
+++ b/application/application.d.ts
@@ -579,4 +579,11 @@ declare module "application" {
*/
removeNotificationObserver(observer: any, notificationName: string): void;
}
+
+ /* tslint:disable */
+ export interface RootViewControllerImpl {
+
+ contentController: any;
+
+ }
}
diff --git a/application/application.ios.ts b/application/application.ios.ts
index 16e0d86ad..1700b9fca 100644
--- a/application/application.ios.ts
+++ b/application/application.ios.ts
@@ -13,6 +13,43 @@ class Responder extends UIResponder {
//
}
+class RootViewControllerImpl extends UIViewController implements definition.RootViewControllerImpl {
+ private _contentController: UIViewController;
+
+ get contentController(): UIViewController {
+ return this._contentController;
+ }
+
+ set contentController(contentController: UIViewController) {
+
+ if (contentController.parentViewController !== null) {
+ contentController.willMoveToParentViewController(null);
+ contentController.view.removeFromSuperview();
+ contentController.removeFromParentViewController();
+ contentController.didMoveToParentViewController(this);
+ }
+
+ if (this._contentController) {
+ this._contentController.willMoveToParentViewController(null);
+ this._contentController.view.removeFromSuperview();
+ this._contentController.removeFromParentViewController();
+ }
+
+ this.addChildViewController(contentController);
+ this.view.addSubview(contentController.view);
+ contentController.view.frame = this.view.bounds;
+ contentController.view.autoresizingMask = UIViewAutoresizing.UIViewAutoresizingFlexibleWidth | UIViewAutoresizing.UIViewAutoresizingFlexibleHeight;
+
+ this._contentController = contentController;
+ this._contentController.didMoveToParentViewController(this);
+ }
+
+ public viewDidLoad(): void {
+ super.viewDidLoad();
+ this.view.backgroundColor = UIColor.whiteColor();
+ }
+}
+
class Window extends UIWindow {
private _content;
@@ -140,11 +177,13 @@ class IOSApplication implements definition.iOSApplication {
rootView = frame;
}
-
+
this._window.content = rootView;
if (rootView instanceof Frame) {
- this.rootController = this._window.rootViewController = rootView.ios.controller;
+ let rootController = new RootViewControllerImpl();
+ this.rootController = this._window.rootViewController = rootController;
+ rootController.contentController = rootView.ios.controller;
}
else if (rootView.ios instanceof UIViewController) {
this.rootController = this._window.rootViewController = rootView.ios;
diff --git a/apps/sample-fonts/app.ts b/apps/sample-fonts/app.ts
new file mode 100644
index 000000000..d903b1c7c
--- /dev/null
+++ b/apps/sample-fonts/app.ts
@@ -0,0 +1,3 @@
+import application = require("application");
+application.cssFile = "app.css"
+application.start({ moduleName: "main-page" });
\ No newline at end of file
diff --git a/apps/sample-fonts/main-page.ts b/apps/sample-fonts/main-page.ts
new file mode 100644
index 000000000..87d957983
--- /dev/null
+++ b/apps/sample-fonts/main-page.ts
@@ -0,0 +1,62 @@
+import { View } from "ui/core/view";
+import { EventData } from "data/observable";
+import { LayoutBase } from "ui/layouts/layout-base";
+import { Label } from "ui/label";
+import { TextField } from "ui/text-field";
+import { TextView } from "ui/text-view";
+import { Button } from "ui/button";
+import { FontStyle, FontWeight } from "ui/enums";
+import typeUtils = require("utils/types");
+import { Color } from "color";
+
+const fontFamilies = ["system", "sans-serif", "serif", "monospace"];
+const fontWeights = [FontWeight.normal, FontWeight.bold];
+const fontStyles = [FontStyle.normal, FontStyle.italic];
+
+export function onStackLayoutLoaded(args: EventData) {
+ var layout = args.object;
+ _generateViews(() => { return new Label(); }, layout);
+ _generateViews(() => { return new TextField(); }, layout);
+ _generateViews(() => { return new TextView(); }, layout);
+ _generateViews(() => { return new Button(); }, layout);
+}
+
+function _generateViews(factory: () => View, layout: LayoutBase) {
+ for (var f = 0; f < fontFamilies.length; f++) {
+ for (var w = 0; w < fontWeights.length; w++) {
+ for (var s = 0; s < fontStyles.length; s++) {
+ var view = factory();
+ var css = `font-family: ${fontFamilies[f]}; font-weight: ${fontWeights[w]}; font-style: ${fontStyles[s]};`;
+ (view).text = `${typeUtils.getClass(view)} ${css}`;
+ (view).textWrap = true;
+ view.style.textAlignment = "left";
+ view.setInlineStyle(css);
+ view.margin = "1 0";
+ view.borderWidth = 1;
+ view.height = 75;
+ view.color = new Color("Black");
+ view.backgroundColor = new Color("LightGray");
+ view.on("loaded", args => {
+ (view).text += _getFontInfo(view);
+ });
+ layout.addChild(view);
+ }
+ }
+ }
+}
+
+function _getFontInfo(view: View): string {
+ if (view.ios) {
+ var uiFont: UIFont;
+ if (view.ios instanceof UIButton) {
+ uiFont = view.ios.titleLabel.font;
+ }
+ else if (view.ios.font) {
+ uiFont = view.ios.font;
+ }
+
+ return ` ${uiFont.fontName} ${uiFont.pointSize}pt.`;
+ }
+
+ return "";
+}
\ No newline at end of file
diff --git a/apps/sample-fonts/main-page.xml b/apps/sample-fonts/main-page.xml
new file mode 100644
index 000000000..e029e0bf4
--- /dev/null
+++ b/apps/sample-fonts/main-page.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/apps/sample-fonts/package.json b/apps/sample-fonts/package.json
new file mode 100644
index 000000000..db7dfb767
--- /dev/null
+++ b/apps/sample-fonts/package.json
@@ -0,0 +1,2 @@
+{ "name" : "sample-fonts",
+ "main" : "app.js" }
diff --git a/apps/tests/app/mainPage.ts b/apps/tests/app/mainPage.ts
index 8060aa485..eb88d4e0f 100644
--- a/apps/tests/app/mainPage.ts
+++ b/apps/tests/app/mainPage.ts
@@ -1,6 +1,7 @@
import {Page} from "ui/page";
import * as trace from "trace";
import tests = require("../testRunner");
+import {Label} from "ui/label";
trace.enable();
trace.addCategories(trace.categories.Test + "," + trace.categories.Error);
@@ -11,6 +12,8 @@ page.id = "mainPage";
page.on(Page.navigatedToEvent, onNavigatedTo);
function onNavigatedTo(args) {
+ let label = new Label({ text: "Running non-UI tests..." });
+ page.content = label
args.object.off(Page.navigatedToEvent, onNavigatedTo);
setTimeout(function () {
tests.runAll();
diff --git a/apps/tests/file-system-tests.ts b/apps/tests/file-system-tests.ts
index f02ee8069..1c382df08 100644
--- a/apps/tests/file-system-tests.ts
+++ b/apps/tests/file-system-tests.ts
@@ -535,4 +535,14 @@ export function test_UnlockAfterWrite(done) {
return file.remove();
}).then(() => done())
.catch(done);
+}
+
+export function test_CreateParentOnNewFile(done) {
+ var documentsFolderName = fs.knownFolders.documents().path;
+ var tempFileName = fs.path.join(documentsFolderName, "folder1", "folder2", "Test_File_Create_Parent.txt");
+ var file = fs.File.fromPath(tempFileName);
+ file.writeText("Hello World!").then(() => {
+ return fs.knownFolders.documents().getFolder("folder1").remove();
+ }).then(() => done())
+ .catch(done);
}
\ No newline at end of file
diff --git a/apps/tests/observable-tests.ts b/apps/tests/observable-tests.ts
index 07e3521fb..2dd833fdd 100644
--- a/apps/tests/observable-tests.ts
+++ b/apps/tests/observable-tests.ts
@@ -421,12 +421,10 @@ export var test_ObservableCreatedWithJSON_shouldDistinguishSeparateObjects = fun
});
observable1.set("val", 10);
- TKUnit.wait(0.1);
TKUnit.assert(propName1 === "val", "propName1 should be 'val'");
TKUnit.assert(newValue1 === 10, "newValue1 should be 10");
observable2.set("val", 20);
- TKUnit.wait(0.1);
TKUnit.assert(propName2 === "val", "propName2 should be 'val'");
TKUnit.assert(newValue2 === 20, "newValue2 should be 20");
@@ -460,12 +458,10 @@ export var test_ObservablesCreatedWithJSON_shouldNotInterfereWithOneAnother = fu
});
observable1.set("property1", 10);
- TKUnit.wait(0.1);
TKUnit.assert(propName1 === "property1", "propName1 should be 'property1'");
TKUnit.assert(newValue1 === 10, "newValue1 should be 10");
observable2.set("property2", 20);
- TKUnit.wait(0.1);
TKUnit.assert(propName2 === "property2", "propName2 should be 'property2'");
TKUnit.assert(newValue2 === 20, "newValue2 should be 20");
};
diff --git a/apps/tests/testRunner.ts b/apps/tests/testRunner.ts
index ffdd3ef1a..fc40fa3fb 100644
--- a/apps/tests/testRunner.ts
+++ b/apps/tests/testRunner.ts
@@ -26,34 +26,44 @@ export function isRunningOnEmulator(): boolean {
}
export var allTests = {};
+if (!isRunningOnEmulator()) {
+ allTests["LOCATION"] = require("./location-tests");
+}
+
+allTests["PLATFORM"] = require("./platform-tests");
+allTests["FILE SYSTEM"] = require("./file-system-tests");
+allTests["HTTP"] = require("./http-tests");
+allTests["XHR"] = require("./xhr-tests");
+allTests["FETCH"] = require("./fetch-tests");
+allTests["APPLICATION SETTINGS"] = require("./application-settings-tests");
+allTests["APPLICATION"] = require("./application-tests");
+allTests["IMAGE SOURCE"] = require("./image-source-tests");
+allTests["OBSERVABLE-ARRAY"] = require("./observable-array-tests");
+allTests["VIRTUAL-ARRAY"] = require("./virtual-array-tests");
+allTests["OBSERVABLE"] = require("./observable-tests");
+allTests["TIMER"] = require("./timer-tests");
+allTests["COLOR"] = require("./color-tests");
+allTests["DEPENDENCY-OBSERVABLE"] = require("./ui/dependency-observable-tests");
+allTests["BINDABLE"] = require("./ui/bindable-tests");
+allTests["BINDING-EXPRESSIONS"] = require("./ui/binding-expressions-tests");
+allTests["XML-PARSER"] = require("./xml-parser-tests/xml-parser-tests");
+allTests["FORMATTEDSTRING"] = require("./text/formatted-string-tests");
+allTests["FILE-SYSTEM-ACCESS"] = require("./file-system-access-tests/file-system-access-tests");
+allTests["FILE-NAME-RESOLVER"] = require("./file-name-resolver-tests/file-name-resolver-tests");
+allTests["WEAK-EVENTS"] = require("./weak-event-listener-tests");
+allTests["CONNECTIVITY"] = require("./connectivity-tests");
+
allTests["PROXY-VIEW-CONTAINER"] = require("./ui/proxy-view-container/proxy-view-container-tests")
allTests["SCROLL-VIEW"] = require("./ui/scroll-view/scroll-view-tests");
allTests["ACTION-BAR"] = require("./ui/action-bar/action-bar-tests");
allTests["XML-DECLARATION"] = require("./xml-declaration/xml-declaration-tests");
-allTests["APPLICATION"] = require("./application-tests");
allTests["DOCKLAYOUT"] = require("./layouts/dock-layout-tests");
allTests["WRAPLAYOUT"] = require("./layouts/wrap-layout-tests");
allTests["ABSOLUTELAYOUT"] = require("./layouts/absolute-layout-tests");
allTests["GRIDLAYOUT"] = require("./layouts/grid-layout-tests");
allTests["STACKLAYOUT"] = require("./layouts/stack-layout-tests");
-allTests["PLATFORM"] = require("./platform-tests");
allTests["STYLE-PROPERTIES"] = require("./ui/style/style-properties-tests");
-allTests["FILE SYSTEM"] = require("./file-system-tests");
-allTests["HTTP"] = require("./http-tests");
-allTests["XHR"] = require("./xhr-tests");
-allTests["FETCH"] = require("./fetch-tests");
allTests["FRAME"] = require("./frame-tests");
-allTests["APPLICATION SETTINGS"] = require("./application-settings-tests");
-allTests["IMAGE SOURCE"] = require("./image-source-tests");
-allTests["TIMER"] = require("./timer-tests");
-allTests["COLOR"] = require("./color-tests");
-allTests["OBSERVABLE-ARRAY"] = require("./observable-array-tests");
-allTests["VIRTUAL-ARRAY"] = require("./virtual-array-tests");
-allTests["OBSERVABLE"] = require("./observable-tests");
-allTests["DEPENDENCY-OBSERVABLE"] = require("./ui/dependency-observable-tests");
-allTests["BINDABLE"] = require("./ui/bindable-tests");
-allTests["BINDING-EXPRESSIONS"] = require("./ui/binding-expressions-tests");
-allTests["XML-PARSER"] = require("./xml-parser-tests/xml-parser-tests");
allTests["VIEW"] = require("./ui/view/view-tests");
allTests["STYLE"] = require("./ui/style/style-tests");
allTests["VISUAL-STATE"] = require("./ui/style/visual-state-tests");
@@ -73,31 +83,22 @@ allTests["LISTVIEW"] = require("./ui/list-view/list-view-tests");
allTests["ACTIVITY-INDICATOR"] = require("./ui/activity-indicator/activity-indicator-tests");
allTests["TEXT-FIELD"] = require("./ui/text-field/text-field-tests");
allTests["TEXT-VIEW"] = require("./ui/text-view/text-view-tests");
-allTests["FORMATTEDSTRING"] = require("./text/formatted-string-tests");
-allTests["FILE-SYSTEM-ACCESS"] = require("./file-system-access-tests/file-system-access-tests");
-allTests["FILE-NAME-RESOLVER"] = require("./file-name-resolver-tests/file-name-resolver-tests");
allTests["LIST-PICKER"] = require("./ui/list-picker/list-picker-tests");
allTests["DATE-PICKER"] = require("./ui/date-picker/date-picker-tests");
allTests["TIME-PICKER"] = require("./ui/time-picker/time-picker-tests");
allTests["WEB-VIEW"] = require("./ui/web-view/web-view-tests");
allTests["HTML-VIEW"] = require("./ui/html-view/html-view-tests");
-allTests["WEAK-EVENTS"] = require("./weak-event-listener-tests");
allTests["REPEATER"] = require("./ui/repeater/repeater-tests");
allTests["SEARCH-BAR"] = require('./ui/search-bar/search-bar-tests');
-allTests["CONNECTIVITY"] = require("./connectivity-tests");
allTests["SEGMENTED-BAR"] = require("./ui/segmented-bar/segmented-bar-tests");
allTests["ANIMATION"] = require("./ui/animation/animation-tests");
allTests["CSS-ANIMATION"] = require("./ui/animation/css-animation-tests");
-if (!isRunningOnEmulator()) {
- allTests["LOCATION"] = require("./location-tests");
-}
// Skip transitions on android emulators with API 23
if (!(platform.device.os === platform.platformNames.android && parseInt(platform.device.sdkVersion) === 23 && isRunningOnEmulator())) {
allTests["TANSITIONS"] = require("./navigation/transition-tests");
}
-// Navigation tests should always be last.
allTests["NAVIGATION"] = require("./navigation/navigation-tests");
var testsWithLongDelay = {
@@ -106,16 +107,19 @@ var testsWithLongDelay = {
testLocationOnce: 10000,
testLocationOnceMaximumAge: 10000,
//web-view-tests
- testLoadExistingUrl: 10000,
- testLoadInvalidUrl: 10000
+ testLoadExistingUrl: 10000 * 5,
+ testLoadLocalFile: 10000 * 5,
+ testLoadInvalidUrl: 10000,
+ testLoadUpperCaseSrc: 10000 * 5
}
-var duration;
+var startTime;
var running = false;
var testsQueue = new Array();
function printRunTestStats() {
let testFileContent = new Array();
+ let testCases = new Array();
var j;
var failedTestCount = 0;
@@ -124,12 +128,11 @@ function printRunTestStats() {
let allTests = testsQueue.filter(t=> t.isTest);
testFileContent.push("");
- testFileContent.push(``);
for (j = 0; j < allTests.length; j++) {
let testName = allTests[j].testName;
- let duration = Math.round(allTests[j].duration / 1000);
-
+ let duration = (allTests[j].duration / 1000).toFixed(2);
+
if (!allTests[j].isPassed) {
failedTestCount++;
@@ -137,15 +140,23 @@ function printRunTestStats() {
failedTestInfo.push(allTests[j].testName + " FAILED: " + allTests[j].errorMessage);
- testFileContent.push(``);
+ testCases.push(``);
} else {
- testFileContent.push(``);
+ testCases.push(``);
}
}
+
+ var totalTime = (TKUnit.time() - startTime).toFixed(2);
+
+ testFileContent.push(``);
+ testFileContent = testFileContent.concat(testCases);
- let finalMessage = `=== ALL TESTS COMPLETE for ${Math.round(TKUnit.time() - duration)} ms === \n${(allTests.length - failedTestCount)} OK, ${failedTestCount} failed\n`;
+// DO NOT CHANGE THE FIRST ROW! Used as an indicator for test run pass detection.
+ let finalMessage = `=== ALL TESTS COMPLETE ===\n` +
+ `${(allTests.length - failedTestCount)} OK, ${failedTestCount} failed\n` +
+ `DURATION: ${totalTime} ms`;
TKUnit.write(finalMessage, messageType.info);
for (j = 0; j < failedTestInfo.length; j++) {
let failureMessage = failedTestInfo[j];
@@ -211,7 +222,7 @@ export var runAll = function (testSelector?: string) {
var totalSuccess = 0;
var totalFailed: Array = [];
- testsQueue.push(new TestInfo(() => { running = true; duration = TKUnit.time(); }));
+ testsQueue.push(new TestInfo(() => { running = true; startTime = TKUnit.time(); }));
for (var name in allTests) {
if (singleModuleName && (singleModuleName !== name.toLowerCase())) {
continue;
diff --git a/apps/tests/timer-tests.ts b/apps/tests/timer-tests.ts
index 5492454e7..d6db49f53 100644
--- a/apps/tests/timer-tests.ts
+++ b/apps/tests/timer-tests.ts
@@ -1,6 +1,5 @@
import TKUnit = require("./TKUnit");
-import platform = require("platform");
-var timer = require("timer/timer");
+import timer = require("timer");
// >> timer-require
// require("globals");
@@ -8,122 +7,108 @@ var timer = require("timer/timer");
// var timer = require("timer");
// << timer-require
-export var test_setTimeout_isDefined = function () {
+export function test_setTimeout_isDefined() {
TKUnit.assert(typeof (timer.setTimeout) !== "undefined", "Method timer.setTimeout() should be defined!");
};
-export var test_clearTimeout_isDefined = function () {
+export function test_clearTimeout_isDefined() {
TKUnit.assert(typeof (timer.clearTimeout) !== "undefined", "Method timer.clearTimeout() should be defined!");
};
-export var test_setInterval_isDefined = function () {
+export function test_setInterval_isDefined() {
TKUnit.assert(typeof (timer.setInterval) !== "undefined", "Method timer.setInterval() should be defined!");
};
-export var test_clearInterval_isDefined = function () {
+export function test_clearInterval_isDefined() {
TKUnit.assert(typeof (timer.clearInterval) !== "undefined", "Method timer.clearInterval() should be defined!");
};
-export var test_setTimeout = function () {
- var completed: boolean;
- var isReady = function () { return completed; }
+export function test_setTimeout() {
+ let completed: boolean;
// >> timer-set-zero
- timer.setTimeout(function () {
+ timer.setTimeout(() => {
// >> (hide)
completed = true;
// << (hide)
});
// << timer-set-zero
- TKUnit.waitUntilReady(isReady, 0.5);
+ TKUnit.waitUntilReady(() => completed, 0.5);
TKUnit.assert(completed, "Callback should be called!");
};
-export var test_setTimeout_callbackCalledAfterSpecifiedTime = function () {
- var completed: boolean;
- var isReady = function () { return completed; }
+export function test_setTimeout_callbackCalledAfterSpecifiedTime() {
+ let completed = false;
// >> timer-set-fivehundred
- timer.setTimeout(function () {
+ timer.setTimeout(() => {
// >> (hide)
completed = true;
// << (hide)
- }, 500);
+ }, 10);
// << timer-set-fivehundred
- TKUnit.waitUntilReady(isReady, 1);
+ TKUnit.waitUntilReady(() => completed, 1);
TKUnit.assert(completed, "Callback should be called after specified time!");
};
-export var test_setTimeout_callbackNotCalled = function () {
- var completed: boolean;
- var isReady = function () { return completed; }
+export function test_setTimeout_callbackNotCalled() {
+ let completed = false;
+ timer.setTimeout(() => completed = true, 50);
- timer.setTimeout(function () {
- completed = true;
- }, 1000);
-
- TKUnit.waitUntilReady(isReady, 0.5);
+ TKUnit.waitUntilReady(() => completed, 0.01);
TKUnit.assert(!completed, "Callback should be called after specified time!");
};
-export var test_setTimeout_shouldReturnNumber = function () {
- var id = timer.setTimeout(function () {
+export function test_setTimeout_shouldReturnNumber() {
+ let id = timer.setTimeout(() => {
//
});
TKUnit.assert(typeof id === "number", "Callback should return number!");
};
-export var test_setTimeout_callbackShouldBeCleared = function () {
- // This test is very unstable in iOS, because the platform does not guarantee the
- // callback will be cleared on time. Better skip it for iOS.
- if (platform.device.os === platform.platformNames.ios) {
- return;
- }
-
- var completed: boolean;
- var isReady = function () { return completed; }
+export function test_setTimeout_callbackShouldBeCleared() {
+ let completed = false;
// >> timer-set-twothousands
- var id = timer.setTimeout(function () {
+ let id = timer.setTimeout(() => {
// >> (hide)
completed = true;
// << (hide)
- }, 2000);
+ }, 50);
+ // << timer-set-twothousands
//// Clear timeout with specified id.
timer.clearTimeout(id);
// << timer-set-twothousands
- TKUnit.waitUntilReady(isReady, 3);
+ TKUnit.waitUntilReady(() => completed, 0.060);
TKUnit.assert(!completed, "Callback should be cleared when clearTimeout() is executed for specified id!");
};
-export var test_setInterval_callbackCalledDuringPeriod = function () {
- var counter = 0;
- var expected = 4;
- var isReady = function () { return counter >= expected; }
+export function test_setInterval_callbackCalledDuringPeriod() {
+ let counter = 0;
+ let expected = 4;
// >> timer-set-expression
- timer.setInterval(function () {
+ timer.setInterval(() => {
// >> (hide)
counter++;
// << (hide)
}, 100);
// << timer-set-expression
- TKUnit.waitUntilReady(isReady, 0.5);
- TKUnit.assert(isReady(), "Callback should be raised at least" + expected + "times! Callback raised " + counter + " times.");
+ TKUnit.waitUntilReady(() => counter >= expected, 0.5);
+ TKUnit.assert(counter >= expected, "Callback should be raised at least" + expected + "times! Callback raised " + counter + " times.");
};
-export var test_setInterval_callbackShouldBeCleared = function () {
- var counter = 0;
- var isReady = function () { return false; }
+export function test_setInterval_callbackShouldBeCleared() {
+ let counter = 0;
// >> timer-set-interval
- var id = timer.setInterval(function () {
+ let id = timer.setInterval(() => {
// >> (hide)
counter++;
// << (hide)
@@ -131,6 +116,6 @@ export var test_setInterval_callbackShouldBeCleared = function () {
}, 100);
// << timer-set-interval
- TKUnit.waitUntilReady(isReady, 0.5);
+ TKUnit.waitUntilReady(() => false, 0.5);
TKUnit.assert(counter === 1, "Callback should be raised only once!");
};
\ No newline at end of file
diff --git a/apps/tests/ui/activity-indicator/activity-indicator-tests.ts b/apps/tests/ui/activity-indicator/activity-indicator-tests.ts
index 012c19989..18e79b54b 100644
--- a/apps/tests/ui/activity-indicator/activity-indicator-tests.ts
+++ b/apps/tests/ui/activity-indicator/activity-indicator-tests.ts
@@ -9,7 +9,6 @@ import color = require("color");
import activityIndicatorModule = require("ui/activity-indicator");
// << activity-indicator-require
-var ASYNC = 0.2;
export function test_default_TNS_values() {
// >> activity-indicator-create
var indicator = new activityIndicatorModule.ActivityIndicator();
@@ -37,7 +36,7 @@ export function test_set_TNS_value_updates_native_value() {
function testAction(views: Array) {
indicator.busy = true;
- TKUnit.wait(ASYNC);
+ TKUnit.waitUntilReady(() => getNativeBusy(indicator) === true);
TKUnit.assertEqual(getNativeBusy(indicator), true, "Native value is different from TNS value.");
};
diff --git a/apps/tests/ui/animation/animation-tests.ts b/apps/tests/ui/animation/animation-tests.ts
index e262cb0ad..70122154c 100644
--- a/apps/tests/ui/animation/animation-tests.ts
+++ b/apps/tests/ui/animation/animation-tests.ts
@@ -1,9 +1,8 @@
import TKUnit = require("../../TKUnit");
import helper = require("../helper");
-import pageModule = require("ui/page");
import viewModule = require("ui/core/view");
-import labelModule = require("ui/label");
-import stackLayoutModule = require("ui/layouts/stack-layout");
+import {Label} from "ui/label";
+import {StackLayout} from "ui/layouts/stack-layout";
import colorModule = require("color");
import enums = require("ui/enums");
@@ -11,21 +10,18 @@ import enums = require("ui/enums");
import animation = require("ui/animation");
// << animation-require
-export var test_AnimatingProperties = function(done) {
- var mainPage: pageModule.Page;
- var label: labelModule.Label;
- var pageFactory = function(): pageModule.Page {
- label = new labelModule.Label();
- label.text = "label";
- var stackLayout = new stackLayoutModule.StackLayout();
- stackLayout.addChild(label);
- mainPage = new pageModule.Page();
- mainPage.content = stackLayout;
- return mainPage;
- };
+function prepareTest(): Label {
+ let mainPage = helper.getCurrentPage();
+ let label = new Label({ text: "label" });
+ let stackLayout = new StackLayout();
+ stackLayout.addChild(label);
+ mainPage.content = stackLayout;
+ TKUnit.waitUntilReady(() => label.isLoaded);
+ return label;
+}
- helper.navigate(pageFactory);
- TKUnit.waitUntilReady(() => { return label.isLoaded });
+export function test_AnimatingProperties(done) {
+ let label = prepareTest();
// >> animation-properties
label.animate({
@@ -34,7 +30,7 @@ export var test_AnimatingProperties = function(done) {
translate: { x: 100, y: 100 },
scale: { x: 2, y: 2 },
rotate: 180,
- duration: 1000,
+ duration: 10,
delay: 100,
iterations: 3,
curve: enums.AnimationCurve.easeIn
@@ -55,24 +51,12 @@ export var test_AnimatingProperties = function(done) {
// << animation-properties
}
-export var test_CancellingAnimation = function(done) {
- var mainPage: pageModule.Page;
- var label: labelModule.Label;
- var pageFactory = function(): pageModule.Page {
- label = new labelModule.Label();
- label.text = "label";
- var stackLayout = new stackLayoutModule.StackLayout();
- stackLayout.addChild(label);
- mainPage = new pageModule.Page();
- mainPage.content = stackLayout;
- return mainPage;
- };
-
- helper.navigate(pageFactory);
- TKUnit.waitUntilReady(() => { return label.isLoaded });
+export function test_CancellingAnimation(done) {
+ let label = prepareTest();
// >> animation-cancel
- var animation1 = label.createAnimation({ translate: { x: 100, y: 100 }, duration: 500 });
+ var animation1 = label.createAnimation({ translate: { x: 100, y: 100 }, duration: 20 });
+
animation1.play()
.then(() => {
////console.log("Animation finished");
@@ -96,24 +80,11 @@ export var test_CancellingAnimation = function(done) {
// << animation-cancel
}
-export var test_CancellingAnimate = function(done) {
- var mainPage: pageModule.Page;
- var label: labelModule.Label;
- var pageFactory = function(): pageModule.Page {
- label = new labelModule.Label();
- label.text = "label";
- var stackLayout = new stackLayoutModule.StackLayout();
- stackLayout.addChild(label);
- mainPage = new pageModule.Page();
- mainPage.content = stackLayout;
- return mainPage;
- };
-
- helper.navigate(pageFactory);
- TKUnit.waitUntilReady(() => { return label.isLoaded });
+export function test_CancellingAnimate(done) {
+ let label = prepareTest();
// >> animation-cancel2
- var animation1 = label.animate({ translate: { x: 100, y: 100 }, duration: 500 })
+ var animation1 = label.animate({ translate: { x: 100, y: 100 }, duration: 20 })
.then(() => {
////console.log("Animation finished");
// >> (hide)
@@ -136,30 +107,22 @@ export var test_CancellingAnimate = function(done) {
// << animation-cancel2
}
-export var test_ChainingAnimations = function(done) {
- var mainPage: pageModule.Page;
- var label: labelModule.Label;
- var pageFactory = function(): pageModule.Page {
- label = new labelModule.Label();
- label.text = "label";
- var stackLayout = new stackLayoutModule.StackLayout();
- stackLayout.addChild(label);
- mainPage = new pageModule.Page();
- mainPage.content = stackLayout;
- return mainPage;
- };
- helper.navigate(pageFactory);
- TKUnit.waitUntilReady(() => { return label.isLoaded });
+export function test_ChainingAnimations(done) {
+ let label = prepareTest();
// >> animation-chaining
- label.animate({ opacity: 0 })
- .then(() => label.animate({ opacity: 1 }))
- .then(() => label.animate({ translate: { x: 200, y: 200 } }))
- .then(() => label.animate({ translate: { x: 0, y: 0 } }))
- .then(() => label.animate({ scale: { x: 5, y: 5 } }))
- .then(() => label.animate({ scale: { x: 1, y: 1 } }))
- .then(() => label.animate({ rotate: 180 }))
- .then(() => label.animate({ rotate: 0 }))
+ let duration = 300;
+ // >> (hide)
+ duration = 5;
+ // << (hide)
+ label.animate({ opacity: 0, duration: duration })
+ .then(() => label.animate({ opacity: 1, duration: duration }))
+ .then(() => label.animate({ translate: { x: 200, y: 200 }, duration: duration }))
+ .then(() => label.animate({ translate: { x: 0, y: 0 }, duration: duration }))
+ .then(() => label.animate({ scale: { x: 5, y: 5 }, duration: duration }))
+ .then(() => label.animate({ scale: { x: 1, y: 1 }, duration: duration }))
+ .then(() => label.animate({ rotate: 180, duration: duration }))
+ .then(() => label.animate({ rotate: 0, duration: duration }))
.then(() => {
////console.log("Animation finished");
// >> (hide)
@@ -176,25 +139,12 @@ export var test_ChainingAnimations = function(done) {
// << animation-chaining
}
-export var test_ReusingAnimations = function(done) {
- var mainPage: pageModule.Page;
- var label: labelModule.Label;
- var pageFactory = function(): pageModule.Page {
- label = new labelModule.Label();
- label.text = "label";
- var stackLayout = new stackLayoutModule.StackLayout();
- stackLayout.addChild(label);
- mainPage = new pageModule.Page();
- mainPage.content = stackLayout;
- return mainPage;
- };
-
- helper.navigate(pageFactory);
- TKUnit.waitUntilReady(() => { return label.isLoaded });
+export function test_ReusingAnimations(done) {
+ let label = prepareTest();
// >> animation-reusing
- var animation1 = label.createAnimation({ translate: { x: 100, y: 100 } });
- var animation2 = label.createAnimation({ translate: { x: 0, y: 0 } });
+ var animation1 = label.createAnimation({ translate: { x: 100, y: 100 }, duration: 5 });
+ var animation2 = label.createAnimation({ translate: { x: 0, y: 0 }, duration: 5 });
animation1.play()
.then(() => animation2.play())
@@ -218,34 +168,23 @@ export var test_ReusingAnimations = function(done) {
// << animation-reusing
}
-export var test_AnimatingMultipleViews = function(done) {
- var mainPage: pageModule.Page;
- var label1: labelModule.Label;
- var label2: labelModule.Label;
- var label3: labelModule.Label;
- var pageFactory = function(): pageModule.Page {
- label1 = new labelModule.Label();
- label1.text = "label1";
- label2 = new labelModule.Label();
- label2.text = "label2";
- label3 = new labelModule.Label();
- label3.text = "label3";
- var stackLayout = new stackLayoutModule.StackLayout();
- stackLayout.addChild(label1);
- stackLayout.addChild(label2);
- stackLayout.addChild(label3);
- mainPage = new pageModule.Page();
- mainPage.content = stackLayout;
- return mainPage;
- };
- helper.navigate(pageFactory);
- TKUnit.waitUntilReady(() => { return label1.isLoaded && label2.isLoaded });
+export function test_AnimatingMultipleViews(done) {
+ let mainPage = helper.getCurrentPage();
+ let label1 = new Label({ text: "label1" });
+ let label2 = new Label({ text: "label2" });
+ let label3 = new Label({ text: "label3" });
+ let stackLayout = new StackLayout();
+ stackLayout.addChild(label1);
+ stackLayout.addChild(label2);
+ stackLayout.addChild(label3);
+ mainPage.content = stackLayout;
+ TKUnit.waitUntilReady(() => label3.isLoaded);
// >> animation-multiple-views
var animations: Array = [
- { target: label1, translate: { x: 200, y: 200 }, duration: 1000, delay: 0 },
- { target: label2, translate: { x: 200, y: 200 }, duration: 1000, delay: 333 },
- { target: label3, translate: { x: 200, y: 200 }, duration: 1000, delay: 666 },
+ { target: label1, translate: { x: 200, y: 200 }, duration: 20, delay: 0 },
+ { target: label2, translate: { x: 200, y: 200 }, duration: 20, delay: 7 },
+ { target: label3, translate: { x: 200, y: 200 }, duration: 20, delay: 14 },
];
var a = new animation.Animation(animations);
a.play()
@@ -267,23 +206,10 @@ export var test_AnimatingMultipleViews = function(done) {
// << animation-multiple-views
}
-export var test_AnimateOpacity = function(done) {
- var mainPage: pageModule.Page;
- var label: labelModule.Label;
- var pageFactory = function(): pageModule.Page {
- label = new labelModule.Label();
- label.text = "label";
- var stackLayout = new stackLayoutModule.StackLayout();
- stackLayout.addChild(label);
- mainPage = new pageModule.Page();
- mainPage.content = stackLayout;
- return mainPage;
- };
+export function test_AnimateOpacity(done) {
+ let label = prepareTest();
- helper.navigate(pageFactory);
- TKUnit.waitUntilReady(() => { return label.isLoaded });
-
- label.animate({ opacity: 0.75 })
+ label.animate({ opacity: 0.75, duration: 20 })
.then(() => {
TKUnit.assertEqual(label.opacity, 0.75, "label.opacity");
done();
@@ -293,8 +219,8 @@ export var test_AnimateOpacity = function(done) {
});
}
-export var test_AnimateOpacity_ShouldThrow_IfNotNumber = () => {
- var label = new labelModule.Label();
+export function test_AnimateOpacity_ShouldThrow_IfNotNumber() {
+ var label = new Label();
helper.buildUIAndRunTest(label, (views: Array) => {
TKUnit.assertThrows(() => {
label.animate({ opacity: "0.75" });
@@ -302,8 +228,8 @@ export var test_AnimateOpacity_ShouldThrow_IfNotNumber = () => {
});
}
-export var test_AnimateDelay_ShouldThrow_IfNotNumber = () => {
- var label = new labelModule.Label();
+export function test_AnimateDelay_ShouldThrow_IfNotNumber() {
+ var label = new Label();
helper.buildUIAndRunTest(label, (views: Array) => {
TKUnit.assertThrows(() => {
label.animate({ delay: "1" });
@@ -311,8 +237,8 @@ export var test_AnimateDelay_ShouldThrow_IfNotNumber = () => {
});
}
-export var test_AnimateDuration_ShouldThrow_IfNotNumber = () => {
- var label = new labelModule.Label();
+export function test_AnimateDuration_ShouldThrow_IfNotNumber() {
+ var label = new Label();
helper.buildUIAndRunTest(label, (views: Array) => {
TKUnit.assertThrows(() => {
label.animate({ duration: "1" });
@@ -320,8 +246,8 @@ export var test_AnimateDuration_ShouldThrow_IfNotNumber = () => {
});
}
-export var test_AnimateIterations_ShouldThrow_IfNotNumber = () => {
- var label = new labelModule.Label();
+export function test_AnimateIterations_ShouldThrow_IfNotNumber() {
+ var label = new Label();
helper.buildUIAndRunTest(label, (views: Array) => {
TKUnit.assertThrows(() => {
label.animate({ iterations: "1" });
@@ -329,8 +255,8 @@ export var test_AnimateIterations_ShouldThrow_IfNotNumber = () => {
});
}
-export var test_AnimateRotate_ShouldThrow_IfNotNumber = () => {
- var label = new labelModule.Label();
+export function test_AnimateRotate_ShouldThrow_IfNotNumber() {
+ var label = new Label();
helper.buildUIAndRunTest(label, (views: Array) => {
TKUnit.assertThrows(() => {
label.animate({ rotate: "1" });
@@ -338,8 +264,8 @@ export var test_AnimateRotate_ShouldThrow_IfNotNumber = () => {
});
}
-export var test_AnimateScale_ShouldThrow_IfNotPair = () => {
- var label = new labelModule.Label();
+export function test_AnimateScale_ShouldThrow_IfNotPair() {
+ var label = new Label();
helper.buildUIAndRunTest(label, (views: Array) => {
TKUnit.assertThrows(() => {
label.animate({ scale: "1" });
@@ -347,8 +273,8 @@ export var test_AnimateScale_ShouldThrow_IfNotPair = () => {
});
}
-export var test_AnimateTranslate_ShouldThrow_IfNotPair = () => {
- var label = new labelModule.Label();
+export function test_AnimateTranslate_ShouldThrow_IfNotPair() {
+ var label = new Label();
helper.buildUIAndRunTest(label, (views: Array) => {
TKUnit.assertThrows(() => {
label.animate({ translate: "1" });
@@ -356,8 +282,8 @@ export var test_AnimateTranslate_ShouldThrow_IfNotPair = () => {
});
}
-export var test_AnimateBackgroundColor_ShouldThrow_IfNotValidColorStringOrColor = () => {
- var label = new labelModule.Label();
+export function test_AnimateBackgroundColor_ShouldThrow_IfNotValidColorStringOrColor() {
+ var label = new Label();
helper.buildUIAndRunTest(label, (views: Array) => {
TKUnit.assertThrows(() => {
label.animate({ backgroundColor: "test" });
@@ -365,24 +291,11 @@ export var test_AnimateBackgroundColor_ShouldThrow_IfNotValidColorStringOrColor
});
}
-export var test_AnimateBackgroundColor = function(done) {
- var mainPage: pageModule.Page;
- var label: labelModule.Label;
- var pageFactory = function(): pageModule.Page {
- label = new labelModule.Label();
- label.text = "label";
- var stackLayout = new stackLayoutModule.StackLayout();
- stackLayout.addChild(label);
- mainPage = new pageModule.Page();
- mainPage.content = stackLayout;
- return mainPage;
- };
-
- helper.navigate(pageFactory);
- TKUnit.waitUntilReady(() => { return label.isLoaded });
+export function test_AnimateBackgroundColor(done) {
+ let label = prepareTest();
var red = new colorModule.Color("Red");
- label.animate({ backgroundColor: red })
+ label.animate({ backgroundColor: red, duration: 20 })
.then(() => {
TKUnit.assert(label.backgroundColor.equals(red));
done();
@@ -392,26 +305,12 @@ export var test_AnimateBackgroundColor = function(done) {
});
}
-export var test_AnimateBackgroundColor_FromString = function(done) {
- var mainPage: pageModule.Page;
- var label: labelModule.Label;
- var pageFactory = function(): pageModule.Page {
- label = new labelModule.Label();
- label.text = "label";
- var stackLayout = new stackLayoutModule.StackLayout();
- stackLayout.addChild(label);
- mainPage = new pageModule.Page();
- mainPage.content = stackLayout;
- return mainPage;
- };
-
- helper.navigate(pageFactory);
- TKUnit.waitUntilReady(() => { return label.isLoaded });
-
+export function test_AnimateBackgroundColor_FromString(done) {
+ let label = prepareTest();
var expected = "Red";
var clr = new colorModule.Color(expected);
- label.animate({ backgroundColor: expected })
+ label.animate({ backgroundColor: expected, duration: 20 })
.then(() => {
TKUnit.assert(label.backgroundColor.equals(clr));
done();
@@ -421,23 +320,10 @@ export var test_AnimateBackgroundColor_FromString = function(done) {
});
}
-export var test_AnimateTranslate = function(done) {
- var mainPage: pageModule.Page;
- var label: labelModule.Label;
- var pageFactory = function(): pageModule.Page {
- label = new labelModule.Label();
- label.text = "label";
- var stackLayout = new stackLayoutModule.StackLayout();
- stackLayout.addChild(label);
- mainPage = new pageModule.Page();
- mainPage.content = stackLayout;
- return mainPage;
- };
+export function test_AnimateTranslate(done) {
+ let label = prepareTest();
- helper.navigate(pageFactory);
- TKUnit.waitUntilReady(() => { return label.isLoaded });
-
- label.animate({ translate: { x: 100, y: 200 } })
+ label.animate({ translate: { x: 100, y: 200 }, duration: 20 })
.then(() => {
TKUnit.assertEqual(label.translateX, 100, "label.translateX");
TKUnit.assertEqual(label.translateY, 200, "label.translateY");
@@ -449,23 +335,10 @@ export var test_AnimateTranslate = function(done) {
});
}
-export var test_AnimateScale = function(done) {
- var mainPage: pageModule.Page;
- var label: labelModule.Label;
- var pageFactory = function(): pageModule.Page {
- label = new labelModule.Label();
- label.text = "label";
- var stackLayout = new stackLayoutModule.StackLayout();
- stackLayout.addChild(label);
- mainPage = new pageModule.Page();
- mainPage.content = stackLayout;
- return mainPage;
- };
+export function test_AnimateScale(done) {
+ let label = prepareTest();
- helper.navigate(pageFactory);
- TKUnit.waitUntilReady(() => { return label.isLoaded });
-
- label.animate({ scale: { x: 2, y: 3 } })
+ label.animate({ scale: { x: 2, y: 3 }, duration: 20 })
.then(() => {
TKUnit.assertEqual(label.scaleX, 2, "label.scaleX");
TKUnit.assertEqual(label.scaleY, 3, "label.scaleY");
@@ -477,23 +350,10 @@ export var test_AnimateScale = function(done) {
});
}
-export var test_AnimateRotate = function(done) {
- var mainPage: pageModule.Page;
- var label: labelModule.Label;
- var pageFactory = function(): pageModule.Page {
- label = new labelModule.Label();
- label.text = "label";
- var stackLayout = new stackLayoutModule.StackLayout();
- stackLayout.addChild(label);
- mainPage = new pageModule.Page();
- mainPage.content = stackLayout;
- return mainPage;
- };
+export function test_AnimateRotate(done) {
+ let label = prepareTest();
- helper.navigate(pageFactory);
- TKUnit.waitUntilReady(() => { return label.isLoaded });
-
- label.animate({ rotate: 123 })
+ label.animate({ rotate: 123, duration: 20 })
.then(() => {
TKUnit.assertEqual(label.rotate, 123, "label.rotate");
assertIOSNativeTransformIsCorrect(label);
@@ -504,26 +364,14 @@ export var test_AnimateRotate = function(done) {
});
}
-export var test_AnimateTranslateScaleAndRotateSimultaneously = function(done) {
- var mainPage: pageModule.Page;
- var label: labelModule.Label;
- var pageFactory = function(): pageModule.Page {
- label = new labelModule.Label();
- label.text = "label";
- var stackLayout = new stackLayoutModule.StackLayout();
- stackLayout.addChild(label);
- mainPage = new pageModule.Page();
- mainPage.content = stackLayout;
- return mainPage;
- };
-
- helper.navigate(pageFactory);
- TKUnit.waitUntilReady(() => { return label.isLoaded });
+export function test_AnimateTranslateScaleAndRotateSimultaneously(done) {
+ let label = prepareTest();
label.animate({
translate: { x: 100, y: 200 },
scale: { x: 2, y: 3 },
- rotate: 123
+ rotate: 123,
+ duration: 20
})
.then(() => {
TKUnit.assertEqual(label.translateX, 100, "label.translateX");
@@ -539,28 +387,15 @@ export var test_AnimateTranslateScaleAndRotateSimultaneously = function(done) {
});
}
-export var test_AnimateTranslateScaleAndRotateSequentially = function(done) {
- var mainPage: pageModule.Page;
- var label: labelModule.Label;
- var pageFactory = function(): pageModule.Page {
- label = new labelModule.Label();
- label.text = "label";
- var stackLayout = new stackLayoutModule.StackLayout();
- stackLayout.addChild(label);
- mainPage = new pageModule.Page();
- mainPage.content = stackLayout;
- return mainPage;
- };
+export function test_AnimateTranslateScaleAndRotateSequentially(done) {
+ let label = prepareTest();
- helper.navigate(pageFactory);
- TKUnit.waitUntilReady(() => { return label.isLoaded });
-
- label.animate({ translate: { x: 100, y: 200 } })
+ label.animate({ translate: { x: 100, y: 200 }, duration: 20 })
.then(() => {
TKUnit.assertEqual(label.translateX, 100, "label.translateX");
TKUnit.assertEqual(label.translateY, 200, "label.translateY");
assertIOSNativeTransformIsCorrect(label);
- return label.animate({ scale: { x: 2, y: 3 } });
+ return label.animate({ scale: { x: 2, y: 3 }, duration: 20 });
})
.then(() => {
TKUnit.assertEqual(label.translateX, 100, "label.translateX");
@@ -568,7 +403,7 @@ export var test_AnimateTranslateScaleAndRotateSequentially = function(done) {
TKUnit.assertEqual(label.scaleX, 2, "label.scaleX");
TKUnit.assertEqual(label.scaleY, 3, "label.scaleY");
assertIOSNativeTransformIsCorrect(label);
- return label.animate({ rotate: 123 });
+ return label.animate({ rotate: 123, duration: 20 });
})
.then(() => {
TKUnit.assertEqual(label.translateX, 100, "label.translateX");
@@ -584,24 +419,11 @@ export var test_AnimateTranslateScaleAndRotateSequentially = function(done) {
});
}
-export var test_AnimationsAreAlwaysPlayed = function(done) {
- var mainPage: pageModule.Page;
- var label: labelModule.Label;
- var pageFactory = function(): pageModule.Page {
- label = new labelModule.Label();
- label.text = "label";
- var stackLayout = new stackLayoutModule.StackLayout();
- stackLayout.addChild(label);
- mainPage = new pageModule.Page();
- mainPage.content = stackLayout;
- return mainPage;
- };
+export function test_AnimationsAreAlwaysPlayed(done) {
+ let label = prepareTest();
- helper.navigate(pageFactory);
- TKUnit.waitUntilReady(() => { return label.isLoaded });
-
- var animation1 = label.createAnimation({ opacity: 0 });
- var animation2 = label.createAnimation({ opacity: 1 });
+ var animation1 = label.createAnimation({ opacity: 0, duration: 20 });
+ var animation2 = label.createAnimation({ opacity: 1, duration: 20 });
animation1.play()
.then(() => {
@@ -618,23 +440,10 @@ export var test_AnimationsAreAlwaysPlayed = function(done) {
});
}
-export var test_PlayPromiseIsResolvedWhenAnimationFinishes = function(done) {
- var mainPage: pageModule.Page;
- var label: labelModule.Label;
- var pageFactory = function(): pageModule.Page {
- label = new labelModule.Label();
- label.text = "label";
- var stackLayout = new stackLayoutModule.StackLayout();
- stackLayout.addChild(label);
- mainPage = new pageModule.Page();
- mainPage.content = stackLayout;
- return mainPage;
- };
+export function test_PlayPromiseIsResolvedWhenAnimationFinishes(done) {
+ let label = prepareTest();
- helper.navigate(pageFactory);
- TKUnit.waitUntilReady(() => { return label.isLoaded });
-
- var animation = label.createAnimation({ opacity: 0, duration: 1000 });
+ var animation = label.createAnimation({ opacity: 0, duration: 20 });
animation.play()
.then(function onResolved() {
@@ -646,23 +455,10 @@ export var test_PlayPromiseIsResolvedWhenAnimationFinishes = function(done) {
});
}
-export var test_PlayPromiseIsRejectedWhenAnimationIsCancelled = function(done) {
- var mainPage: pageModule.Page;
- var label: labelModule.Label;
- var pageFactory = function(): pageModule.Page {
- label = new labelModule.Label();
- label.text = "label";
- var stackLayout = new stackLayoutModule.StackLayout();
- stackLayout.addChild(label);
- mainPage = new pageModule.Page();
- mainPage.content = stackLayout;
- return mainPage;
- };
+export function test_PlayPromiseIsRejectedWhenAnimationIsCancelled(done) {
+ let label = prepareTest();
- helper.navigate(pageFactory);
- TKUnit.waitUntilReady(() => { return label.isLoaded });
-
- var animation = label.createAnimation({ opacity: 0, duration: 1000 });
+ var animation = label.createAnimation({ opacity: 0, duration: 20 });
animation.play()
.then(function onResolved() {
diff --git a/apps/tests/ui/animation/css-animation-tests.ts b/apps/tests/ui/animation/css-animation-tests.ts
index 6aff374b5..a7f5fd175 100644
--- a/apps/tests/ui/animation/css-animation-tests.ts
+++ b/apps/tests/ui/animation/css-animation-tests.ts
@@ -1,5 +1,4 @@
import TKUnit = require("../../TKUnit");
-import page = require("ui/page");
import styleScope = require("ui/styling/style-scope");
import keyframeAnimation = require("ui/animation/keyframe-animation");
import enums = require("ui/enums");
@@ -8,6 +7,7 @@ import stackModule = require("ui/layouts/stack-layout");
import labelModule = require("ui/label");
import color = require("color");
import selectorModule = require("ui/styling/css-selector");
+//import styling = require("ui/styling");
function createAnimationFromCSS(css: string, name: string): keyframeAnimation.KeyframeAnimationInfo {
let scope = new styleScope.StyleScope();
@@ -32,7 +32,7 @@ function findSelectorInScope(scope: styleScope.StyleScope, name: string): select
return selector;
}
-exports.test_ReadAnimationProperties = function () {
+export function test_ReadAnimationProperties() {
let css = ".test { " +
"animation-name: first; " +
"animation-duration: 4s; " +
@@ -50,16 +50,18 @@ exports.test_ReadAnimationProperties = function () {
TKUnit.assertEqual(animation.iterations, 10);
TKUnit.assertTrue(animation.isForwards);
TKUnit.assertTrue(animation.isReverse);
-};
-exports.test_ReadTheAnimationProperty = function () {
+}
+
+export function test_ReadTheAnimationProperty() {
let animation = createAnimationFromCSS(".test { animation: second 0.2s ease-out 1 2 }", "test");
TKUnit.assertEqual(animation.name, "second");
TKUnit.assertEqual(animation.duration, 200);
TKUnit.assertEqual(animation.curve, enums.AnimationCurve.easeOut);
TKUnit.assertEqual(animation.delay, 1000);
TKUnit.assertEqual(animation.iterations, 2);
-};
-exports.test_ReadAnimationCurve = function () {
+}
+
+export function test_ReadAnimationCurve() {
let animation = createAnimationFromCSS(".test { animation-timing-function: ease-in; }", "test");
TKUnit.assertEqual(animation.curve, enums.AnimationCurve.easeIn);
animation = createAnimationFromCSS(".test { animation-timing-function: ease-out; }", "test");
@@ -73,30 +75,34 @@ exports.test_ReadAnimationCurve = function () {
animation = createAnimationFromCSS(".test { animation-timing-function: cubic-bezier(0.1, 1.0, 0.5, 0.5); }", "test");
let curve = animation.curve;
TKUnit.assert(curve.x1 === 0.1 && curve.y1 === 1.0 && curve.x2 === 0.5 && curve.y2 === 0.5);
-};
-exports.test_ReadIterations = function () {
+}
+
+export function test_ReadIterations() {
let animation = createAnimationFromCSS(".test { animation-iteration-count: 5; }", "test");
TKUnit.assertEqual(animation.iterations, 5);
animation = createAnimationFromCSS(".test { animation-iteration-count: infinite; }", "test");
TKUnit.assertEqual(animation.iterations, Number.MAX_VALUE);
-};
-exports.test_ReadFillMode = function () {
+}
+
+export function test_ReadFillMode() {
let animation = createAnimationFromCSS(".test { animation-iteration-count: 5; }", "test");
TKUnit.assertFalse(animation.isForwards);
animation = createAnimationFromCSS(".test { animation-fill-mode: forwards; }", "test");
TKUnit.assertTrue(animation.isForwards);
animation = createAnimationFromCSS(".test { animation-fill-mode: backwards; }", "test");
TKUnit.assertFalse(animation.isForwards);
-};
-exports.test_ReadDirection = function () {
+}
+
+export function test_ReadDirection() {
let animation = createAnimationFromCSS(".test { animation-iteration-count: 5; }", "test");
TKUnit.assertFalse(animation.isReverse);
animation = createAnimationFromCSS(".test { animation-direction: reverse; }", "test");
TKUnit.assertTrue(animation.isReverse);
animation = createAnimationFromCSS(".test { animation-direction: normal; }", "test");
TKUnit.assertFalse(animation.isReverse);
-};
-exports.test_ReadKeyframe = function () {
+}
+
+export function test_ReadKeyframe() {
let scope = new styleScope.StyleScope();
scope.css = ".test { animation-name: test; } @keyframes test { from { background-color: red; } to { background-color: blue; } }";
scope.ensureSelectors();
@@ -109,8 +115,9 @@ exports.test_ReadKeyframe = function () {
TKUnit.assertEqual(animation.keyframes[1].duration, 1, "Second keyframe duration should be 1");
TKUnit.assertEqual(animation.keyframes[0].declarations.length, 1, "Keyframe declarations are not correct");
TKUnit.assertEqual(animation.keyframes[0].declarations[0].property, "backgroundColor", "Keyframe declarations are not correct");
-};
-exports.test_ReadScale = function () {
+}
+
+export function test_ReadScale() {
let animation = createAnimationFromCSS(".test { animation-name: test; } @keyframes test { to { transform: scaleX(5),scaleY(10); } }", "test");
let scale = animation.keyframes[0].declarations[0].value;
TKUnit.assertEqual(animation.keyframes[0].declarations[0].property, "scale");
@@ -127,8 +134,9 @@ exports.test_ReadScale = function () {
scale = animation.keyframes[0].declarations[0].value;
TKUnit.assertEqual(animation.keyframes[0].declarations[0].property, "scale");
TKUnit.assert(scale.x === 10 && scale.y === 20);
-};
-exports.test_ReadTranslate = function () {
+}
+
+export function test_ReadTranslate() {
let animation = createAnimationFromCSS(".test { animation-name: test; } @keyframes test { to { transform: translateX(5),translateY(10); } }", "test");
let translate = animation.keyframes[0].declarations[0].value;
TKUnit.assertEqual(animation.keyframes[0].declarations[0].property, "translate");
@@ -145,8 +153,9 @@ exports.test_ReadTranslate = function () {
translate = animation.keyframes[0].declarations[0].value;
TKUnit.assertEqual(animation.keyframes[0].declarations[0].property, "translate");
TKUnit.assert(translate.x === 10 && translate.y === 20);
-};
-exports.test_ReadRotate = function () {
+}
+
+export function test_ReadRotate() {
let animation = createAnimationFromCSS(".test { animation-name: test; } @keyframes test { to { transform: rotate(5); } }", "test");
TKUnit.assertEqual(animation.keyframes[0].declarations[0].property, "rotate");
TKUnit.assertEqual(animation.keyframes[0].declarations[0].value, 5);
@@ -156,8 +165,9 @@ exports.test_ReadRotate = function () {
animation = createAnimationFromCSS(".test { animation-name: test; } @keyframes test { to { transform: rotate(0.7853981634rad); } }", "test");
TKUnit.assertEqual(animation.keyframes[0].declarations[0].property, "rotate");
TKUnit.assertTrue(animation.keyframes[0].declarations[0].value - 45 < 0.1);
-};
-exports.test_ReadTransform = function () {
+}
+
+export function test_ReadTransform() {
let css = ".test { animation-name: test; } @keyframes test { to { transform: rotate(10),scaleX(5),translate(2,4); } }";
let animation = createAnimationFromCSS(css, "test");
let rotate = animation.keyframes[0].declarations[0].value;
@@ -173,8 +183,9 @@ exports.test_ReadTransform = function () {
TKUnit.assertEqual(rotate, 0);
TKUnit.assert(scale.x === 1 && scale.y === 1);
TKUnit.assert(translate.x === 0 && translate.y === 0);
-};
-exports.test_ReadAnimationWithUnsortedKeyframes = function () {
+}
+
+export function test_ReadAnimationWithUnsortedKeyframes() {
let css = ".test { animation-name: test; } " +
"@keyframes test { " +
"from { opacity: 0; } " +
@@ -196,14 +207,16 @@ exports.test_ReadAnimationWithUnsortedKeyframes = function () {
TKUnit.assertEqual(animation.keyframes[3].duration, 0.6);
TKUnit.assertEqual(animation.keyframes[4].duration, 0.8);
TKUnit.assertEqual(animation.keyframes[5].duration, 1);
-};
-exports.test_ReadAnimationsWithCSSImport = function () {
+}
+
+export function test_ReadAnimationsWithCSSImport() {
let css = "@import '~/ui/animation/test.css'; .test { animation-name: test; }";
let animation = createAnimationFromCSS(css, "test");
TKUnit.assertEqual(animation.keyframes.length, 3);
TKUnit.assertEqual(animation.keyframes[1].declarations[0].property, "backgroundColor");
-};
-exports.test_LoadTwoAnimationsWithTheSameName = function () {
+}
+
+export function test_LoadTwoAnimationsWithTheSameName() {
let scope = new styleScope.StyleScope();
scope.css = "@keyframes a1 { from { opacity: 0; } to { opacity: 1; } } @keyframes a1 { from { opacity: 0; } to { opacity: 0.5; } } .a { animation-name: a1; }";
scope.ensureSelectors();
@@ -217,8 +230,9 @@ exports.test_LoadTwoAnimationsWithTheSameName = function () {
selector = findSelectorInScope(scope, "a");
TKUnit.assertEqual(selector.animations[0].keyframes.length, 2);
TKUnit.assertEqual(selector.animations[0].keyframes.length, 2);
-};
-exports.test_LoadAnimationProgrammatically = function () {
+}
+
+export function test_LoadAnimationProgrammatically() {
let stack = new stackModule.StackLayout();
helper.buildUIAndRunTest(stack, function (views) {
let page = views[1];
@@ -228,54 +242,54 @@ exports.test_LoadAnimationProgrammatically = function () {
TKUnit.assertEqual(animation.keyframes[1].declarations[0].property, "opacity");
TKUnit.assertEqual(animation.keyframes[1].declarations[0].value, 0);
});
-};
-exports.test_ExecuteCSSAnimation = function () {
- let mainPage;
- let label;
- let pageFactory = function () {
- label = new labelModule.Label();
- label.text = "label";
- let stackLayout = new stackModule.StackLayout();
- stackLayout.addChild(label);
- mainPage = new page.Page();
- mainPage.css = "@keyframes k { from { background-color: red; } to { background-color: green; } } .l { animation-name: k; animation-duration: 0.5s; animation-fill-mode: forwards; }";
- mainPage.content = stackLayout;
- return mainPage;
- };
- helper.navigate(pageFactory);
- TKUnit.waitUntilReady(function () { return label.isLoaded; });
+}
+
+export function test_ExecuteCSSAnimation() {
+ let mainPage = helper.getCurrentPage();
+ mainPage.css = null;
+ let label = new labelModule.Label({ text: "label" });
+ let stackLayout = new stackModule.StackLayout();
+ stackLayout.addChild(label);
+
+ mainPage.css = "@keyframes k { from { background-color: red; } to { background-color: green; } } .l { animation-name: k; animation-duration: 0.1s; animation-fill-mode: forwards; }";
+ mainPage.content = stackLayout;
+
+ TKUnit.waitUntilReady(() => label.isLoaded);
label.className = "l";
- TKUnit.waitUntilReady(function () { return new color.Color("green").equals(label.backgroundColor); }, 1);
- TKUnit.assert(new color.Color("green").equals(label.backgroundColor));
-};
-// exports.test_ExecuteFillMode = function () {
-// let mainPage;
-// let label;
-// let pageFactory = function () {
-// label = new labelModule.Label();
-// label.text = "label";
-// let stackLayout = new stackModule.StackLayout();
-// stackLayout.addChild(label);
-// mainPage = new page.Page();
-// mainPage.css = "@keyframes k { from { background-color: red; } to { background-color: green; } } " +
-// ".l { animation-name: k; animation-duration: 0.5s; animation-fill-mode: none; } " +
-// ".l2 { animation-name: k; animation-duration: 0.5s; animation-fill-mode: forwards; }";
-// mainPage.content = stackLayout;
-// return mainPage;
-// };
-// helper.navigate(pageFactory);
-// TKUnit.waitUntilReady(function () { return label.isLoaded; });
-// TKUnit.assertEqual(label.backgroundColor, undefined);
-// label.className = "l";
-// TKUnit.wait(2);
-// TKUnit.assertEqual(label.backgroundColor, undefined);
-// label.className = "l2";
-// TKUnit.waitUntilReady(function() { return new color.Color("green").equals(label.backgroundColor); }, 1);
-// TKUnit.assert(new color.Color("green").equals(label.backgroundColor));
-// helper.goBack();
-// helper.goBack();
-// };
-exports.test_ReadTwoAnimations = function () {
+ let green = new color.Color("green");
+ TKUnit.waitUntilReady(() => green.equals(label.backgroundColor), 1);
+ TKUnit.assertEqual(label.backgroundColor, green);
+}
+
+//export function test_ExecuteFillMode() {
+// let mainPage = helper.getCurrentPage();
+// mainPage.style._resetValue(styling.properties.backgroundColorProperty);
+// mainPage.style._resetValue(styling.properties.colorProperty);
+// mainPage._resetValue(labelModule.Label.bindingContextProperty);
+// mainPage._resetValue(labelModule.Label.cssClassProperty);
+// mainPage._resetValue(labelModule.Label.idProperty);
+// mainPage.css = null;
+
+// let label = new labelModule.Label({ text: "label" });
+// let stackLayout = new stackModule.StackLayout();
+// stackLayout.addChild(label);
+// mainPage.css = "@keyframes k { from { background-color: red; } to { background-color: green; } } " +
+// ".l { animation-name: k; animation-duration: 0.5s; animation-fill-mode: none; } " +
+// ".l2 { animation-name: k; animation-duration: 0.5s; animation-fill-mode: forwards; }";
+// mainPage.content = stackLayout;
+
+// TKUnit.waitUntilReady(() => label.isLoaded);
+
+// TKUnit.assertEqual(label.backgroundColor, undefined, "label.backgroundColor should be undefind");
+
+// label.className = "l";
+// TKUnit.assertEqual(label.backgroundColor, undefined, "label.backgroundColor should be undefind");
+
+// label.className = "l2";
+// TKUnit.assertEqual(label.backgroundColor, new color.Color("green"));
+//}
+
+export function test_ReadTwoAnimations() {
let scope = new styleScope.StyleScope();
scope.css = ".test { animation: one 0.2s ease-out 1 2, two 2s ease-in; }";
scope.ensureSelectors();
@@ -285,8 +299,9 @@ exports.test_ReadTwoAnimations = function () {
TKUnit.assertEqual(selector.animations[1].curve, enums.AnimationCurve.easeIn);
TKUnit.assertEqual(selector.animations[1].name, "two");
TKUnit.assertEqual(selector.animations[1].duration, 2000);
-};
-exports.test_AnimationCurveInKeyframes = function () {
+}
+
+export function test_AnimationCurveInKeyframes() {
let scope = new styleScope.StyleScope();
scope.css = "@keyframes an { from { animation-timing-function: linear; background-color: red; } 50% { background-color: green; } to { background-color: black; } } .test { animation-name: an; animation-timing-function: ease-in; }";
scope.ensureSelectors();
@@ -298,4 +313,4 @@ exports.test_AnimationCurveInKeyframes = function () {
let realAnimation = keyframeAnimation.KeyframeAnimation.keyframeAnimationFromInfo(animation, 2);
TKUnit.assertEqual(realAnimation.animations[1].curve, enums.AnimationCurve.linear);
TKUnit.assertEqual(realAnimation.animations[2].curve, enums.AnimationCurve.easeIn);
-};
+}
\ No newline at end of file
diff --git a/apps/tests/ui/bindable-tests.ts b/apps/tests/ui/bindable-tests.ts
index 3af9b5712..338078102 100644
--- a/apps/tests/ui/bindable-tests.ts
+++ b/apps/tests/ui/bindable-tests.ts
@@ -917,7 +917,7 @@ export function test_BindingContextOfAChildElementIsNotOverwrittenBySettingTheBi
});
page.content = child;
- TKUnit.waitUntilReady(() => { return testFinished });
+ TKUnit.waitUntilReady(() => testFinished);
}
export var test_BindingHitsGetterTooManyTimes = function () {
diff --git a/apps/tests/ui/helper.ts b/apps/tests/ui/helper.ts
index 8e1fdbb7a..b1e0fde4e 100644
--- a/apps/tests/ui/helper.ts
+++ b/apps/tests/ui/helper.ts
@@ -109,7 +109,8 @@ export function buildUIWithWeakRefAndInteract(createFunc: (
newPage.content = sp;
- TKUnit.waitUntilReady(() => { return testFinished; }, MEMORY_ASYNC);
+ TKUnit.waitUntilReady(() => testFinished, MEMORY_ASYNC);
+ TKUnit.assertTrue(testFinished, "Test did not completed.")
done(null);
}
diff --git a/apps/tests/ui/page/page-tests-common.ts b/apps/tests/ui/page/page-tests-common.ts
index 7573729cf..effd343e6 100644
--- a/apps/tests/ui/page/page-tests-common.ts
+++ b/apps/tests/ui/page/page-tests-common.ts
@@ -471,11 +471,17 @@ export function test_WhenPageIsNavigatedToItCanShowAnotherPageAsModal() {
let page = args.object;
TKUnit.assertNull(page.modal, "currentPage.modal should be undefined when no modal page is shown!");
let basePath = "ui/page/";
- modalPage = page.showModal(basePath + "modal-page", ctx, modalCloseCallback, false);
- TKUnit.assertTrue((modalPage).showingModally, "showingModally");
+ let entry: frameModule.NavigationEntry = {
+ moduleName: basePath + "modal-page"
+ };
+
+ modalPage = frameModule.resolvePageFromEntry(entry);
modalPage.on(Page.shownModallyEvent, onShownModal);
modalPage.on(Page.loadedEvent, onModalLoaded);
modalPage.on(Page.unloadedEvent, onModalUnloaded);
+
+ page.showModal(modalPage, ctx, modalCloseCallback, false);
+ TKUnit.assertTrue((modalPage).showingModally, "showingModally");
};
var masterPageFactory = function (): Page {
diff --git a/apps/tests/ui/page/page-tests.ios.ts b/apps/tests/ui/page/page-tests.ios.ts
index ec65f5c36..9c296cdf5 100644
--- a/apps/tests/ui/page/page-tests.ios.ts
+++ b/apps/tests/ui/page/page-tests.ios.ts
@@ -77,8 +77,8 @@ export function test_page_no_anctionBar_measure_no_spanUnderBackground_measure_l
let lbl = new Label();
page.content = lbl;
- helper.navigate(() => { return page; });
- TKUnit.waitUntilReady(() => { return page.isLayoutValid; });
+ helper.navigate(() => page);
+ TKUnit.waitUntilReady(() => page.isLayoutValid);
TKUnit.assertTrue(page.isLoaded, "page NOT loaded!");
let bounds = page._getCurrentLayoutBounds();
@@ -92,7 +92,7 @@ export function test_page_no_anctionBar_measure_no_spanUnderBackground_measure_l
TKUnit.assertEqual(contentHeight, frameHeight - statusBarHeight, "Page.content height should match Frame height - statusBar height.");
page.backgroundSpanUnderStatusBar = false;
- TKUnit.waitUntilReady(() => { return page.isLayoutValid; });
+ TKUnit.waitUntilReady(() => page.isLayoutValid);
pageHeight = page._getCurrentLayoutBounds().bottom - page._getCurrentLayoutBounds().top;
TKUnit.assertEqual(pageHeight, frameHeight - statusBarHeight, "Page should be given Frame height - statusBar height.");
@@ -100,7 +100,7 @@ export function test_page_no_anctionBar_measure_no_spanUnderBackground_measure_l
TKUnit.assertEqual(contentHeight, pageHeight, "Page.content height should match Page height.");
page.actionBarHidden = false;
- TKUnit.waitUntilReady(() => { return page.isLayoutValid; });
+ TKUnit.waitUntilReady(() => page.isLayoutValid);
pageHeight = page._getCurrentLayoutBounds().bottom - page._getCurrentLayoutBounds().top;
TKUnit.assertEqual(pageHeight, frameHeight - statusBarHeight, "Page should be given Frame height - statusBar height.");
diff --git a/apps/tests/ui/repeater/repeater-tests.ts b/apps/tests/ui/repeater/repeater-tests.ts
index fafd11e7e..33da39ed3 100644
--- a/apps/tests/ui/repeater/repeater-tests.ts
+++ b/apps/tests/ui/repeater/repeater-tests.ts
@@ -37,7 +37,7 @@ export function test_set_items_to_array_loads_all_items() {
repeater.items = colors;
// << article-repeater-with-array
- TKUnit.wait(ASYNC);
+ TKUnit.waitUntilReady(() => repeater.isLayoutValid);
TKUnit.assert(getChildAtText(repeater, 0) === "red", "Item not created for index 0");
TKUnit.assert(getChildAtText(repeater, 1) === "green", "Item not created for index 1");
@@ -53,7 +53,7 @@ export function test_set_items_to_array_creates_views() {
function testAction(views: Array) {
repeater.items = FEW_ITEMS;
- TKUnit.wait(ASYNC);
+ TKUnit.waitUntilReady(() => repeater.isLayoutValid);
TKUnit.assertEqual(getChildrenCount(repeater), FEW_ITEMS.length, "views count.");
};
@@ -68,7 +68,7 @@ export function test_refresh_after_adding_items_to_array_loads_new_items() {
var colors = ["red", "green", "blue"];
repeater.items = colors;
- TKUnit.wait(ASYNC);
+ TKUnit.waitUntilReady(() => repeater.isLayoutValid);
TKUnit.assertEqual(getChildrenCount(repeater), colors.length, "views count.");
// >> artcle-array-push-element
colors.push("yellow");
@@ -92,7 +92,7 @@ export function test_refresh_reloads_all_items() {
repeater.items = itemsToBind;
- TKUnit.wait(ASYNC);
+ TKUnit.waitUntilReady(() => repeater.isLayoutValid);
testStarted = true;
itemsToBind[0] = "red";
@@ -101,7 +101,7 @@ export function test_refresh_reloads_all_items() {
repeater.refresh();
- TKUnit.wait(ASYNC);
+ TKUnit.waitUntilReady(() => repeater.isLayoutValid);
TKUnit.assert(getChildAtText(repeater, 0) === "red", "Item not created for index 0");
TKUnit.assert(getChildAtText(repeater, 1) === "green", "Item not created for index 1");
@@ -116,11 +116,11 @@ export function test_set_itmes_to_null_clears_items() {
function testAction(views: Array) {
repeater.items = FEW_ITEMS;
- TKUnit.wait(ASYNC);
+ TKUnit.waitUntilReady(() => repeater.isLayoutValid);
TKUnit.assertEqual(getChildrenCount(repeater), FEW_ITEMS.length, "views count.");
repeater.items = null;
- TKUnit.wait(ASYNC);
+ TKUnit.waitUntilReady(() => repeater.isLayoutValid);
TKUnit.assertEqual(getChildrenCount(repeater), 0, "views count.");
};
@@ -138,7 +138,7 @@ export function test_set_itemsLayout_accepted() {
function testAction(views: Array) {
repeater.items = FEW_ITEMS;
- TKUnit.wait(ASYNC);
+ TKUnit.waitUntilReady(() => repeater.isLayoutValid);
TKUnit.assert((repeater.itemsLayout).orientation === "horizontal", "views count.");
TKUnit.assertEqual(getChildrenCount(repeater), FEW_ITEMS.length, "views count.");
};
@@ -151,11 +151,11 @@ export function test_set_itmes_to_undefiend_clears_items() {
function testAction(views: Array) {
repeater.items = FEW_ITEMS;
- TKUnit.wait(ASYNC);
+ TKUnit.waitUntilReady(() => repeater.isLayoutValid);
TKUnit.assertEqual(getChildrenCount(repeater), FEW_ITEMS.length, "views count.");
repeater.items = undefined;
- TKUnit.wait(ASYNC);
+ TKUnit.waitUntilReady(() => repeater.isLayoutValid);
TKUnit.assertEqual(getChildrenCount(repeater), 0, "views count.");
};
@@ -167,11 +167,11 @@ export function test_set_itmes_to_different_source_loads_new_items() {
function testAction(views: Array) {
repeater.items = [1, 2, 3];
- TKUnit.wait(ASYNC);
+ TKUnit.waitUntilReady(() => repeater.isLayoutValid);
TKUnit.assertEqual(getChildrenCount(repeater), 3, "views count.");
repeater.items = ["a", "b", "c", "d"];
- TKUnit.wait(ASYNC);
+ TKUnit.waitUntilReady(() => repeater.isLayoutValid);
TKUnit.assertEqual(getChildrenCount(repeater), 4, "views count.");
};
@@ -187,6 +187,7 @@ export function test_set_items_to_observable_array_loads_all_items() {
repeater.items = colors;
// << article-repeater-observablearray
+ TKUnit.waitUntilReady(() => repeater.isLayoutValid);
TKUnit.assert(getChildAtText(repeater, 0) === "red", "Item not created for index 0");
TKUnit.assert(getChildAtText(repeater, 1) === "green", "Item not created for index 1");
TKUnit.assert(getChildAtText(repeater, 2) === "blue", "Item not created for index 2");
@@ -202,7 +203,7 @@ export function test_add_to_observable_array_refreshes_the_Repeater() {
var colors = new observableArray.ObservableArray(["red", "green", "blue"]);
repeater.items = colors;
- TKUnit.wait(ASYNC);
+ TKUnit.waitUntilReady(() => repeater.isLayoutValid);
TKUnit.assertEqual(getChildrenCount(repeater), 3, "getChildrenCount");
// >> article-push-to-observablearray
@@ -210,6 +211,7 @@ export function test_add_to_observable_array_refreshes_the_Repeater() {
//// The Repeater will be updated automatically.
// << article-push-to-observablearray
TKUnit.wait(ASYNC);
+ TKUnit.waitUntilReady(() => repeater.isLayoutValid);
TKUnit.assertEqual(getChildrenCount(repeater), 4, "getChildrenCount");
};
@@ -224,11 +226,11 @@ export function test_remove_from_observable_array_refreshes_the_Repeater() {
function testAction(views: Array) {
repeater.items = data;
- TKUnit.wait(ASYNC);
+ TKUnit.waitUntilReady(() => repeater.isLayoutValid);
TKUnit.assertEqual(getChildrenCount(repeater), 3, "getChildrenCount");
data.pop();
- TKUnit.wait(ASYNC);
+ TKUnit.waitUntilReady(() => repeater.isLayoutValid);
TKUnit.assertEqual(getChildrenCount(repeater), 2, "getChildrenCount");
};
@@ -243,12 +245,12 @@ export function test_splice_observable_array_refreshes_the_Repeater() {
function testAction(views: Array) {
repeater.items = data;
- TKUnit.wait(ASYNC);
+ TKUnit.waitUntilReady(() => repeater.isLayoutValid);
TKUnit.assertEqual(getChildrenCount(repeater), 3, "getChildrenCount");
// Remove the first 2 elements and add
data.splice(0, 2, "d", "e", "f");
- TKUnit.wait(ASYNC);
+ TKUnit.waitUntilReady(() => repeater.isLayoutValid);
TKUnit.assertEqual(getChildrenCount(repeater), 4, "getChildrenCount");
};
@@ -279,7 +281,7 @@ export function test_usingAppLevelConvertersInRepeaterItems() {
repeater.itemTemplate = "";
repeater.items = data;
- TKUnit.wait(ASYNC);
+ TKUnit.waitUntilReady(() => repeater.isLayoutValid);
TKUnit.assertEqual(getChildAtText(repeater, 0), dateConverter(new Date(), "DD.MM.YYYY"), "element");
};
@@ -294,7 +296,7 @@ export function test_BindingRepeaterToASimpleArray() {
repeater.itemTemplate = "";
repeater.items = [1, 2, 3];
- TKUnit.wait(ASYNC);
+ TKUnit.waitUntilReady(() => repeater.isLayoutValid);
TKUnit.assertEqual(getChildAtText(repeater, 0), "1", "first element text");
TKUnit.assertEqual(getChildAtText(repeater, 1), "2", "second element text");
@@ -316,7 +318,7 @@ export function test_ItemTemplateFactoryFunction() {
}
repeater.items = [1, 2, 3];
- TKUnit.wait(ASYNC);
+ TKUnit.waitUntilReady(() => repeater.isLayoutValid);
TKUnit.assertEqual(getChildAtText(repeater, 0), "1", "first element text");
TKUnit.assertEqual(getChildAtText(repeater, 1), "2", "second element text");
@@ -333,7 +335,7 @@ export function test_BindingRepeaterToASimpleArrayWithExpression() {
repeater.itemTemplate = "";
repeater.items = [1, 2, 3];
- TKUnit.wait(ASYNC);
+ TKUnit.waitUntilReady(() => repeater.isLayoutValid);
TKUnit.assertEqual(getChildAtText(repeater, 0), "1 some static text", "first element text");
TKUnit.assertEqual(getChildAtText(repeater, 1), "2 some static text", "second element text");
@@ -407,7 +409,7 @@ export function test_ChildrenAreNotCreatedUntilTheRepeaterIsLoaded() {
TKUnit.assertEqual(getChildrenCount(repeater), 0, "Repeater should not create its children until loaded.");
function testAction(views: Array) {
- TKUnit.waitUntilReady(() => repeater.isLoaded);
+ TKUnit.waitUntilReady(() => repeater.isLayoutValid);
TKUnit.assertEqual(getChildrenCount(repeater), 3, "Repeater should have created its children when loaded.");
}
diff --git a/apps/tests/ui/tab-view/tab-view-navigation-tests.ts b/apps/tests/ui/tab-view/tab-view-navigation-tests.ts
index 0240ceade..28b6ad7ab 100644
--- a/apps/tests/ui/tab-view/tab-view-navigation-tests.ts
+++ b/apps/tests/ui/tab-view/tab-view-navigation-tests.ts
@@ -53,7 +53,7 @@ function _createListView(): ListView {
return listView;
}
-var _clickHandlerFactory = function (index: number) {
+function _clickHandlerFactory(index: number) {
return function () {
var pageFactory = function (): Page {
var detailsLabel = new Label();
@@ -64,30 +64,33 @@ var _clickHandlerFactory = function (index: number) {
return detailsPage;
};
- helper.navigate(pageFactory);
+ helper.navigateWithHistory(pageFactory);
}
}
export function testWhenNavigatingBackToANonCachedPageContainingATabViewWithAListViewTheListViewIsThere() {
var topFrame = frameModule.topmost();
- var oldChache;
+ let oldChache;
if (topFrame.android) {
oldChache = topFrame.android.cachePagesOnNavigate;
topFrame.android.cachePagesOnNavigate = true;
}
- var tabView;
- var pageFactory = function (): Page {
+ let tabViewPage: Page;
+ let tabView: TabView;
+
+ let pageFactory = function (): Page {
tabView = _createTabView();
- var items = [];
+ let items = [];
items.push({
title: "List",
view: _createListView()
});
- var label = new Label();
+
+ let label = new Label();
label.text = "About";
- var aboutLayout = new StackLayout();
+ let aboutLayout = new StackLayout();
aboutLayout.id = "AboutLayout";
aboutLayout.addChild(label);
items.push({
@@ -96,27 +99,29 @@ export function testWhenNavigatingBackToANonCachedPageContainingATabViewWithALis
});
tabView.items = items;
- var tabViewPage = new Page();
+ tabViewPage = new Page();
tabViewPage.id = "tab-view-page";
tabViewPage.content = tabView;
return tabViewPage;
}
+ let rootPage = helper.getCurrentPage();
+
helper.navigateWithHistory(pageFactory);
- TKUnit.waitUntilReady(() => topFrame.currentPage.id === "tab-view-page", ASYNC);
- TKUnit.waitUntilReady(() => tabViewIsFullyLoaded(tabView), ASYNC);
+ TKUnit.waitUntilReady(() => topFrame.currentPage === tabViewPage);
+ TKUnit.waitUntilReady(() => tabViewIsFullyLoaded(tabView));
// This will navigate to a details page. The wait is inside the method.
_clickTheFirstButtonInTheListViewNatively(tabView);
- TKUnit.waitUntilReady(() => { return topFrame.currentPage.id === "details-page" }, ASYNC);
+ TKUnit.waitUntilReady(() => topFrame.currentPage.id === "details-page");
frameModule.goBack();
- TKUnit.waitUntilReady(() => { return topFrame.currentPage.id === "tab-view-page" }, ASYNC);
- TKUnit.waitUntilReady(() => { return tabViewIsFullyLoaded(tabView) }, ASYNC);
+ TKUnit.waitUntilReady(() => topFrame.currentPage === tabViewPage);
+ TKUnit.waitUntilReady(() => tabViewIsFullyLoaded(tabView));
frameModule.goBack();
- TKUnit.waitUntilReady(() => { return topFrame.currentPage.id === "mainPage" }, ASYNC);
+ TKUnit.waitUntilReady(() => topFrame.currentPage === rootPage);
if (topFrame.android) {
topFrame.android.cachePagesOnNavigate = oldChache;
@@ -155,31 +160,31 @@ function tabViewIsFullyLoaded(tabView: TabView): boolean {
}
function testLoadedAndUnloadedAreFired_WhenNavigatingAwayAndBack(enablePageCache: boolean) {
- var topFrame = frameModule.topmost();
- topFrame.currentPage.id = "mainPage";
+ let topFrame = frameModule.topmost();
+ let rootPage = helper.getCurrentPage();
- var oldChache;
+ let oldChache;
if (topFrame.android) {
oldChache = topFrame.android.cachePagesOnNavigate;
topFrame.android.cachePagesOnNavigate = enablePageCache;
}
- var i: number;
- var itemCount = 2;
- var loadedEventsCount = [0, 0];
- var unloadedEventsCount = [0, 0];
+ let itemCount = 2;
+ let loadedEventsCount = [0, 0];
+ let unloadedEventsCount = [0, 0];
- var tabView = _createTabView();
+ let tabView = _createTabView();
tabView.items = _createItems(itemCount);
- helper.navigate(() => {
- var tabViewPage = new Page();
- tabViewPage.id = "tab-view-page";
+ let tabViewPage: Page;
+ helper.navigateWithHistory(() => {
+ tabViewPage = new Page();
tabViewPage.content = tabView;
return tabViewPage;
});
- TKUnit.waitUntilReady(() => { return topFrame.currentPage.id === "tab-view-page" }, ASYNC);
- TKUnit.waitUntilReady(() => { return tabViewIsFullyLoaded(tabView) }, ASYNC);
+
+ TKUnit.waitUntilReady(() => topFrame.currentPage === tabViewPage, ASYNC);
+ TKUnit.waitUntilReady(() => tabViewIsFullyLoaded(tabView), ASYNC);
function createLoadedFor(tabIndex: number) {
return function () {
@@ -193,13 +198,12 @@ function testLoadedAndUnloadedAreFired_WhenNavigatingAwayAndBack(enablePageCache
}
}
- for (i = 0; i < itemCount; i++) {
+ for (let i = 0; i < itemCount; i++) {
tabView.items[i].view.on("loaded", createLoadedFor(i));
tabView.items[i].view.on("unloaded", createUnloadedFor(i));
}
- var detailsPage = new Page();
- detailsPage.id = "details-page";
+ let detailsPage = new Page();
let createFunc = () => {
return detailsPage;
@@ -208,20 +212,20 @@ function testLoadedAndUnloadedAreFired_WhenNavigatingAwayAndBack(enablePageCache
let entry: frameModule.NavigationEntry = { create: createFunc, animated: false };
topFrame.navigate(entry);
- TKUnit.waitUntilReady(() => { return topFrame.currentPage.id === "details-page" }, ASYNC);
+ TKUnit.waitUntilReady(() => topFrame.currentPage === detailsPage);
topFrame.goBack();
- TKUnit.waitUntilReady(() => { return topFrame.currentPage.id === "tab-view-page" }, ASYNC);
- TKUnit.waitUntilReady(() => { return tabViewIsFullyLoaded(tabView) }, ASYNC);
+ TKUnit.waitUntilReady(() => topFrame.currentPage === tabViewPage);
+ TKUnit.waitUntilReady(() => tabViewIsFullyLoaded(tabView));
- for (i = 0; i < itemCount; i++) {
+ for (let i = 0; i < itemCount; i++) {
tabView.items[i].view.off("loaded");
tabView.items[i].view.off("unloaded");
}
topFrame.goBack();
- TKUnit.waitUntilReady(() => { return topFrame.currentPage.id === "mainPage" }, ASYNC);
+ TKUnit.waitUntilReady(() => topFrame.currentPage === rootPage);
if (topFrame.android) {
topFrame.android.cachePagesOnNavigate = oldChache;
diff --git a/apps/tests/ui/view/view-tests-common.ts b/apps/tests/ui/view/view-tests-common.ts
index 2691ce7dd..7604ba6e5 100644
--- a/apps/tests/ui/view/view-tests-common.ts
+++ b/apps/tests/ui/view/view-tests-common.ts
@@ -740,8 +740,7 @@ export var test_getLocationRelativeToOtherView = function () {
a1.addChild(a2);
helper.buildUIAndRunTest(a1, function (views: Array) {
- frame.topmost().requestLayout();
- TKUnit.wait(0.1);
+ TKUnit.waitUntilReady(() => a1.isLayoutValid);
var labelInA2 = label.getLocationRelativeTo(a2);
var labelInA1 = label.getLocationRelativeTo(a1);
@@ -763,8 +762,7 @@ export var test_getActualSize = function () {
label.width = 100;
label.height = 200;
helper.buildUIAndRunTest(label, function (views: Array) {
- frame.topmost().requestLayout();
- TKUnit.wait(0.1);
+ TKUnit.waitUntilReady(() => label.isLayoutValid);
var actualSize = label.getActualSize();
TKUnit.assertAreClose(actualSize.width, 100, delta, "actualSize.width");
TKUnit.assertAreClose(actualSize.height, 200, delta, "actualSize.height");
diff --git a/apps/tests/weak-event-listener-tests.ts b/apps/tests/weak-event-listener-tests.ts
index 7d8949948..4da490026 100644
--- a/apps/tests/weak-event-listener-tests.ts
+++ b/apps/tests/weak-event-listener-tests.ts
@@ -8,7 +8,6 @@ class Target {
public onEvent(data: observable.EventData) {
this.counter++;
}
-
}
export function test_addWeakEventListener_throwsWhenCalledwitnInvalid_source() {
@@ -45,8 +44,6 @@ export function test_addWeakEventListener_listensForEvent() {
target.onEvent,
target);
- helper.forceGC();
-
source.set("testProp", "some value");
TKUnit.assertEqual(target.counter, 1, "Handler not called.");
@@ -60,8 +57,6 @@ export function test_addWeakEventListener_listensForEven_multipleTargetst() {
weakEvents.addWeakEventListener(source, observable.Observable.propertyChangeEvent, target1.onEvent, target1);
weakEvents.addWeakEventListener(source, observable.Observable.propertyChangeEvent, target2.onEvent, target2);
- helper.forceGC();
-
source.set("testProp", "some value");
TKUnit.assertEqual(target1.counter, 1, "Handler not called.");
diff --git a/apps/tests/xml-declaration/xml-declaration-tests.ts b/apps/tests/xml-declaration/xml-declaration-tests.ts
index 77a270e3c..949c758bf 100644
--- a/apps/tests/xml-declaration/xml-declaration-tests.ts
+++ b/apps/tests/xml-declaration/xml-declaration-tests.ts
@@ -179,8 +179,7 @@ export function test_parse_ShouldResolveExportsFromCodeFileForTemplates() {
});
p.bindingContext = obj;
- TKUnit.wait(0.2);
-
+ TKUnit.waitUntilReady(() => ctrl !== null);
TKUnit.assert((ctrl).customCodeLoaded, "Parse should resolve exports for templates from custom code file.");
};
@@ -640,9 +639,7 @@ export function test_parse_NestedRepeaters() {
function testAction(views: Array) {
p.bindingContext = [["0", "1"], ["2", "3"]];
- TKUnit.wait(0.2);
-
- var lbls = new Array');
function testAction(views: Array) {
- var tab: TabView = p.content;
-
- TKUnit.wait(0.2);
-
+ let tab: TabView = p.content;
TKUnit.assertEqual(tab.selectedIndex, 1);
};
diff --git a/apps/ui-tests-app/css/letter-spacing.xml b/apps/ui-tests-app/css/letter-spacing.xml
index d1572b6b5..d0fd08e60 100644
--- a/apps/ui-tests-app/css/letter-spacing.xml
+++ b/apps/ui-tests-app/css/letter-spacing.xml
@@ -1,8 +1,14 @@
-
-
+
+
+
+
+
+
+
+
@@ -13,9 +19,15 @@
-
-
-
+
-
-
-
+
+
+
+
+
+
+
+
+
@@ -39,11 +57,17 @@
-
+
-
-
-
+
+
+
+
+
+
+
+
+
@@ -53,7 +77,7 @@
-
+
\ No newline at end of file
diff --git a/apps/ui-tests-app/css/text-decoration.ts b/apps/ui-tests-app/css/text-decoration.ts
index a1870be63..3304b372e 100644
--- a/apps/ui-tests-app/css/text-decoration.ts
+++ b/apps/ui-tests-app/css/text-decoration.ts
@@ -50,5 +50,11 @@ export function butonTap(args) {
btn.style.textDecoration = "none";
textField.style.textDecoration = "none";
textView.style.textDecoration = "none";
+
+ if(lbl.text === "Change text") {
+ lbl.text = btn.text = textField.text = textView.text = "Text changed";
+ } else {
+ lbl.text = btn.text = textField.text = textView.text = "Change text";
+ }
}
}
diff --git a/apps/ui-tests-app/css/text-decoration.xml b/apps/ui-tests-app/css/text-decoration.xml
index c3d6e6308..9de343b28 100644
--- a/apps/ui-tests-app/css/text-decoration.xml
+++ b/apps/ui-tests-app/css/text-decoration.xml
@@ -1,6 +1,6 @@
-
+
diff --git a/apps/ui-tests-app/mainPage.ts b/apps/ui-tests-app/mainPage.ts
index 1f71d2414..786cb986c 100644
--- a/apps/ui-tests-app/mainPage.ts
+++ b/apps/ui-tests-app/mainPage.ts
@@ -38,6 +38,7 @@ examples.set("xmlbasics", "bindings/xmlbasics");
examples.set("background", "css/background");
examples.set("formatted", "css/decoration-transform-formattedtext");
+examples.set("spacing", "css/letter-spacing");
examples.set("decoration", "css/text-decoration");
examples.set("transform", "css/text-transform");
examples.set("whitespace", "css/white-space");
diff --git a/apps/ui-tests-app/tab-view/nowrap.xml b/apps/ui-tests-app/tab-view/nowrap.xml
new file mode 100644
index 000000000..d64f1c16a
--- /dev/null
+++ b/apps/ui-tests-app/tab-view/nowrap.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/apps/ui-tests-app/time-picker/time-picker.xml b/apps/ui-tests-app/time-picker/time-picker.xml
new file mode 100644
index 000000000..a69da67ee
--- /dev/null
+++ b/apps/ui-tests-app/time-picker/time-picker.xml
@@ -0,0 +1,3 @@
+
+
+
\ No newline at end of file
diff --git a/build/run-testsapp.grunt.js b/build/run-testsapp.grunt.js
index b389589be..7ffd381dc 100644
--- a/build/run-testsapp.grunt.js
+++ b/build/run-testsapp.grunt.js
@@ -115,8 +115,8 @@ module.exports = {
},
addAndroidPermissions: {
src: "AndroidManifest.xml",
- dest: localCfg.applicationDir + "/platforms/android/src/main/",
- cwd: localCfg.applicationDir + "/platforms/android/src/main",
+ dest: localCfg.applicationDir + "/app/App_Resources/Android/",
+ cwd: localCfg.applicationDir + "/app/App_Resources/Android",
expand: true,
options: {
process: function(content, srcPath) {
diff --git a/build/travis-scripts/add-publishConfig.js b/build/travis-scripts/add-publishConfig.js
new file mode 100755
index 000000000..742487a99
--- /dev/null
+++ b/build/travis-scripts/add-publishConfig.js
@@ -0,0 +1,25 @@
+#!/usr/bin/env node
+
+var fsModule = require('fs');
+
+//Adds a publishConfig section to the package.json file
+// and sets a tag to it
+
+var path = './package.json';
+var fileOptions = {encoding: "utf-8"};
+var content = fsModule.readFileSync(path, fileOptions);
+
+var tag = process.argv[2];
+if (!tag) {
+ console.log('Please pass the tag name as an argument!');
+ process.exit(1);
+}
+
+var packageDef = JSON.parse(content);
+if (!packageDef.publishConfig) {
+ packageDef.publishConfig = {};
+}
+packageDef.publishConfig.tag = tag;
+
+var newContent = JSON.stringify(packageDef, null, ' ');
+fsModule.writeFileSync(path, newContent, fileOptions);
diff --git a/build/travis-scripts/check-testrun-broken.js b/build/travis-scripts/check-testrun-broken.js
index 47e5999a4..a19fbe3c4 100755
--- a/build/travis-scripts/check-testrun-broken.js
+++ b/build/travis-scripts/check-testrun-broken.js
@@ -1,7 +1,7 @@
#!/usr/bin/env node
var fsModule = require('fs');
var resultsFile = 'TestRunResult.txt';
-var successMarker ='=== ALL TESTS COMPLETE ===';
+var successMarker = /=== ALL TESTS COMPLETE ===/;
var passMarker = /=== ALL TESTS COMPLETE ===\s+[^\n]*OK,\s+0\s+failed/mg;
var messages = {
@@ -13,7 +13,7 @@ var messages = {
var results = fsModule.readFileSync(resultsFile, 'utf-8');
-if (results.indexOf(successMarker) == -1) {
+if (!results.match(successMarker)) {
console.log(messages.crash);
process.exit(1);
} else if (results.match(passMarker)) {
diff --git a/file-system/file-system-access.android.ts b/file-system/file-system-access.android.ts
index 0b74fea65..7e3c6eded 100644
--- a/file-system/file-system-access.android.ts
+++ b/file-system/file-system-access.android.ts
@@ -327,6 +327,7 @@ export class FileSystemAccess {
if (isFolder) {
created = javaFile.mkdirs();
} else {
+ javaFile.getParentFile().mkdirs();
created = javaFile.createNewFile();
}
diff --git a/file-system/file-system-access.ios.ts b/file-system/file-system-access.ios.ts
index b12bf0aff..7e796fcd6 100644
--- a/file-system/file-system-access.ios.ts
+++ b/file-system/file-system-access.ios.ts
@@ -52,11 +52,12 @@ export class FileSystemAccess {
var exists = fileManager.fileExistsAtPath(path);
if (!exists) {
- if (!fileManager.createFileAtPathContentsAttributes(path, null, null)) {
+ var parentPath = this.getParent(path, onError).path;
+ if (!fileManager.createDirectoryAtPathWithIntermediateDirectoriesAttributesError(parentPath, true, null) ||
+ !fileManager.createFileAtPathContentsAttributes(path, null, null)) {
if (onError) {
- onError(new Error("Failed to create folder at path '" + path + "'"));
+ onError(new Error("Failed to create file at path '" + path + "'"));
}
-
return undefined;
}
}
@@ -406,4 +407,4 @@ export class FileSystemAccess {
var nsString = NSString.stringWithString(NSString.pathWithComponents(nsArray));
return nsString.stringByStandardizingPath;
}
-}
\ No newline at end of file
+}
diff --git a/timer/timer.ios.ts b/timer/timer.ios.ts
index d97d4fc04..fbd938573 100644
--- a/timer/timer.ios.ts
+++ b/timer/timer.ios.ts
@@ -1,23 +1,42 @@
/**
* iOS specific timer functions implementation.
*/
-var timeoutCallbacks = {};
+var timeoutCallbacks = new Map>();
var timerId = 0;
+interface KeyValuePair {
+ k: K;
+ v: V
+}
+
class TimerTargetImpl extends NSObject {
- static new(): TimerTargetImpl {
- return super.new();
- }
-
private _callback: Function;
+ public canceled = false;
+ private id: number
+ private shouldRepeat: boolean
- public initWithCallback(callback: Function): TimerTargetImpl {
- this._callback = callback;
- return this;
+ public static initWithCallback(callback: Function, id: number, shouldRepeat: boolean): TimerTargetImpl {
+ let handler = TimerTargetImpl.new();
+ handler._callback = callback;
+ handler.id = id;
+ handler.shouldRepeat = shouldRepeat;
+ return handler;
}
public tick(timer): void {
- this._callback();
+ if (!this.canceled) {
+ this._callback();
+ }
+
+ if (this.canceled || !this.shouldRepeat) {
+ this.unregister();
+ }
+ }
+
+ public unregister() {
+ let timer = timeoutCallbacks.get(this.id).k;
+ timer.invalidate();
+ timeoutCallbacks.delete(this.id);
}
public static ObjCExposedMethods = {
@@ -27,14 +46,12 @@ class TimerTargetImpl extends NSObject {
function createTimerAndGetId(callback: Function, milliseconds: number, shouldRepeat: boolean): number {
timerId++;
- var id = timerId;
+ let id = timerId;
+ let timerTarget = TimerTargetImpl.initWithCallback(callback, id, shouldRepeat);
+ let timer = NSTimer.scheduledTimerWithTimeIntervalTargetSelectorUserInfoRepeats(milliseconds / 1000, timerTarget, "tick", null, shouldRepeat);
- var timerTarget = TimerTargetImpl.new().initWithCallback(callback);
- var timer = NSTimer.scheduledTimerWithTimeIntervalTargetSelectorUserInfoRepeats(milliseconds / 1000, timerTarget, "tick", null, shouldRepeat);
-
- if (!timeoutCallbacks[id]) {
- timeoutCallbacks[id] = timer;
- }
+ let pair: KeyValuePair = { k: timer, v: timerTarget };
+ timeoutCallbacks.set(id, pair);
return id;
}
@@ -44,9 +61,9 @@ export function setTimeout(callback: Function, milliseconds = 0): number {
}
export function clearTimeout(id: number): void {
- if (timeoutCallbacks[id]) {
- timeoutCallbacks[id].invalidate();
- delete timeoutCallbacks[id];
+ let pair = timeoutCallbacks.get(id);
+ if (pair) {
+ pair.v.unregister();
}
}
@@ -54,4 +71,4 @@ export function setInterval(callback: Function, milliseconds = 0): number {
return createTimerAndGetId(zonedCallback(callback), milliseconds, true);
}
-export var clearInterval = clearTimeout;
+export var clearInterval = clearTimeout;
\ No newline at end of file
diff --git a/tsconfig.json b/tsconfig.json
index 73a78486a..f5a0260d4 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -66,6 +66,8 @@
"apps/editable-text-demo/app.ts",
"apps/editable-text-demo/main-page.ts",
"apps/editable-text-demo/model.ts",
+ "apps/sample-fonts/app.ts",
+ "apps/sample-fonts/main-page.ts",
"apps/gallery-app/app.ts",
"apps/gallery-app/main-page.ts",
"apps/gallery-app/views/dialogs.ts",
@@ -77,9 +79,9 @@
"apps/modal-views-demo/app.ts",
"apps/modal-views-demo/login-page.ts",
"apps/modal-views-demo/main-page.ts",
- "apps/navigation-events-demo/app.ts",
- "apps/navigation-events-demo/page1.ts",
- "apps/navigation-events-demo/page2.ts",
+ "apps/navigation-events-demo/app.ts",
+ "apps/navigation-events-demo/page1.ts",
+ "apps/navigation-events-demo/page2.ts",
"apps/notifications-demo/app.ts",
"apps/notifications-demo/main-page.ts",
"apps/orientation-demo/app.ts",
diff --git a/ui/animation/animation.android.ts b/ui/animation/animation.android.ts
index f569e5441..d19a11c05 100644
--- a/ui/animation/animation.android.ts
+++ b/ui/animation/animation.android.ts
@@ -9,6 +9,10 @@ import styleModule = require("ui/styling/style");
global.moduleMerge(common, exports);
+interface AnimationDefinitionInternal extends definition.AnimationDefinition {
+ valueSource?: number;
+}
+
let argbEvaluator: android.animation.ArgbEvaluator;
function ensureArgbEvaluator() {
if (!argbEvaluator) {
@@ -79,11 +83,11 @@ export class Animation extends common.Animation implements definition.Animation
this._animatorSet.cancel();
}
- constructor(animationDefinitions: Array, playSequentially?: boolean) {
+ constructor(animationDefinitions: Array, playSequentially?: boolean) {
super(animationDefinitions, playSequentially);
- if (animationDefinitions.length > 0 && (animationDefinitions[0]).valueSource !== undefined) {
- this._valueSource = (animationDefinitions[0]).valueSource;
+ if (animationDefinitions.length > 0 && animationDefinitions[0].valueSource !== undefined) {
+ this._valueSource = animationDefinitions[0].valueSource;
}
let that = this;
diff --git a/ui/animation/animation.ios.ts b/ui/animation/animation.ios.ts
index f030a3377..c69e01718 100644
--- a/ui/animation/animation.ios.ts
+++ b/ui/animation/animation.ios.ts
@@ -30,7 +30,7 @@ interface PropertyAnimationInfo extends common.PropertyAnimation {
}
interface AnimationDefinitionInternal extends definition.AnimationDefinition {
- valueSource: number;
+ valueSource?: number;
}
interface IOSView extends viewModule.View {
@@ -258,6 +258,9 @@ export class Animation extends common.Animation implements definition.Animation
else {
originalValue = nativeView.layer.valueForKeyPath("transform.rotation");
}
+ if (originalValue === 0 && animation.target.rotate !== 0 && Math.floor(value / 360) - value / 360 === 0) {
+ originalValue = animation.target.rotate * Math.PI / 180;
+ }
value = value * Math.PI / 180;
abs = fabs(originalValue - value);
if (abs < 0.001 && originalValue !== tempRotate) {
@@ -332,7 +335,7 @@ export class Animation extends common.Animation implements definition.Animation
repeatCount = FLT_MAX;
}
else {
- repeatCount = animation.iterations - 1;
+ repeatCount = animation.iterations;
}
}
diff --git a/ui/core/view.d.ts b/ui/core/view.d.ts
index cd6594e20..d2c4a886c 100644
--- a/ui/core/view.d.ts
+++ b/ui/core/view.d.ts
@@ -96,22 +96,19 @@ declare module "ui/core/view" {
/**
* Specifies extra space on the left side of this view.
*/
- marginLeft: number;
-
+ marginLeft?: number;
/**
* Specifies extra space on the top side of this view.
*/
- marginTop: number;
-
+ marginTop?: number;
/**
* Specifies extra space on the right side of this view.
*/
- marginRight: number;
-
+ marginRight?: number;
/**
* Specifies extra space on the bottom side of this view.
*/
- marginBottom: number;
+ marginBottom?: number;
/**
* Gets or sets the visibility of this view.
*/
@@ -120,7 +117,6 @@ declare module "ui/core/view" {
* [Deprecated. Please use className instead] Gets or sets the CSS class of this view.
*/
cssClass?: string;
-
/**
* Gets or sets the CSS class name of this view.
*/
diff --git a/ui/editable-text-base/editable-text-base.android.ts b/ui/editable-text-base/editable-text-base.android.ts
index de64a19df..6540edc21 100644
--- a/ui/editable-text-base/editable-text-base.android.ts
+++ b/ui/editable-text-base/editable-text-base.android.ts
@@ -8,6 +8,7 @@ import types = require("utils/types");
export class EditableTextBase extends common.EditableTextBase {
private _android: android.widget.EditText;
private _textWatcher: android.text.TextWatcher;
+ private _keyListenerCache: android.text.method.IKeyListener;
/* tslint:disable */
private _dirtyTextAccumulator: string;
/* tslint:enable */
@@ -23,15 +24,15 @@ export class EditableTextBase extends common.EditableTextBase {
public _createUI() {
this._android = new android.widget.EditText(this._context);
this._configureEditText();
- this.android.setTag(this.android.getKeyListener());
+ this._keyListenerCache = this.android.getKeyListener();
var that = new WeakRef(this);
this._textWatcher = new android.text.TextWatcher({
- beforeTextChanged: function(text: string, start: number, count: number, after: number) {
+ beforeTextChanged: function (text: string, start: number, count: number, after: number) {
//
},
- onTextChanged: function(text: string, start: number, before: number, count: number) {
+ onTextChanged: function (text: string, start: number, before: number, count: number) {
var owner = that.get();
if (!owner) {
return;
@@ -42,7 +43,7 @@ export class EditableTextBase extends common.EditableTextBase {
owner.android.addTextChangedListener(owner._textWatcher);
owner.android.setSelection(selectionStart);
},
- afterTextChanged: function(editable: android.text.IEditable) {
+ afterTextChanged: function (editable: android.text.IEditable) {
var owner = that.get();
if (!owner) {
return;
@@ -63,7 +64,7 @@ export class EditableTextBase extends common.EditableTextBase {
this._android.addTextChangedListener(this._textWatcher);
var focusChangeListener = new android.view.View.OnFocusChangeListener({
- onFocusChange: function(view: android.view.View, hasFocus: boolean) {
+ onFocusChange: function (view: android.view.View, hasFocus: boolean) {
var owner = that.get();
if (!owner) {
return;
@@ -82,7 +83,7 @@ export class EditableTextBase extends common.EditableTextBase {
this._android.setOnFocusChangeListener(focusChangeListener);
var editorActionListener = new android.widget.TextView.OnEditorActionListener({
- onEditorAction: function(textView: android.widget.TextView, actionId: number, event: android.view.KeyEvent): boolean {
+ onEditorAction: function (textView: android.widget.TextView, actionId: number, event: android.view.KeyEvent): boolean {
var owner = that.get();
if (owner) {
if (actionId === android.view.inputmethod.EditorInfo.IME_ACTION_DONE ||
@@ -164,7 +165,7 @@ export class EditableTextBase extends common.EditableTextBase {
break;
}
- this._android.setInputType(newInputType);
+ this._setInputType(newInputType);
}
public _onReturnKeyTypePropertyChanged(data: dependencyObservable.PropertyChangeData) {
@@ -203,7 +204,7 @@ export class EditableTextBase extends common.EditableTextBase {
}
if (data.newValue) {
- this.android.setKeyListener(this.android.getTag());
+ this.android.setKeyListener(this._keyListenerCache);
}
else {
this.android.setKeyListener(null);
@@ -237,7 +238,7 @@ export class EditableTextBase extends common.EditableTextBase {
break;
}
- editableTextBase.android.setInputType(inputType);
+ editableTextBase._setInputType(inputType);
}
public _onAutocorrectPropertyChanged(data: dependencyObservable.PropertyChangeData) {
@@ -263,7 +264,7 @@ export class EditableTextBase extends common.EditableTextBase {
break;
}
- editableTextBase.android.setInputType(inputType);
+ editableTextBase._setInputType(inputType);
}
public _onHintPropertyChanged(data: dependencyObservable.PropertyChangeData) {
@@ -274,4 +275,19 @@ export class EditableTextBase extends common.EditableTextBase {
editableTextBase.android.setHint(data.newValue + "");
}
+
+ private _setInputType(inputType): void {
+ this.android.setInputType(inputType);
+
+ // setInputType will change the keyListener so we should cache it again
+ let listener = this.android.getKeyListener();
+ if (listener) {
+ this._keyListenerCache = listener;
+ }
+
+ // clear the listener if editable is false
+ if (!this.editable) {
+ this.android.setKeyListener(null);
+ }
+ }
}
diff --git a/ui/frame/frame.ios.ts b/ui/frame/frame.ios.ts
index 8f142cc62..56a028302 100644
--- a/ui/frame/frame.ios.ts
+++ b/ui/frame/frame.ios.ts
@@ -430,6 +430,7 @@ class UINavigationControllerImpl extends UINavigationController {
}
public viewDidLoad(): void {
+ super.viewDidLoad();
let owner = this._owner.get();
if (owner) {
owner.onLoaded();
diff --git a/ui/label/label.ios.ts b/ui/label/label.ios.ts
index c36fca70b..57dae2b10 100644
--- a/ui/label/label.ios.ts
+++ b/ui/label/label.ios.ts
@@ -76,6 +76,13 @@ export class Label extends common.Label {
return this._ios;
}
+ public onLoaded() {
+ super.onLoaded();
+
+ this.style._updateTextDecoration();
+ this.style._updateTextTransform();
+ }
+
public onMeasure(widthMeasureSpec: number, heightMeasureSpec: number): void {
var nativeView = this._nativeView;
if (nativeView) {
@@ -109,7 +116,7 @@ export class Label extends common.Label {
this.setMeasuredDimension(widthAndState, heightAndState);
}
}
-}
+}
export class LabelStyler implements style.Styler {
//Background methods
diff --git a/ui/page/page.d.ts b/ui/page/page.d.ts
index 06472aefa..29ac2e6eb 100644
--- a/ui/page/page.d.ts
+++ b/ui/page/page.d.ts
@@ -195,7 +195,7 @@ declare module "ui/page" {
showModal(moduleName: string, context: any, closeCallback: Function, fullscreen?: boolean): Page;
/**
- * Shows the page contained in moduleName as a modal view.
+ * Shows the page passed as parameter as a modal view.
* @param page - Page instance to be shown modally.
* @param context - Any context you want to pass to the modally shown page. This same context will be available in the arguments of the Page.shownModally event handler.
* @param closeCallback - A function that will be called when the page is closed. Any arguments provided when calling ShownModallyData.closeCallback will be available here.
diff --git a/ui/page/page.ios.ts b/ui/page/page.ios.ts
index ee8f6b814..35ae089fd 100644
--- a/ui/page/page.ios.ts
+++ b/ui/page/page.ios.ts
@@ -345,16 +345,8 @@ export class Page extends pageCommon.Page {
super._raiseShowingModallyEvent();
- parent.ios.presentViewControllerAnimatedCompletion(this._ios, utils.ios.MajorVersion >= 8, null);
-
- if (utils.ios.MajorVersion >= 8) {
- var that = this;
- UIViewControllerTransitionCoordinator.prototype.animateAlongsideTransitionCompletion.call(parent.ios.transitionCoordinator(), null, function() {
- that._raiseShownModallyEvent();
- });
- } else {
- this._raiseShownModallyEvent();
- }
+ parent.ios.presentViewControllerAnimatedCompletion(this._ios, utils.ios.MajorVersion >= 7, null);
+ UIViewControllerTransitionCoordinator.prototype.animateAlongsideTransitionCompletion.call(parent.ios.transitionCoordinator(), null, () => this._raiseShownModallyEvent());
}
protected _hideNativeModalView(parent: Page) {
diff --git a/ui/segmented-bar/segmented-bar-common.ts b/ui/segmented-bar/segmented-bar-common.ts
index dc627e480..adbd007c5 100644
--- a/ui/segmented-bar/segmented-bar-common.ts
+++ b/ui/segmented-bar/segmented-bar-common.ts
@@ -17,6 +17,8 @@ export module knownCollections {
export var items = "items";
}
+var CHILD_SEGMENTED_BAR_ITEM = "SegmentedBarItem";
+
export class SegmentedBarItem extends bindable.Bindable implements definition.SegmentedBarItem {
private _title: string = "";
public _parent: SegmentedBar;
@@ -97,4 +99,35 @@ export class SegmentedBar extends view.View implements definition.SegmentedBar {
}
}
}
+
+ public _addChildFromBuilder(name: string, value: any): void {
+ if(name === CHILD_SEGMENTED_BAR_ITEM) {
+ if (!this.items) {
+ this.items = new Array();
+ }
+ this.items.push(value);
+ this.insertTab(value);
+
+ }
+ }
+
+ public insertTab(tabItem: SegmentedBarItem, index?: number): void {
+ //
+ }
+
+ public getValidIndex(index?: number): number {
+ ensureTypes();
+ let idx: number;
+ let itemsLength = this.items ? this.items.length : 0;
+ if (types.isNullOrUndefined(index)) {
+ idx = itemsLength;
+ } else {
+ if (index < 0 || index > itemsLength) {
+ idx = itemsLength;
+ } else {
+ idx = index;
+ }
+ }
+ return idx;
+ }
}
diff --git a/ui/segmented-bar/segmented-bar.android.ts b/ui/segmented-bar/segmented-bar.android.ts
index 6bef96974..12233db82 100644
--- a/ui/segmented-bar/segmented-bar.android.ts
+++ b/ui/segmented-bar/segmented-bar.android.ts
@@ -27,7 +27,7 @@ function onSelectedIndexPropertyChanged(data: dependencyObservable.PropertyChang
view.notify({ eventName: SegmentedBar.selectedIndexChangedEvent, object: view, oldIndex: data.oldValue, newIndex: data.newValue });
} else {
view.selectedIndex = undefined;
- throw new Error("selectedIndex should be between [0, items.length - 1]");
+ throw new Error("selectedIndex should be between [0, " + (view.items.length - 1) + "]");
}
}
}
@@ -53,19 +53,7 @@ function onItemsPropertyChanged(data: dependencyObservable.PropertyChangeData) {
if (newItems && newItems.length) {
for (var i = 0; i < newItems.length; i++) {
- (newItems[i])._parent = view;
- var tab = view.android.newTabSpec(i + "");
- tab.setIndicator(newItems[i].title || "");
-
- tab.setContent(new android.widget.TabHost.TabContentFactory({
- createTabContent: function (tag: string): android.view.View {
- var tv = new android.widget.TextView(view._context);
- tv.setVisibility(android.view.View.GONE);
- return tv;
- }
- }));
-
- view.android.addTab(tab);
+ view.insertTab((newItems[i]), i);
}
if (types.isNumber(view.selectedIndex) && view.android.getCurrentTab() !== view.selectedIndex) {
@@ -102,6 +90,9 @@ function onItemsPropertyChanged(data: dependencyObservable.PropertyChangeData) {
if (view.color) {
t.setTextColor(view.color.android);
}
+
+ t.setMaxLines(1);
+ t.setEllipsize(android.text.TextUtils.TruncateAt.END);
}
}
}
@@ -158,7 +149,7 @@ export class SegmentedBar extends common.SegmentedBar {
var that = new WeakRef(this);
this._listener = new android.widget.TabHost.OnTabChangeListener({
- onTabChanged: function (id: string) {
+ onTabChanged: function(id: string) {
var bar = that.get();
if (bar) {
bar.selectedIndex = parseInt(id);
@@ -185,6 +176,24 @@ export class SegmentedBar extends common.SegmentedBar {
get android(): android.widget.TabHost {
return this._android;
}
+
+ public insertTab(tabItem: SegmentedBarItem, index?: number): void {
+ super.insertTab(tabItem, index);
+ tabItem._parent = this;
+
+ var tab = this.android.newTabSpec(this.getValidIndex(index) + "");
+ tab.setIndicator(tabItem.title || "");
+ let that = this;
+ tab.setContent(new android.widget.TabHost.TabContentFactory({
+ createTabContent: function (tag: string): android.view.View {
+ var tv = new android.widget.TextView(that._context);
+ tv.setVisibility(android.view.View.GONE);
+ return tv;
+ }
+ }));
+
+ this.android.addTab(tab);
+ }
}
var TabHostClass;
diff --git a/ui/segmented-bar/segmented-bar.d.ts b/ui/segmented-bar/segmented-bar.d.ts
index d3ddec3cc..17d7ed41d 100644
--- a/ui/segmented-bar/segmented-bar.d.ts
+++ b/ui/segmented-bar/segmented-bar.d.ts
@@ -36,7 +36,7 @@ declare module "ui/segmented-bar" {
/**
* Represents a UI SegmentedBar component.
*/
- export class SegmentedBar extends view.View {
+ export class SegmentedBar extends view.View implements view.AddChildFromBuilder {
/**
* Gets or sets the selected index of the SegmentedBar component.
*/
@@ -84,5 +84,16 @@ declare module "ui/segmented-bar" {
* Raised when the selected index changes.
*/
on(event: "selectedIndexChanged", callback: (args: SelectedIndexChangedEventData) => void, thisArg?: any);
+
+ /**
+ * Called for every child element declared in xml.
+ * @param name - Name of the element.
+ * @param value - Value of the element.
+ */
+ public _addChildFromBuilder(name: string, value: any): void;
+
+ public insertTab(tabItem: SegmentedBarItem, index?: number): void;
+
+ public getValidIndex(index?: number): number;
}
}
\ No newline at end of file
diff --git a/ui/segmented-bar/segmented-bar.ios.ts b/ui/segmented-bar/segmented-bar.ios.ts
index 40e62798f..8117c2546 100644
--- a/ui/segmented-bar/segmented-bar.ios.ts
+++ b/ui/segmented-bar/segmented-bar.ios.ts
@@ -56,8 +56,7 @@ function onItemsPropertyChanged(data: dependencyObservable.PropertyChangeData) {
var newItems = >data.newValue;
if (newItems && newItems.length) {
for (var i = 0; i < newItems.length; i++) {
- view.ios.insertSegmentWithTitleAtIndexAnimated(newItems[i].title || "", i, false);
- (newItems[i])._parent = view;
+ view.insertTab((newItems[i]), i);
}
if (view.ios.selectedSegmentIndex !== view.selectedIndex) {
@@ -105,6 +104,12 @@ export class SegmentedBar extends common.SegmentedBar {
get ios(): UISegmentedControl {
return this._ios;
}
+
+ public insertTab(tabItem: SegmentedBarItem, index?: number): void {
+ super.insertTab(tabItem, index);
+ tabItem._parent = this;
+ this.ios.insertSegmentWithTitleAtIndexAnimated(tabItem.title || "", this.getValidIndex(index), false);
+ }
}
class SelectionHandlerImpl extends NSObject {
diff --git a/ui/styling/font-common.ts b/ui/styling/font-common.ts
index 86e26f729..e5f2f8e27 100644
--- a/ui/styling/font-common.ts
+++ b/ui/styling/font-common.ts
@@ -130,6 +130,7 @@ export module genericFontFamilies {
export var serif = "serif";
export var sansSerif = "sans-serif";
export var monospace = "monospace";
+ export var system = "system";
}
var styles = new Set();
diff --git a/ui/styling/font.android.ts b/ui/styling/font.android.ts
index 6f012b169..bf2cf329e 100644
--- a/ui/styling/font.android.ts
+++ b/ui/styling/font.android.ts
@@ -102,6 +102,10 @@ export class Font extends common.Font {
result = android.graphics.Typeface.MONOSPACE;
break;
+ case common.genericFontFamilies.system:
+ result = android.graphics.Typeface.DEFAULT;
+ break;
+
default:
result = this.loadFontFromFile(fonts[i]);
break;
diff --git a/ui/styling/font.ios.ts b/ui/styling/font.ios.ts
index dc0ca0016..de3527586 100644
--- a/ui/styling/font.ios.ts
+++ b/ui/styling/font.ios.ts
@@ -3,10 +3,6 @@ import common = require("./font-common");
import fs = require("file-system");
import * as traceModule from "trace";
-var DEFAULT_SERIF = "Times New Roman";
-var DEFAULT_SANS_SERIF = "Helvetica";
-var DEFAULT_MONOSPACE = "Courier New";
-
export class Font extends common.Font {
public static default = new Font(undefined, undefined, enums.FontStyle.normal, enums.FontWeight.normal);
@@ -18,6 +14,8 @@ export class Font extends common.Font {
public getUIFont(defaultFont: UIFont): UIFont {
if (!this._uiFont) {
+ var size = this.fontSize || defaultFont.pointSize;
+
var symbolicTraits: number = 0;
if (this.isBold) {
symbolicTraits |= UIFontDescriptorSymbolicTraits.UIFontDescriptorTraitBold;
@@ -26,11 +24,30 @@ export class Font extends common.Font {
symbolicTraits |= UIFontDescriptorSymbolicTraits.UIFontDescriptorTraitItalic;
}
- var descriptor = resolveFontDescriptor(this.fontFamily, symbolicTraits);
+ var descriptor: UIFontDescriptor;
+ switch (this.fontFamily) {
+
+ case common.genericFontFamilies.sansSerif:
+ case common.genericFontFamilies.system:
+ let uiFont = UIFont.systemFontOfSize(size);
+ descriptor = uiFont.fontDescriptor().fontDescriptorWithSymbolicTraits(symbolicTraits);
+ break;
+
+ case common.genericFontFamilies.monospace:
+ if ((UIFont).monospacedDigitSystemFontOfSizeWeight) {// This method is available on iOS 9.0 and later.
+ let uiFont = (UIFont).monospacedDigitSystemFontOfSizeWeight(size, 0);
+ descriptor = uiFont.fontDescriptor().fontDescriptorWithSymbolicTraits(symbolicTraits);
+ }
+ break;
+ }
+
+ if (!descriptor) {
+ descriptor = resolveFontDescriptor(this.fontFamily, symbolicTraits);
+ }
+
if (!descriptor) {
descriptor = defaultFont.fontDescriptor().fontDescriptorWithSymbolicTraits(symbolicTraits);
}
- var size = this.fontSize || defaultFont.pointSize;
this._uiFont = UIFont.fontWithDescriptorSize(descriptor, size);
}
@@ -121,6 +138,9 @@ function resolveFontDescriptor(fontFamilyValue: string, symbolicTraits: number):
return null;
}
+const DEFAULT_SERIF = "Times New Roman";
+const DEFAULT_MONOSPACE = "Courier New";
+
function getFontFamilyRespectingGenericFonts(fontFamily: string): string {
if (!fontFamily) {
return fontFamily;
@@ -130,9 +150,6 @@ function getFontFamilyRespectingGenericFonts(fontFamily: string): string {
case common.genericFontFamilies.serif:
return DEFAULT_SERIF;
- case common.genericFontFamilies.sansSerif:
- return DEFAULT_SANS_SERIF;
-
case common.genericFontFamilies.monospace:
return DEFAULT_MONOSPACE;
diff --git a/ui/time-picker/time-picker.android.ts b/ui/time-picker/time-picker.android.ts
index 12fb086b4..83dcbb35a 100644
--- a/ui/time-picker/time-picker.android.ts
+++ b/ui/time-picker/time-picker.android.ts
@@ -26,7 +26,7 @@ export class TimePicker extends common.TimePicker {
if (this.owner) {
var validTime = common.getValidTime(this.owner, hour, minute);
this.owner._setNativeValueSilently(validTime.hour, validTime.minute);
- this.owner._onPropertyChangedFromNative(common.TimePicker.timeProperty, new Date(0, 0, 0, hour, minute));
+ this.owner._onPropertyChangedFromNative(common.TimePicker.timeProperty, new Date(0, 0, 0, validTime.hour, validTime.minute));
}
}
});