Fixed some slow tests. (#1968)

Fixed modal page on iOS7.
This commit is contained in:
Hristo Hristov
2016-04-14 15:01:32 +03:00
parent 3dd0d51ebb
commit f768fda881
21 changed files with 398 additions and 598 deletions

View File

@@ -99,6 +99,7 @@
<TypeScriptCompile Include="apps\tests\navigation\custom-transition.ios.ts" />
<TypeScriptCompile Include="apps\tests\navigation\transition-tests.ts" />
<TypeScriptCompile Include="apps\tests\ui\action-bar\ActionBar_NumberAsText.ts" />
<TypeScriptCompile Include="apps\tests\ui\animation\css-animation-tests.ts" />
<TypeScriptCompile Include="apps\tests\ui\page\modal-page.ts">
<DependentUpon>modal-page.xml</DependentUpon>
</TypeScriptCompile>
@@ -161,6 +162,7 @@
</Content>
<Content Include="apps\tests\ui\action-bar\ActionBar_BetweenTags.xml" />
<Content Include="apps\tests\ui\action-bar\ActionBar_NumberAsText.xml" />
<Content Include="apps\tests\ui\animation\test.css" />
<Content Include="apps\tests\ui\page\modal-page.xml">
<SubType>Designer</SubType>
</Content>
@@ -2211,7 +2213,7 @@
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
</WebProjectProperties>
</FlavorProperties>
<UserProperties ui_2scroll-view_2package_1json__JSONSchema="http://json.schemastore.org/package" apps_2editable-text-demo_2package_1json__JSONSchema="http://json.schemastore.org/package" apps_2absolute-layout-demo_2package_1json__JSONSchema="http://json.schemastore.org/package" apps_2gallery-app_2package_1json__JSONSchema="http://json.schemastore.org/package" ui_2content-view_2package_1json__JSONSchema="http://json.schemastore.org/package" ui_2web-view_2package_1json__JSONSchema="http://json.schemastore.org/package" ui_2layouts_2absolute-layout_2package_1json__JSONSchema="http://json.schemastore.org/package" ui_2layouts_2dock-layout_2package_1json__JSONSchema="" ui_2layouts_2grid-layout_2package_1json__JSONSchema="" ui_2layouts_2wrap-layout_2package_1json__JSONSchema="http://json.schemastore.org/package" />
<UserProperties ui_2layouts_2wrap-layout_2package_1json__JSONSchema="http://json.schemastore.org/package" ui_2layouts_2grid-layout_2package_1json__JSONSchema="" ui_2layouts_2dock-layout_2package_1json__JSONSchema="" ui_2layouts_2absolute-layout_2package_1json__JSONSchema="http://json.schemastore.org/package" ui_2web-view_2package_1json__JSONSchema="http://json.schemastore.org/package" ui_2content-view_2package_1json__JSONSchema="http://json.schemastore.org/package" apps_2gallery-app_2package_1json__JSONSchema="http://json.schemastore.org/package" apps_2absolute-layout-demo_2package_1json__JSONSchema="http://json.schemastore.org/package" apps_2editable-text-demo_2package_1json__JSONSchema="http://json.schemastore.org/package" ui_2scroll-view_2package_1json__JSONSchema="http://json.schemastore.org/package" />
</VisualStudio>
</ProjectExtensions>
</Project>

View File

@@ -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();

View File

@@ -431,12 +431,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");
@@ -470,12 +468,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");
};

View File

