Merged master onto feature/docs

This commit is contained in:
Nikolay Tsonev
2016-04-15 16:54:37 +03:00
54 changed files with 874 additions and 706 deletions

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

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

View File

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

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 = {
@@ -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<TestInfo>();
function printRunTestStats() {
let testFileContent = new Array<string>();
let testCases = new Array<string>();
var j;
var failedTestCount = 0;
@@ -124,12 +128,11 @@ function printRunTestStats() {
let allTests = testsQueue.filter(t=> t.isTest);
testFileContent.push("<testsuites>");
testFileContent.push(`<testsuite name="NativeScript Tests" timestamp="${new Date()}" hostname="hostname" time="0" errors="0" tests="${allTests.length}" skipped="0" failures="${failedTestCount}">`);
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(`<testcase classname="${platform.device.os}" name="${testName}" time="${duration}"><failure type="exceptions.AssertionError"><![CDATA[${errorMessage}]]></failure></testcase>`);
testCases.push(`<testcase classname="${platform.device.os}" name="${testName}" time="${duration}"><failure type="exceptions.AssertionError"><![CDATA[${errorMessage}]]></failure></testcase>`);
} else {
testFileContent.push(`<testcase classname="${platform.device.os}" name="${testName}" time="${duration}"></testcase>`);
testCases.push(`<testcase classname="${platform.device.os}" name="${testName}" time="${duration}"></testcase>`);
}
}
var totalTime = (TKUnit.time() - startTime).toFixed(2);
testFileContent.push(`<testsuite name="NativeScript Tests" timestamp="${new Date()}" hostname="hostname" time="${totalTime}" errors="0" tests="${allTests.length}" skipped="0" failures="${failedTestCount}">`);
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<TKUnit.TestFailure> = [];
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;

View File

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

View File

@@ -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<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");
@@ -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<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()
@@ -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<viewModule.View>) => {
TKUnit.assertThrows(() => {
label.animate({ opacity: <any>"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<viewModule.View>) => {
TKUnit.assertThrows(() => {
label.animate({ delay: <any>"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<viewModule.View>) => {
TKUnit.assertThrows(() => {
label.animate({ duration: <any>"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<viewModule.View>) => {
TKUnit.assertThrows(() => {
label.animate({ iterations: <any>"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<viewModule.View>) => {
TKUnit.assertThrows(() => {
label.animate({ rotate: <any>"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<viewModule.View>) => {
TKUnit.assertThrows(() => {
label.animate({ scale: <any>"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<viewModule.View>) => {
TKUnit.assertThrows(() => {
label.animate({ translate: <any>"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<viewModule.View>) => {
TKUnit.assertThrows(() => {
label.animate({ backgroundColor: <any>"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: <any>expected })
label.animate({ backgroundColor: <any>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() {

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

@@ -471,11 +471,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

@@ -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<viewModule.View>) {
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<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.");
};
@@ -138,7 +138,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.");
};
@@ -151,11 +151,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.");
};
@@ -167,11 +167,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.");
};
@@ -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<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");
};
@@ -243,12 +245,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");
};
@@ -279,7 +281,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");
};
@@ -294,7 +296,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");
@@ -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 = "<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");
@@ -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<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);
};