diff --git a/.travis.yml b/.travis.yml index 1637ea83b..edd73e9d6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,35 +1,69 @@ +env: + global: + - DATE=$(date +%Y-%m-%d) + - PACKAGE_VERSION=$DATE-$TRAVIS_BUILD_NUMBER + - PACKAGE_NAME=tns-core-modules + - NODE_VERSION=5.10.1 + - EMULATOR_API_VER=22 + - RUNTIMEVERSION=next + - AVD_NAME=Arm$EMULATOR_API_VER +addons: + artifacts: + paths: + - "$HOME/test-run-results$PACKAGE_VERSION.xml" sudo: required dist: trusty language: android node_js: - - 4.2.3 + - 4.2.3 jdk: - - oraclejdk8 + - oraclejdk8 android: - components: - - platform-tools - - tools - - build-tools-23.0.3 - - android-21 - - android-23 - - extra-android-support - - extra-android-m2repository - - sys-img-armeabi-v7a-android-21 - + components: + - platform-tools + - tools + - build-tools-23.0.3 + - android-$EMULATOR_API_VER + - android-23 + - extra-android-support + - extra-android-m2repository + - sys-img-armeabi-v7a-android-$EMULATOR_API_VER before_script: - - nvm install 5.10.1 - - npm install -g grunt-cli - - npm install - - (cd build/platform-declarations && npm install) - - echo no | android create avd --force -n Arm21 -t android-21 -b armeabi-v7a -c 12M - - emulator -avd Arm21 -no-skin -no-audio -no-window & - - android-wait-for-emulator + - nvm install $NODE_VERSION + - npm install -g grunt-cli + - npm install + - "(cd build/platform-declarations && npm install)" + - echo no | android create avd --force -n $AVD_NAME -t android-$EMULATOR_API_VER -b + armeabi-v7a -c 12M + - emulator -avd $AVD_NAME -skin WXGA720 -no-audio -no-window & + - android-wait-for-emulator script: - - jdk_switcher use oraclejdk8 - - grunt default && - (cd build/platform-declarations && grunt) && - echo no | npm install nativescript -g > /dev/null && - grunt buildOnlyTestsApp --platform=Android --modulesPath=./bin/dist/tns-core-modules-2.0.0.tgz --runtimeVersion=next --emuPId=.*emulator.* --avd=Api21 --showEmu=false > /dev/null && - grunt runOnlyTestsApp --platform=Android --modulesPath=./bin/dist/tns-core-modules-2.0.0.tgz --emuPId=.*emulator.* --avd=Api21 --showEmu=false - - - node ./build/travis-scripts/check-testrun-broken.js + - jdk_switcher use oraclejdk8 + - grunt default && + FULL_PACKAGE_VERSION=`node -e 'console.log(require("./bin/dist/modules/package.json").version);'` && + (cd build/platform-declarations && grunt) && + echo no | npm install nativescript -g > /dev/null && + grunt buildOnlyTestsApp --platform=Android --modulesPath=./bin/dist/$PACKAGE_NAME-$FULL_PACKAGE_VERSION.tgz --runtimeVersion=$RUNTIMEVERSION --emuPId=.*emulator.* --avd=$AVD_NAME --showEmu=false > /dev/null && + grunt runOnlyTestsApp --platform=Android --modulesPath=./bin/dist/$PACKAGE_NAME-$FULL_PACKAGE_VERSION.tgz --emuPId=.*emulator.* --avd=$AVD_NAME --showEmu=false + - node ./build/travis-scripts/check-testrun-broken.js + - adb pull /data/data/org.nativescript.TestsApp/files/test-results.xml && + mv test-results.xml ~/test-run-results$PACKAGE_VERSION.xml +before_deploy: + - mv bin/dist/$PACKAGE_NAME-$FULL_PACKAGE_VERSION.tgz ../.deploymentpackage + - mv build ../ + - cd .. + - rm -rf NativeScript + - tar -zxvf .deploymentpackage + - mv package $PACKAGE_NAME + - cd $PACKAGE_NAME + - rm ../.deploymentpackage + - mv ../build ./ + - node ./build/travis-scripts/add-publishConfig.js next +deploy: + provider: npm + email: nativescript@telerik.com + on: + branch: master + skip_cleanup: true + api_key: + secure: j2gE5jnGSuCFy7s3pDB6Or2j+vhlRYIlSSB1mDI7R5PvpV0kWr8yE1rLnyqeb0pI7WY/36SV/0NZCClJhlrZFvd7QvaP3+55cGX3ijmsDp8WxfQRyHppA9RZuMFujG7swFr/s0RmoYgO9mYNe46lJTX8m0HZeNN2qlAC7LDD3x8= diff --git a/CrossPlatformModules.csproj b/CrossPlatformModules.csproj index 88f3c1311..f3bbc4871 100644 --- a/CrossPlatformModules.csproj +++ b/CrossPlatformModules.csproj @@ -90,11 +90,16 @@ + + + main-page.xml + + modal-page.xml @@ -152,8 +157,12 @@ + + Designer + + Designer @@ -2106,6 +2115,7 @@ PreserveNewest + @@ -2203,7 +2213,7 @@ False - + \ No newline at end of file diff --git a/application/application.d.ts b/application/application.d.ts index 079e2bad9..1a7105d28 100644 --- a/application/application.d.ts +++ b/application/application.d.ts @@ -579,4 +579,11 @@ declare module "application" { */ removeNotificationObserver(observer: any, notificationName: string): void; } + + /* tslint:disable */ + export interface RootViewControllerImpl { + + contentController: any; + + } } diff --git a/application/application.ios.ts b/application/application.ios.ts index 16e0d86ad..1700b9fca 100644 --- a/application/application.ios.ts +++ b/application/application.ios.ts @@ -13,6 +13,43 @@ class Responder extends UIResponder { // } +class RootViewControllerImpl extends UIViewController implements definition.RootViewControllerImpl { + private _contentController: UIViewController; + + get contentController(): UIViewController { + return this._contentController; + } + + set contentController(contentController: UIViewController) { + + if (contentController.parentViewController !== null) { + contentController.willMoveToParentViewController(null); + contentController.view.removeFromSuperview(); + contentController.removeFromParentViewController(); + contentController.didMoveToParentViewController(this); + } + + if (this._contentController) { + this._contentController.willMoveToParentViewController(null); + this._contentController.view.removeFromSuperview(); + this._contentController.removeFromParentViewController(); + } + + this.addChildViewController(contentController); + this.view.addSubview(contentController.view); + contentController.view.frame = this.view.bounds; + contentController.view.autoresizingMask = UIViewAutoresizing.UIViewAutoresizingFlexibleWidth | UIViewAutoresizing.UIViewAutoresizingFlexibleHeight; + + this._contentController = contentController; + this._contentController.didMoveToParentViewController(this); + } + + public viewDidLoad(): void { + super.viewDidLoad(); + this.view.backgroundColor = UIColor.whiteColor(); + } +} + class Window extends UIWindow { private _content; @@ -140,11 +177,13 @@ class IOSApplication implements definition.iOSApplication { rootView = frame; } - + this._window.content = rootView; if (rootView instanceof Frame) { - this.rootController = this._window.rootViewController = rootView.ios.controller; + let rootController = new RootViewControllerImpl(); + this.rootController = this._window.rootViewController = rootController; + rootController.contentController = rootView.ios.controller; } else if (rootView.ios instanceof UIViewController) { this.rootController = this._window.rootViewController = rootView.ios; diff --git a/apps/sample-fonts/app.ts b/apps/sample-fonts/app.ts new file mode 100644 index 000000000..d903b1c7c --- /dev/null +++ b/apps/sample-fonts/app.ts @@ -0,0 +1,3 @@ +import application = require("application"); +application.cssFile = "app.css" +application.start({ moduleName: "main-page" }); \ No newline at end of file diff --git a/apps/sample-fonts/main-page.ts b/apps/sample-fonts/main-page.ts new file mode 100644 index 000000000..87d957983 --- /dev/null +++ b/apps/sample-fonts/main-page.ts @@ -0,0 +1,62 @@ +import { View } from "ui/core/view"; +import { EventData } from "data/observable"; +import { LayoutBase } from "ui/layouts/layout-base"; +import { Label } from "ui/label"; +import { TextField } from "ui/text-field"; +import { TextView } from "ui/text-view"; +import { Button } from "ui/button"; +import { FontStyle, FontWeight } from "ui/enums"; +import typeUtils = require("utils/types"); +import { Color } from "color"; + +const fontFamilies = ["system", "sans-serif", "serif", "monospace"]; +const fontWeights = [FontWeight.normal, FontWeight.bold]; +const fontStyles = [FontStyle.normal, FontStyle.italic]; + +export function onStackLayoutLoaded(args: EventData) { + var layout = args.object; + _generateViews(() => { return new Label(); }, layout); + _generateViews(() => { return new TextField(); }, layout); + _generateViews(() => { return new TextView(); }, layout); + _generateViews(() => { return new Button(); }, layout); +} + +function _generateViews(factory: () => View, layout: LayoutBase) { + for (var f = 0; f < fontFamilies.length; f++) { + for (var w = 0; w < fontWeights.length; w++) { + for (var s = 0; s < fontStyles.length; s++) { + var view = factory(); + var css = `font-family: ${fontFamilies[f]}; font-weight: ${fontWeights[w]}; font-style: ${fontStyles[s]};`; + (view).text = `${typeUtils.getClass(view)} ${css}`; + (view).textWrap = true; + view.style.textAlignment = "left"; + view.setInlineStyle(css); + view.margin = "1 0"; + view.borderWidth = 1; + view.height = 75; + view.color = new Color("Black"); + view.backgroundColor = new Color("LightGray"); + view.on("loaded", args => { + (view).text += _getFontInfo(view); + }); + layout.addChild(view); + } + } + } +} + +function _getFontInfo(view: View): string { + if (view.ios) { + var uiFont: UIFont; + if (view.ios instanceof UIButton) { + uiFont = view.ios.titleLabel.font; + } + else if (view.ios.font) { + uiFont = view.ios.font; + } + + return ` ${uiFont.fontName} ${uiFont.pointSize}pt.`; + } + + return ""; +} \ No newline at end of file diff --git a/apps/sample-fonts/main-page.xml b/apps/sample-fonts/main-page.xml new file mode 100644 index 000000000..e029e0bf4 --- /dev/null +++ b/apps/sample-fonts/main-page.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/apps/sample-fonts/package.json b/apps/sample-fonts/package.json new file mode 100644 index 000000000..db7dfb767 --- /dev/null +++ b/apps/sample-fonts/package.json @@ -0,0 +1,2 @@ +{ "name" : "sample-fonts", + "main" : "app.js" } diff --git a/apps/tests/app/mainPage.ts b/apps/tests/app/mainPage.ts index 8060aa485..eb88d4e0f 100644 --- a/apps/tests/app/mainPage.ts +++ b/apps/tests/app/mainPage.ts @@ -1,6 +1,7 @@ import {Page} from "ui/page"; import * as trace from "trace"; import tests = require("../testRunner"); +import {Label} from "ui/label"; trace.enable(); trace.addCategories(trace.categories.Test + "," + trace.categories.Error); @@ -11,6 +12,8 @@ page.id = "mainPage"; page.on(Page.navigatedToEvent, onNavigatedTo); function onNavigatedTo(args) { + let label = new Label({ text: "Running non-UI tests..." }); + page.content = label args.object.off(Page.navigatedToEvent, onNavigatedTo); setTimeout(function () { tests.runAll(); diff --git a/apps/tests/file-system-tests.ts b/apps/tests/file-system-tests.ts index f02ee8069..1c382df08 100644 --- a/apps/tests/file-system-tests.ts +++ b/apps/tests/file-system-tests.ts @@ -535,4 +535,14 @@ export function test_UnlockAfterWrite(done) { return file.remove(); }).then(() => done()) .catch(done); +} + +export function test_CreateParentOnNewFile(done) { + var documentsFolderName = fs.knownFolders.documents().path; + var tempFileName = fs.path.join(documentsFolderName, "folder1", "folder2", "Test_File_Create_Parent.txt"); + var file = fs.File.fromPath(tempFileName); + file.writeText("Hello World!").then(() => { + return fs.knownFolders.documents().getFolder("folder1").remove(); + }).then(() => done()) + .catch(done); } \ No newline at end of file diff --git a/apps/tests/observable-tests.ts b/apps/tests/observable-tests.ts index 07e3521fb..2dd833fdd 100644 --- a/apps/tests/observable-tests.ts +++ b/apps/tests/observable-tests.ts @@ -421,12 +421,10 @@ export var test_ObservableCreatedWithJSON_shouldDistinguishSeparateObjects = fun }); observable1.set("val", 10); - TKUnit.wait(0.1); TKUnit.assert(propName1 === "val", "propName1 should be 'val'"); TKUnit.assert(newValue1 === 10, "newValue1 should be 10"); observable2.set("val", 20); - TKUnit.wait(0.1); TKUnit.assert(propName2 === "val", "propName2 should be 'val'"); TKUnit.assert(newValue2 === 20, "newValue2 should be 20"); @@ -460,12 +458,10 @@ export var test_ObservablesCreatedWithJSON_shouldNotInterfereWithOneAnother = fu }); observable1.set("property1", 10); - TKUnit.wait(0.1); TKUnit.assert(propName1 === "property1", "propName1 should be 'property1'"); TKUnit.assert(newValue1 === 10, "newValue1 should be 10"); observable2.set("property2", 20); - TKUnit.wait(0.1); TKUnit.assert(propName2 === "property2", "propName2 should be 'property2'"); TKUnit.assert(newValue2 === 20, "newValue2 should be 20"); }; diff --git a/apps/tests/testRunner.ts b/apps/tests/testRunner.ts index ffdd3ef1a..fc40fa3fb 100644 --- a/apps/tests/testRunner.ts +++ b/apps/tests/testRunner.ts @@ -26,34 +26,44 @@ export function isRunningOnEmulator(): boolean { } export var allTests = {}; +if (!isRunningOnEmulator()) { + allTests["LOCATION"] = require("./location-tests"); +} + +allTests["PLATFORM"] = require("./platform-tests"); +allTests["FILE SYSTEM"] = require("./file-system-tests"); +allTests["HTTP"] = require("./http-tests"); +allTests["XHR"] = require("./xhr-tests"); +allTests["FETCH"] = require("./fetch-tests"); +allTests["APPLICATION SETTINGS"] = require("./application-settings-tests"); +allTests["APPLICATION"] = require("./application-tests"); +allTests["IMAGE SOURCE"] = require("./image-source-tests"); +allTests["OBSERVABLE-ARRAY"] = require("./observable-array-tests"); +allTests["VIRTUAL-ARRAY"] = require("./virtual-array-tests"); +allTests["OBSERVABLE"] = require("./observable-tests"); +allTests["TIMER"] = require("./timer-tests"); +allTests["COLOR"] = require("./color-tests"); +allTests["DEPENDENCY-OBSERVABLE"] = require("./ui/dependency-observable-tests"); +allTests["BINDABLE"] = require("./ui/bindable-tests"); +allTests["BINDING-EXPRESSIONS"] = require("./ui/binding-expressions-tests"); +allTests["XML-PARSER"] = require("./xml-parser-tests/xml-parser-tests"); +allTests["FORMATTEDSTRING"] = require("./text/formatted-string-tests"); +allTests["FILE-SYSTEM-ACCESS"] = require("./file-system-access-tests/file-system-access-tests"); +allTests["FILE-NAME-RESOLVER"] = require("./file-name-resolver-tests/file-name-resolver-tests"); +allTests["WEAK-EVENTS"] = require("./weak-event-listener-tests"); +allTests["CONNECTIVITY"] = require("./connectivity-tests"); + allTests["PROXY-VIEW-CONTAINER"] = require("./ui/proxy-view-container/proxy-view-container-tests") allTests["SCROLL-VIEW"] = require("./ui/scroll-view/scroll-view-tests"); allTests["ACTION-BAR"] = require("./ui/action-bar/action-bar-tests"); allTests["XML-DECLARATION"] = require("./xml-declaration/xml-declaration-tests"); -allTests["APPLICATION"] = require("./application-tests"); allTests["DOCKLAYOUT"] = require("./layouts/dock-layout-tests"); allTests["WRAPLAYOUT"] = require("./layouts/wrap-layout-tests"); allTests["ABSOLUTELAYOUT"] = require("./layouts/absolute-layout-tests"); allTests["GRIDLAYOUT"] = require("./layouts/grid-layout-tests"); allTests["STACKLAYOUT"] = require("./layouts/stack-layout-tests"); -allTests["PLATFORM"] = require("./platform-tests"); allTests["STYLE-PROPERTIES"] = require("./ui/style/style-properties-tests"); -allTests["FILE SYSTEM"] = require("./file-system-tests"); -allTests["HTTP"] = require("./http-tests"); -allTests["XHR"] = require("./xhr-tests"); -allTests["FETCH"] = require("./fetch-tests"); allTests["FRAME"] = require("./frame-tests"); -allTests["APPLICATION SETTINGS"] = require("./application-settings-tests"); -allTests["IMAGE SOURCE"] = require("./image-source-tests"); -allTests["TIMER"] = require("./timer-tests"); -allTests["COLOR"] = require("./color-tests"); -allTests["OBSERVABLE-ARRAY"] = require("./observable-array-tests"); -allTests["VIRTUAL-ARRAY"] = require("./virtual-array-tests"); -allTests["OBSERVABLE"] = require("./observable-tests"); -allTests["DEPENDENCY-OBSERVABLE"] = require("./ui/dependency-observable-tests"); -allTests["BINDABLE"] = require("./ui/bindable-tests"); -allTests["BINDING-EXPRESSIONS"] = require("./ui/binding-expressions-tests"); -allTests["XML-PARSER"] = require("./xml-parser-tests/xml-parser-tests"); allTests["VIEW"] = require("./ui/view/view-tests"); allTests["STYLE"] = require("./ui/style/style-tests"); allTests["VISUAL-STATE"] = require("./ui/style/visual-state-tests"); @@ -73,31 +83,22 @@ allTests["LISTVIEW"] = require("./ui/list-view/list-view-tests"); allTests["ACTIVITY-INDICATOR"] = require("./ui/activity-indicator/activity-indicator-tests"); allTests["TEXT-FIELD"] = require("./ui/text-field/text-field-tests"); allTests["TEXT-VIEW"] = require("./ui/text-view/text-view-tests"); -allTests["FORMATTEDSTRING"] = require("./text/formatted-string-tests"); -allTests["FILE-SYSTEM-ACCESS"] = require("./file-system-access-tests/file-system-access-tests"); -allTests["FILE-NAME-RESOLVER"] = require("./file-name-resolver-tests/file-name-resolver-tests"); allTests["LIST-PICKER"] = require("./ui/list-picker/list-picker-tests"); allTests["DATE-PICKER"] = require("./ui/date-picker/date-picker-tests"); allTests["TIME-PICKER"] = require("./ui/time-picker/time-picker-tests"); allTests["WEB-VIEW"] = require("./ui/web-view/web-view-tests"); allTests["HTML-VIEW"] = require("./ui/html-view/html-view-tests"); -allTests["WEAK-EVENTS"] = require("./weak-event-listener-tests"); allTests["REPEATER"] = require("./ui/repeater/repeater-tests"); allTests["SEARCH-BAR"] = require('./ui/search-bar/search-bar-tests'); -allTests["CONNECTIVITY"] = require("./connectivity-tests"); allTests["SEGMENTED-BAR"] = require("./ui/segmented-bar/segmented-bar-tests"); allTests["ANIMATION"] = require("./ui/animation/animation-tests"); allTests["CSS-ANIMATION"] = require("./ui/animation/css-animation-tests"); -if (!isRunningOnEmulator()) { - allTests["LOCATION"] = require("./location-tests"); -} // Skip transitions on android emulators with API 23 if (!(platform.device.os === platform.platformNames.android && parseInt(platform.device.sdkVersion) === 23 && isRunningOnEmulator())) { allTests["TANSITIONS"] = require("./navigation/transition-tests"); } -// Navigation tests should always be last. allTests["NAVIGATION"] = require("./navigation/navigation-tests"); var testsWithLongDelay = { @@ -106,16 +107,19 @@ var testsWithLongDelay = { testLocationOnce: 10000, testLocationOnceMaximumAge: 10000, //web-view-tests - testLoadExistingUrl: 10000, - testLoadInvalidUrl: 10000 + testLoadExistingUrl: 10000 * 5, + testLoadLocalFile: 10000 * 5, + testLoadInvalidUrl: 10000, + testLoadUpperCaseSrc: 10000 * 5 } -var duration; +var startTime; var running = false; var testsQueue = new Array(); function printRunTestStats() { let testFileContent = new Array(); + let testCases = new Array(); var j; var failedTestCount = 0; @@ -124,12 +128,11 @@ function printRunTestStats() { let allTests = testsQueue.filter(t=> t.isTest); testFileContent.push(""); - testFileContent.push(``); for (j = 0; j < allTests.length; j++) { let testName = allTests[j].testName; - let duration = Math.round(allTests[j].duration / 1000); - + let duration = (allTests[j].duration / 1000).toFixed(2); + if (!allTests[j].isPassed) { failedTestCount++; @@ -137,15 +140,23 @@ function printRunTestStats() { failedTestInfo.push(allTests[j].testName + " FAILED: " + allTests[j].errorMessage); - testFileContent.push(``); + testCases.push(``); } else { - testFileContent.push(``); + testCases.push(``); } } + + var totalTime = (TKUnit.time() - startTime).toFixed(2); + + testFileContent.push(``); + testFileContent = testFileContent.concat(testCases); - let finalMessage = `=== ALL TESTS COMPLETE for ${Math.round(TKUnit.time() - duration)} ms === \n${(allTests.length - failedTestCount)} OK, ${failedTestCount} failed\n`; +// DO NOT CHANGE THE FIRST ROW! Used as an indicator for test run pass detection. + let finalMessage = `=== ALL TESTS COMPLETE ===\n` + + `${(allTests.length - failedTestCount)} OK, ${failedTestCount} failed\n` + + `DURATION: ${totalTime} ms`; TKUnit.write(finalMessage, messageType.info); for (j = 0; j < failedTestInfo.length; j++) { let failureMessage = failedTestInfo[j]; @@ -211,7 +222,7 @@ export var runAll = function (testSelector?: string) { var totalSuccess = 0; var totalFailed: Array = []; - testsQueue.push(new TestInfo(() => { running = true; duration = TKUnit.time(); })); + testsQueue.push(new TestInfo(() => { running = true; startTime = TKUnit.time(); })); for (var name in allTests) { if (singleModuleName && (singleModuleName !== name.toLowerCase())) { continue; diff --git a/apps/tests/timer-tests.ts b/apps/tests/timer-tests.ts index 5492454e7..d6db49f53 100644 --- a/apps/tests/timer-tests.ts +++ b/apps/tests/timer-tests.ts @@ -1,6 +1,5 @@ import TKUnit = require("./TKUnit"); -import platform = require("platform"); -var timer = require("timer/timer"); +import timer = require("timer"); // >> timer-require // require("globals"); @@ -8,122 +7,108 @@ var timer = require("timer/timer"); // var timer = require("timer"); // << timer-require -export var test_setTimeout_isDefined = function () { +export function test_setTimeout_isDefined() { TKUnit.assert(typeof (timer.setTimeout) !== "undefined", "Method timer.setTimeout() should be defined!"); }; -export var test_clearTimeout_isDefined = function () { +export function test_clearTimeout_isDefined() { TKUnit.assert(typeof (timer.clearTimeout) !== "undefined", "Method timer.clearTimeout() should be defined!"); }; -export var test_setInterval_isDefined = function () { +export function test_setInterval_isDefined() { TKUnit.assert(typeof (timer.setInterval) !== "undefined", "Method timer.setInterval() should be defined!"); }; -export var test_clearInterval_isDefined = function () { +export function test_clearInterval_isDefined() { TKUnit.assert(typeof (timer.clearInterval) !== "undefined", "Method timer.clearInterval() should be defined!"); }; -export var test_setTimeout = function () { - var completed: boolean; - var isReady = function () { return completed; } +export function test_setTimeout() { + let completed: boolean; // >> timer-set-zero - timer.setTimeout(function () { + timer.setTimeout(() => { // >> (hide) completed = true; // << (hide) }); // << timer-set-zero - TKUnit.waitUntilReady(isReady, 0.5); + TKUnit.waitUntilReady(() => completed, 0.5); TKUnit.assert(completed, "Callback should be called!"); }; -export var test_setTimeout_callbackCalledAfterSpecifiedTime = function () { - var completed: boolean; - var isReady = function () { return completed; } +export function test_setTimeout_callbackCalledAfterSpecifiedTime() { + let completed = false; // >> timer-set-fivehundred - timer.setTimeout(function () { + timer.setTimeout(() => { // >> (hide) completed = true; // << (hide) - }, 500); + }, 10); // << timer-set-fivehundred - TKUnit.waitUntilReady(isReady, 1); + TKUnit.waitUntilReady(() => completed, 1); TKUnit.assert(completed, "Callback should be called after specified time!"); }; -export var test_setTimeout_callbackNotCalled = function () { - var completed: boolean; - var isReady = function () { return completed; } +export function test_setTimeout_callbackNotCalled() { + let completed = false; + timer.setTimeout(() => completed = true, 50); - timer.setTimeout(function () { - completed = true; - }, 1000); - - TKUnit.waitUntilReady(isReady, 0.5); + TKUnit.waitUntilReady(() => completed, 0.01); TKUnit.assert(!completed, "Callback should be called after specified time!"); }; -export var test_setTimeout_shouldReturnNumber = function () { - var id = timer.setTimeout(function () { +export function test_setTimeout_shouldReturnNumber() { + let id = timer.setTimeout(() => { // }); TKUnit.assert(typeof id === "number", "Callback should return number!"); }; -export var test_setTimeout_callbackShouldBeCleared = function () { - // This test is very unstable in iOS, because the platform does not guarantee the - // callback will be cleared on time. Better skip it for iOS. - if (platform.device.os === platform.platformNames.ios) { - return; - } - - var completed: boolean; - var isReady = function () { return completed; } +export function test_setTimeout_callbackShouldBeCleared() { + let completed = false; // >> timer-set-twothousands - var id = timer.setTimeout(function () { + let id = timer.setTimeout(() => { // >> (hide) completed = true; // << (hide) - }, 2000); + }, 50); + // << timer-set-twothousands //// Clear timeout with specified id. timer.clearTimeout(id); // << timer-set-twothousands - TKUnit.waitUntilReady(isReady, 3); + TKUnit.waitUntilReady(() => completed, 0.060); TKUnit.assert(!completed, "Callback should be cleared when clearTimeout() is executed for specified id!"); }; -export var test_setInterval_callbackCalledDuringPeriod = function () { - var counter = 0; - var expected = 4; - var isReady = function () { return counter >= expected; } +export function test_setInterval_callbackCalledDuringPeriod() { + let counter = 0; + let expected = 4; // >> timer-set-expression - timer.setInterval(function () { + timer.setInterval(() => { // >> (hide) counter++; // << (hide) }, 100); // << timer-set-expression - TKUnit.waitUntilReady(isReady, 0.5); - TKUnit.assert(isReady(), "Callback should be raised at least" + expected + "times! Callback raised " + counter + " times."); + TKUnit.waitUntilReady(() => counter >= expected, 0.5); + TKUnit.assert(counter >= expected, "Callback should be raised at least" + expected + "times! Callback raised " + counter + " times."); }; -export var test_setInterval_callbackShouldBeCleared = function () { - var counter = 0; - var isReady = function () { return false; } +export function test_setInterval_callbackShouldBeCleared() { + let counter = 0; // >> timer-set-interval - var id = timer.setInterval(function () { + let id = timer.setInterval(() => { // >> (hide) counter++; // << (hide) @@ -131,6 +116,6 @@ export var test_setInterval_callbackShouldBeCleared = function () { }, 100); // << timer-set-interval - TKUnit.waitUntilReady(isReady, 0.5); + TKUnit.waitUntilReady(() => false, 0.5); TKUnit.assert(counter === 1, "Callback should be raised only once!"); }; \ No newline at end of file diff --git a/apps/tests/ui/activity-indicator/activity-indicator-tests.ts b/apps/tests/ui/activity-indicator/activity-indicator-tests.ts index 012c19989..18e79b54b 100644 --- a/apps/tests/ui/activity-indicator/activity-indicator-tests.ts +++ b/apps/tests/ui/activity-indicator/activity-indicator-tests.ts @@ -9,7 +9,6 @@ import color = require("color"); import activityIndicatorModule = require("ui/activity-indicator"); // << activity-indicator-require -var ASYNC = 0.2; export function test_default_TNS_values() { // >> activity-indicator-create var indicator = new activityIndicatorModule.ActivityIndicator(); @@ -37,7 +36,7 @@ export function test_set_TNS_value_updates_native_value() { function testAction(views: Array) { indicator.busy = true; - TKUnit.wait(ASYNC); + TKUnit.waitUntilReady(() => getNativeBusy(indicator) === true); TKUnit.assertEqual(getNativeBusy(indicator), true, "Native value is different from TNS value."); }; diff --git a/apps/tests/ui/animation/animation-tests.ts b/apps/tests/ui/animation/animation-tests.ts index e262cb0ad..70122154c 100644 --- a/apps/tests/ui/animation/animation-tests.ts +++ b/apps/tests/ui/animation/animation-tests.ts @@ -1,9 +1,8 @@ import TKUnit = require("../../TKUnit"); import helper = require("../helper"); -import pageModule = require("ui/page"); import viewModule = require("ui/core/view"); -import labelModule = require("ui/label"); -import stackLayoutModule = require("ui/layouts/stack-layout"); +import {Label} from "ui/label"; +import {StackLayout} from "ui/layouts/stack-layout"; import colorModule = require("color"); import enums = require("ui/enums"); @@ -11,21 +10,18 @@ import enums = require("ui/enums"); import animation = require("ui/animation"); // << animation-require -export var test_AnimatingProperties = function(done) { - var mainPage: pageModule.Page; - var label: labelModule.Label; - var pageFactory = function(): pageModule.Page { - label = new labelModule.Label(); - label.text = "label"; - var stackLayout = new stackLayoutModule.StackLayout(); - stackLayout.addChild(label); - mainPage = new pageModule.Page(); - mainPage.content = stackLayout; - return mainPage; - }; +function prepareTest(): Label { + let mainPage = helper.getCurrentPage(); + let label = new Label({ text: "label" }); + let stackLayout = new StackLayout(); + stackLayout.addChild(label); + mainPage.content = stackLayout; + TKUnit.waitUntilReady(() => label.isLoaded); + return label; +} - helper.navigate(pageFactory); - TKUnit.waitUntilReady(() => { return label.isLoaded }); +export function test_AnimatingProperties(done) { + let label = prepareTest(); // >> animation-properties label.animate({ @@ -34,7 +30,7 @@ export var test_AnimatingProperties = function(done) { translate: { x: 100, y: 100 }, scale: { x: 2, y: 2 }, rotate: 180, - duration: 1000, + duration: 10, delay: 100, iterations: 3, curve: enums.AnimationCurve.easeIn @@ -55,24 +51,12 @@ export var test_AnimatingProperties = function(done) { // << animation-properties } -export var test_CancellingAnimation = function(done) { - var mainPage: pageModule.Page; - var label: labelModule.Label; - var pageFactory = function(): pageModule.Page { - label = new labelModule.Label(); - label.text = "label"; - var stackLayout = new stackLayoutModule.StackLayout(); - stackLayout.addChild(label); - mainPage = new pageModule.Page(); - mainPage.content = stackLayout; - return mainPage; - }; - - helper.navigate(pageFactory); - TKUnit.waitUntilReady(() => { return label.isLoaded }); +export function test_CancellingAnimation(done) { + let label = prepareTest(); // >> animation-cancel - var animation1 = label.createAnimation({ translate: { x: 100, y: 100 }, duration: 500 }); + var animation1 = label.createAnimation({ translate: { x: 100, y: 100 }, duration: 20 }); + animation1.play() .then(() => { ////console.log("Animation finished"); @@ -96,24 +80,11 @@ export var test_CancellingAnimation = function(done) { // << animation-cancel } -export var test_CancellingAnimate = function(done) { - var mainPage: pageModule.Page; - var label: labelModule.Label; - var pageFactory = function(): pageModule.Page { - label = new labelModule.Label(); - label.text = "label"; - var stackLayout = new stackLayoutModule.StackLayout(); - stackLayout.addChild(label); - mainPage = new pageModule.Page(); - mainPage.content = stackLayout; - return mainPage; - }; - - helper.navigate(pageFactory); - TKUnit.waitUntilReady(() => { return label.isLoaded }); +export function test_CancellingAnimate(done) { + let label = prepareTest(); // >> animation-cancel2 - var animation1 = label.animate({ translate: { x: 100, y: 100 }, duration: 500 }) + var animation1 = label.animate({ translate: { x: 100, y: 100 }, duration: 20 }) .then(() => { ////console.log("Animation finished"); // >> (hide) @@ -136,30 +107,22 @@ export var test_CancellingAnimate = function(done) { // << animation-cancel2 } -export var test_ChainingAnimations = function(done) { - var mainPage: pageModule.Page; - var label: labelModule.Label; - var pageFactory = function(): pageModule.Page { - label = new labelModule.Label(); - label.text = "label"; - var stackLayout = new stackLayoutModule.StackLayout(); - stackLayout.addChild(label); - mainPage = new pageModule.Page(); - mainPage.content = stackLayout; - return mainPage; - }; - helper.navigate(pageFactory); - TKUnit.waitUntilReady(() => { return label.isLoaded }); +export function test_ChainingAnimations(done) { + let label = prepareTest(); // >> animation-chaining - label.animate({ opacity: 0 }) - .then(() => label.animate({ opacity: 1 })) - .then(() => label.animate({ translate: { x: 200, y: 200 } })) - .then(() => label.animate({ translate: { x: 0, y: 0 } })) - .then(() => label.animate({ scale: { x: 5, y: 5 } })) - .then(() => label.animate({ scale: { x: 1, y: 1 } })) - .then(() => label.animate({ rotate: 180 })) - .then(() => label.animate({ rotate: 0 })) + let duration = 300; + // >> (hide) + duration = 5; + // << (hide) + label.animate({ opacity: 0, duration: duration }) + .then(() => label.animate({ opacity: 1, duration: duration })) + .then(() => label.animate({ translate: { x: 200, y: 200 }, duration: duration })) + .then(() => label.animate({ translate: { x: 0, y: 0 }, duration: duration })) + .then(() => label.animate({ scale: { x: 5, y: 5 }, duration: duration })) + .then(() => label.animate({ scale: { x: 1, y: 1 }, duration: duration })) + .then(() => label.animate({ rotate: 180, duration: duration })) + .then(() => label.animate({ rotate: 0, duration: duration })) .then(() => { ////console.log("Animation finished"); // >> (hide) @@ -176,25 +139,12 @@ export var test_ChainingAnimations = function(done) { // << animation-chaining } -export var test_ReusingAnimations = function(done) { - var mainPage: pageModule.Page; - var label: labelModule.Label; - var pageFactory = function(): pageModule.Page { - label = new labelModule.Label(); - label.text = "label"; - var stackLayout = new stackLayoutModule.StackLayout(); - stackLayout.addChild(label); - mainPage = new pageModule.Page(); - mainPage.content = stackLayout; - return mainPage; - }; - - helper.navigate(pageFactory); - TKUnit.waitUntilReady(() => { return label.isLoaded }); +export function test_ReusingAnimations(done) { + let label = prepareTest(); // >> animation-reusing - var animation1 = label.createAnimation({ translate: { x: 100, y: 100 } }); - var animation2 = label.createAnimation({ translate: { x: 0, y: 0 } }); + var animation1 = label.createAnimation({ translate: { x: 100, y: 100 }, duration: 5 }); + var animation2 = label.createAnimation({ translate: { x: 0, y: 0 }, duration: 5 }); animation1.play() .then(() => animation2.play()) @@ -218,34 +168,23 @@ export var test_ReusingAnimations = function(done) { // << animation-reusing } -export var test_AnimatingMultipleViews = function(done) { - var mainPage: pageModule.Page; - var label1: labelModule.Label; - var label2: labelModule.Label; - var label3: labelModule.Label; - var pageFactory = function(): pageModule.Page { - label1 = new labelModule.Label(); - label1.text = "label1"; - label2 = new labelModule.Label(); - label2.text = "label2"; - label3 = new labelModule.Label(); - label3.text = "label3"; - var stackLayout = new stackLayoutModule.StackLayout(); - stackLayout.addChild(label1); - stackLayout.addChild(label2); - stackLayout.addChild(label3); - mainPage = new pageModule.Page(); - mainPage.content = stackLayout; - return mainPage; - }; - helper.navigate(pageFactory); - TKUnit.waitUntilReady(() => { return label1.isLoaded && label2.isLoaded }); +export function test_AnimatingMultipleViews(done) { + let mainPage = helper.getCurrentPage(); + let label1 = new Label({ text: "label1" }); + let label2 = new Label({ text: "label2" }); + let label3 = new Label({ text: "label3" }); + let stackLayout = new StackLayout(); + stackLayout.addChild(label1); + stackLayout.addChild(label2); + stackLayout.addChild(label3); + mainPage.content = stackLayout; + TKUnit.waitUntilReady(() => label3.isLoaded); // >> animation-multiple-views var animations: Array = [ - { target: label1, translate: { x: 200, y: 200 }, duration: 1000, delay: 0 }, - { target: label2, translate: { x: 200, y: 200 }, duration: 1000, delay: 333 }, - { target: label3, translate: { x: 200, y: 200 }, duration: 1000, delay: 666 }, + { target: label1, translate: { x: 200, y: 200 }, duration: 20, delay: 0 }, + { target: label2, translate: { x: 200, y: 200 }, duration: 20, delay: 7 }, + { target: label3, translate: { x: 200, y: 200 }, duration: 20, delay: 14 }, ]; var a = new animation.Animation(animations); a.play() @@ -267,23 +206,10 @@ export var test_AnimatingMultipleViews = function(done) { // << animation-multiple-views } -export var test_AnimateOpacity = function(done) { - var mainPage: pageModule.Page; - var label: labelModule.Label; - var pageFactory = function(): pageModule.Page { - label = new labelModule.Label(); - label.text = "label"; - var stackLayout = new stackLayoutModule.StackLayout(); - stackLayout.addChild(label); - mainPage = new pageModule.Page(); - mainPage.content = stackLayout; - return mainPage; - }; +export function test_AnimateOpacity(done) { + let label = prepareTest(); - helper.navigate(pageFactory); - TKUnit.waitUntilReady(() => { return label.isLoaded }); - - label.animate({ opacity: 0.75 }) + label.animate({ opacity: 0.75, duration: 20 }) .then(() => { TKUnit.assertEqual(label.opacity, 0.75, "label.opacity"); done(); @@ -293,8 +219,8 @@ export var test_AnimateOpacity = function(done) { }); } -export var test_AnimateOpacity_ShouldThrow_IfNotNumber = () => { - var label = new labelModule.Label(); +export function test_AnimateOpacity_ShouldThrow_IfNotNumber() { + var label = new Label(); helper.buildUIAndRunTest(label, (views: Array) => { TKUnit.assertThrows(() => { label.animate({ opacity: "0.75" }); @@ -302,8 +228,8 @@ export var test_AnimateOpacity_ShouldThrow_IfNotNumber = () => { }); } -export var test_AnimateDelay_ShouldThrow_IfNotNumber = () => { - var label = new labelModule.Label(); +export function test_AnimateDelay_ShouldThrow_IfNotNumber() { + var label = new Label(); helper.buildUIAndRunTest(label, (views: Array) => { TKUnit.assertThrows(() => { label.animate({ delay: "1" }); @@ -311,8 +237,8 @@ export var test_AnimateDelay_ShouldThrow_IfNotNumber = () => { }); } -export var test_AnimateDuration_ShouldThrow_IfNotNumber = () => { - var label = new labelModule.Label(); +export function test_AnimateDuration_ShouldThrow_IfNotNumber() { + var label = new Label(); helper.buildUIAndRunTest(label, (views: Array) => { TKUnit.assertThrows(() => { label.animate({ duration: "1" }); @@ -320,8 +246,8 @@ export var test_AnimateDuration_ShouldThrow_IfNotNumber = () => { }); } -export var test_AnimateIterations_ShouldThrow_IfNotNumber = () => { - var label = new labelModule.Label(); +export function test_AnimateIterations_ShouldThrow_IfNotNumber() { + var label = new Label(); helper.buildUIAndRunTest(label, (views: Array) => { TKUnit.assertThrows(() => { label.animate({ iterations: "1" }); @@ -329,8 +255,8 @@ export var test_AnimateIterations_ShouldThrow_IfNotNumber = () => { }); } -export var test_AnimateRotate_ShouldThrow_IfNotNumber = () => { - var label = new labelModule.Label(); +export function test_AnimateRotate_ShouldThrow_IfNotNumber() { + var label = new Label(); helper.buildUIAndRunTest(label, (views: Array) => { TKUnit.assertThrows(() => { label.animate({ rotate: "1" }); @@ -338,8 +264,8 @@ export var test_AnimateRotate_ShouldThrow_IfNotNumber = () => { }); } -export var test_AnimateScale_ShouldThrow_IfNotPair = () => { - var label = new labelModule.Label(); +export function test_AnimateScale_ShouldThrow_IfNotPair() { + var label = new Label(); helper.buildUIAndRunTest(label, (views: Array) => { TKUnit.assertThrows(() => { label.animate({ scale: "1" }); @@ -347,8 +273,8 @@ export var test_AnimateScale_ShouldThrow_IfNotPair = () => { }); } -export var test_AnimateTranslate_ShouldThrow_IfNotPair = () => { - var label = new labelModule.Label(); +export function test_AnimateTranslate_ShouldThrow_IfNotPair() { + var label = new Label(); helper.buildUIAndRunTest(label, (views: Array) => { TKUnit.assertThrows(() => { label.animate({ translate: "1" }); @@ -356,8 +282,8 @@ export var test_AnimateTranslate_ShouldThrow_IfNotPair = () => { }); } -export var test_AnimateBackgroundColor_ShouldThrow_IfNotValidColorStringOrColor = () => { - var label = new labelModule.Label(); +export function test_AnimateBackgroundColor_ShouldThrow_IfNotValidColorStringOrColor() { + var label = new Label(); helper.buildUIAndRunTest(label, (views: Array) => { TKUnit.assertThrows(() => { label.animate({ backgroundColor: "test" }); @@ -365,24 +291,11 @@ export var test_AnimateBackgroundColor_ShouldThrow_IfNotValidColorStringOrColor }); } -export var test_AnimateBackgroundColor = function(done) { - var mainPage: pageModule.Page; - var label: labelModule.Label; - var pageFactory = function(): pageModule.Page { - label = new labelModule.Label(); - label.text = "label"; - var stackLayout = new stackLayoutModule.StackLayout(); - stackLayout.addChild(label); - mainPage = new pageModule.Page(); - mainPage.content = stackLayout; - return mainPage; - }; - - helper.navigate(pageFactory); - TKUnit.waitUntilReady(() => { return label.isLoaded }); +export function test_AnimateBackgroundColor(done) { + let label = prepareTest(); var red = new colorModule.Color("Red"); - label.animate({ backgroundColor: red }) + label.animate({ backgroundColor: red, duration: 20 }) .then(() => { TKUnit.assert(label.backgroundColor.equals(red)); done(); @@ -392,26 +305,12 @@ export var test_AnimateBackgroundColor = function(done) { }); } -export var test_AnimateBackgroundColor_FromString = function(done) { - var mainPage: pageModule.Page; - var label: labelModule.Label; - var pageFactory = function(): pageModule.Page { - label = new labelModule.Label(); - label.text = "label"; - var stackLayout = new stackLayoutModule.StackLayout(); - stackLayout.addChild(label); - mainPage = new pageModule.Page(); - mainPage.content = stackLayout; - return mainPage; - }; - - helper.navigate(pageFactory); - TKUnit.waitUntilReady(() => { return label.isLoaded }); - +export function test_AnimateBackgroundColor_FromString(done) { + let label = prepareTest(); var expected = "Red"; var clr = new colorModule.Color(expected); - label.animate({ backgroundColor: expected }) + label.animate({ backgroundColor: expected, duration: 20 }) .then(() => { TKUnit.assert(label.backgroundColor.equals(clr)); done(); @@ -421,23 +320,10 @@ export var test_AnimateBackgroundColor_FromString = function(done) { }); } -export var test_AnimateTranslate = function(done) { - var mainPage: pageModule.Page; - var label: labelModule.Label; - var pageFactory = function(): pageModule.Page { - label = new labelModule.Label(); - label.text = "label"; - var stackLayout = new stackLayoutModule.StackLayout(); - stackLayout.addChild(label); - mainPage = new pageModule.Page(); - mainPage.content = stackLayout; - return mainPage; - }; +export function test_AnimateTranslate(done) { + let label = prepareTest(); - helper.navigate(pageFactory); - TKUnit.waitUntilReady(() => { return label.isLoaded }); - - label.animate({ translate: { x: 100, y: 200 } }) + label.animate({ translate: { x: 100, y: 200 }, duration: 20 }) .then(() => { TKUnit.assertEqual(label.translateX, 100, "label.translateX"); TKUnit.assertEqual(label.translateY, 200, "label.translateY"); @@ -449,23 +335,10 @@ export var test_AnimateTranslate = function(done) { }); } -export var test_AnimateScale = function(done) { - var mainPage: pageModule.Page; - var label: labelModule.Label; - var pageFactory = function(): pageModule.Page { - label = new labelModule.Label(); - label.text = "label"; - var stackLayout = new stackLayoutModule.StackLayout(); - stackLayout.addChild(label); - mainPage = new pageModule.Page(); - mainPage.content = stackLayout; - return mainPage; - }; +export function test_AnimateScale(done) { + let label = prepareTest(); - helper.navigate(pageFactory); - TKUnit.waitUntilReady(() => { return label.isLoaded }); - - label.animate({ scale: { x: 2, y: 3 } }) + label.animate({ scale: { x: 2, y: 3 }, duration: 20 }) .then(() => { TKUnit.assertEqual(label.scaleX, 2, "label.scaleX"); TKUnit.assertEqual(label.scaleY, 3, "label.scaleY"); @@ -477,23 +350,10 @@ export var test_AnimateScale = function(done) { }); } -export var test_AnimateRotate = function(done) { - var mainPage: pageModule.Page; - var label: labelModule.Label; - var pageFactory = function(): pageModule.Page { - label = new labelModule.Label(); - label.text = "label"; - var stackLayout = new stackLayoutModule.StackLayout(); - stackLayout.addChild(label); - mainPage = new pageModule.Page(); - mainPage.content = stackLayout; - return mainPage; - }; +export function test_AnimateRotate(done) { + let label = prepareTest(); - helper.navigate(pageFactory); - TKUnit.waitUntilReady(() => { return label.isLoaded }); - - label.animate({ rotate: 123 }) + label.animate({ rotate: 123, duration: 20 }) .then(() => { TKUnit.assertEqual(label.rotate, 123, "label.rotate"); assertIOSNativeTransformIsCorrect(label); @@ -504,26 +364,14 @@ export var test_AnimateRotate = function(done) { }); } -export var test_AnimateTranslateScaleAndRotateSimultaneously = function(done) { - var mainPage: pageModule.Page; - var label: labelModule.Label; - var pageFactory = function(): pageModule.Page { - label = new labelModule.Label(); - label.text = "label"; - var stackLayout = new stackLayoutModule.StackLayout(); - stackLayout.addChild(label); - mainPage = new pageModule.Page(); - mainPage.content = stackLayout; - return mainPage; - }; - - helper.navigate(pageFactory); - TKUnit.waitUntilReady(() => { return label.isLoaded }); +export function test_AnimateTranslateScaleAndRotateSimultaneously(done) { + let label = prepareTest(); label.animate({ translate: { x: 100, y: 200 }, scale: { x: 2, y: 3 }, - rotate: 123 + rotate: 123, + duration: 20 }) .then(() => { TKUnit.assertEqual(label.translateX, 100, "label.translateX"); @@ -539,28 +387,15 @@ export var test_AnimateTranslateScaleAndRotateSimultaneously = function(done) { }); } -export var test_AnimateTranslateScaleAndRotateSequentially = function(done) { - var mainPage: pageModule.Page; - var label: labelModule.Label; - var pageFactory = function(): pageModule.Page { - label = new labelModule.Label(); - label.text = "label"; - var stackLayout = new stackLayoutModule.StackLayout(); - stackLayout.addChild(label); - mainPage = new pageModule.Page(); - mainPage.content = stackLayout; - return mainPage; - }; +export function test_AnimateTranslateScaleAndRotateSequentially(done) { + let label = prepareTest(); - helper.navigate(pageFactory); - TKUnit.waitUntilReady(() => { return label.isLoaded }); - - label.animate({ translate: { x: 100, y: 200 } }) + label.animate({ translate: { x: 100, y: 200 }, duration: 20 }) .then(() => { TKUnit.assertEqual(label.translateX, 100, "label.translateX"); TKUnit.assertEqual(label.translateY, 200, "label.translateY"); assertIOSNativeTransformIsCorrect(label); - return label.animate({ scale: { x: 2, y: 3 } }); + return label.animate({ scale: { x: 2, y: 3 }, duration: 20 }); }) .then(() => { TKUnit.assertEqual(label.translateX, 100, "label.translateX"); @@ -568,7 +403,7 @@ export var test_AnimateTranslateScaleAndRotateSequentially = function(done) { TKUnit.assertEqual(label.scaleX, 2, "label.scaleX"); TKUnit.assertEqual(label.scaleY, 3, "label.scaleY"); assertIOSNativeTransformIsCorrect(label); - return label.animate({ rotate: 123 }); + return label.animate({ rotate: 123, duration: 20 }); }) .then(() => { TKUnit.assertEqual(label.translateX, 100, "label.translateX"); @@ -584,24 +419,11 @@ export var test_AnimateTranslateScaleAndRotateSequentially = function(done) { }); } -export var test_AnimationsAreAlwaysPlayed = function(done) { - var mainPage: pageModule.Page; - var label: labelModule.Label; - var pageFactory = function(): pageModule.Page { - label = new labelModule.Label(); - label.text = "label"; - var stackLayout = new stackLayoutModule.StackLayout(); - stackLayout.addChild(label); - mainPage = new pageModule.Page(); - mainPage.content = stackLayout; - return mainPage; - }; +export function test_AnimationsAreAlwaysPlayed(done) { + let label = prepareTest(); - helper.navigate(pageFactory); - TKUnit.waitUntilReady(() => { return label.isLoaded }); - - var animation1 = label.createAnimation({ opacity: 0 }); - var animation2 = label.createAnimation({ opacity: 1 }); + var animation1 = label.createAnimation({ opacity: 0, duration: 20 }); + var animation2 = label.createAnimation({ opacity: 1, duration: 20 }); animation1.play() .then(() => { @@ -618,23 +440,10 @@ export var test_AnimationsAreAlwaysPlayed = function(done) { }); } -export var test_PlayPromiseIsResolvedWhenAnimationFinishes = function(done) { - var mainPage: pageModule.Page; - var label: labelModule.Label; - var pageFactory = function(): pageModule.Page { - label = new labelModule.Label(); - label.text = "label"; - var stackLayout = new stackLayoutModule.StackLayout(); - stackLayout.addChild(label); - mainPage = new pageModule.Page(); - mainPage.content = stackLayout; - return mainPage; - }; +export function test_PlayPromiseIsResolvedWhenAnimationFinishes(done) { + let label = prepareTest(); - helper.navigate(pageFactory); - TKUnit.waitUntilReady(() => { return label.isLoaded }); - - var animation = label.createAnimation({ opacity: 0, duration: 1000 }); + var animation = label.createAnimation({ opacity: 0, duration: 20 }); animation.play() .then(function onResolved() { @@ -646,23 +455,10 @@ export var test_PlayPromiseIsResolvedWhenAnimationFinishes = function(done) { }); } -export var test_PlayPromiseIsRejectedWhenAnimationIsCancelled = function(done) { - var mainPage: pageModule.Page; - var label: labelModule.Label; - var pageFactory = function(): pageModule.Page { - label = new labelModule.Label(); - label.text = "label"; - var stackLayout = new stackLayoutModule.StackLayout(); - stackLayout.addChild(label); - mainPage = new pageModule.Page(); - mainPage.content = stackLayout; - return mainPage; - }; +export function test_PlayPromiseIsRejectedWhenAnimationIsCancelled(done) { + let label = prepareTest(); - helper.navigate(pageFactory); - TKUnit.waitUntilReady(() => { return label.isLoaded }); - - var animation = label.createAnimation({ opacity: 0, duration: 1000 }); + var animation = label.createAnimation({ opacity: 0, duration: 20 }); animation.play() .then(function onResolved() { diff --git a/apps/tests/ui/animation/css-animation-tests.ts b/apps/tests/ui/animation/css-animation-tests.ts index 6aff374b5..a7f5fd175 100644 --- a/apps/tests/ui/animation/css-animation-tests.ts +++ b/apps/tests/ui/animation/css-animation-tests.ts @@ -1,5 +1,4 @@ import TKUnit = require("../../TKUnit"); -import page = require("ui/page"); import styleScope = require("ui/styling/style-scope"); import keyframeAnimation = require("ui/animation/keyframe-animation"); import enums = require("ui/enums"); @@ -8,6 +7,7 @@ import stackModule = require("ui/layouts/stack-layout"); import labelModule = require("ui/label"); import color = require("color"); import selectorModule = require("ui/styling/css-selector"); +//import styling = require("ui/styling"); function createAnimationFromCSS(css: string, name: string): keyframeAnimation.KeyframeAnimationInfo { let scope = new styleScope.StyleScope(); @@ -32,7 +32,7 @@ function findSelectorInScope(scope: styleScope.StyleScope, name: string): select return selector; } -exports.test_ReadAnimationProperties = function () { +export function test_ReadAnimationProperties() { let css = ".test { " + "animation-name: first; " + "animation-duration: 4s; " + @@ -50,16 +50,18 @@ exports.test_ReadAnimationProperties = function () { TKUnit.assertEqual(animation.iterations, 10); TKUnit.assertTrue(animation.isForwards); TKUnit.assertTrue(animation.isReverse); -}; -exports.test_ReadTheAnimationProperty = function () { +} + +export function test_ReadTheAnimationProperty() { let animation = createAnimationFromCSS(".test { animation: second 0.2s ease-out 1 2 }", "test"); TKUnit.assertEqual(animation.name, "second"); TKUnit.assertEqual(animation.duration, 200); TKUnit.assertEqual(animation.curve, enums.AnimationCurve.easeOut); TKUnit.assertEqual(animation.delay, 1000); TKUnit.assertEqual(animation.iterations, 2); -}; -exports.test_ReadAnimationCurve = function () { +} + +export function test_ReadAnimationCurve() { let animation = createAnimationFromCSS(".test { animation-timing-function: ease-in; }", "test"); TKUnit.assertEqual(animation.curve, enums.AnimationCurve.easeIn); animation = createAnimationFromCSS(".test { animation-timing-function: ease-out; }", "test"); @@ -73,30 +75,34 @@ exports.test_ReadAnimationCurve = function () { animation = createAnimationFromCSS(".test { animation-timing-function: cubic-bezier(0.1, 1.0, 0.5, 0.5); }", "test"); let curve = animation.curve; TKUnit.assert(curve.x1 === 0.1 && curve.y1 === 1.0 && curve.x2 === 0.5 && curve.y2 === 0.5); -}; -exports.test_ReadIterations = function () { +} + +export function test_ReadIterations() { let animation = createAnimationFromCSS(".test { animation-iteration-count: 5; }", "test"); TKUnit.assertEqual(animation.iterations, 5); animation = createAnimationFromCSS(".test { animation-iteration-count: infinite; }", "test"); TKUnit.assertEqual(animation.iterations, Number.MAX_VALUE); -}; -exports.test_ReadFillMode = function () { +} + +export function test_ReadFillMode() { let animation = createAnimationFromCSS(".test { animation-iteration-count: 5; }", "test"); TKUnit.assertFalse(animation.isForwards); animation = createAnimationFromCSS(".test { animation-fill-mode: forwards; }", "test"); TKUnit.assertTrue(animation.isForwards); animation = createAnimationFromCSS(".test { animation-fill-mode: backwards; }", "test"); TKUnit.assertFalse(animation.isForwards); -}; -exports.test_ReadDirection = function () { +} + +export function test_ReadDirection() { let animation = createAnimationFromCSS(".test { animation-iteration-count: 5; }", "test"); TKUnit.assertFalse(animation.isReverse); animation = createAnimationFromCSS(".test { animation-direction: reverse; }", "test"); TKUnit.assertTrue(animation.isReverse); animation = createAnimationFromCSS(".test { animation-direction: normal; }", "test"); TKUnit.assertFalse(animation.isReverse); -}; -exports.test_ReadKeyframe = function () { +} + +export function test_ReadKeyframe() { let scope = new styleScope.StyleScope(); scope.css = ".test { animation-name: test; } @keyframes test { from { background-color: red; } to { background-color: blue; } }"; scope.ensureSelectors(); @@ -109,8 +115,9 @@ exports.test_ReadKeyframe = function () { TKUnit.assertEqual(animation.keyframes[1].duration, 1, "Second keyframe duration should be 1"); TKUnit.assertEqual(animation.keyframes[0].declarations.length, 1, "Keyframe declarations are not correct"); TKUnit.assertEqual(animation.keyframes[0].declarations[0].property, "backgroundColor", "Keyframe declarations are not correct"); -}; -exports.test_ReadScale = function () { +} + +export function test_ReadScale() { let animation = createAnimationFromCSS(".test { animation-name: test; } @keyframes test { to { transform: scaleX(5),scaleY(10); } }", "test"); let scale = animation.keyframes[0].declarations[0].value; TKUnit.assertEqual(animation.keyframes[0].declarations[0].property, "scale"); @@ -127,8 +134,9 @@ exports.test_ReadScale = function () { scale = animation.keyframes[0].declarations[0].value; TKUnit.assertEqual(animation.keyframes[0].declarations[0].property, "scale"); TKUnit.assert(scale.x === 10 && scale.y === 20); -}; -exports.test_ReadTranslate = function () { +} + +export function test_ReadTranslate() { let animation = createAnimationFromCSS(".test { animation-name: test; } @keyframes test { to { transform: translateX(5),translateY(10); } }", "test"); let translate = animation.keyframes[0].declarations[0].value; TKUnit.assertEqual(animation.keyframes[0].declarations[0].property, "translate"); @@ -145,8 +153,9 @@ exports.test_ReadTranslate = function () { translate = animation.keyframes[0].declarations[0].value; TKUnit.assertEqual(animation.keyframes[0].declarations[0].property, "translate"); TKUnit.assert(translate.x === 10 && translate.y === 20); -}; -exports.test_ReadRotate = function () { +} + +export function test_ReadRotate() { let animation = createAnimationFromCSS(".test { animation-name: test; } @keyframes test { to { transform: rotate(5); } }", "test"); TKUnit.assertEqual(animation.keyframes[0].declarations[0].property, "rotate"); TKUnit.assertEqual(animation.keyframes[0].declarations[0].value, 5); @@ -156,8 +165,9 @@ exports.test_ReadRotate = function () { animation = createAnimationFromCSS(".test { animation-name: test; } @keyframes test { to { transform: rotate(0.7853981634rad); } }", "test"); TKUnit.assertEqual(animation.keyframes[0].declarations[0].property, "rotate"); TKUnit.assertTrue(animation.keyframes[0].declarations[0].value - 45 < 0.1); -}; -exports.test_ReadTransform = function () { +} + +export function test_ReadTransform() { let css = ".test { animation-name: test; } @keyframes test { to { transform: rotate(10),scaleX(5),translate(2,4); } }"; let animation = createAnimationFromCSS(css, "test"); let rotate = animation.keyframes[0].declarations[0].value; @@ -173,8 +183,9 @@ exports.test_ReadTransform = function () { TKUnit.assertEqual(rotate, 0); TKUnit.assert(scale.x === 1 && scale.y === 1); TKUnit.assert(translate.x === 0 && translate.y === 0); -}; -exports.test_ReadAnimationWithUnsortedKeyframes = function () { +} + +export function test_ReadAnimationWithUnsortedKeyframes() { let css = ".test { animation-name: test; } " + "@keyframes test { " + "from { opacity: 0; } " + @@ -196,14 +207,16 @@ exports.test_ReadAnimationWithUnsortedKeyframes = function () { TKUnit.assertEqual(animation.keyframes[3].duration, 0.6); TKUnit.assertEqual(animation.keyframes[4].duration, 0.8); TKUnit.assertEqual(animation.keyframes[5].duration, 1); -}; -exports.test_ReadAnimationsWithCSSImport = function () { +} + +export function test_ReadAnimationsWithCSSImport() { let css = "@import '~/ui/animation/test.css'; .test { animation-name: test; }"; let animation = createAnimationFromCSS(css, "test"); TKUnit.assertEqual(animation.keyframes.length, 3); TKUnit.assertEqual(animation.keyframes[1].declarations[0].property, "backgroundColor"); -}; -exports.test_LoadTwoAnimationsWithTheSameName = function () { +} + +export function test_LoadTwoAnimationsWithTheSameName() { let scope = new styleScope.StyleScope(); scope.css = "@keyframes a1 { from { opacity: 0; } to { opacity: 1; } } @keyframes a1 { from { opacity: 0; } to { opacity: 0.5; } } .a { animation-name: a1; }"; scope.ensureSelectors(); @@ -217,8 +230,9 @@ exports.test_LoadTwoAnimationsWithTheSameName = function () { selector = findSelectorInScope(scope, "a"); TKUnit.assertEqual(selector.animations[0].keyframes.length, 2); TKUnit.assertEqual(selector.animations[0].keyframes.length, 2); -}; -exports.test_LoadAnimationProgrammatically = function () { +} + +export function test_LoadAnimationProgrammatically() { let stack = new stackModule.StackLayout(); helper.buildUIAndRunTest(stack, function (views) { let page = views[1]; @@ -228,54 +242,54 @@ exports.test_LoadAnimationProgrammatically = function () { TKUnit.assertEqual(animation.keyframes[1].declarations[0].property, "opacity"); TKUnit.assertEqual(animation.keyframes[1].declarations[0].value, 0); }); -}; -exports.test_ExecuteCSSAnimation = function () { - let mainPage; - let label; - let pageFactory = function () { - label = new labelModule.Label(); - label.text = "label"; - let stackLayout = new stackModule.StackLayout(); - stackLayout.addChild(label); - mainPage = new page.Page(); - mainPage.css = "@keyframes k { from { background-color: red; } to { background-color: green; } } .l { animation-name: k; animation-duration: 0.5s; animation-fill-mode: forwards; }"; - mainPage.content = stackLayout; - return mainPage; - }; - helper.navigate(pageFactory); - TKUnit.waitUntilReady(function () { return label.isLoaded; }); +} + +export function test_ExecuteCSSAnimation() { + let mainPage = helper.getCurrentPage(); + mainPage.css = null; + let label = new labelModule.Label({ text: "label" }); + let stackLayout = new stackModule.StackLayout(); + stackLayout.addChild(label); + + mainPage.css = "@keyframes k { from { background-color: red; } to { background-color: green; } } .l { animation-name: k; animation-duration: 0.1s; animation-fill-mode: forwards; }"; + mainPage.content = stackLayout; + + TKUnit.waitUntilReady(() => label.isLoaded); label.className = "l"; - TKUnit.waitUntilReady(function () { return new color.Color("green").equals(label.backgroundColor); }, 1); - TKUnit.assert(new color.Color("green").equals(label.backgroundColor)); -}; -// exports.test_ExecuteFillMode = function () { -// let mainPage; -// let label; -// let pageFactory = function () { -// label = new labelModule.Label(); -// label.text = "label"; -// let stackLayout = new stackModule.StackLayout(); -// stackLayout.addChild(label); -// mainPage = new page.Page(); -// mainPage.css = "@keyframes k { from { background-color: red; } to { background-color: green; } } " + -// ".l { animation-name: k; animation-duration: 0.5s; animation-fill-mode: none; } " + -// ".l2 { animation-name: k; animation-duration: 0.5s; animation-fill-mode: forwards; }"; -// mainPage.content = stackLayout; -// return mainPage; -// }; -// helper.navigate(pageFactory); -// TKUnit.waitUntilReady(function () { return label.isLoaded; }); -// TKUnit.assertEqual(label.backgroundColor, undefined); -// label.className = "l"; -// TKUnit.wait(2); -// TKUnit.assertEqual(label.backgroundColor, undefined); -// label.className = "l2"; -// TKUnit.waitUntilReady(function() { return new color.Color("green").equals(label.backgroundColor); }, 1); -// TKUnit.assert(new color.Color("green").equals(label.backgroundColor)); -// helper.goBack(); -// helper.goBack(); -// }; -exports.test_ReadTwoAnimations = function () { + let green = new color.Color("green"); + TKUnit.waitUntilReady(() => green.equals(label.backgroundColor), 1); + TKUnit.assertEqual(label.backgroundColor, green); +} + +//export function test_ExecuteFillMode() { +// let mainPage = helper.getCurrentPage(); +// mainPage.style._resetValue(styling.properties.backgroundColorProperty); +// mainPage.style._resetValue(styling.properties.colorProperty); +// mainPage._resetValue(labelModule.Label.bindingContextProperty); +// mainPage._resetValue(labelModule.Label.cssClassProperty); +// mainPage._resetValue(labelModule.Label.idProperty); +// mainPage.css = null; + +// let label = new labelModule.Label({ text: "label" }); +// let stackLayout = new stackModule.StackLayout(); +// stackLayout.addChild(label); +// mainPage.css = "@keyframes k { from { background-color: red; } to { background-color: green; } } " + +// ".l { animation-name: k; animation-duration: 0.5s; animation-fill-mode: none; } " + +// ".l2 { animation-name: k; animation-duration: 0.5s; animation-fill-mode: forwards; }"; +// mainPage.content = stackLayout; + +// TKUnit.waitUntilReady(() => label.isLoaded); + +// TKUnit.assertEqual(label.backgroundColor, undefined, "label.backgroundColor should be undefind"); + +// label.className = "l"; +// TKUnit.assertEqual(label.backgroundColor, undefined, "label.backgroundColor should be undefind"); + +// label.className = "l2"; +// TKUnit.assertEqual(label.backgroundColor, new color.Color("green")); +//} + +export function test_ReadTwoAnimations() { let scope = new styleScope.StyleScope(); scope.css = ".test { animation: one 0.2s ease-out 1 2, two 2s ease-in; }"; scope.ensureSelectors(); @@ -285,8 +299,9 @@ exports.test_ReadTwoAnimations = function () { TKUnit.assertEqual(selector.animations[1].curve, enums.AnimationCurve.easeIn); TKUnit.assertEqual(selector.animations[1].name, "two"); TKUnit.assertEqual(selector.animations[1].duration, 2000); -}; -exports.test_AnimationCurveInKeyframes = function () { +} + +export function test_AnimationCurveInKeyframes() { let scope = new styleScope.StyleScope(); scope.css = "@keyframes an { from { animation-timing-function: linear; background-color: red; } 50% { background-color: green; } to { background-color: black; } } .test { animation-name: an; animation-timing-function: ease-in; }"; scope.ensureSelectors(); @@ -298,4 +313,4 @@ exports.test_AnimationCurveInKeyframes = function () { let realAnimation = keyframeAnimation.KeyframeAnimation.keyframeAnimationFromInfo(animation, 2); TKUnit.assertEqual(realAnimation.animations[1].curve, enums.AnimationCurve.linear); TKUnit.assertEqual(realAnimation.animations[2].curve, enums.AnimationCurve.easeIn); -}; +} \ No newline at end of file diff --git a/apps/tests/ui/bindable-tests.ts b/apps/tests/ui/bindable-tests.ts index 3af9b5712..338078102 100644 --- a/apps/tests/ui/bindable-tests.ts +++ b/apps/tests/ui/bindable-tests.ts @@ -917,7 +917,7 @@ export function test_BindingContextOfAChildElementIsNotOverwrittenBySettingTheBi }); page.content = child; - TKUnit.waitUntilReady(() => { return testFinished }); + TKUnit.waitUntilReady(() => testFinished); } export var test_BindingHitsGetterTooManyTimes = function () { diff --git a/apps/tests/ui/helper.ts b/apps/tests/ui/helper.ts index 8e1fdbb7a..b1e0fde4e 100644 --- a/apps/tests/ui/helper.ts +++ b/apps/tests/ui/helper.ts @@ -109,7 +109,8 @@ export function buildUIWithWeakRefAndInteract(createFunc: ( newPage.content = sp; - TKUnit.waitUntilReady(() => { return testFinished; }, MEMORY_ASYNC); + TKUnit.waitUntilReady(() => testFinished, MEMORY_ASYNC); + TKUnit.assertTrue(testFinished, "Test did not completed.") done(null); } diff --git a/apps/tests/ui/page/page-tests-common.ts b/apps/tests/ui/page/page-tests-common.ts index 7573729cf..effd343e6 100644 --- a/apps/tests/ui/page/page-tests-common.ts +++ b/apps/tests/ui/page/page-tests-common.ts @@ -471,11 +471,17 @@ export function test_WhenPageIsNavigatedToItCanShowAnotherPageAsModal() { let page = args.object; TKUnit.assertNull(page.modal, "currentPage.modal should be undefined when no modal page is shown!"); let basePath = "ui/page/"; - modalPage = page.showModal(basePath + "modal-page", ctx, modalCloseCallback, false); - TKUnit.assertTrue((modalPage).showingModally, "showingModally"); + let entry: frameModule.NavigationEntry = { + moduleName: basePath + "modal-page" + }; + + modalPage = frameModule.resolvePageFromEntry(entry); modalPage.on(Page.shownModallyEvent, onShownModal); modalPage.on(Page.loadedEvent, onModalLoaded); modalPage.on(Page.unloadedEvent, onModalUnloaded); + + page.showModal(modalPage, ctx, modalCloseCallback, false); + TKUnit.assertTrue((modalPage).showingModally, "showingModally"); }; var masterPageFactory = function (): Page { diff --git a/apps/tests/ui/page/page-tests.ios.ts b/apps/tests/ui/page/page-tests.ios.ts index ec65f5c36..9c296cdf5 100644 --- a/apps/tests/ui/page/page-tests.ios.ts +++ b/apps/tests/ui/page/page-tests.ios.ts @@ -77,8 +77,8 @@ export function test_page_no_anctionBar_measure_no_spanUnderBackground_measure_l let lbl = new Label(); page.content = lbl; - helper.navigate(() => { return page; }); - TKUnit.waitUntilReady(() => { return page.isLayoutValid; }); + helper.navigate(() => page); + TKUnit.waitUntilReady(() => page.isLayoutValid); TKUnit.assertTrue(page.isLoaded, "page NOT loaded!"); let bounds = page._getCurrentLayoutBounds(); @@ -92,7 +92,7 @@ export function test_page_no_anctionBar_measure_no_spanUnderBackground_measure_l TKUnit.assertEqual(contentHeight, frameHeight - statusBarHeight, "Page.content height should match Frame height - statusBar height."); page.backgroundSpanUnderStatusBar = false; - TKUnit.waitUntilReady(() => { return page.isLayoutValid; }); + TKUnit.waitUntilReady(() => page.isLayoutValid); pageHeight = page._getCurrentLayoutBounds().bottom - page._getCurrentLayoutBounds().top; TKUnit.assertEqual(pageHeight, frameHeight - statusBarHeight, "Page should be given Frame height - statusBar height."); @@ -100,7 +100,7 @@ export function test_page_no_anctionBar_measure_no_spanUnderBackground_measure_l TKUnit.assertEqual(contentHeight, pageHeight, "Page.content height should match Page height."); page.actionBarHidden = false; - TKUnit.waitUntilReady(() => { return page.isLayoutValid; }); + TKUnit.waitUntilReady(() => page.isLayoutValid); pageHeight = page._getCurrentLayoutBounds().bottom - page._getCurrentLayoutBounds().top; TKUnit.assertEqual(pageHeight, frameHeight - statusBarHeight, "Page should be given Frame height - statusBar height."); diff --git a/apps/tests/ui/repeater/repeater-tests.ts b/apps/tests/ui/repeater/repeater-tests.ts index fafd11e7e..33da39ed3 100644 --- a/apps/tests/ui/repeater/repeater-tests.ts +++ b/apps/tests/ui/repeater/repeater-tests.ts @@ -37,7 +37,7 @@ export function test_set_items_to_array_loads_all_items() { repeater.items = colors; // << article-repeater-with-array - TKUnit.wait(ASYNC); + TKUnit.waitUntilReady(() => repeater.isLayoutValid); TKUnit.assert(getChildAtText(repeater, 0) === "red", "Item not created for index 0"); TKUnit.assert(getChildAtText(repeater, 1) === "green", "Item not created for index 1"); @@ -53,7 +53,7 @@ export function test_set_items_to_array_creates_views() { function testAction(views: Array) { repeater.items = FEW_ITEMS; - TKUnit.wait(ASYNC); + TKUnit.waitUntilReady(() => repeater.isLayoutValid); TKUnit.assertEqual(getChildrenCount(repeater), FEW_ITEMS.length, "views count."); }; @@ -68,7 +68,7 @@ export function test_refresh_after_adding_items_to_array_loads_new_items() { var colors = ["red", "green", "blue"]; repeater.items = colors; - TKUnit.wait(ASYNC); + TKUnit.waitUntilReady(() => repeater.isLayoutValid); TKUnit.assertEqual(getChildrenCount(repeater), colors.length, "views count."); // >> artcle-array-push-element colors.push("yellow"); @@ -92,7 +92,7 @@ export function test_refresh_reloads_all_items() { repeater.items = itemsToBind; - TKUnit.wait(ASYNC); + TKUnit.waitUntilReady(() => repeater.isLayoutValid); testStarted = true; itemsToBind[0] = "red"; @@ -101,7 +101,7 @@ export function test_refresh_reloads_all_items() { repeater.refresh(); - TKUnit.wait(ASYNC); + TKUnit.waitUntilReady(() => repeater.isLayoutValid); TKUnit.assert(getChildAtText(repeater, 0) === "red", "Item not created for index 0"); TKUnit.assert(getChildAtText(repeater, 1) === "green", "Item not created for index 1"); @@ -116,11 +116,11 @@ export function test_set_itmes_to_null_clears_items() { function testAction(views: Array) { repeater.items = FEW_ITEMS; - TKUnit.wait(ASYNC); + TKUnit.waitUntilReady(() => repeater.isLayoutValid); TKUnit.assertEqual(getChildrenCount(repeater), FEW_ITEMS.length, "views count."); repeater.items = null; - TKUnit.wait(ASYNC); + TKUnit.waitUntilReady(() => repeater.isLayoutValid); TKUnit.assertEqual(getChildrenCount(repeater), 0, "views count."); }; @@ -138,7 +138,7 @@ export function test_set_itemsLayout_accepted() { function testAction(views: Array) { repeater.items = FEW_ITEMS; - TKUnit.wait(ASYNC); + TKUnit.waitUntilReady(() => repeater.isLayoutValid); TKUnit.assert((repeater.itemsLayout).orientation === "horizontal", "views count."); TKUnit.assertEqual(getChildrenCount(repeater), FEW_ITEMS.length, "views count."); }; @@ -151,11 +151,11 @@ export function test_set_itmes_to_undefiend_clears_items() { function testAction(views: Array) { repeater.items = FEW_ITEMS; - TKUnit.wait(ASYNC); + TKUnit.waitUntilReady(() => repeater.isLayoutValid); TKUnit.assertEqual(getChildrenCount(repeater), FEW_ITEMS.length, "views count."); repeater.items = undefined; - TKUnit.wait(ASYNC); + TKUnit.waitUntilReady(() => repeater.isLayoutValid); TKUnit.assertEqual(getChildrenCount(repeater), 0, "views count."); }; @@ -167,11 +167,11 @@ export function test_set_itmes_to_different_source_loads_new_items() { function testAction(views: Array) { repeater.items = [1, 2, 3]; - TKUnit.wait(ASYNC); + TKUnit.waitUntilReady(() => repeater.isLayoutValid); TKUnit.assertEqual(getChildrenCount(repeater), 3, "views count."); repeater.items = ["a", "b", "c", "d"]; - TKUnit.wait(ASYNC); + TKUnit.waitUntilReady(() => repeater.isLayoutValid); TKUnit.assertEqual(getChildrenCount(repeater), 4, "views count."); }; @@ -187,6 +187,7 @@ export function test_set_items_to_observable_array_loads_all_items() { repeater.items = colors; // << article-repeater-observablearray + TKUnit.waitUntilReady(() => repeater.isLayoutValid); TKUnit.assert(getChildAtText(repeater, 0) === "red", "Item not created for index 0"); TKUnit.assert(getChildAtText(repeater, 1) === "green", "Item not created for index 1"); TKUnit.assert(getChildAtText(repeater, 2) === "blue", "Item not created for index 2"); @@ -202,7 +203,7 @@ export function test_add_to_observable_array_refreshes_the_Repeater() { var colors = new observableArray.ObservableArray(["red", "green", "blue"]); repeater.items = colors; - TKUnit.wait(ASYNC); + TKUnit.waitUntilReady(() => repeater.isLayoutValid); TKUnit.assertEqual(getChildrenCount(repeater), 3, "getChildrenCount"); // >> article-push-to-observablearray @@ -210,6 +211,7 @@ export function test_add_to_observable_array_refreshes_the_Repeater() { //// The Repeater will be updated automatically. // << article-push-to-observablearray TKUnit.wait(ASYNC); + TKUnit.waitUntilReady(() => repeater.isLayoutValid); TKUnit.assertEqual(getChildrenCount(repeater), 4, "getChildrenCount"); }; @@ -224,11 +226,11 @@ export function test_remove_from_observable_array_refreshes_the_Repeater() { function testAction(views: Array) { repeater.items = data; - TKUnit.wait(ASYNC); + TKUnit.waitUntilReady(() => repeater.isLayoutValid); TKUnit.assertEqual(getChildrenCount(repeater), 3, "getChildrenCount"); data.pop(); - TKUnit.wait(ASYNC); + TKUnit.waitUntilReady(() => repeater.isLayoutValid); TKUnit.assertEqual(getChildrenCount(repeater), 2, "getChildrenCount"); }; @@ -243,12 +245,12 @@ export function test_splice_observable_array_refreshes_the_Repeater() { function testAction(views: Array) { repeater.items = data; - TKUnit.wait(ASYNC); + TKUnit.waitUntilReady(() => repeater.isLayoutValid); TKUnit.assertEqual(getChildrenCount(repeater), 3, "getChildrenCount"); // Remove the first 2 elements and add data.splice(0, 2, "d", "e", "f"); - TKUnit.wait(ASYNC); + TKUnit.waitUntilReady(() => repeater.isLayoutValid); TKUnit.assertEqual(getChildrenCount(repeater), 4, "getChildrenCount"); }; @@ -279,7 +281,7 @@ export function test_usingAppLevelConvertersInRepeaterItems() { repeater.itemTemplate = "'); function testAction(views: Array) { - var tab: TabView = p.content; - - TKUnit.wait(0.2); - + let tab: TabView = p.content; TKUnit.assertEqual(tab.selectedIndex, 1); }; diff --git a/apps/ui-tests-app/css/letter-spacing.xml b/apps/ui-tests-app/css/letter-spacing.xml index d1572b6b5..d0fd08e60 100644 --- a/apps/ui-tests-app/css/letter-spacing.xml +++ b/apps/ui-tests-app/css/letter-spacing.xml @@ -1,8 +1,14 @@  - \ No newline at end of file diff --git a/apps/ui-tests-app/css/text-decoration.ts b/apps/ui-tests-app/css/text-decoration.ts index a1870be63..3304b372e 100644 --- a/apps/ui-tests-app/css/text-decoration.ts +++ b/apps/ui-tests-app/css/text-decoration.ts @@ -50,5 +50,11 @@ export function butonTap(args) { btn.style.textDecoration = "none"; textField.style.textDecoration = "none"; textView.style.textDecoration = "none"; + + if(lbl.text === "Change text") { + lbl.text = btn.text = textField.text = textView.text = "Text changed"; + } else { + lbl.text = btn.text = textField.text = textView.text = "Change text"; + } } } diff --git a/apps/ui-tests-app/css/text-decoration.xml b/apps/ui-tests-app/css/text-decoration.xml index c3d6e6308..9de343b28 100644 --- a/apps/ui-tests-app/css/text-decoration.xml +++ b/apps/ui-tests-app/css/text-decoration.xml @@ -1,6 +1,6 @@  -