@@ -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 = {

View File

@@ -1,6 +1,5 @@
import TKUnit = require("./TKUnit");
import platform = require("platform");
var timer = require("timer/timer");
import timer = require("timer");
// <snippet module="timer" title="timer">
// # Timer module
@@ -12,30 +11,29 @@ var timer = require("timer/timer");
// ```
// </snippet>
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;
// <snippet module="timer" title="timer">
// ### Evaluates an expression after 0 milliseconds.
// ``` JavaScript
timer.setTimeout(function () {
timer.setTimeout(() => {
// <hide>
completed = true;
// </hide>
@@ -43,66 +41,54 @@ export var test_setTimeout = function () {
// ```
// </snippet>
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;
// <snippet module="timer" title="timer">
// ### Evaluates an expression after a specified number of milliseconds.
// ``` JavaScript
timer.setTimeout(function () {
timer.setTimeout(() => {
// <hide>
completed = true;
// </hide>
}, 500);
}, 10);
// ```
// </snippet>
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;
// <snippet module="timer" title="timer">
// ### Cancels the evaluation with the clearTimeout method.
// ``` JavaScript
var id = timer.setTimeout(function () {
let id = timer.setTimeout(() => {
// <hide>
completed = true;
// </hide>
}, 2000);
}, 50);
//// Clear timeout with specified id.
timer.clearTimeout(id);
@@ -110,19 +96,18 @@ export var test_setTimeout_callbackShouldBeCleared = function () {
// ```
// </snippet>
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;
// <snippet module="timer" title="timer">
// ### Evaluates an expression each time a specified number of milliseconds has elapsed.
// ``` JavaScript
timer.setInterval(function () {
timer.setInterval(() => {
// <hide>
counter++;
// </hide>
@@ -130,18 +115,17 @@ export var test_setInterval_callbackCalledDuringPeriod = function () {
// ```
// </snippet>
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;
// <snippet module="timer" title="timer">
// ### Cancel the interval previously started using the setInterval method.
// ``` JavaScript
var id = timer.setInterval(function () {
let id = timer.setInterval(() => {
// <hide>
counter++;
// </hide>
@@ -150,6 +134,6 @@ export var test_setInterval_callbackShouldBeCleared = function () {
// ```
// </snippet>
TKUnit.waitUntilReady(isReady, 0.5);
TKUnit.waitUntilReady(() => false, 0.5);
TKUnit.assert(counter === 1, "Callback should be raised only once!");
};

View File

@@ -19,7 +19,6 @@ import activityIndicatorModule = require("ui/activity-indicator");
//```
// </snippet>
var ASYNC = 0.2;
export function test_default_TNS_values() {
// <snippet module="ui/activity-indicator" title="activity-indicator">
// ### Creating an activity indicator
@@ -50,7 +49,7 @@ export function test_set_TNS_value_updates_native_value() {
function testAction(views: Array<viewModule.View>) {
indicator.busy = true;
TKUnit.wait(ASYNC);
TKUnit.waitUntilReady(() => getNativeBusy(indicator) === true);
TKUnit.assertEqual(getNativeBusy(indicator), true, "Native value is different from TNS value.");
};

View File

@@ -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");
@@ -15,21 +14,18 @@ import animation = require("ui/animation");
// ```
// </snippet>
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();
// <snippet module="ui/animation" title="animation">
// # Animating properties
@@ -40,7 +36,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
@@ -62,26 +58,13 @@ export var test_AnimatingProperties = function(done) {
// </snippet>
}
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();
// <snippet module="ui/animation" title="animation">
// # Cancelling animation
// ``` JavaScript
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");
@@ -106,26 +89,13 @@ export var test_CancellingAnimation = function(done) {
// </snippet>
}
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();
// <snippet module="ui/animation" title="animation">
// # Cancelling animation
// ``` JavaScript
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>
@@ -149,32 +119,25 @@ export var test_CancellingAnimate = function(done) {
// </snippet>
}
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();
// <snippet module="ui/animation" title="animation">
// # Chaining animations
// ``` JavaScript
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>
@@ -192,27 +155,14 @@ export var test_ChainingAnimations = function(done) {
// </snippet>
}
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();
// <snippet module="ui/animation" title="animation">
// # Reusing animations
// ``` JavaScript
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())
@@ -237,36 +187,25 @@ export var test_ReusingAnimations = function(done) {
// </snippet>
}
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);
// <snippet module="ui/animation" title="animation">
// # Animating multiple views simultaneously
// ``` JavaScript
var animations: Array<animation.AnimationDefinition> = [
{ 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()
@@ -289,23 +228,10 @@ export var test_AnimatingMultipleViews = function(done) {
// </snippet>
}
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();
@@ -315,8 +241,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<viewModule.View>) => {
TKUnit.assertThrows(() => {
label.animate({ opacity: <any>"0.75" });
@@ -324,8 +250,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<viewModule.View>) => {
TKUnit.assertThrows(() => {
label.animate({ delay: <any>"1" });
@@ -333,8 +259,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<viewModule.View>) => {
TKUnit.assertThrows(() => {
label.animate({ duration: <any>"1" });
@@ -342,8 +268,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<viewModule.View>) => {
TKUnit.assertThrows(() => {
label.animate({ iterations: <any>"1" });
@@ -351,8 +277,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<viewModule.View>) => {
TKUnit.assertThrows(() => {
label.animate({ rotate: <any>"1" });
@@ -360,8 +286,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<viewModule.View>) => {
TKUnit.assertThrows(() => {
label.animate({ scale: <any>"1" });
@@ -369,8 +295,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<viewModule.View>) => {
TKUnit.assertThrows(() => {
label.animate({ translate: <any>"1" });
@@ -378,8 +304,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<viewModule.View>) => {
TKUnit.assertThrows(() => {
label.animate({ backgroundColor: <any>"test" });
@@ -387,24 +313,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();
@@ -414,26 +327,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: <any>expected })
label.animate({ backgroundColor: <any>expected, duration: 20 })
.then(() => {
TKUnit.assert(label.backgroundColor.equals(clr));
done();
@@ -443,23 +342,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");
@@ -471,23 +357,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");
@@ -499,23 +372,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);
@@ -526,26 +386,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");
@@ -561,28 +409,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");
@@ -590,7 +425,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");
@@ -606,24 +441,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(() => {
@@ -640,23 +462,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() {
@@ -668,23 +477,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() {

View File

@@ -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);
};
}

View File

@@ -917,7 +917,7 @@ export function test_BindingContextOfAChildElementIsNotOverwrittenBySettingTheBi
});
page.content = child;
TKUnit.waitUntilReady(() => { return testFinished });
TKUnit.waitUntilReady(() => testFinished);
}
export var test_BindingHitsGetterTooManyTimes = function () {

View File

@@ -109,7 +109,8 @@ export function buildUIWithWeakRefAndInteract<T extends view.View>(createFunc: (
newPage.content = sp;
TKUnit.waitUntilReady(() => { return testFinished; }, MEMORY_ASYNC);
TKUnit.waitUntilReady(() => testFinished, MEMORY_ASYNC);
TKUnit.assertTrue(testFinished, "Test did not completed.")
done(null);
}

View File

@@ -490,11 +490,17 @@ export function test_WhenPageIsNavigatedToItCanShowAnotherPageAsModal() {
let page = <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((<any>modalPage).showingModally, "showingModally");
let entry: frameModule.NavigationEntry = {
moduleName: basePath + "modal-page"
};
modalPage = <Page>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((<any>modalPage).showingModally, "showingModally");
};
var masterPageFactory = function (): Page {

View File

@@ -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.");

View File

@@ -88,7 +88,7 @@ export function test_set_items_to_array_loads_all_items() {
// ```
// </snippet>
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");
@@ -104,7 +104,7 @@ export function test_set_items_to_array_creates_views() {
function testAction(views: Array<viewModule.View>) {
repeater.items = FEW_ITEMS;
TKUnit.wait(ASYNC);
TKUnit.waitUntilReady(() => repeater.isLayoutValid);
TKUnit.assertEqual(getChildrenCount(repeater), FEW_ITEMS.length, "views count.");
};
@@ -119,7 +119,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.");
// <snippet module="ui/repeater" title="repeater">
// > Note, that changing the array after the repeater is shown will not update the UI.
@@ -147,7 +147,7 @@ export function test_refresh_reloads_all_items() {
repeater.items = itemsToBind;
TKUnit.wait(ASYNC);
TKUnit.waitUntilReady(() => repeater.isLayoutValid);
testStarted = true;
itemsToBind[0] = "red";
@@ -156,7 +156,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");
@@ -171,11 +171,11 @@ export function test_set_itmes_to_null_clears_items() {
function testAction(views: Array<viewModule.View>) {
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.");
};
@@ -196,7 +196,7 @@ export function test_set_itemsLayout_accepted() {
function testAction(views: Array<viewModule.View>) {
repeater.items = FEW_ITEMS;
TKUnit.wait(ASYNC);
TKUnit.waitUntilReady(() => repeater.isLayoutValid);
TKUnit.assert((<stackLayoutModule.StackLayout>repeater.itemsLayout).orientation === "horizontal", "views count.");
TKUnit.assertEqual(getChildrenCount(repeater), FEW_ITEMS.length, "views count.");
};
@@ -209,11 +209,11 @@ export function test_set_itmes_to_undefiend_clears_items() {
function testAction(views: Array<viewModule.View>) {
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.");
};
@@ -225,11 +225,11 @@ export function test_set_itmes_to_different_source_loads_new_items() {
function testAction(views: Array<viewModule.View>) {
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.");
};
@@ -248,6 +248,7 @@ export function test_set_items_to_observable_array_loads_all_items() {
// ```
// </snippet>
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");
@@ -263,7 +264,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");
// <snippet module="ui/repeater" title="repeater">
@@ -273,7 +274,7 @@ export function test_add_to_observable_array_refreshes_the_Repeater() {
//// The Repeater will be updated automatically.
// ```
// </snippet>
TKUnit.wait(ASYNC);
TKUnit.waitUntilReady(() => repeater.isLayoutValid);
TKUnit.assertEqual(getChildrenCount(repeater), 4, "getChildrenCount");
};
@@ -288,11 +289,11 @@ export function test_remove_from_observable_array_refreshes_the_Repeater() {
function testAction(views: Array<viewModule.View>) {
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");
};
@@ -307,12 +308,12 @@ export function test_splice_observable_array_refreshes_the_Repeater() {
function testAction(views: Array<viewModule.View>) {
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");
};
@@ -343,7 +344,7 @@ export function test_usingAppLevelConvertersInRepeaterItems() {
repeater.itemTemplate = "<Label id=\"testLabel\" text=\"{{ date, date | dateConverter('DD.MM.YYYY') }}\" />";
repeater.items = data;
TKUnit.wait(ASYNC);
TKUnit.waitUntilReady(() => repeater.isLayoutValid);
TKUnit.assertEqual(getChildAtText(repeater, 0), dateConverter(new Date(), "DD.MM.YYYY"), "element");
};
@@ -358,7 +359,7 @@ export function test_BindingRepeaterToASimpleArray() {
repeater.itemTemplate = "<Label id=\"testLabel\" text=\"{{ $value }}\" />";
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");
@@ -380,7 +381,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");
@@ -397,7 +398,7 @@ export function test_BindingRepeaterToASimpleArrayWithExpression() {
repeater.itemTemplate = "<Label id=\"testLabel\" text=\"{{ $value, $value + ' some static text' }}\" />";
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");
@@ -471,7 +472,7 @@ export function test_ChildrenAreNotCreatedUntilTheRepeaterIsLoaded() {
TKUnit.assertEqual(getChildrenCount(repeater), 0, "Repeater should not create its children until loaded.");
function testAction(views: Array<viewModule.View>) {
TKUnit.waitUntilReady(() => repeater.isLoaded);
TKUnit.waitUntilReady(() => repeater.isLayoutValid);
TKUnit.assertEqual(getChildrenCount(repeater), 3, "Repeater should have created its children when loaded.");
}

View File

@@ -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;

View File

@@ -740,8 +740,7 @@ export var test_getLocationRelativeToOtherView = function () {
a1.addChild(a2);
helper.buildUIAndRunTest(a1, function (views: Array<viewModule.View>) {
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<viewModule.View>) {
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");

View File

@@ -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.");

View File

@@ -179,8 +179,7 @@ export function test_parse_ShouldResolveExportsFromCodeFileForTemplates() {
});
p.bindingContext = obj;
TKUnit.wait(0.2);
TKUnit.waitUntilReady(() => ctrl !== null);
TKUnit.assert((<any>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<viewModule.View>) {
p.bindingContext = [["0", "1"], ["2", "3"]];
TKUnit.wait(0.2);
var lbls = new Array<Label>();
let lbls = new Array<Label>();
view.eachDescendant(p, (v) => {
if (v instanceof Label) {
lbls.push(v);
@@ -855,10 +852,7 @@ export function test_tabview_selectedindex_will_work_from_xml() {
'</Page>');
function testAction(views: Array<viewModule.View>) {
var tab: TabView = <TabView>p.content;
TKUnit.wait(0.2);
let tab: TabView = <TabView>p.content;
TKUnit.assertEqual(tab.selectedIndex, 1);
};

View File

@@ -1,23 +1,42 @@
/**
* iOS specific timer functions implementation.
*/
var timeoutCallbacks = {};
var timeoutCallbacks = new Map<number, KeyValuePair<NSTimer, TimerTargetImpl>>();
var timerId = 0;
interface KeyValuePair<K, V> {
k: K;
v: V
}
class TimerTargetImpl extends NSObject {
static new(): TimerTargetImpl {
return <TimerTargetImpl>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>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<NSTimer, TimerTargetImpl> = { 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;

12
ui/core/view.d.ts vendored
View File

@@ -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.
*/

2
ui/page/page.d.ts vendored
View File

@@ -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.

View File

@@ -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) {