mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
Fixed xml-declaration tests.
This commit is contained in:
@@ -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");
|
||||
|
||||
@@ -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<TemplateView, string>({
|
||||
name: "template",
|
||||
affectsLayout: true
|
||||
});
|
||||
templateProperty.register(TemplateView);
|
||||
|
||||
@@ -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 = <Page>builder.parse("<Page><AbsoluteLayout><Label left='1' top='2' right='3' bottom='4' /></AbsoluteLayout></Page>");
|
||||
var grid = <gridLayoutModule.GridLayout>p.content;
|
||||
var child = grid.getChildAt(0);
|
||||
var absLayout = <absoluteLayoutModule.AbsoluteLayout>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: ${(<any>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: ${(<any>top).value};`)
|
||||
};
|
||||
|
||||
export function test_parse_ShouldParseNumberProperties() {
|
||||
@@ -445,13 +446,13 @@ export function test_parse_ShouldParseBindingsToGesturesWithOn() {
|
||||
};
|
||||
|
||||
export function test_parse_ShouldParseSubProperties() {
|
||||
var p = <Page>builder.parse("<Page><Switch style.visibility='collapsed' checked='{{ myProp }}' /></Page>");
|
||||
var p = <Page>builder.parse("<Page><Switch style.visibility='collapse' checked='{{ myProp }}' /></Page>");
|
||||
var obj = new observable.Observable();
|
||||
obj.set("myProp", true);
|
||||
p.bindingContext = obj;
|
||||
var sw = <switchModule.Switch>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 = <Page>builder.parse('<Page xmlns:customControls="xml-declaration/mymodulewithxml"><customControls:MyControl visibility="collapsed" /></Page>');
|
||||
var p = <Page>builder.parse('<Page xmlns:customControls="xml-declaration/mymodulewithxml"><customControls:MyControl visibility="collapse" /></Page>');
|
||||
var panel = <stackLayoutModule.StackLayout>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 = <Page>builder.parse('<Page xmlns:customControls="xml-declaration/mymodulewithxml"><customControls:my-control-no-js visibility="collapsed" /></Page>');
|
||||
var p = <Page>builder.parse('<Page xmlns:customControls="xml-declaration/mymodulewithxml"><customControls:my-control-no-js visibility="collapse" /></Page>');
|
||||
var panel = <stackLayoutModule.StackLayout>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 = <Page>builder.parse('<Page xmlns="http://schemas.nativescript.org/tns.xsd"><ListView items="{{ items }}" itemLoading="{{ itemLoading }}"><ListView.itemTemplate><SegmentedBar items="{{ $parents[\'ListView\'].items }}" selectedIndexChanged="{{ $parents[\'ListView\'].changed }}" /></ListView.itemTemplate></ListView></Page>');
|
||||
var p = <Page>builder.parse('<Page xmlns="http://schemas.nativescript.org/tns.xsd"><ListView items="{{ items }}" itemLoading="{{ itemLoading }}"><ListView.itemTemplate><SegmentedBar items="{{ $parents[\'ListView\'].segmentedBarItems }}" selectedIndexChanged="{{ $parents[\'ListView\'].changed }}" /></ListView.itemTemplate></ListView></Page>');
|
||||
|
||||
function testAction(views: Array<viewModule.View>) {
|
||||
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 = <segmentedBar.SegmentedBar>args.view
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user