diff --git a/tests/app/testRunner.ts b/tests/app/testRunner.ts index 6e05b6763..789b5bd0d 100644 --- a/tests/app/testRunner.ts +++ b/tests/app/testRunner.ts @@ -56,7 +56,7 @@ 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["XML-DECLARATION"] = require("./xml-declaration/xml-declaration-tests"); allTests["DOCKLAYOUT"] = require("./ui/layouts/dock-layout-tests"); allTests["WRAPLAYOUT"] = require("./ui/layouts/wrap-layout-tests"); allTests["ABSOLUTELAYOUT"] = require("./ui/layouts/absolute-layout-tests"); diff --git a/tests/app/xml-declaration/template-builder-tests/template-view.ts b/tests/app/xml-declaration/template-builder-tests/template-view.ts index 7e263802a..a5f65d710 100644 --- a/tests/app/xml-declaration/template-builder-tests/template-view.ts +++ b/tests/app/xml-declaration/template-builder-tests/template-view.ts @@ -1,5 +1,5 @@ -import {Template} from "ui/core/view" -import {Property, PropertyMetadataSettings} from "ui/core/dependency-observable" +import { Template } from "ui/core/view" +import { Property } from "ui/core/properties" import * as proxy from "ui/core/proxy" import { LayoutBase } from "ui/layouts/layout-base" import { parse } from "ui/builder" @@ -9,27 +9,17 @@ export module knownTemplates { } export class TemplateView extends LayoutBase { - public static templateProperty = new Property( - "template", - "TemplateView", - new proxy.PropertyMetadata( - undefined, - PropertyMetadataSettings.AffectsLayout, - null - ) - ); - - public static testEvent: string = "test"; - - get template(): string | Template { - return this._getValue(TemplateView.templateProperty); - } - - set template(value: string | Template) { - this._setValue(TemplateView.templateProperty, value); - } + public template: string; + + public static testEvent: string = "test"; public parseTemplate() { this.addChild(parse(this.template)); } } + +export const templateProperty = new Property({ + name: "template", + affectsLayout: true + }); +templateProperty.register(TemplateView); diff --git a/tests/app/xml-declaration/xml-declaration-tests.ts b/tests/app/xml-declaration/xml-declaration-tests.ts index cc19afbfb..e9f5b3de6 100644 --- a/tests/app/xml-declaration/xml-declaration-tests.ts +++ b/tests/app/xml-declaration/xml-declaration-tests.ts @@ -25,7 +25,7 @@ import * as platform from "platform"; import * as gesturesModule from "ui/gestures"; import * as segmentedBar from "ui/segmented-bar"; import { Source } from "utils/debug"; -import { PercentLength } from "ui/core/view"; +import { PercentLength, Length } from "ui/core/view"; export function test_load_IsDefined() { TKUnit.assertTrue(types.isFunction(builder.load), "ui/builder should have load method!"); @@ -296,14 +296,15 @@ export function test_parse_ShouldSetGridAttachedProperties() { export function test_parse_ShouldSetCanvasAttachedProperties() { var p = builder.parse(""); - var grid = p.content; - var child = grid.getChildAt(0); + var absLayout = p.content; + var child = absLayout.getChildAt(0); var left = absoluteLayoutModule.AbsoluteLayout.getLeft(child); - TKUnit.assertEqual(left, 1, "Expected result for canvas left: 1; Actual result: " + left + ";"); + + TKUnit.assert(Length.equals(left, Length.parse("1")), `Expected result for canvas left: 1; Actual result: ${(left).value};`) var top = absoluteLayoutModule.AbsoluteLayout.getTop(child); - TKUnit.assertEqual(top, 2, "Expected result for canvas top: 2; Actual result: " + top + ";"); + TKUnit.assert(Length.equals(top, Length.parse("2")), `Expected result for canvas top: 2; Actual result: ${(top).value};`) }; export function test_parse_ShouldParseNumberProperties() { @@ -445,13 +446,13 @@ export function test_parse_ShouldParseBindingsToGesturesWithOn() { }; export function test_parse_ShouldParseSubProperties() { - var p = builder.parse(""); + var p = builder.parse(""); var obj = new observable.Observable(); obj.set("myProp", true); p.bindingContext = obj; var sw = p.content; - TKUnit.assert(sw.visibility === "collapse", "Expected result: collapsed; Actual result: " + sw.visibility + "; type: " + typeof (sw.visibility)); + TKUnit.assert(sw.visibility === "collapse", "Expected result: collapse; Actual result: " + sw.visibility + "; type: " + typeof (sw.visibility)); }; export function test_parse_ShouldParseBindingToSpecialProperty() { @@ -539,10 +540,10 @@ export function test_parse_ShouldParseCustomComponentWithXml() { }; export function test_parse_ShouldParseCustomComponentWithXml_WithAttributes() { - var p = builder.parse(''); + var p = builder.parse(''); var panel = p.content; - TKUnit.assertEqual(panel.visibility, "collapsed", "panel.visibility"); + TKUnit.assertEqual(panel.visibility, "collapse", "panel.visibility"); }; export function test_parse_ShouldParseCustomComponentWithXml_WithCustomAttributes() { @@ -561,10 +562,10 @@ export function test_parse_ShouldParseCustomComponentWithXmlNoJS() { }; export function test_parse_ShouldParseCustomComponentWithXmlNoJS_WithAttributes() { - var p = builder.parse(''); + var p = builder.parse(''); var panel = p.content; - TKUnit.assertEqual(panel.visibility, "collapsed", "panel.visibility"); + TKUnit.assertEqual(panel.visibility, "collapse", "panel.visibility"); }; export function test_parse_ShouldParseCustomComponentWithXmlNoJS_WithCustomAttributes() { @@ -613,13 +614,23 @@ export function test_parse_ShouldParseNestedListViewInListViewTemplate() { } export function test_parse_ShouldEvaluateEventBindingExpressionInListViewTemplate() { - var p = builder.parse(''); + var p = builder.parse(''); function testAction(views: Array) { let ctrl: segmentedBar.SegmentedBar = null; let changed; let obj = new observable.Observable(); + + let firstItem = new segmentedBar.SegmentedBarItem(); + firstItem.title = "One"; + let secondItem = new segmentedBar.SegmentedBarItem(); + secondItem.title = "Two"; + let thirdItem = new segmentedBar.SegmentedBarItem(); + thirdItem.title = "Tree"; + let segmentedBarItems = [firstItem, secondItem, thirdItem]; + obj.set("items", [1, 2, 3]); + obj.set("segmentedBarItems", segmentedBarItems); obj.set("itemLoading", function (args: listViewModule.ItemEventData) { ctrl = args.view }); diff --git a/tns-core-modules/ui/core/bindable.ts b/tns-core-modules/ui/core/bindable.ts index 7bffcaa5f..e1f1db8c8 100644 --- a/tns-core-modules/ui/core/bindable.ts +++ b/tns-core-modules/ui/core/bindable.ts @@ -192,7 +192,7 @@ export class Binding { public loadedHandlerVisualTreeBinding(args) { let target = args.object; - target.off(ViewBase.loadedEvent, this.loadedHandlerVisualTreeBinding, this); + target.off("loaded", this.loadedHandlerVisualTreeBinding, this); if (!types.isNullOrUndefined(target.bindingContext)) { this.bind(target.bindingContext); } @@ -288,8 +288,8 @@ export class Binding { currentObject = parentView.bindingContext; } else { let targetInstance = this.target.get(); - targetInstance.off(ViewBase.loadedEvent, this.loadedHandlerVisualTreeBinding, this); - targetInstance.on(ViewBase.loadedEvent, this.loadedHandlerVisualTreeBinding, this); + targetInstance.off("loaded", this.loadedHandlerVisualTreeBinding, this); + targetInstance.on("loaded", this.loadedHandlerVisualTreeBinding, this); } currentObjectChanged = true; diff --git a/tns-core-modules/ui/core/properties.ts b/tns-core-modules/ui/core/properties.ts index 7c9c79169..3b65869b3 100644 --- a/tns-core-modules/ui/core/properties.ts +++ b/tns-core-modules/ui/core/properties.ts @@ -362,7 +362,6 @@ export class InheritedProperty extends Property imp if (currentValue !== newValue) { if (this.hasListeners(eventName)) { - console.log("Notify " + eventName); this.notify({ eventName: eventName, propertyName: name, diff --git a/tns-core-modules/ui/gestures/gestures.ios.ts b/tns-core-modules/ui/gestures/gestures.ios.ts index 9228a2290..8186b110f 100644 --- a/tns-core-modules/ui/gestures/gestures.ios.ts +++ b/tns-core-modules/ui/gestures/gestures.ios.ts @@ -1,5 +1,5 @@ import { GestureEventData, SwipeGestureEventData, PanGestureEventData, RotationGestureEventData, PinchGestureEventData } from "ui/gestures"; -import { GesturesObserverBase, toString, TouchAction, GestureStateTypes, GestureTypes, SwipeDirection, View, EventData } from "./gestures-common"; +import { GesturesObserverBase, toString, TouchAction, GestureStateTypes, GestureTypes, SwipeDirection, View, EventData } from "./gestures-common"; import { ios } from "utils/utils"; import getter = ios.getter; @@ -92,8 +92,8 @@ export class GesturesObserver extends GesturesObserverBase { this._detach(); }; - this.target.on(View.loadedEvent, this._onTargetLoaded); - this.target.on(View.unloadedEvent, this._onTargetUnloaded); + this.target.on("loaded", this._onTargetLoaded); + this.target.on("unloaded", this._onTargetUnloaded); if (this.target.isLoaded) { this._attach(this.target, type); @@ -183,8 +183,8 @@ export class GesturesObserver extends GesturesObserverBase { this._detach(); if (this.target) { - this.target.off(View.loadedEvent, this._onTargetLoaded); - this.target.off(View.unloadedEvent, this._onTargetUnloaded); + this.target.off("loaded", this._onTargetLoaded); + this.target.off("unloaded", this._onTargetUnloaded); this._onTargetLoaded = null; this._onTargetUnloaded = null; diff --git a/tns-core-modules/ui/html-view/html-view.ios.ts b/tns-core-modules/ui/html-view/html-view.ios.ts index 572dd34f3..f60dddbbf 100644 --- a/tns-core-modules/ui/html-view/html-view.ios.ts +++ b/tns-core-modules/ui/html-view/html-view.ios.ts @@ -67,5 +67,3 @@ export class HtmlView extends HtmlViewBase { this._ios.attributedText = NSAttributedString.alloc().initWithDataOptionsDocumentAttributesError(nsData, { [NSDocumentTypeDocumentAttribute]: NSHTMLTextDocumentType }, null); } } - -htmlProperty.register(HtmlView); \ No newline at end of file diff --git a/tns-core-modules/ui/layouts/absolute-layout/absolute-layout.d.ts b/tns-core-modules/ui/layouts/absolute-layout/absolute-layout.d.ts index ec9ac51e6..09d7635f0 100644 --- a/tns-core-modules/ui/layouts/absolute-layout/absolute-layout.d.ts +++ b/tns-core-modules/ui/layouts/absolute-layout/absolute-layout.d.ts @@ -1,5 +1,5 @@ declare module "ui/layouts/absolute-layout" { - import { LayoutBase, View, Property } from "ui/layouts/layout-base"; + import { LayoutBase, View, Property, Length } from "ui/layouts/layout-base"; /** * A layout that lets you specify exact locations (left/top coordinates) of its children. @@ -8,31 +8,31 @@ /** * Gets the value of the Left property from a given View. */ - static getLeft(view: View): number; + static getLeft(view: View): Length; /** * Sets the value of the Left property from a given View. */ - static setLeft(view: View, value: number): void; + static setLeft(view: View, value: Length): void; /** * Gets the value of the Top property from a given View. */ - static getTop(view: View): number; + static getTop(view: View): Length; /** * Sets the value of the Top property from a given View. */ - static setTop(view: View, value: number): void; + static setTop(view: View, value: Length): void; } /** * Represents the observable property backing the left property. */ - export const leftProperty: Property; + export const leftProperty: Property; /** * Represents the observable property backing the top property. */ - export const topProperty: Property; + export const topProperty: Property; } \ No newline at end of file diff --git a/tns-core-modules/ui/segmented-bar/segmented-bar-common.ts b/tns-core-modules/ui/segmented-bar/segmented-bar-common.ts index 904aafbe6..b426e38a6 100644 --- a/tns-core-modules/ui/segmented-bar/segmented-bar-common.ts +++ b/tns-core-modules/ui/segmented-bar/segmented-bar-common.ts @@ -46,6 +46,7 @@ export abstract class SegmentedBarBase extends View implements SegmentedBarDefin this.items = new Array(); } this.items.push(value); + selectedIndexProperty.coerce(this); } } diff --git a/tns-core-modules/ui/segmented-bar/segmented-bar.android.ts b/tns-core-modules/ui/segmented-bar/segmented-bar.android.ts index 8fc8d2750..3efc3d6d5 100644 --- a/tns-core-modules/ui/segmented-bar/segmented-bar.android.ts +++ b/tns-core-modules/ui/segmented-bar/segmented-bar.android.ts @@ -259,9 +259,9 @@ export class SegmentedBar extends SegmentedBarBase { if (newItems) { newItems.forEach((item, i, arr) => this.insertTab(item, i)); - if (this.selectedIndex < 0) { - this.selectedIndex = tabHost.getCurrentTab(); - } + // if (this.selectedIndex < 0) { + // this.selectedIndex = tabHost.getCurrentTab(); + // } } } } diff --git a/tns-core-modules/ui/segmented-bar/segmented-bar.ios.ts b/tns-core-modules/ui/segmented-bar/segmented-bar.ios.ts index 7730cd6b4..133d164f8 100644 --- a/tns-core-modules/ui/segmented-bar/segmented-bar.ios.ts +++ b/tns-core-modules/ui/segmented-bar/segmented-bar.ios.ts @@ -57,9 +57,9 @@ export class SegmentedBar extends SegmentedBarBase { segmentedControl.insertSegmentWithTitleAtIndexAnimated(title, index, false); }) - if (this.selectedIndex < 0) { - this.selectedIndex = segmentedControl.selectedSegmentIndex; - } + // if (this.selectedIndex < 0) { + // this.selectedIndex = segmentedControl.selectedSegmentIndex; + // } } } diff --git a/tns-core-modules/ui/tab-view/tab-view-common.ts b/tns-core-modules/ui/tab-view/tab-view-common.ts index f55c71a16..fad893d70 100644 --- a/tns-core-modules/ui/tab-view/tab-view-common.ts +++ b/tns-core-modules/ui/tab-view/tab-view-common.ts @@ -91,6 +91,7 @@ export class TabViewBase extends View implements TabViewDefinition, AddChildFrom } this.items.push(value); this._addView(value); + selectedIndexProperty.coerce(this); } } diff --git a/tns-core-modules/ui/tab-view/tab-view.android.ts b/tns-core-modules/ui/tab-view/tab-view.android.ts index 979ed7799..533e30698 100644 --- a/tns-core-modules/ui/tab-view/tab-view.android.ts +++ b/tns-core-modules/ui/tab-view/tab-view.android.ts @@ -358,11 +358,6 @@ export class TabView extends TabViewBase { const tv = tabLayout.getTextViewForItemAt(i); item.setNativeView(tv); }); - - let selectedIndex = this.selectedIndex; - if (selectedIndex < 0) { - this.selectedIndex = this._viewPager.getCurrentItem(); - } } get [androidOffscreenTabLimitProperty.native](): number { diff --git a/tns-core-modules/ui/tab-view/tab-view.ios.ts b/tns-core-modules/ui/tab-view/tab-view.ios.ts index c25aee44c..f1de61226 100644 --- a/tns-core-modules/ui/tab-view/tab-view.ios.ts +++ b/tns-core-modules/ui/tab-view/tab-view.ios.ts @@ -268,10 +268,6 @@ export class TabView extends TabViewBase { // When we set this._ios.viewControllers, someone is clearing the moreNavigationController.delegate, so we have to reassign it each time here. this._ios.moreNavigationController.delegate = this._moreNavigationControllerDelegate; - - if (this.selectedIndex < 0) { - this.selectedIndex = this._ios.selectedIndex; - } } private _getIconRenderingMode(): UIImageRenderingMode {