mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
chore: cleanup
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
export function loaded(args) {
|
||||
args.object.customCodeLoaded = true;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
.MyClass {
|
||||
background-color: green;
|
||||
}
|
||||
|
||||
stack-layout {
|
||||
background-color: green;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<Page xmlns="http://schemas.nativescript.org/tns.xsd"
|
||||
xmlns:tc="xml-declaration/template-builder-tests/template-view">
|
||||
<tc:TemplateView id="template-view">
|
||||
<tc:TemplateView.template>
|
||||
<StackLayout>
|
||||
<!--
|
||||
At first I was going to put "MenuItem",
|
||||
as per https://github.com/NativeScript/NativeScript/issues/501,
|
||||
but then again we may re-introduce "MenuItem" in future and blow this test up.
|
||||
So here is something unique that has better chance not to appear.
|
||||
This comment also offsets error's row and column numbers so if you edit,
|
||||
please do so beyond the unicorn.
|
||||
-->
|
||||
<Unicorn backgroundColor="pink" />
|
||||
<Label text="Modal Page" />
|
||||
</StackLayout>
|
||||
</tc:TemplateView.template>
|
||||
</tc:TemplateView>
|
||||
</Page>
|
||||
@@ -0,0 +1,14 @@
|
||||
<Page shownModally="onShownModally">
|
||||
<StackLayout>
|
||||
<!--
|
||||
At first I was going to put "MenuItem",
|
||||
as per https://github.com/NativeScript/NativeScript/issues/501,
|
||||
but then again we may re-introduce "MenuItem" in future and blow this test up.
|
||||
So here is something unique that has better chance not to appear.
|
||||
This comment also offsets error's row and column numbers so if you edit,
|
||||
please do so beyond the unicorn.
|
||||
-->
|
||||
<Unicorn backgroundColor="pink" />
|
||||
<Label text="Modal Page" />
|
||||
</StackLayout>
|
||||
</Page>
|
||||
@@ -0,0 +1,5 @@
|
||||
<Page xmlns="http://schemas.nativescript.org/tns.xsd">
|
||||
<GridLayout id="grid">
|
||||
<Label id="label" text="Text" />
|
||||
</GridLayout>
|
||||
</Page>
|
||||
@@ -0,0 +1,3 @@
|
||||
import { Page } from '@nativescript/core/ui/page';
|
||||
|
||||
export class InheritedPage extends Page {}
|
||||
7
apps/automated/app/xml-declaration/inherited-page.ts
Normal file
7
apps/automated/app/xml-declaration/inherited-page.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import { Page } from '@nativescript/core/ui/page';
|
||||
import { Label } from '@nativescript/core/ui/label';
|
||||
|
||||
export function pageLoaded(args) {
|
||||
var page = <Page>args.object;
|
||||
(<Label>page.content).text += ' and loaded';
|
||||
}
|
||||
4
apps/automated/app/xml-declaration/inherited-page.xml
Normal file
4
apps/automated/app/xml-declaration/inherited-page.xml
Normal file
@@ -0,0 +1,4 @@
|
||||
<inherited:InheritedPage xmlns="http://schemas.nativescript.org/tns.xsd"
|
||||
xmlns:inherited="xml-declaration/inherited-base-page" loaded="pageLoaded">
|
||||
<Label text="Inherited" />
|
||||
</inherited:InheritedPage>
|
||||
56
apps/automated/app/xml-declaration/mainPage.ts
Normal file
56
apps/automated/app/xml-declaration/mainPage.ts
Normal file
@@ -0,0 +1,56 @@
|
||||
import * as observable from '@nativescript/core/data/observable';
|
||||
import * as view from '@nativescript/core/ui/core/view';
|
||||
import * as label from '@nativescript/core/ui/label';
|
||||
import * as pages from '@nativescript/core/ui/page';
|
||||
import * as http from '@nativescript/core/http';
|
||||
|
||||
var obj = new observable.Observable();
|
||||
obj.set('id', 0);
|
||||
obj.set('text', 'Button with event binding');
|
||||
obj.set('myFunction', (args: observable.EventData) => {
|
||||
console.log('Button with event binding: ' + args.object);
|
||||
});
|
||||
|
||||
//obj.set("someItems", [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15])
|
||||
obj.set('someItems', ['One', 'Two', 'Three', 'Four', 'Five', 'Six', 'Seven']);
|
||||
|
||||
var subObj = new observable.Observable();
|
||||
subObj.set('subId', 0);
|
||||
|
||||
obj.set('subObj', subObj);
|
||||
|
||||
var count = 0;
|
||||
export function buttonTap(args: observable.EventData) {
|
||||
count++;
|
||||
|
||||
obj.set('id', obj.get('id') + 1);
|
||||
|
||||
subObj.set('subId', subObj.get('subId') + 1);
|
||||
|
||||
var parent = (<view.View>args.object).parent;
|
||||
if (parent) {
|
||||
var lbl = parent.getViewById<label.Label>('Label1');
|
||||
if (lbl) {
|
||||
lbl.text = 'You clicked ' + count + ' times!';
|
||||
}
|
||||
}
|
||||
|
||||
http.getString('http://it-ebooks-api.info/v1/book/1615005640').then((r) => {
|
||||
console.log('R: ' + r);
|
||||
});
|
||||
|
||||
http.getString('http://www.telerik.com').then((r) => {
|
||||
console.log('R: ' + r);
|
||||
});
|
||||
}
|
||||
|
||||
export function MyPageLoaded(args: observable.EventData) {
|
||||
console.log('Page is loaded!');
|
||||
var page = <pages.Page>args.object;
|
||||
|
||||
page.bindingContext = obj;
|
||||
}
|
||||
|
||||
export function setPicture(args: observable.EventData) {
|
||||
//
|
||||
}
|
||||
85
apps/automated/app/xml-declaration/mainPage.xml
Normal file
85
apps/automated/app/xml-declaration/mainPage.xml
Normal file
@@ -0,0 +1,85 @@
|
||||
<Page xmlns="http://schemas.nativescript.org/tns.xsd" loaded="MyPageLoaded"
|
||||
xmlns:customControls="xml-declaration/mymodule"
|
||||
xmlns:customControls2="xml-declaration/mymodulewithxml">
|
||||
<TabView>
|
||||
<TabView.items>
|
||||
<TabViewItem title="Tab 1">
|
||||
<TabViewItem.view>
|
||||
<StackLayout>
|
||||
|
||||
<Label ios:text="" android:text="" style="font-family: FontAwesome; font-size: 25;" />
|
||||
|
||||
<HtmlView html="<span><font color='#ff0000'>Test</font></span>" />
|
||||
|
||||
<WebView src="<html><body><span style='color:red'>Test</span></body></html>" />
|
||||
|
||||
<!--<ToolBar>
|
||||
<ToolBar.items>
|
||||
<ToolBarItem>
|
||||
<ToolBarItem.view>
|
||||
<Label text="Label" />
|
||||
</ToolBarItem.view>
|
||||
</ToolBarItem>
|
||||
<ToolBarItem>
|
||||
<ToolBarItem.view>
|
||||
<Button text="Button" />
|
||||
</ToolBarItem.view>
|
||||
</ToolBarItem>
|
||||
<ToolBarItem>
|
||||
<ToolBarItem.view>
|
||||
<Image url="http://icons.iconarchive.com/icons/oxygen-icons.org/oxygen/256/Places-favorites-icon.png" />
|
||||
</ToolBarItem.view>
|
||||
</ToolBarItem>
|
||||
</ToolBar.items>
|
||||
</ToolBar>-->
|
||||
|
||||
<SegmentedBar selectedIndex="1" style="background-color: red; color: white" selectedBackgroundColor="green">
|
||||
<SegmentedBar.items>
|
||||
<SegmentedBarItem title="MAY 3" />
|
||||
<SegmentedBarItem title="MAY 4" />
|
||||
<SegmentedBarItem title="MAY 5" />
|
||||
</SegmentedBar.items>
|
||||
</SegmentedBar>
|
||||
|
||||
<ListPicker items="{{ someItems }}" selectedIndex="3"/>
|
||||
<DatePicker year="1976" month="10" day="30" />
|
||||
<TimePicker hour="10" minute="34" />
|
||||
<Image id="cameraImage" />
|
||||
<Button tap="setPicture" text="Get picture and set is to the image" />
|
||||
<Label id="Label1" text="This is Label!" />
|
||||
<StackLayout orientation="horizontal">
|
||||
<Label text="From expression {{ id + 1 }}: " />
|
||||
<Label text="{{ id + 1 }}" />
|
||||
<customControls:MyControl>
|
||||
<Label text="This is test!" />
|
||||
</customControls:MyControl>
|
||||
</StackLayout>
|
||||
<StackLayout orientation="horizontal">
|
||||
<Label text="From sub prop {{ subObj.subId + 1 }}: " />
|
||||
<Label text="{{ subObj.subId + 1 }}" />
|
||||
</StackLayout>
|
||||
<Button text="This is Button!" tap="buttonTap" />
|
||||
<customControls:MyControl />
|
||||
</StackLayout>
|
||||
</TabViewItem.view>
|
||||
</TabViewItem>
|
||||
<TabViewItem title="Tab 2">
|
||||
<TabViewItem.view>
|
||||
<StackLayout>
|
||||
<customControls2:MyControl />
|
||||
<Label text="This is Label in Tab 2" />
|
||||
</StackLayout>
|
||||
</TabViewItem.view>
|
||||
</TabViewItem>
|
||||
<TabViewItem title="Tab 3">
|
||||
<TabViewItem.view>
|
||||
<GridLayout columns="50, auto, *" rows="50, auto, *">
|
||||
<Label text="This is Label in Tab 3" row="0" />
|
||||
<Label text="This is second Label in Tab 3" row="1" />
|
||||
<customControls:MyControl />
|
||||
</GridLayout>
|
||||
</TabViewItem.view>
|
||||
</TabViewItem>
|
||||
</TabView.items>
|
||||
</TabView>
|
||||
</Page>
|
||||
@@ -0,0 +1,3 @@
|
||||
.MyStackLayout {
|
||||
background-color: red;
|
||||
}
|
||||
21
apps/automated/app/xml-declaration/mymodule/MyControl.ts
Normal file
21
apps/automated/app/xml-declaration/mymodule/MyControl.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { StackLayout, Label, Button, EventData } from '@nativescript/core';
|
||||
|
||||
export class MyControl extends StackLayout {
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
var counter: number = 0;
|
||||
|
||||
var lbl = new Label();
|
||||
var btn = new Button();
|
||||
btn.text = 'Tap me!';
|
||||
btn.on(Button.tapEvent, (args: EventData) => {
|
||||
lbl.text = 'Tap ' + counter++;
|
||||
});
|
||||
|
||||
this.addChild(lbl);
|
||||
this.addChild(btn);
|
||||
|
||||
this.className = 'MyStackLayout';
|
||||
}
|
||||
}
|
||||
4
apps/automated/app/xml-declaration/mymodule/package.json
Normal file
4
apps/automated/app/xml-declaration/mymodule/package.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"name": "MyControl",
|
||||
"main": "MyControl.js"
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
.MySecondCustomStackLayout {
|
||||
background-color: green;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
import * as observable from '@nativescript/core/data/observable';
|
||||
import * as view from '@nativescript/core/ui/core/view';
|
||||
import * as label from '@nativescript/core/ui/label';
|
||||
|
||||
var count = 0;
|
||||
export function buttonTap2(args: observable.EventData) {
|
||||
count++;
|
||||
|
||||
var parent = (<view.View>args.object).parent;
|
||||
if (parent) {
|
||||
var lbl = parent.getViewById<label.Label>('Label1');
|
||||
if (lbl) {
|
||||
lbl.text = 'You clicked ' + count + ' times!';
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
<StackLayout xmlns:customControls="xml-declaration/mymodule" class="MySecondCustomStackLayout">
|
||||
<Label id="Label1" text="mymodulewithxml" />
|
||||
<Button text="Click!" tap="buttonTap2" />
|
||||
</StackLayout>
|
||||
@@ -0,0 +1,11 @@
|
||||
import { Label } from '@nativescript/core/ui/label';
|
||||
import { Observable } from '@nativescript/core/data/observable';
|
||||
import { Page } from '@nativescript/core/ui/page';
|
||||
|
||||
export function loaded(args) {
|
||||
(<Observable>(<Label>args.object).page.bindingContext).set('testPassed', true);
|
||||
}
|
||||
|
||||
export function onNavigatingTo(args) {
|
||||
(<Page>args.object).bindingContext = args.context;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<Page navigatingTo="onNavigatingTo">
|
||||
<TabView selectedIndex= "1">
|
||||
<TabView.items>
|
||||
<TabViewItem title="First">
|
||||
<TabViewItem.view>
|
||||
<Label text="First View" />
|
||||
</TabViewItem.view>
|
||||
</TabViewItem>
|
||||
<TabViewItem title= "Second">
|
||||
<TabViewItem.view>
|
||||
<Label text="Second View" loaded="loaded"/>
|
||||
</TabViewItem.view>
|
||||
</TabViewItem>
|
||||
</TabView.items>
|
||||
</TabView>
|
||||
</Page>
|
||||
@@ -0,0 +1,3 @@
|
||||
<StackLayout>
|
||||
<Label text="I'm all about taht XML, no JS" />
|
||||
</StackLayout>
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"name": "MyControl",
|
||||
"main": "MyControl.js"
|
||||
}
|
||||
4
apps/automated/app/xml-declaration/package.json
Normal file
4
apps/automated/app/xml-declaration/package.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"name": "xml-declaration",
|
||||
"main": "app.js"
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
<tc:TemplateView id="template-view" xmlns:tc="xml-declaration/template-builder-tests/template-view">
|
||||
<tc:TemplateView.template>
|
||||
<tc:TemplateView text="Click!" test="test" />
|
||||
</tc:TemplateView.template>
|
||||
</tc:TemplateView>
|
||||
@@ -0,0 +1,10 @@
|
||||
let callback: (args: any) => void;
|
||||
export function test(args: any) {
|
||||
if (callback) {
|
||||
callback(args);
|
||||
}
|
||||
}
|
||||
|
||||
export function setCallback(cb: (args: any) => void) {
|
||||
callback = cb;
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
<Page xmlns="http://schemas.nativescript.org/tns.xsd"
|
||||
xmlns:fragment="xml-declaration/template-builder-tests">
|
||||
<fragment:event-in-codeless-fragment-the-fragment />
|
||||
</Page>
|
||||
@@ -0,0 +1,4 @@
|
||||
// Our unit test will set this function and expect it to be set as a handler on a View in the XML.
|
||||
export interface ITestEvent {
|
||||
test: (args: any) => void;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
<Page xmlns="http://schemas.nativescript.org/tns.xsd"
|
||||
xmlns:tc="xml-declaration/template-builder-tests/template-view">
|
||||
<tc:TemplateView id="template-view">
|
||||
<tc:TemplateView.template>
|
||||
<tc:TemplateView text="Click!" test="test" />
|
||||
</tc:TemplateView.template>
|
||||
</tc:TemplateView>
|
||||
</Page>
|
||||
@@ -0,0 +1,8 @@
|
||||
<Page xmlns="http://schemas.nativescript.org/tns.xsd"
|
||||
xmlns:tc="xml-declaration/template-builder-tests/template-view">
|
||||
<tc:TemplateView id="template-view">
|
||||
<tc:TemplateView.template>
|
||||
<Button text="Click!" />
|
||||
</tc:TemplateView.template>
|
||||
</tc:TemplateView>
|
||||
</Page>
|
||||
@@ -0,0 +1,21 @@
|
||||
import { Property, LayoutBase, Builder } from '@nativescript/core';
|
||||
|
||||
export module knownTemplates {
|
||||
export var template = 'template';
|
||||
}
|
||||
|
||||
export class TemplateView extends LayoutBase {
|
||||
public template: string;
|
||||
|
||||
public static testEvent: string = 'test';
|
||||
|
||||
public parseTemplate() {
|
||||
this.addChild(Builder.parse(this.template));
|
||||
}
|
||||
}
|
||||
|
||||
export const templateProperty = new Property<TemplateView, string>({
|
||||
name: 'template',
|
||||
affectsLayout: true,
|
||||
});
|
||||
templateProperty.register(TemplateView);
|
||||
835
apps/automated/app/xml-declaration/tns.xsd
Normal file
835
apps/automated/app/xml-declaration/tns.xsd
Normal file
@@ -0,0 +1,835 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--SCHEMA VERSION: 1.4.0-2015.9.25.1-->
|
||||
<xs:schema id="tns" xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://schemas.nativescript.org/tns.xsd" xmlns="http://schemas.nativescript.org/tns.xsd" elementFormDefault="qualified" attributeFormDefault="unqualified">
|
||||
<xs:attributeGroup name="actionBarAttributes">
|
||||
<xs:attribute name="title" type="StringValidator"/>
|
||||
<xs:attribute name="navigationButton" type="StringValidator"/>
|
||||
<xs:attribute name="actionItems" type="StringValidator"/>
|
||||
<xs:attribute name="page" type="StringValidator"/>
|
||||
</xs:attributeGroup>
|
||||
<xs:complexType name="ActionBar">
|
||||
<xs:complexContent>
|
||||
<xs:extension base="View">
|
||||
<xs:choice>
|
||||
<xs:element name="ActionBar.actionItems" maxOccurs="1">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="ActionItem" type="ActionItem" maxOccurs="unbounded"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:choice>
|
||||
<xs:attributeGroup ref="actionBarAttributes"/>
|
||||
</xs:extension>
|
||||
</xs:complexContent>
|
||||
</xs:complexType>
|
||||
<xs:element name="ActionBar" type="ActionBar"/>
|
||||
<xs:attributeGroup name="actionItemBaseAttributes">
|
||||
<xs:attribute name="tap" type="StringValidator"/>
|
||||
<xs:attribute name="text" type="StringValidator"/>
|
||||
<xs:attribute name="icon" type="StringValidator"/>
|
||||
<xs:attribute name="actionBar" type="StringValidator"/>
|
||||
</xs:attributeGroup>
|
||||
<xs:complexType name="ActionItemBase">
|
||||
<xs:complexContent>
|
||||
<xs:extension base="Bindable">
|
||||
<xs:attributeGroup ref="actionItemBaseAttributes"/>
|
||||
</xs:extension>
|
||||
</xs:complexContent>
|
||||
</xs:complexType>
|
||||
<xs:element name="ActionItemBase" type="ActionItemBase"/>
|
||||
<xs:attributeGroup name="actionItemAttributes"/>
|
||||
<xs:complexType name="ActionItem">
|
||||
<xs:complexContent>
|
||||
<xs:extension base="ActionItemBase">
|
||||
<xs:attributeGroup ref="actionItemAttributes"/>
|
||||
</xs:extension>
|
||||
</xs:complexContent>
|
||||
</xs:complexType>
|
||||
<xs:element name="ActionItem" type="ActionItem"/>
|
||||
<xs:attributeGroup name="activityIndicatorAttributes">
|
||||
<xs:attribute name="busy" type="BooleanValidator"/>
|
||||
</xs:attributeGroup>
|
||||
<xs:complexType name="ActivityIndicator">
|
||||
<xs:complexContent>
|
||||
<xs:extension base="View">
|
||||
<xs:attributeGroup ref="activityIndicatorAttributes"/>
|
||||
</xs:extension>
|
||||
</xs:complexContent>
|
||||
</xs:complexType>
|
||||
<xs:element name="ActivityIndicator" type="ActivityIndicator"/>
|
||||
<xs:attributeGroup name="borderAttributes">
|
||||
<xs:attribute name="cornerRadius" type="NumberValidator"/>
|
||||
</xs:attributeGroup>
|
||||
<xs:complexType name="Border">
|
||||
<xs:complexContent>
|
||||
<xs:extension base="ContentView">
|
||||
<xs:attributeGroup ref="borderAttributes"/>
|
||||
</xs:extension>
|
||||
</xs:complexContent>
|
||||
</xs:complexType>
|
||||
<xs:element name="Border" type="Border"/>
|
||||
<xs:attributeGroup name="buttonAttributes">
|
||||
<xs:attribute name="tap" type="StringValidator"/>
|
||||
<xs:attribute name="text" type="StringValidator"/>
|
||||
<xs:attribute name="formattedText" type="StringValidator"/>
|
||||
</xs:attributeGroup>
|
||||
<xs:complexType name="Button">
|
||||
<xs:complexContent>
|
||||
<xs:extension base="View">
|
||||
<xs:attributeGroup ref="buttonAttributes"/>
|
||||
</xs:extension>
|
||||
</xs:complexContent>
|
||||
</xs:complexType>
|
||||
<xs:element name="Button" type="Button"/>
|
||||
<xs:attributeGroup name="contentViewAttributes"/>
|
||||
<xs:complexType name="ContentView">
|
||||
<xs:complexContent>
|
||||
<xs:extension base="View">
|
||||
<xs:sequence>
|
||||
<xs:group ref="UIComponents" minOccurs="0" maxOccurs="1"/>
|
||||
</xs:sequence>
|
||||
<xs:attributeGroup ref="contentViewAttributes"/>
|
||||
</xs:extension>
|
||||
</xs:complexContent>
|
||||
</xs:complexType>
|
||||
<xs:element name="ContentView" type="ContentView"/>
|
||||
<xs:attributeGroup name="bindableAttributes"/>
|
||||
<xs:complexType name="Bindable">
|
||||
<xs:attributeGroup ref="bindableAttributes"/>
|
||||
</xs:complexType>
|
||||
<xs:element name="Bindable" type="Bindable"/>
|
||||
<xs:attributeGroup name="viewAttributes">
|
||||
<xs:attribute name="borderRadius" type="NumberValidator"/>
|
||||
<xs:attribute name="borderWidth" type="NumberValidator"/>
|
||||
<xs:attribute name="borderColor" type="ColorValidator"/>
|
||||
<xs:attribute name="loaded" type="StringValidator"/>
|
||||
<xs:attribute name="unloaded" type="StringValidator"/>
|
||||
<xs:attribute name="color" type="ColorValidator"/>
|
||||
<xs:attribute name="backgroundColor" type="ColorValidator"/>
|
||||
<xs:attribute name="backgroundImage" type="StringValidator"/>
|
||||
<xs:attribute name="minWidth" type="NumberValidator"/>
|
||||
<xs:attribute name="minHeight" type="NumberValidator"/>
|
||||
<xs:attribute name="width" type="NumberValidator"/>
|
||||
<xs:attribute name="height" type="NumberValidator"/>
|
||||
<xs:attribute name="margin" type="StringValidator"/>
|
||||
<xs:attribute name="marginLeft" type="NumberValidator"/>
|
||||
<xs:attribute name="marginTop" type="NumberValidator"/>
|
||||
<xs:attribute name="marginRight" type="NumberValidator"/>
|
||||
<xs:attribute name="marginBottom" type="NumberValidator"/>
|
||||
<xs:attribute name="horizontalAlignment" type="StringValidator"/>
|
||||
<xs:attribute name="verticalAlignment" type="StringValidator"/>
|
||||
<xs:attribute name="visibility" type="StringValidator"/>
|
||||
<xs:attribute name="opacity" type="NumberValidator"/>
|
||||
<xs:attribute name="translateX" type="NumberValidator"/>
|
||||
<xs:attribute name="translateY" type="NumberValidator"/>
|
||||
<xs:attribute name="scaleX" type="NumberValidator"/>
|
||||
<xs:attribute name="scaleY" type="NumberValidator"/>
|
||||
<xs:attribute name="rotate" type="NumberValidator"/>
|
||||
<xs:attribute name="isEnabled" type="BooleanValidator"/>
|
||||
<xs:attribute name="isUserInteractionEnabled" type="BooleanValidator"/>
|
||||
<xs:attribute name="id" type="StringValidator"/>
|
||||
<xs:attribute name="cssClass" type="StringValidator"/>
|
||||
<xs:attribute name="className" type="StringValidator"/>
|
||||
<xs:attribute name="style" type="StringValidator"/>
|
||||
<xs:attribute name="cssType" type="StringValidator"/>
|
||||
<xs:attribute name="row" type="NumberValidator"/>
|
||||
<xs:attribute name="col" type="NumberValidator"/>
|
||||
<xs:attribute name="rowSpan" type="NumberValidator"/>
|
||||
<xs:attribute name="colSpan" type="NumberValidator"/>
|
||||
<xs:attribute name="left" type="NumberValidator"/>
|
||||
<xs:attribute name="top" type="NumberValidator"/>
|
||||
<xs:attribute name="dock" type="StringValidator"/>
|
||||
</xs:attributeGroup>
|
||||
<xs:complexType name="View">
|
||||
<xs:attributeGroup ref="viewAttributes"/>
|
||||
</xs:complexType>
|
||||
<xs:element name="View" type="View"/>
|
||||
<xs:attributeGroup name="customLayoutViewAttributes"/>
|
||||
<xs:complexType name="CustomLayoutView">
|
||||
<xs:complexContent>
|
||||
<xs:extension base="View">
|
||||
<xs:sequence>
|
||||
<xs:group ref="UIComponents" minOccurs="0" maxOccurs="unbounded"/>
|
||||
</xs:sequence>
|
||||
<xs:attributeGroup ref="customLayoutViewAttributes"/>
|
||||
</xs:extension>
|
||||
</xs:complexContent>
|
||||
</xs:complexType>
|
||||
<xs:element name="CustomLayoutView" type="CustomLayoutView"/>
|
||||
<xs:attributeGroup name="datePickerAttributes">
|
||||
<xs:attribute name="year" type="NumberValidator"/>
|
||||
<xs:attribute name="month" type="NumberValidator"/>
|
||||
<xs:attribute name="day" type="NumberValidator"/>
|
||||
<xs:attribute name="maxDate" type="StringValidator"/>
|
||||
<xs:attribute name="minDate" type="StringValidator"/>
|
||||
</xs:attributeGroup>
|
||||
<xs:complexType name="DatePicker">
|
||||
<xs:complexContent>
|
||||
<xs:extension base="View">
|
||||
<xs:attributeGroup ref="datePickerAttributes"/>
|
||||
</xs:extension>
|
||||
</xs:complexContent>
|
||||
</xs:complexType>
|
||||
<xs:element name="DatePicker" type="DatePicker"/>
|
||||
<xs:attributeGroup name="editableTextBaseAttributes">
|
||||
<xs:attribute name="keyboardType" type="StringValidator"/>
|
||||
<xs:attribute name="returnKeyType" type="StringValidator"/>
|
||||
<xs:attribute name="editable" type="BooleanValidator"/>
|
||||
<xs:attribute name="updateTextTrigger" type="StringValidator"/>
|
||||
<xs:attribute name="autocapitalizationType" type="StringValidator"/>
|
||||
<xs:attribute name="autocorrect" type="BooleanValidator"/>
|
||||
<xs:attribute name="hint" type="StringValidator"/>
|
||||
</xs:attributeGroup>
|
||||
<xs:complexType name="EditableTextBase">
|
||||
<xs:complexContent>
|
||||
<xs:extension base="TextBase">
|
||||
<xs:attributeGroup ref="editableTextBaseAttributes"/>
|
||||
</xs:extension>
|
||||
</xs:complexContent>
|
||||
</xs:complexType>
|
||||
<xs:element name="EditableTextBase" type="EditableTextBase"/>
|
||||
<xs:attributeGroup name="htmlViewAttributes">
|
||||
<xs:attribute name="html" type="StringValidator"/>
|
||||
</xs:attributeGroup>
|
||||
<xs:complexType name="HtmlView">
|
||||
<xs:complexContent>
|
||||
<xs:extension base="View">
|
||||
<xs:attributeGroup ref="htmlViewAttributes"/>
|
||||
</xs:extension>
|
||||
</xs:complexContent>
|
||||
</xs:complexType>
|
||||
<xs:element name="HtmlView" type="HtmlView"/>
|
||||
<xs:attributeGroup name="imageAttributes">
|
||||
<xs:attribute name="isLoading" type="BooleanValidator"/>
|
||||
<xs:attribute name="stretch" type="StringValidator"/>
|
||||
<xs:attribute name="src" type="StringValidator"/>
|
||||
</xs:attributeGroup>
|
||||
<xs:complexType name="Image">
|
||||
<xs:complexContent>
|
||||
<xs:extension base="View">
|
||||
<xs:attributeGroup ref="imageAttributes"/>
|
||||
</xs:extension>
|
||||
</xs:complexContent>
|
||||
</xs:complexType>
|
||||
<xs:element name="Image" type="Image"/>
|
||||
<xs:attributeGroup name="labelAttributes">
|
||||
<xs:attribute name="textWrap" type="BooleanValidator"/>
|
||||
</xs:attributeGroup>
|
||||
<xs:complexType name="Label">
|
||||
<xs:complexContent>
|
||||
<xs:extension base="TextBase">
|
||||
<xs:attributeGroup ref="labelAttributes"/>
|
||||
</xs:extension>
|
||||
</xs:complexContent>
|
||||
</xs:complexType>
|
||||
<xs:element name="Label" type="Label"/>
|
||||
<xs:attributeGroup name="absoluteLayoutAttributes"/>
|
||||
<xs:complexType name="AbsoluteLayout">
|
||||
<xs:complexContent>
|
||||
<xs:extension base="LayoutBase">
|
||||
<xs:attributeGroup ref="absoluteLayoutAttributes"/>
|
||||
</xs:extension>
|
||||
</xs:complexContent>
|
||||
</xs:complexType>
|
||||
<xs:element name="AbsoluteLayout" type="AbsoluteLayout"/>
|
||||
<xs:attributeGroup name="dockLayoutAttributes">
|
||||
<xs:attribute name="stretchLastChild" type="BooleanValidator"/>
|
||||
</xs:attributeGroup>
|
||||
<xs:complexType name="DockLayout">
|
||||
<xs:complexContent>
|
||||
<xs:extension base="LayoutBase">
|
||||
<xs:attributeGroup ref="dockLayoutAttributes"/>
|
||||
</xs:extension>
|
||||
</xs:complexContent>
|
||||
</xs:complexType>
|
||||
<xs:element name="DockLayout" type="DockLayout"/>
|
||||
<xs:attributeGroup name="gridLayoutAttributes">
|
||||
<xs:attribute name="rows" type="StringValidator"/>
|
||||
<xs:attribute name="columns" type="StringValidator"/>
|
||||
</xs:attributeGroup>
|
||||
<xs:complexType name="GridLayout">
|
||||
<xs:complexContent>
|
||||
<xs:extension base="LayoutBase">
|
||||
<xs:attributeGroup ref="gridLayoutAttributes"/>
|
||||
</xs:extension>
|
||||
</xs:complexContent>
|
||||
</xs:complexType>
|
||||
<xs:element name="GridLayout" type="GridLayout"/>
|
||||
<xs:attributeGroup name="layoutBaseAttributes">
|
||||
<xs:attribute name="padding" type="StringValidator"/>
|
||||
<xs:attribute name="paddingBottom" type="NumberValidator"/>
|
||||
<xs:attribute name="paddingLeft" type="NumberValidator"/>
|
||||
<xs:attribute name="paddingRight" type="NumberValidator"/>
|
||||
<xs:attribute name="paddingTop" type="NumberValidator"/>
|
||||
</xs:attributeGroup>
|
||||
<xs:complexType name="LayoutBase">
|
||||
<xs:complexContent>
|
||||
<xs:extension base="CustomLayoutView">
|
||||
<xs:attributeGroup ref="layoutBaseAttributes"/>
|
||||
</xs:extension>
|
||||
</xs:complexContent>
|
||||
</xs:complexType>
|
||||
<xs:element name="LayoutBase" type="LayoutBase"/>
|
||||
<xs:attributeGroup name="layoutAttributes"/>
|
||||
<xs:complexType name="Layout">
|
||||
<xs:complexContent>
|
||||
<xs:extension base="LayoutBase">
|
||||
<xs:sequence>
|
||||
<xs:group ref="UIComponents" minOccurs="0" maxOccurs="unbounded"/>
|
||||
</xs:sequence>
|
||||
<xs:attributeGroup ref="layoutAttributes"/>
|
||||
</xs:extension>
|
||||
</xs:complexContent>
|
||||
</xs:complexType>
|
||||
<xs:element name="Layout" type="Layout"/>
|
||||
<xs:attributeGroup name="stackLayoutAttributes">
|
||||
<xs:attribute name="orientation" type="StringValidator"/>
|
||||
</xs:attributeGroup>
|
||||
<xs:complexType name="StackLayout">
|
||||
<xs:complexContent>
|
||||
<xs:extension base="LayoutBase">
|
||||
<xs:attributeGroup ref="stackLayoutAttributes"/>
|
||||
</xs:extension>
|
||||
</xs:complexContent>
|
||||
</xs:complexType>
|
||||
<xs:element name="StackLayout" type="StackLayout"/>
|
||||
<xs:attributeGroup name="wrapLayoutAttributes">
|
||||
<xs:attribute name="orientation" type="StringValidator"/>
|
||||
<xs:attribute name="itemWidth" type="NumberValidator"/>
|
||||
<xs:attribute name="itemHeight" type="NumberValidator"/>
|
||||
</xs:attributeGroup>
|
||||
<xs:complexType name="WrapLayout">
|
||||
<xs:complexContent>
|
||||
<xs:extension base="LayoutBase">
|
||||
<xs:attributeGroup ref="wrapLayoutAttributes"/>
|
||||
</xs:extension>
|
||||
</xs:complexContent>
|
||||
</xs:complexType>
|
||||
<xs:element name="WrapLayout" type="WrapLayout"/>
|
||||
<xs:attributeGroup name="listPickerAttributes">
|
||||
<xs:attribute name="selectedIndex" type="NumberValidator"/>
|
||||
</xs:attributeGroup>
|
||||
<xs:complexType name="ListPicker">
|
||||
<xs:complexContent>
|
||||
<xs:extension base="View">
|
||||
<xs:attributeGroup ref="listPickerAttributes"/>
|
||||
</xs:extension>
|
||||
</xs:complexContent>
|
||||
</xs:complexType>
|
||||
<xs:element name="ListPicker" type="ListPicker"/>
|
||||
<xs:attributeGroup name="listViewAttributes">
|
||||
<xs:attribute name="itemLoading" type="StringValidator"/>
|
||||
<xs:attribute name="itemTap" type="StringValidator"/>
|
||||
<xs:attribute name="loadMoreItems" type="StringValidator"/>
|
||||
<xs:attribute name="isScrolling" type="BooleanValidator"/>
|
||||
<xs:attribute name="itemTemplate" type="StringValidator"/>
|
||||
<xs:attribute name="separatorColor" type="ColorValidator"/>
|
||||
<xs:attribute name="items" type="StringValidator"/>
|
||||
</xs:attributeGroup>
|
||||
<xs:complexType name="ListView">
|
||||
<xs:complexContent>
|
||||
<xs:extension base="View">
|
||||
<xs:all>
|
||||
<xs:element name="ListView.itemTemplate" minOccurs="0" maxOccurs="1">
|
||||
<xs:complexType>
|
||||
<xs:group ref="UIComponents" minOccurs="0" maxOccurs="1"/>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:all>
|
||||
<xs:attributeGroup ref="listViewAttributes"/>
|
||||
</xs:extension>
|
||||
</xs:complexContent>
|
||||
</xs:complexType>
|
||||
<xs:element name="ListView" type="ListView"/>
|
||||
<xs:attributeGroup name="pageAttributes">
|
||||
<xs:attribute name="shownModally" type="StringValidator"/>
|
||||
<xs:attribute name="navigatingTo" type="StringValidator"/>
|
||||
<xs:attribute name="navigatedTo" type="StringValidator"/>
|
||||
<xs:attribute name="navigatingFrom" type="StringValidator"/>
|
||||
<xs:attribute name="navigatedFrom" type="StringValidator"/>
|
||||
<xs:attribute name="actionBarHidden" type="BooleanValidator"/>
|
||||
<xs:attribute name="css" type="StringValidator"/>
|
||||
<xs:attribute name="actionBar" type="StringValidator"/>
|
||||
</xs:attributeGroup>
|
||||
<xs:complexType name="Page">
|
||||
<xs:complexContent>
|
||||
<xs:extension base="View">
|
||||
<xs:sequence>
|
||||
<xs:element name="Page.actionBar" minOccurs="0" maxOccurs="1">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="ActionBar" type="ActionBar" maxOccurs="1"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:group ref="UIComponents" minOccurs="0" maxOccurs="1"/>
|
||||
</xs:sequence>
|
||||
<xs:attributeGroup ref="pageAttributes"/>
|
||||
</xs:extension>
|
||||
</xs:complexContent>
|
||||
</xs:complexType>
|
||||
<xs:element name="Page" type="Page"/>
|
||||
<xs:attributeGroup name="placeholderAttributes">
|
||||
<xs:attribute name="creatingView" type="StringValidator"/>
|
||||
</xs:attributeGroup>
|
||||
<xs:complexType name="Placeholder">
|
||||
<xs:complexContent>
|
||||
<xs:extension base="View">
|
||||
<xs:attributeGroup ref="placeholderAttributes"/>
|
||||
</xs:extension>
|
||||
</xs:complexContent>
|
||||
</xs:complexType>
|
||||
<xs:element name="Placeholder" type="Placeholder"/>
|
||||
<xs:attributeGroup name="progressAttributes">
|
||||
<xs:attribute name="value" type="NumberValidator"/>
|
||||
<xs:attribute name="maxValue" type="NumberValidator"/>
|
||||
</xs:attributeGroup>
|
||||
<xs:complexType name="Progress">
|
||||
<xs:complexContent>
|
||||
<xs:extension base="View">
|
||||
<xs:attributeGroup ref="progressAttributes"/>
|
||||
</xs:extension>
|
||||
</xs:complexContent>
|
||||
</xs:complexType>
|
||||
<xs:element name="Progress" type="Progress"/>
|
||||
<xs:attributeGroup name="repeaterAttributes">
|
||||
<xs:attribute name="itemTemplate" type="StringValidator"/>
|
||||
<xs:attribute name="itemsLayout" type="LayoutValidator"/>
|
||||
</xs:attributeGroup>
|
||||
<xs:complexType name="Repeater">
|
||||
<xs:complexContent>
|
||||
<xs:extension base="View">
|
||||
<xs:all>
|
||||
<xs:element name="Repeater.itemTemplate" minOccurs="0" maxOccurs="1">
|
||||
<xs:complexType>
|
||||
<xs:group ref="UIComponents" minOccurs="0" maxOccurs="1"/>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:element name="Repeater.itemsLayout" maxOccurs="1">
|
||||
<xs:complexType>
|
||||
<xs:group ref="UILayouts" maxOccurs="1"/>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:all>
|
||||
<xs:attributeGroup ref="repeaterAttributes"/>
|
||||
</xs:extension>
|
||||
</xs:complexContent>
|
||||
</xs:complexType>
|
||||
<xs:element name="Repeater" type="Repeater"/>
|
||||
<xs:attributeGroup name="scrollViewAttributes">
|
||||
<xs:attribute name="verticalOffset" type="NumberValidator"/>
|
||||
<xs:attribute name="horizontalOffset" type="NumberValidator"/>
|
||||
<xs:attribute name="scrollableHeight" type="NumberValidator"/>
|
||||
<xs:attribute name="scrollableWidth" type="NumberValidator"/>
|
||||
<xs:attribute name="orientation" type="StringValidator"/>
|
||||
</xs:attributeGroup>
|
||||
<xs:complexType name="ScrollView">
|
||||
<xs:complexContent>
|
||||
<xs:extension base="ContentView">
|
||||
<xs:attributeGroup ref="scrollViewAttributes"/>
|
||||
</xs:extension>
|
||||
</xs:complexContent>
|
||||
</xs:complexType>
|
||||
<xs:element name="ScrollView" type="ScrollView"/>
|
||||
<xs:attributeGroup name="searchBarAttributes">
|
||||
<xs:attribute name="submit" type="StringValidator"/>
|
||||
<xs:attribute name="clear" type="StringValidator"/>
|
||||
<xs:attribute name="text" type="StringValidator"/>
|
||||
<xs:attribute name="hint" type="StringValidator"/>
|
||||
<xs:attribute name="textFieldBackgroundColor" type="ColorValidator"/>
|
||||
<xs:attribute name="textFieldHintColor" type="ColorValidator"/>
|
||||
</xs:attributeGroup>
|
||||
<xs:complexType name="SearchBar">
|
||||
<xs:complexContent>
|
||||
<xs:extension base="View">
|
||||
<xs:attributeGroup ref="searchBarAttributes"/>
|
||||
</xs:extension>
|
||||
</xs:complexContent>
|
||||
</xs:complexType>
|
||||
<xs:element name="SearchBar" type="SearchBar"/>
|
||||
<xs:attributeGroup name="segmentedBarAttributes">
|
||||
<xs:attribute name="selectedIndex" type="NumberValidator"/>
|
||||
<xs:attribute name="selectedBackgroundColor" type="ColorValidator"/>
|
||||
<xs:attribute name="items" type="StringValidator"/>
|
||||
<xs:attribute name="selectedIndexChanged" type="StringValidator"/>
|
||||
</xs:attributeGroup>
|
||||
<xs:complexType name="SegmentedBar">
|
||||
<xs:complexContent>
|
||||
<xs:extension base="View">
|
||||
<xs:choice>
|
||||
<xs:element name="SegmentedBar.items" maxOccurs="1">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="SegmentedBarItem" maxOccurs="unbounded">
|
||||
<xs:complexType>
|
||||
<xs:attribute name="title" type="StringValidator"/>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:choice>
|
||||
<xs:attributeGroup ref="segmentedBarAttributes"/>
|
||||
</xs:extension>
|
||||
</xs:complexContent>
|
||||
</xs:complexType>
|
||||
<xs:element name="SegmentedBar" type="SegmentedBar"/>
|
||||
<xs:attributeGroup name="sliderAttributes">
|
||||
<xs:attribute name="value" type="NumberValidator"/>
|
||||
<xs:attribute name="minValue" type="NumberValidator"/>
|
||||
<xs:attribute name="maxValue" type="NumberValidator"/>
|
||||
</xs:attributeGroup>
|
||||
<xs:complexType name="Slider">
|
||||
<xs:complexContent>
|
||||
<xs:extension base="View">
|
||||
<xs:attributeGroup ref="sliderAttributes"/>
|
||||
</xs:extension>
|
||||
</xs:complexContent>
|
||||
</xs:complexType>
|
||||
<xs:element name="Slider" type="Slider"/>
|
||||
<xs:attributeGroup name="switchAttributes">
|
||||
<xs:attribute name="checked" type="BooleanValidator"/>
|
||||
</xs:attributeGroup>
|
||||
<xs:complexType name="Switch">
|
||||
<xs:complexContent>
|
||||
<xs:extension base="View">
|
||||
<xs:attributeGroup ref="switchAttributes"/>
|
||||
</xs:extension>
|
||||
</xs:complexContent>
|
||||
</xs:complexType>
|
||||
<xs:element name="Switch" type="Switch"/>
|
||||
<xs:attributeGroup name="tabViewAttributes">
|
||||
<xs:attribute name="items" type="StringValidator"/>
|
||||
<xs:attribute name="selectedIndex" type="NumberValidator"/>
|
||||
<xs:attribute name="selectedIndexChanged" type="StringValidator"/>
|
||||
</xs:attributeGroup>
|
||||
<xs:complexType name="TabView">
|
||||
<xs:complexContent>
|
||||
<xs:extension base="View">
|
||||
<xs:choice>
|
||||
<xs:element name="TabView.items" maxOccurs="1">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="TabViewItem" maxOccurs="unbounded">
|
||||
<xs:complexType>
|
||||
<xs:complexContent>
|
||||
<xs:extension base="View">
|
||||
<xs:all>
|
||||
<xs:element name="TabViewItem.view" minOccurs="0" maxOccurs="1">
|
||||
<xs:complexType>
|
||||
<xs:group ref="UIComponents" minOccurs="0" maxOccurs="1"/>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:all>
|
||||
<xs:attribute name="title" type="StringValidator"/>
|
||||
</xs:extension>
|
||||
</xs:complexContent>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:choice>
|
||||
<xs:attributeGroup ref="tabViewAttributes"/>
|
||||
</xs:extension>
|
||||
</xs:complexContent>
|
||||
</xs:complexType>
|
||||
<xs:element name="TabView" type="TabView"/>
|
||||
<xs:attributeGroup name="textBaseAttributes">
|
||||
<xs:attribute name="text" type="StringValidator"/>
|
||||
<xs:attribute name="textAlignment" type="StringValidator"/>
|
||||
<xs:attribute name="fontSize" type="NumberValidator"/>
|
||||
<xs:attribute name="formattedText" type="StringValidator"/>
|
||||
</xs:attributeGroup>
|
||||
<xs:complexType name="TextBase">
|
||||
<xs:complexContent>
|
||||
<xs:extension base="View">
|
||||
<xs:attributeGroup ref="textBaseAttributes"/>
|
||||
</xs:extension>
|
||||
</xs:complexContent>
|
||||
</xs:complexType>
|
||||
<xs:element name="TextBase" type="TextBase"/>
|
||||
<xs:attributeGroup name="textFieldAttributes">
|
||||
<xs:attribute name="secure" type="BooleanValidator"/>
|
||||
</xs:attributeGroup>
|
||||
<xs:complexType name="TextField">
|
||||
<xs:complexContent>
|
||||
<xs:extension base="EditableTextBase">
|
||||
<xs:attributeGroup ref="textFieldAttributes"/>
|
||||
</xs:extension>
|
||||
</xs:complexContent>
|
||||
</xs:complexType>
|
||||
<xs:element name="TextField" type="TextField"/>
|
||||
<xs:attributeGroup name="textViewAttributes"/>
|
||||
<xs:complexType name="TextView">
|
||||
<xs:complexContent>
|
||||
<xs:extension base="EditableTextBase">
|
||||
<xs:attributeGroup ref="textViewAttributes"/>
|
||||
</xs:extension>
|
||||
</xs:complexContent>
|
||||
</xs:complexType>
|
||||
<xs:element name="TextView" type="TextView"/>
|
||||
<xs:attributeGroup name="timePickerAttributes">
|
||||
<xs:attribute name="hour" type="NumberValidator"/>
|
||||
<xs:attribute name="minute" type="NumberValidator"/>
|
||||
</xs:attributeGroup>
|
||||
<xs:complexType name="TimePicker">
|
||||
<xs:complexContent>
|
||||
<xs:extension base="View">
|
||||
<xs:attributeGroup ref="timePickerAttributes"/>
|
||||
</xs:extension>
|
||||
</xs:complexContent>
|
||||
</xs:complexType>
|
||||
<xs:element name="TimePicker" type="TimePicker"/>
|
||||
<xs:attributeGroup name="webViewAttributes">
|
||||
<xs:attribute name="loadStarted" type="StringValidator"/>
|
||||
<xs:attribute name="loadFinished" type="StringValidator"/>
|
||||
<xs:attribute name="url" type="StringValidator"/>
|
||||
<xs:attribute name="src" type="StringValidator"/>
|
||||
<xs:attribute name="canGoBack" type="BooleanValidator"/>
|
||||
<xs:attribute name="canGoForward" type="BooleanValidator"/>
|
||||
</xs:attributeGroup>
|
||||
<xs:complexType name="WebView">
|
||||
<xs:complexContent>
|
||||
<xs:extension base="View">
|
||||
<xs:attributeGroup ref="webViewAttributes"/>
|
||||
</xs:extension>
|
||||
</xs:complexContent>
|
||||
</xs:complexType>
|
||||
<xs:element name="WebView" type="WebView"/>
|
||||
<xs:simpleType name="BindingValidator">
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:pattern value="\{\{.*\}\}"/>
|
||||
<xs:whiteSpace value="collapse"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
<xs:simpleType name="StringValidator">
|
||||
<xs:union memberTypes="BindingValidator">
|
||||
<xs:simpleType>
|
||||
<xs:restriction base="xs:string"/>
|
||||
</xs:simpleType>
|
||||
</xs:union>
|
||||
</xs:simpleType>
|
||||
<xs:simpleType name="BooleanValidator">
|
||||
<xs:union memberTypes="BindingValidator">
|
||||
<xs:simpleType>
|
||||
<xs:restriction base="xs:boolean"/>
|
||||
</xs:simpleType>
|
||||
</xs:union>
|
||||
</xs:simpleType>
|
||||
<xs:simpleType name="NumberValidator">
|
||||
<xs:union memberTypes="BindingValidator">
|
||||
<xs:simpleType>
|
||||
<xs:restriction base="xs:integer"/>
|
||||
</xs:simpleType>
|
||||
</xs:union>
|
||||
</xs:simpleType>
|
||||
<xs:simpleType name="ColorValidator">
|
||||
<xs:union memberTypes="BindingValidator">
|
||||
<xs:simpleType>
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:pattern value="#ddd(ddd)?"/>
|
||||
<xs:enumeration value="Transparent"/>
|
||||
<xs:enumeration value="AliceBlue"/>
|
||||
<xs:enumeration value="AntiqueWhite"/>
|
||||
<xs:enumeration value="Aqua"/>
|
||||
<xs:enumeration value="Aquamarine"/>
|
||||
<xs:enumeration value="Azure"/>
|
||||
<xs:enumeration value="Beige"/>
|
||||
<xs:enumeration value="Bisque"/>
|
||||
<xs:enumeration value="Black"/>
|
||||
<xs:enumeration value="BlanchedAlmond"/>
|
||||
<xs:enumeration value="Blue"/>
|
||||
<xs:enumeration value="BlueViolet"/>
|
||||
<xs:enumeration value="Brown"/>
|
||||
<xs:enumeration value="BurlyWood"/>
|
||||
<xs:enumeration value="CadetBlue"/>
|
||||
<xs:enumeration value="Chartreuse"/>
|
||||
<xs:enumeration value="Chocolate"/>
|
||||
<xs:enumeration value="Coral"/>
|
||||
<xs:enumeration value="CornflowerBlue"/>
|
||||
<xs:enumeration value="Cornsilk"/>
|
||||
<xs:enumeration value="Crimson"/>
|
||||
<xs:enumeration value="Cyan"/>
|
||||
<xs:enumeration value="DarkBlue"/>
|
||||
<xs:enumeration value="DarkCyan"/>
|
||||
<xs:enumeration value="DarkGoldenRod"/>
|
||||
<xs:enumeration value="DarkGray"/>
|
||||
<xs:enumeration value="DarkGreen"/>
|
||||
<xs:enumeration value="DarkKhaki"/>
|
||||
<xs:enumeration value="DarkMagenta"/>
|
||||
<xs:enumeration value="DarkOliveGreen"/>
|
||||
<xs:enumeration value="DarkOrange"/>
|
||||
<xs:enumeration value="DarkOrchid"/>
|
||||
<xs:enumeration value="DarkRed"/>
|
||||
<xs:enumeration value="DarkSalmon"/>
|
||||
<xs:enumeration value="DarkSeaGreen"/>
|
||||
<xs:enumeration value="DarkSlateBlue"/>
|
||||
<xs:enumeration value="DarkSlateGray"/>
|
||||
<xs:enumeration value="DarkTurquoise"/>
|
||||
<xs:enumeration value="DarkViolet"/>
|
||||
<xs:enumeration value="DeepPink"/>
|
||||
<xs:enumeration value="DeepSkyBlue"/>
|
||||
<xs:enumeration value="DimGray"/>
|
||||
<xs:enumeration value="DodgerBlue"/>
|
||||
<xs:enumeration value="FireBrick"/>
|
||||
<xs:enumeration value="FloralWhite"/>
|
||||
<xs:enumeration value="ForestGreen"/>
|
||||
<xs:enumeration value="Fuchsia"/>
|
||||
<xs:enumeration value="Gainsboro"/>
|
||||
<xs:enumeration value="GhostWhite"/>
|
||||
<xs:enumeration value="Gold"/>
|
||||
<xs:enumeration value="GoldenRod"/>
|
||||
<xs:enumeration value="Gray"/>
|
||||
<xs:enumeration value="Green"/>
|
||||
<xs:enumeration value="GreenYellow"/>
|
||||
<xs:enumeration value="HoneyDew"/>
|
||||
<xs:enumeration value="HotPink"/>
|
||||
<xs:enumeration value="IndianRed"/>
|
||||
<xs:enumeration value="Indigo"/>
|
||||
<xs:enumeration value="Ivory"/>
|
||||
<xs:enumeration value="Khaki"/>
|
||||
<xs:enumeration value="Lavender"/>
|
||||
<xs:enumeration value="LavenderBlush"/>
|
||||
<xs:enumeration value="LawnGreen"/>
|
||||
<xs:enumeration value="LemonChiffon"/>
|
||||
<xs:enumeration value="LightBlue"/>
|
||||
<xs:enumeration value="LightCoral"/>
|
||||
<xs:enumeration value="LightCyan"/>
|
||||
<xs:enumeration value="LightGoldenRodYellow"/>
|
||||
<xs:enumeration value="LightGray"/>
|
||||
<xs:enumeration value="LightGreen"/>
|
||||
<xs:enumeration value="LightPink"/>
|
||||
<xs:enumeration value="LightSalmon"/>
|
||||
<xs:enumeration value="LightSeaGreen"/>
|
||||
<xs:enumeration value="LightSkyBlue"/>
|
||||
<xs:enumeration value="LightSlateGray"/>
|
||||
<xs:enumeration value="LightSteelBlue"/>
|
||||
<xs:enumeration value="LightYellow"/>
|
||||
<xs:enumeration value="Lime"/>
|
||||
<xs:enumeration value="LimeGreen"/>
|
||||
<xs:enumeration value="Linen"/>
|
||||
<xs:enumeration value="Magenta"/>
|
||||
<xs:enumeration value="Maroon"/>
|
||||
<xs:enumeration value="MediumAquaMarine"/>
|
||||
<xs:enumeration value="MediumBlue"/>
|
||||
<xs:enumeration value="MediumOrchid"/>
|
||||
<xs:enumeration value="MediumPurple"/>
|
||||
<xs:enumeration value="MediumSeaGreen"/>
|
||||
<xs:enumeration value="MediumSlateBlue"/>
|
||||
<xs:enumeration value="MediumSpringGreen"/>
|
||||
<xs:enumeration value="MediumTurquoise"/>
|
||||
<xs:enumeration value="MediumVioletRed"/>
|
||||
<xs:enumeration value="MidnightBlue"/>
|
||||
<xs:enumeration value="MintCream"/>
|
||||
<xs:enumeration value="MistyRose"/>
|
||||
<xs:enumeration value="Moccasin"/>
|
||||
<xs:enumeration value="NavajoWhite"/>
|
||||
<xs:enumeration value="Navy"/>
|
||||
<xs:enumeration value="OldLace"/>
|
||||
<xs:enumeration value="Olive"/>
|
||||
<xs:enumeration value="OliveDrab"/>
|
||||
<xs:enumeration value="Orange"/>
|
||||
<xs:enumeration value="OrangeRed"/>
|
||||
<xs:enumeration value="Orchid"/>
|
||||
<xs:enumeration value="PaleGoldenRod"/>
|
||||
<xs:enumeration value="PaleGreen"/>
|
||||
<xs:enumeration value="PaleTurquoise"/>
|
||||
<xs:enumeration value="PaleVioletRed"/>
|
||||
<xs:enumeration value="PapayaWhip"/>
|
||||
<xs:enumeration value="PeachPuff"/>
|
||||
<xs:enumeration value="Peru"/>
|
||||
<xs:enumeration value="Pink"/>
|
||||
<xs:enumeration value="Plum"/>
|
||||
<xs:enumeration value="PowderBlue"/>
|
||||
<xs:enumeration value="Purple"/>
|
||||
<xs:enumeration value="RebeccaPurple"/>
|
||||
<xs:enumeration value="Red"/>
|
||||
<xs:enumeration value="RosyBrown"/>
|
||||
<xs:enumeration value="RoyalBlue"/>
|
||||
<xs:enumeration value="SaddleBrown"/>
|
||||
<xs:enumeration value="Salmon"/>
|
||||
<xs:enumeration value="SandyBrown"/>
|
||||
<xs:enumeration value="SeaGreen"/>
|
||||
<xs:enumeration value="SeaShell"/>
|
||||
<xs:enumeration value="Sienna"/>
|
||||
<xs:enumeration value="Silver"/>
|
||||
<xs:enumeration value="SkyBlue"/>
|
||||
<xs:enumeration value="SlateBlue"/>
|
||||
<xs:enumeration value="SlateGray"/>
|
||||
<xs:enumeration value="Snow"/>
|
||||
<xs:enumeration value="SpringGreen"/>
|
||||
<xs:enumeration value="SteelBlue"/>
|
||||
<xs:enumeration value="Tan"/>
|
||||
<xs:enumeration value="Teal"/>
|
||||
<xs:enumeration value="Thistle"/>
|
||||
<xs:enumeration value="Tomato"/>
|
||||
<xs:enumeration value="Turquoise"/>
|
||||
<xs:enumeration value="Violet"/>
|
||||
<xs:enumeration value="Wheat"/>
|
||||
<xs:enumeration value="White"/>
|
||||
<xs:enumeration value="WhiteSmoke"/>
|
||||
<xs:enumeration value="Yellow"/>
|
||||
<xs:enumeration value="YellowGreen"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
</xs:union>
|
||||
</xs:simpleType>
|
||||
<xs:simpleType name="LayoutValidator">
|
||||
<xs:union memberTypes="BindingValidator">
|
||||
<xs:simpleType>
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:enumeration value="StackLayout"/>
|
||||
<xs:enumeration value="GridLayout"/>
|
||||
<xs:enumeration value="AbsoluteLayout"/>
|
||||
<xs:enumeration value="DockLayout"/>
|
||||
<xs:enumeration value="WrapLayout"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
</xs:union>
|
||||
</xs:simpleType>
|
||||
<xs:group name="UIComponents">
|
||||
<xs:choice>
|
||||
<xs:element name="ActionBar" type="ActionBar"/>
|
||||
<xs:element name="ActivityIndicator" type="ActivityIndicator"/>
|
||||
<xs:element name="Border" type="Border"/>
|
||||
<xs:element name="Button" type="Button"/>
|
||||
<xs:element name="ContentView" type="ContentView"/>
|
||||
<xs:element name="DatePicker" type="DatePicker"/>
|
||||
<xs:element name="HtmlView" type="HtmlView"/>
|
||||
<xs:element name="Image" type="Image"/>
|
||||
<xs:element name="Label" type="Label"/>
|
||||
<xs:element name="AbsoluteLayout" type="AbsoluteLayout"/>
|
||||
<xs:element name="DockLayout" type="DockLayout"/>
|
||||
<xs:element name="GridLayout" type="GridLayout"/>
|
||||
<xs:element name="StackLayout" type="StackLayout"/>
|
||||
<xs:element name="WrapLayout" type="WrapLayout"/>
|
||||
<xs:element name="ListPicker" type="ListPicker"/>
|
||||
<xs:element name="ListView" type="ListView"/>
|
||||
<xs:element name="Page" type="Page"/>
|
||||
<xs:element name="Placeholder" type="Placeholder"/>
|
||||
<xs:element name="Progress" type="Progress"/>
|
||||
<xs:element name="Repeater" type="Repeater"/>
|
||||
<xs:element name="ScrollView" type="ScrollView"/>
|
||||
<xs:element name="SearchBar" type="SearchBar"/>
|
||||
<xs:element name="SegmentedBar" type="SegmentedBar"/>
|
||||
<xs:element name="Slider" type="Slider"/>
|
||||
<xs:element name="Switch" type="Switch"/>
|
||||
<xs:element name="TabView" type="TabView"/>
|
||||
<xs:element name="TextField" type="TextField"/>
|
||||
<xs:element name="TextView" type="TextView"/>
|
||||
<xs:element name="TimePicker" type="TimePicker"/>
|
||||
<xs:element name="WebView" type="WebView"/>
|
||||
</xs:choice>
|
||||
</xs:group>
|
||||
<xs:group name="UILayouts">
|
||||
<xs:choice>
|
||||
<xs:element name="AbsoluteLayout" type="AbsoluteLayout"/>
|
||||
<xs:element name="DockLayout" type="DockLayout"/>
|
||||
<xs:element name="GridLayout" type="GridLayout"/>
|
||||
<xs:element name="StackLayout" type="StackLayout"/>
|
||||
<xs:element name="WrapLayout" type="WrapLayout"/>
|
||||
</xs:choice>
|
||||
</xs:group>
|
||||
</xs:schema>
|
||||
920
apps/automated/app/xml-declaration/xml-declaration-tests.ts
Normal file
920
apps/automated/app/xml-declaration/xml-declaration-tests.ts
Normal file
@@ -0,0 +1,920 @@
|
||||
import * as TKUnit from '../tk-unit';
|
||||
import { EventData, ItemEventData, ListView, Builder, Button, Switch, SearchBar, TextField, GridLayout, AbsoluteLayout, Observable, TabView, Page, Label, platformNames, Device, GestureTypes, StackLayout, SegmentedBar, View, getAncestor, eachDescendant, PercentLength, Length, Utils, SegmentedBarItem } from '@nativescript/core';
|
||||
import { TemplateView } from './template-builder-tests/template-view';
|
||||
import * as helper from '../ui-helper';
|
||||
|
||||
export function test_load_IsDefined() {
|
||||
TKUnit.assertTrue(Utils.isFunction(Builder.load), 'Builder should have load method!');
|
||||
}
|
||||
|
||||
export function test_parse_IsDefined() {
|
||||
TKUnit.assertTrue(Utils.isFunction(Builder.parse), 'Builder should have parse method!');
|
||||
}
|
||||
|
||||
export function test_load_ShouldThrowWithInvalidFileName() {
|
||||
TKUnit.assertThrows(() => Builder.load('./xml-declaration/invalid-page.xml'), 'Loading component from a missing module SHOULD throw an error.');
|
||||
}
|
||||
|
||||
export function test_load_ShouldNotCrashWithoutExports() {
|
||||
var v = Builder.load('./xml-declaration/mainPage.xml');
|
||||
TKUnit.assertTrue(v instanceof View, 'Expected result: View; Actual result: ' + v + ';');
|
||||
}
|
||||
|
||||
export function test_loadWithOptionsNoXML() {
|
||||
var v = Builder.load({
|
||||
path: '~/xml-declaration/mymodule',
|
||||
name: 'MyControl',
|
||||
exports: exports,
|
||||
page: new Page(),
|
||||
});
|
||||
|
||||
TKUnit.assertTrue(v instanceof View, 'Expected result: View; Actual result: ' + v + ';');
|
||||
}
|
||||
|
||||
export function test_loadWithOptionsNoXML_CSSIsApplied() {
|
||||
let newPage = helper.getCurrentPage();
|
||||
newPage.content = Builder.load({
|
||||
path: '~/xml-declaration/mymodule',
|
||||
name: 'MyControl',
|
||||
exports: exports,
|
||||
page: newPage,
|
||||
});
|
||||
|
||||
TKUnit.assert(newPage.isLoaded, 'The page should be loaded here.');
|
||||
helper.assertViewBackgroundColor(newPage.content, '#FF0000');
|
||||
}
|
||||
|
||||
export function test_loadInheritedPageAndResolveFromChild() {
|
||||
var basePath = 'xml-declaration/';
|
||||
helper.navigateToModuleAndRunTest(basePath + 'inherited-page', null, (page) => {
|
||||
let contentLabel = <Label>page.content;
|
||||
TKUnit.assertEqual('Inherited and loaded', contentLabel.text);
|
||||
|
||||
let discoveredPage = contentLabel.page;
|
||||
TKUnit.assertEqual(page, discoveredPage);
|
||||
|
||||
let discoveredAncestorByBaseType = getAncestor(contentLabel, Page);
|
||||
TKUnit.assertEqual(page, discoveredAncestorByBaseType);
|
||||
|
||||
let discoveredAncestorByInheritedTypeName = getAncestor(contentLabel, 'InheritedPage');
|
||||
TKUnit.assertEqual(page, discoveredAncestorByInheritedTypeName);
|
||||
});
|
||||
}
|
||||
|
||||
export function test_loadWithOptionsWithXML() {
|
||||
var v = Builder.load({
|
||||
path: '~/xml-declaration/mymodulewithxml',
|
||||
name: 'MyControl',
|
||||
exports: exports,
|
||||
page: new Page(),
|
||||
});
|
||||
TKUnit.assertTrue(v instanceof View, 'Expected result: View; Actual result: ' + v + ';');
|
||||
}
|
||||
|
||||
export function test_loadWithOptionsWithXML_CSSIsApplied() {
|
||||
var newPage: Page;
|
||||
var pageFactory = function (): Page {
|
||||
newPage = new Page();
|
||||
|
||||
newPage.content = Builder.load({
|
||||
path: '~/xml-declaration/mymodulewithxml',
|
||||
name: 'MyControl',
|
||||
exports: exports,
|
||||
page: newPage,
|
||||
});
|
||||
|
||||
return newPage;
|
||||
};
|
||||
|
||||
helper.navigate(pageFactory);
|
||||
TKUnit.assert(newPage.isLoaded, 'The page should be loaded here.');
|
||||
helper.assertViewBackgroundColor(newPage.content, '#008000');
|
||||
}
|
||||
|
||||
export function test_loadWithOptionsFromTNS() {
|
||||
var v = Builder.load({
|
||||
path: 'ui/label',
|
||||
name: 'Label',
|
||||
});
|
||||
|
||||
TKUnit.assert(v instanceof Label, 'Expected result: Label; Actual result: ' + v + ';');
|
||||
}
|
||||
|
||||
export function test_loadWithOptionsFromTNSPath() {
|
||||
var v = Builder.load({
|
||||
path: 'ui/label',
|
||||
name: 'Label',
|
||||
});
|
||||
|
||||
TKUnit.assert(v instanceof Label, 'Expected result: Label; Actual result: ' + v + ';');
|
||||
}
|
||||
|
||||
export function test_loadWithAttributes() {
|
||||
var lText = 'Nativescript rocks';
|
||||
var lWrap = true;
|
||||
var lColor = '#FF0000'; // red
|
||||
|
||||
var v = Builder.load({
|
||||
path: 'ui/label',
|
||||
name: 'Label',
|
||||
attributes: {
|
||||
text: lText,
|
||||
textWrap: lWrap,
|
||||
style: 'color: ' + lColor + ';',
|
||||
},
|
||||
});
|
||||
|
||||
TKUnit.assertEqual(v['text'], lText, 'Expected result: true; Actual result: ' + v + ';');
|
||||
TKUnit.assertEqual(v['textWrap'], true, 'Expected result: true; Actual result: ' + v + ';');
|
||||
helper.assertViewColor(v, lColor);
|
||||
}
|
||||
|
||||
export function test_parse_ShouldNotCrashWithoutExports() {
|
||||
const xml = (<any>global).loadModule('xml-declaration/mainPage.xml', true);
|
||||
|
||||
var v: View = Builder.parse(xml);
|
||||
TKUnit.assert(v instanceof View, 'Expected result: View; Actual result: ' + v + ';');
|
||||
}
|
||||
|
||||
export function test_parse_ShouldResolveExportsFromCodeFile() {
|
||||
var page = Builder.parse("<Page codeFile='~/xml-declaration/custom-code-file-page' loaded='loaded'></Page>");
|
||||
page._emit('loaded');
|
||||
|
||||
TKUnit.assert((<any>page).customCodeLoaded, 'Parse should resolve exports from custom code file.');
|
||||
}
|
||||
|
||||
export function test_parse_ShouldResolveExportsFromImport() {
|
||||
var page = Builder.parse("<Page import='~/xml-declaration/custom-code-file-page' loaded='loaded'></Page>");
|
||||
page._emit('loaded');
|
||||
|
||||
TKUnit.assert((<any>page).customCodeLoaded, 'Parse should resolve exports from import.');
|
||||
}
|
||||
|
||||
export function test_parse_ShouldResolveExportsFromCodeFileForPageContent() {
|
||||
var page = Builder.parse("<Page codeFile='~/xml-declaration/custom-code-file-page' loaded='loaded'><Button loaded='loaded' /></Page>");
|
||||
(<any>page).content._emit('loaded');
|
||||
|
||||
TKUnit.assert((<any>page).content.customCodeLoaded, 'Parse should resolve exports from custom code file for page content.');
|
||||
}
|
||||
|
||||
export function test_parse_ShouldThrowErrorWhenInvalidCodeFileIsSpecified() {
|
||||
var e: Error;
|
||||
try {
|
||||
Builder.parse("<Page codeFile='~/xml-declaration/some-code-file' loaded='pageLoaded'></Page>");
|
||||
} catch (ex) {
|
||||
e = ex;
|
||||
}
|
||||
|
||||
TKUnit.assert(e, 'Expected result: Error; Actual result: ' + e);
|
||||
}
|
||||
|
||||
export function test_parse_ShouldResolveExportsFromCodeFileForTemplates() {
|
||||
var p = <Page>Builder.parse(`
|
||||
<Page codeFile="~/xml-declaration/custom-code-file-page" xmlns:customControls="xml-declaration/mymodulewithxml">
|
||||
<ListView items="{{ items }}" itemLoading="{{ itemLoading }}">
|
||||
<ListView.itemTemplate>
|
||||
<customControls:MyControl loaded="loaded" />
|
||||
</ListView.itemTemplate>
|
||||
</ListView>
|
||||
</Page>`);
|
||||
function testAction(views: Array<View>) {
|
||||
var ctrl;
|
||||
|
||||
var obj = new Observable();
|
||||
obj.set('items', [1]);
|
||||
obj.set('itemLoading', function (args: ItemEventData) {
|
||||
ctrl = args.view;
|
||||
});
|
||||
p.bindingContext = obj;
|
||||
|
||||
TKUnit.waitUntilReady(() => !!ctrl);
|
||||
TKUnit.assert((<any>ctrl).customCodeLoaded, 'Parse should resolve exports for templates from custom code file.');
|
||||
}
|
||||
|
||||
helper.navigate(function () {
|
||||
return p;
|
||||
});
|
||||
testAction([p.content, p]);
|
||||
}
|
||||
|
||||
export function test_parse_css_is_applied_by_type_to_lower_case_dashed_components() {
|
||||
var newPage: Page;
|
||||
var pageFactory = function (): Page {
|
||||
newPage = <Page>Builder.parse("<page cssFile='~/xml-declaration/custom-css-file-page.css'><stack-layout /></page>");
|
||||
|
||||
return newPage;
|
||||
};
|
||||
|
||||
helper.navigate(pageFactory);
|
||||
TKUnit.assert(newPage.isLoaded, 'The page should be loaded here.');
|
||||
helper.assertViewBackgroundColor(newPage.content, '#008000');
|
||||
}
|
||||
|
||||
export function test_parse_ShouldApplyCssFromCssFile() {
|
||||
var newPage: Page;
|
||||
var pageFactory = function (): Page {
|
||||
newPage = <Page>Builder.parse("<Page cssFile='~/xml-declaration/custom-css-file-page.css'><Label class='MyClass' /></Page>");
|
||||
|
||||
return newPage;
|
||||
};
|
||||
|
||||
helper.navigate(pageFactory);
|
||||
TKUnit.assert(newPage.isLoaded, 'The page should be loaded here.');
|
||||
helper.assertViewBackgroundColor(newPage.content, '#008000');
|
||||
}
|
||||
|
||||
export function test_parse_ShouldResolveExportsFromCodeFileAndApplyCssFile() {
|
||||
var newPage: Page;
|
||||
var pageFactory = function (): Page {
|
||||
newPage = <Page>Builder.parse("<Page codeFile='~/xml-declaration/custom-code-file-page' cssFile='~/xml-declaration/custom-css-file-page.css' loaded='loaded'><Label class='MyClass' /></Page>");
|
||||
|
||||
return newPage;
|
||||
};
|
||||
|
||||
helper.navigate(pageFactory);
|
||||
TKUnit.assert(newPage.isLoaded, 'The page should be loaded here.');
|
||||
TKUnit.assert((<any>newPage).customCodeLoaded, 'Parse should resolve exports from custom code file.');
|
||||
helper.assertViewBackgroundColor(newPage.content, '#008000');
|
||||
}
|
||||
|
||||
export function test_parse_ShouldFindEventHandlersInExports() {
|
||||
var loaded;
|
||||
var page = Builder.parse("<Page loaded='myLoaded'></Page>", {
|
||||
myLoaded: (args) => {
|
||||
loaded = true;
|
||||
},
|
||||
});
|
||||
page._emit('loaded');
|
||||
|
||||
TKUnit.assertTrue(loaded, 'Parse should find event handlers in exports.');
|
||||
}
|
||||
|
||||
export function test_parse_ShouldFindEventHandlersWithOnInExports() {
|
||||
var loaded;
|
||||
var page = Builder.parse("<Page onloaded='myLoaded'></Page>", {
|
||||
myLoaded: (args) => {
|
||||
loaded = true;
|
||||
},
|
||||
});
|
||||
page._emit('loaded');
|
||||
|
||||
TKUnit.assertTrue(loaded, 'Parse should find event handlers in exports.');
|
||||
}
|
||||
|
||||
export function test_parse_ShouldSetGridAttachedProperties() {
|
||||
var p = <Page>Builder.parse("<Page><GridLayout><Label row='1' col='2' rowSpan='3' colSpan='4' /></GridLayout></Page>");
|
||||
var grid = <GridLayout>p.content;
|
||||
var child = grid.getChildAt(0);
|
||||
|
||||
var col = GridLayout.getColumn(child);
|
||||
TKUnit.assertEqual(col, 2, 'Expected result for grid column: 2; Actual result: ' + col + ';');
|
||||
|
||||
var row = GridLayout.getRow(child);
|
||||
TKUnit.assertEqual(row, 1, 'Expected result for grid row: 1; Actual result: ' + row + ';');
|
||||
|
||||
var colSpan = GridLayout.getColumnSpan(child);
|
||||
TKUnit.assertEqual(colSpan, 4, 'Expected result for grid column span: 4; Actual result: ' + colSpan + ';');
|
||||
|
||||
var rowSpan = GridLayout.getRowSpan(child);
|
||||
TKUnit.assertEqual(rowSpan, 3, 'Expected result for grid row span: 3; Actual result: ' + rowSpan + ';');
|
||||
}
|
||||
|
||||
export function test_parse_ShouldSetCanvasAttachedProperties() {
|
||||
var p = <Page>Builder.parse("<Page><AbsoluteLayout><Label left='1' top='2' right='3' bottom='4' /></AbsoluteLayout></Page>");
|
||||
var absLayout = <AbsoluteLayout>p.content;
|
||||
var child = absLayout.getChildAt(0);
|
||||
|
||||
var left = AbsoluteLayout.getLeft(child);
|
||||
|
||||
TKUnit.assert(Length.equals(left, Length.parse('1')), `Expected result for canvas left: 1; Actual result: ${(<any>left).value};`);
|
||||
|
||||
var top = AbsoluteLayout.getTop(child);
|
||||
TKUnit.assert(Length.equals(top, Length.parse('2')), `Expected result for canvas top: 2; Actual result: ${(<any>top).value};`);
|
||||
}
|
||||
|
||||
export function test_parse_ShouldParseNumberProperties() {
|
||||
var p = <Page>Builder.parse("<Page width='100' />");
|
||||
TKUnit.assertTrue(PercentLength.equals(p.width, 100));
|
||||
}
|
||||
|
||||
export function test_parse_ShouldParseBooleanProperties() {
|
||||
var p = <Page>Builder.parse("<Page><Switch checked='true' /></Page>");
|
||||
var sw = <Switch>p.content;
|
||||
|
||||
TKUnit.assertTrue(sw.checked, 'Expected result: true; Actual result: ' + sw.checked + '; type: ' + typeof sw.checked);
|
||||
}
|
||||
|
||||
export function test_parse_ShouldParseBooleanPropertiesIgnoreCase() {
|
||||
var p = <Page>Builder.parse("<Page><Switch checked='False' /></Page>");
|
||||
var sw = <Switch>p.content;
|
||||
|
||||
TKUnit.assert(sw.checked === false, 'Expected result: false; Actual result: ' + sw.checked + '; type: ' + typeof sw.checked);
|
||||
}
|
||||
|
||||
export function test_parse_ShouldParseBooleanPropertiesIgnoreCaseInverted() {
|
||||
var p = <Page>Builder.parse("<Page><TextField editable='False' /></Page>");
|
||||
var tf = <TextField>p.content;
|
||||
|
||||
TKUnit.assertFalse(tf.editable, 'Expected result: false; Actual result: ' + tf.editable + '; type: ' + typeof tf.editable);
|
||||
}
|
||||
|
||||
export function test_parse_ShouldParsePlatformSpecificProperties() {
|
||||
var p = <Page>Builder.parse("<Page><TextField ios:editable='False' android:editable='True' /></Page>");
|
||||
var tf = <TextField>p.content;
|
||||
|
||||
if (Device.os === platformNames.ios) {
|
||||
TKUnit.assertFalse(tf.editable, 'Expected result: false; Actual result: ' + tf.editable + '; type: ' + typeof tf.editable);
|
||||
} else {
|
||||
TKUnit.assertTrue(tf.editable, 'Expected result: true; Actual result: ' + tf.editable + '; type: ' + typeof tf.editable);
|
||||
}
|
||||
}
|
||||
|
||||
export function test_parse_ShouldParsePlatformSpecificComponents() {
|
||||
var p = <Page>Builder.parse('<Page><ios><TextField /></ios><android><Label /></android></Page>');
|
||||
if (Device.os === platformNames.ios) {
|
||||
TKUnit.assert(p.content instanceof TextField, 'Expected result: TextField; Actual result: ' + p.content);
|
||||
} else {
|
||||
TKUnit.assert(p.content instanceof Label, 'Expected result: Label; Actual result: ' + p.content);
|
||||
}
|
||||
}
|
||||
|
||||
export function test_parse_ThrowErrorWhenNestingPlatforms() {
|
||||
var e: Error;
|
||||
try {
|
||||
Builder.parse('<Page><ios><TextField /><android><Label /></android></ios></Page>');
|
||||
} catch (ex) {
|
||||
e = ex;
|
||||
}
|
||||
|
||||
TKUnit.assert(e, 'Expected result: Error; Actual result: ' + e);
|
||||
}
|
||||
|
||||
export function test_parse_ShouldParseBindings() {
|
||||
var p = <Page>Builder.parse("<Page><Switch checked='{{ myProp }}' /></Page>");
|
||||
p.bindingContext = { myProp: true };
|
||||
var sw = <Switch>p.content;
|
||||
|
||||
TKUnit.assertTrue(sw.checked, 'Expected result: true; Actual result: ' + sw.checked + '; type: ' + typeof sw.checked);
|
||||
}
|
||||
|
||||
export function test_parse_ShouldParseBindingsWithObservable() {
|
||||
var p = <Page>Builder.parse("<Page><Switch checked='{{ myProp }}' /></Page>");
|
||||
var obj = new Observable();
|
||||
obj.set('myProp', true);
|
||||
p.bindingContext = obj;
|
||||
var sw = <Switch>p.content;
|
||||
|
||||
TKUnit.assertTrue(sw.checked, 'Expected result: true; Actual result: ' + sw.checked + '; type: ' + typeof sw.checked);
|
||||
|
||||
obj.set('myProp', false);
|
||||
|
||||
TKUnit.assertFalse(sw.checked, 'Expected result: false; Actual result: ' + sw.checked + '; type: ' + typeof sw.checked);
|
||||
}
|
||||
|
||||
export function test_parse_ShouldParseBindingsToEvents() {
|
||||
var p = <Page>Builder.parse("<Page><Button tap='{{ myTap }}' /></Page>");
|
||||
p.bindingContext = {
|
||||
myTap: function (args) {
|
||||
//
|
||||
},
|
||||
};
|
||||
var btn = <Button>p.content;
|
||||
|
||||
TKUnit.assert(btn.hasListeners('tap'), 'Expected result: true.');
|
||||
}
|
||||
|
||||
export function test_parse_ShouldParseBindingsToEventsWithOn() {
|
||||
var p = <Page>Builder.parse("<Page><Button ontap='{{ myTap }}' /></Page>");
|
||||
p.bindingContext = {
|
||||
myTap: function (args) {
|
||||
//
|
||||
},
|
||||
};
|
||||
var btn = <Button>p.content;
|
||||
|
||||
TKUnit.assert(btn.hasListeners('tap'), 'Expected result: true.');
|
||||
}
|
||||
|
||||
export function test_parse_ShouldParseBindingsToGestures() {
|
||||
var p = <Page>Builder.parse("<Page><Label tap='{{ myTap }}' /></Page>");
|
||||
var context = {
|
||||
myTap: function (args) {
|
||||
//
|
||||
},
|
||||
};
|
||||
|
||||
p.bindingContext = context;
|
||||
var lbl = <Label>p.content;
|
||||
|
||||
var observer = (<View>lbl).getGestureObservers(GestureTypes.tap)[0];
|
||||
|
||||
TKUnit.assert(observer !== undefined, 'Expected result: true.');
|
||||
TKUnit.assert(observer.context === context, 'Context should be equal to binding context. Actual result: ' + observer.context);
|
||||
}
|
||||
|
||||
export function test_parse_ShouldParseBindingsToGesturesWithOn() {
|
||||
var p = <Page>Builder.parse("<Page><Label ontap='{{ myTap }}' /></Page>");
|
||||
var context = {
|
||||
myTap: function (args) {
|
||||
//
|
||||
},
|
||||
};
|
||||
|
||||
p.bindingContext = context;
|
||||
var lbl = <Label>p.content;
|
||||
|
||||
var observer = (<View>lbl).getGestureObservers(GestureTypes.tap)[0];
|
||||
|
||||
TKUnit.assert(observer !== undefined, 'Expected result: true.');
|
||||
TKUnit.assert(observer.context === context, 'Context should be equal to binding context. Actual result: ' + observer.context);
|
||||
}
|
||||
|
||||
export function test_parse_ShouldParseSubProperties() {
|
||||
var p = <Page>Builder.parse("<Page><Switch style.visibility='collapse' checked='{{ myProp }}' /></Page>");
|
||||
var obj = new Observable();
|
||||
obj.set('myProp', true);
|
||||
p.bindingContext = obj;
|
||||
var sw = <Switch>p.content;
|
||||
|
||||
TKUnit.assert(sw.visibility === 'collapse', 'Expected result: collapse; Actual result: ' + sw.visibility + '; type: ' + typeof sw.visibility);
|
||||
}
|
||||
|
||||
export function test_parse_ShouldParseBindingToSpecialProperty() {
|
||||
var classProp = 'MyClass';
|
||||
var p = <Page>Builder.parse("<Page><Label class='{{ myProp }}' /></Page>");
|
||||
var obj = new Observable();
|
||||
obj.set('myProp', classProp);
|
||||
p.bindingContext = obj;
|
||||
|
||||
TKUnit.assertEqual(p.content.className, classProp);
|
||||
TKUnit.assert(p.content.cssClasses.has(classProp));
|
||||
}
|
||||
|
||||
export function test_parse_ShouldParseBindingsWithCommaInsideSingleQuote() {
|
||||
var expected = 'Hi,test';
|
||||
var bindingString = "{{ 'Hi,' + myProp }}";
|
||||
var p = <Page>Builder.parse('<Page><Label text="' + bindingString + '" /></Page>');
|
||||
var obj = new Observable();
|
||||
obj.set('myProp', 'test');
|
||||
p.bindingContext = obj;
|
||||
var lbl = <Label>p.content;
|
||||
|
||||
TKUnit.assert(lbl.text === expected, 'Expected ' + expected + '; Actual result: ' + lbl.text + '; type: ' + typeof lbl.text);
|
||||
}
|
||||
|
||||
export function test_parse_ShouldParseBindingsWithCommaInsideDoubleQuote() {
|
||||
var expected = 'Hi,test';
|
||||
var bindingString = '{{ "Hi," + myProp }}';
|
||||
var p = <Page>Builder.parse("<Page><Label text='" + bindingString + "' /></Page>");
|
||||
var obj = new Observable();
|
||||
obj.set('myProp', 'test');
|
||||
p.bindingContext = obj;
|
||||
var lbl = <Label>p.content;
|
||||
|
||||
TKUnit.assert(lbl.text === expected, 'Expected ' + expected + '; Actual result: ' + lbl.text + '; type: ' + typeof lbl.text);
|
||||
}
|
||||
|
||||
export function test_parse_CanBindBackgroundImage() {
|
||||
var p = <Page>Builder.parse("<Page><StackLayout backgroundImage='{{ myProp }}' /></Page>");
|
||||
var expected = '~/assets/logo.png';
|
||||
var obj = new Observable();
|
||||
obj.set('myProp', expected);
|
||||
p.bindingContext = obj;
|
||||
var sw = <StackLayout>p.content;
|
||||
|
||||
TKUnit.assert(sw.backgroundImage === expected, 'Expected result: ' + expected + '; Actual result: ' + sw.backgroundImage);
|
||||
}
|
||||
|
||||
export function test_parse_ShouldParseLowerCaseDashedComponentDeclaration() {
|
||||
var p = <Page>Builder.parse('<page><stack-layout><label text="Label" /><segmented-bar><segmented-bar.items><segmented-bar-item title="test" /></segmented-bar.items></segmented-bar></stack-layout></page>');
|
||||
var ctrl = <StackLayout>p.content;
|
||||
|
||||
TKUnit.assert(ctrl instanceof StackLayout, 'Expected result: StackLayout!; Actual result: ' + ctrl);
|
||||
TKUnit.assert(ctrl.getChildAt(0) instanceof Label, 'Expected result: Label!; Actual result: ' + ctrl.getChildAt(0));
|
||||
TKUnit.assert(ctrl.getChildAt(1) instanceof SegmentedBar, 'Expected result: Label!; Actual result: ' + ctrl.getChildAt(0));
|
||||
}
|
||||
|
||||
export function test_parse_ShouldParseCustomComponentWithoutXml() {
|
||||
var p = <Page>Builder.parse('<Page xmlns:customControls="xml-declaration/mymodule"><customControls:MyControl /></Page>');
|
||||
var ctrl = p.content;
|
||||
TKUnit.assertNotNull(ctrl);
|
||||
TKUnit.assertEqual(ctrl.className, 'MyStackLayout', 'Expected result custom control is created');
|
||||
}
|
||||
|
||||
export function test_parse_ShouldParseCustomComponentWithoutXmlFromTNSModules() {
|
||||
var p = <Page>Builder.parse('<Page xmlns' + ':customControls="ui/label"><customControls:Label /></Page>');
|
||||
var ctrl = p.content;
|
||||
|
||||
TKUnit.assert(ctrl instanceof Label, 'Expected result: custom control is defined!; Actual result: ' + ctrl);
|
||||
}
|
||||
|
||||
export function test_parse_ShouldParseCustomComponentWithoutXmlFromTNSModulesWhenNotSpecified() {
|
||||
var p = <Page>Builder.parse('<Page xmlns' + ':customControls="ui/label"><customControls:Label /></Page>');
|
||||
var ctrl = p.content;
|
||||
|
||||
TKUnit.assert(ctrl instanceof Label, 'Expected result: custom control is defined!; Actual result: ' + ctrl);
|
||||
}
|
||||
|
||||
export function test_parse_ShouldParseCustomComponentWithXml() {
|
||||
var p = <Page>Builder.parse('<Page xmlns:customControls="xml-declaration/mymodulewithxml"><customControls:MyControl /></Page>');
|
||||
var panel = <StackLayout>p.content;
|
||||
var lbl = <Label>panel.getChildAt(0);
|
||||
|
||||
TKUnit.assert(lbl.text === 'mymodulewithxml', "Expected result: 'mymodulewithxml'; Actual result: " + lbl);
|
||||
}
|
||||
|
||||
export function test_parse_ShouldParseCustomComponentWithXml_WithAttributes() {
|
||||
var p = <Page>Builder.parse('<Page xmlns:customControls="xml-declaration/mymodulewithxml"><customControls:MyControl visibility="collapse" /></Page>');
|
||||
var panel = <StackLayout>p.content;
|
||||
|
||||
TKUnit.assertEqual(panel.visibility, 'collapse', 'panel.visibility');
|
||||
}
|
||||
|
||||
export function test_parse_ShouldParseCustomComponentWithXml_WithCustomAttributes() {
|
||||
var p = <Page>Builder.parse('<Page xmlns:customControls="xml-declaration/mymodulewithxml"><customControls:MyControl myProperty="myValue" /></Page>');
|
||||
var panel = <StackLayout>p.content;
|
||||
|
||||
TKUnit.assertEqual(panel['myProperty'], 'myValue', 'customControl.myProperty');
|
||||
}
|
||||
|
||||
export function test_parse_ShouldParseCustomComponentWithXmlNoJS() {
|
||||
var p = <Page>Builder.parse('<Page xmlns:customControls="xml-declaration/mymodulewithxml"><customControls:my-no-js-control /></Page>');
|
||||
var panel = <StackLayout>p.content;
|
||||
var lbl = <Label>panel.getChildAt(0);
|
||||
|
||||
TKUnit.assertEqual(lbl.text, "I'm all about taht XML, no JS", 'label.text');
|
||||
}
|
||||
|
||||
export function test_parse_ShouldParseCustomComponentWithXmlNoJS_WithAttributes() {
|
||||
var p = <Page>Builder.parse('<Page xmlns:customControls="xml-declaration/mymodulewithxml"><customControls:my-no-js-control visibility="collapse" /></Page>');
|
||||
var panel = <StackLayout>p.content;
|
||||
|
||||
TKUnit.assertEqual(panel.visibility, 'collapse', 'panel.visibility');
|
||||
}
|
||||
|
||||
export function test_parse_ShouldParseCustomComponentWithXmlNoJS_WithCustomAttributes() {
|
||||
var p = <Page>Builder.parse('<Page xmlns:customControls="xml-declaration/mymodulewithxml"><customControls:my-no-js-control myProperty="myValue" /></Page>');
|
||||
var panel = <StackLayout>p.content;
|
||||
|
||||
TKUnit.assertEqual(panel['myProperty'], 'myValue', 'customControl.myProperty');
|
||||
}
|
||||
|
||||
export function test_parse_ShouldParseCustomComponentWithoutXmlInListViewTemplate() {
|
||||
var p = <Page>Builder.parse('<Page xmlns:customControls="xml-declaration/mymodule"><ListView items="{{ items }}" itemLoading="{{ itemLoading }}"><ListView.itemTemplate><customControls:MyControl /></ListView.itemTemplate></ListView></Page>');
|
||||
|
||||
function testAction(views: Array<View>) {
|
||||
let ctrl;
|
||||
let obj = new Observable();
|
||||
obj.set('items', [1]);
|
||||
obj.set('itemLoading', function (args: ItemEventData) {
|
||||
ctrl = args.view;
|
||||
});
|
||||
p.bindingContext = obj;
|
||||
TKUnit.waitUntilReady(() => !!ctrl);
|
||||
TKUnit.assertNotNull(ctrl);
|
||||
TKUnit.assertEqual(ctrl.className, 'MyStackLayout', 'Expected result custom control is created');
|
||||
}
|
||||
|
||||
helper.navigate(function () {
|
||||
return p;
|
||||
});
|
||||
testAction([p.content, p]);
|
||||
}
|
||||
|
||||
export function test_parse_ShouldParseNestedListViewInListViewTemplate() {
|
||||
var p = <Page>Builder.parse('<Page xmlns="http://schemas.nativescript.org/tns.xsd"><ListView items="{{ items }}" itemLoading="{{ itemLoading }}"><ListView.itemTemplate><ListView items="{{ subItems }}" /></ListView.itemTemplate></ListView></Page>');
|
||||
|
||||
function testAction(views: Array<View>) {
|
||||
let ctrl;
|
||||
let obj = new Observable();
|
||||
obj.set('items', [{ subItems: [1] }]);
|
||||
obj.set('itemLoading', function (args: ItemEventData) {
|
||||
ctrl = args.view;
|
||||
});
|
||||
p.bindingContext = obj;
|
||||
TKUnit.waitUntilReady(() => !!ctrl);
|
||||
TKUnit.assert(ctrl instanceof ListView, 'Expected result: ListView!; Actual result: ' + ctrl);
|
||||
}
|
||||
|
||||
helper.navigate(function () {
|
||||
return p;
|
||||
});
|
||||
testAction([p.content, p]);
|
||||
}
|
||||
|
||||
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\'].segmentedBarItems }}" selectedIndexChanged="{{ $parents[\'ListView\'].changed }}" /></ListView.itemTemplate></ListView></Page>');
|
||||
|
||||
function testAction(views: Array<View>) {
|
||||
let ctrl: SegmentedBar = null;
|
||||
let changed;
|
||||
let obj = new Observable();
|
||||
|
||||
let firstItem = new SegmentedBarItem();
|
||||
firstItem.title = 'One';
|
||||
let secondItem = new SegmentedBarItem();
|
||||
secondItem.title = 'Two';
|
||||
let thirdItem = new SegmentedBarItem();
|
||||
thirdItem.title = 'Tree';
|
||||
let segmentedBarItems = [firstItem, secondItem, thirdItem];
|
||||
|
||||
obj.set('items', [1, 2, 3]);
|
||||
obj.set('segmentedBarItems', segmentedBarItems);
|
||||
obj.set('itemLoading', function (args: ItemEventData) {
|
||||
ctrl = <SegmentedBar>args.view;
|
||||
});
|
||||
|
||||
obj.set('changed', function (args: EventData) {
|
||||
changed = true;
|
||||
});
|
||||
|
||||
p.bindingContext = obj;
|
||||
TKUnit.waitUntilReady(() => !!ctrl);
|
||||
ctrl.selectedIndex = 1;
|
||||
|
||||
TKUnit.assert(changed, 'Expected result: true!; Actual result: ' + changed);
|
||||
}
|
||||
|
||||
helper.navigate(function () {
|
||||
return p;
|
||||
});
|
||||
testAction([p.content, p]);
|
||||
}
|
||||
|
||||
export function test_parse_NestedRepeaters() {
|
||||
var pageXML =
|
||||
"<Page xmlns='http://schemas.nativescript.org/tns.xsd'>" +
|
||||
' <TabView>' +
|
||||
' <TabView.items>' +
|
||||
" <TabViewItem title='List'>" +
|
||||
' <TabViewItem.view>' +
|
||||
" <Repeater items='{{ $value }}'>" +
|
||||
' <Repeater.itemTemplate>' +
|
||||
' <StackLayout>' +
|
||||
" <Repeater items='{{ $value }}'>" +
|
||||
' <Repeater.itemTemplate>' +
|
||||
" <Label text='{{ $value }}'/>" +
|
||||
' </Repeater.itemTemplate>' +
|
||||
' </Repeater>' +
|
||||
' </StackLayout>' +
|
||||
' </Repeater.itemTemplate>' +
|
||||
' </Repeater>' +
|
||||
' </TabViewItem.view>' +
|
||||
' </TabViewItem>' +
|
||||
' </TabView.items>' +
|
||||
' </TabView>' +
|
||||
'</Page>';
|
||||
var p = <Page>Builder.parse(pageXML);
|
||||
|
||||
function testAction(views: Array<View>) {
|
||||
p.bindingContext = [
|
||||
['0', '1'],
|
||||
['2', '3'],
|
||||
];
|
||||
let lbls = new Array<Label>();
|
||||
eachDescendant(p, (v) => {
|
||||
if (v instanceof Label) {
|
||||
lbls.push(v);
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
TKUnit.assertEqual(lbls.length, 4, 'labels count');
|
||||
lbls.forEach((lbl, index, arr) => {
|
||||
TKUnit.assertEqual(lbl.text.toString(), index.toString(), 'label text');
|
||||
});
|
||||
}
|
||||
|
||||
helper.navigate(function () {
|
||||
return p;
|
||||
});
|
||||
testAction([p.content, p]);
|
||||
}
|
||||
|
||||
export function test_parseSpansDirectlyOnLabel() {
|
||||
var p = <Page>Builder.parse('<Page xmlns="http://schemas.nativescript.org/tns.xsd" navigatedTo="pageNavigated"><StackLayout><Label id="testLabel"><Span text="We are" fontSize="10"/><Span text="Awesome" fontWeight="bold"/></Label></StackLayout></Page>');
|
||||
function testAction(views: Array<View>) {
|
||||
var page = <Page>views[0];
|
||||
var testLabel = <Label>page.getViewById('testLabel');
|
||||
TKUnit.assertEqual(testLabel.formattedText + '', 'We areAwesome', 'formattedText');
|
||||
TKUnit.assertEqual(testLabel.text + '', 'We areAwesome', 'text');
|
||||
}
|
||||
|
||||
helper.navigate(function () {
|
||||
return p;
|
||||
});
|
||||
testAction([p]);
|
||||
}
|
||||
|
||||
export function test_parseSpansDirectlyOnButton() {
|
||||
var p = <Page>Builder.parse('<Page xmlns="http://schemas.nativescript.org/tns.xsd" navigatedTo="pageNavigated"><StackLayout><Button id="testButton"><Span text="We are" fontSize="10"/><Span text="Awesome" fontWeight="bold"/></Button></StackLayout></Page>');
|
||||
function testAction(views: Array<View>) {
|
||||
var page = <Page>views[0];
|
||||
var testButton = <Button>page.getViewById('testButton');
|
||||
TKUnit.assertEqual(testButton.formattedText + '', 'We areAwesome', 'formattedText');
|
||||
TKUnit.assertEqual(testButton.text + '', 'We areAwesome', 'text');
|
||||
}
|
||||
|
||||
helper.navigate(function () {
|
||||
return p;
|
||||
});
|
||||
testAction([p]);
|
||||
}
|
||||
|
||||
export function test_parseFormattedStringWithoutFormattedText() {
|
||||
var p = <Page>Builder.parse('<Page xmlns="http://schemas.nativescript.org/tns.xsd" navigatedTo="pageNavigated"><StackLayout><Button id="testButton"><FormattedString><FormattedString.spans><Span text="author"/><Span text=" num_comments"/></FormattedString.spans></FormattedString></Button></StackLayout></Page>');
|
||||
function testAction(views: Array<View>) {
|
||||
var page = <Page>views[0];
|
||||
var testButton = <Button>page.getViewById('testButton');
|
||||
TKUnit.assertEqual(testButton.formattedText + '', 'author num_comments', 'formattedText');
|
||||
TKUnit.assertEqual(testButton.text + '', 'author num_comments', 'text');
|
||||
}
|
||||
|
||||
helper.navigate(function () {
|
||||
return p;
|
||||
});
|
||||
testAction([p]);
|
||||
}
|
||||
|
||||
export function test_parseFormattedStringFullSyntax() {
|
||||
var p = <Page>Builder.parse('<Page xmlns="http://schemas.nativescript.org/tns.xsd" navigatedTo="pageNavigated"><StackLayout><Button id="testButton"><Button.formattedText><FormattedString><FormattedString.spans><Span text="author"/><Span text=" num_comments"/></FormattedString.spans></FormattedString></Button.formattedText></Button></StackLayout></Page>');
|
||||
function testAction(views: Array<View>) {
|
||||
var page = <Page>views[0];
|
||||
var testButton = <Button>page.getViewById('testButton');
|
||||
TKUnit.assertEqual(testButton.formattedText + '', 'author num_comments', 'formattedText');
|
||||
TKUnit.assertEqual(testButton.text + '', 'author num_comments', 'text');
|
||||
}
|
||||
|
||||
helper.navigate(function () {
|
||||
return p;
|
||||
});
|
||||
testAction([p]);
|
||||
}
|
||||
|
||||
export function test_parseSpansDirectlyToFormattedString() {
|
||||
var p = <Page>Builder.parse('<Page xmlns="http://schemas.nativescript.org/tns.xsd" navigatedTo="pageNavigated"><StackLayout><Button id="testButton"><FormattedString><Span text="author"/><Span text=" num_comments"/></FormattedString></Button></StackLayout></Page>');
|
||||
function testAction(views: Array<View>) {
|
||||
var page = <Page>views[0];
|
||||
var testButton = <Button>page.getViewById('testButton');
|
||||
TKUnit.assertEqual(testButton.formattedText + '', 'author num_comments', 'formattedText');
|
||||
TKUnit.assertEqual(testButton.text + '', 'author num_comments', 'text');
|
||||
}
|
||||
|
||||
helper.navigate(function () {
|
||||
return p;
|
||||
});
|
||||
testAction([p]);
|
||||
}
|
||||
|
||||
export function test_searchbar_donotcrash_whentext_isempty() {
|
||||
var p = <Page>Builder.parse('<Page><SearchBar text="" hint="Search" /></Page>');
|
||||
var sb = <SearchBar>p.content;
|
||||
|
||||
TKUnit.assertEqual(sb.text, '');
|
||||
}
|
||||
|
||||
export function test_searchbar_donotcrash_whentext_isspace() {
|
||||
var p = <Page>Builder.parse('<Page><SearchBar text=" " hint="Search" /></Page>');
|
||||
var sb = <SearchBar>p.content;
|
||||
|
||||
TKUnit.assertEqual(sb.text, ' ');
|
||||
}
|
||||
|
||||
export function test_parse_template_property() {
|
||||
var page = <Page>Builder.load('xml-declaration/template-builder-tests/simple-template-page.xml');
|
||||
TKUnit.assert(page, 'Expected root page.');
|
||||
var templateView = <TemplateView>page.getViewById('template-view');
|
||||
TKUnit.assert(templateView, 'Expected TemplateView.');
|
||||
TKUnit.assert(templateView.template, 'Expected the template of the TemplateView to be defined');
|
||||
|
||||
TKUnit.assertEqual(templateView.getChildrenCount(), 0, 'Expected TemplateView initially to have no children.');
|
||||
templateView.parseTemplate();
|
||||
TKUnit.assertEqual(templateView.getChildrenCount(), 1, 'Expected TemplateView initially to have 1 child.');
|
||||
var button = <Button>templateView.getChildAt(0);
|
||||
TKUnit.assert(button, "Expected the TemplateView's template to create a button child.");
|
||||
TKUnit.assertEqual(button.text, 'Click!', "Expected child Button to have text 'Click!'");
|
||||
}
|
||||
|
||||
export function test_NonExistingElementError() {
|
||||
var basePath = 'xml-declaration/';
|
||||
var expectedErrorStart = 'Building UI from XML. @' + basePath + 'errors/non-existing-element.xml:11:5\n' + " > Module 'ui/unicorn' not found for element 'Unicorn'.";
|
||||
var message;
|
||||
try {
|
||||
Builder.load('xml-declaration/errors/non-existing-element.xml');
|
||||
} catch (e) {
|
||||
message = e.message;
|
||||
}
|
||||
TKUnit.assertEqual(message.substr(0, expectedErrorStart.length), expectedErrorStart, 'Expected load to throw, and the message to start with specific string');
|
||||
}
|
||||
|
||||
export function test_NonExistingElementInTemplateError() {
|
||||
var basePath = 'xml-declaration/';
|
||||
var expectedErrorStart = 'Building UI from XML. @' + basePath + 'errors/non-existing-element-in-template.xml:14:17\n' + " > Module 'ui/unicorn' not found for element 'Unicorn'.";
|
||||
var message;
|
||||
var page = Builder.load('xml-declaration/errors/non-existing-element-in-template.xml');
|
||||
TKUnit.assert(page, 'Expected the xml to generate a page');
|
||||
var templateView = <TemplateView>page.getViewById('template-view');
|
||||
TKUnit.assert(templateView, "Expected the page to have a TemplateView with 'temaplte-view' id.");
|
||||
|
||||
try {
|
||||
templateView.parseTemplate();
|
||||
} catch (e) {
|
||||
message = e.message;
|
||||
}
|
||||
TKUnit.assertEqual(message.substr(0, expectedErrorStart.length), expectedErrorStart, 'Expected load to throw, and the message to start with specific string');
|
||||
}
|
||||
|
||||
export function test_EventInTemplate() {
|
||||
var pageCode = (<any>global).loadModule('xml-declaration/template-builder-tests/event-in-template', true);
|
||||
var notified = false;
|
||||
pageCode.test = (args) => {
|
||||
notified = true;
|
||||
};
|
||||
|
||||
var page = Builder.load('xml-declaration/template-builder-tests/event-in-template.xml', pageCode);
|
||||
TKUnit.assert(page, 'Expected the xml to generate a page');
|
||||
var templateView = <TemplateView>page.getViewById('template-view');
|
||||
TKUnit.assert(templateView, "Expected the page to have a TemplateView with 'temaplte-view' id.");
|
||||
templateView.parseTemplate();
|
||||
TKUnit.assertEqual(templateView.getChildrenCount(), 1, 'Expected TemplateView initially to have 1 child.');
|
||||
var childTemplateView = <TemplateView>templateView.getChildAt(0);
|
||||
TKUnit.assert(childTemplateView, "Expected the TemplateView's template to create a child TemplateView.");
|
||||
childTemplateView.notify({
|
||||
eventName: 'test',
|
||||
object: childTemplateView,
|
||||
});
|
||||
|
||||
TKUnit.assert(notified, 'Expected the child to raise the test event.');
|
||||
}
|
||||
|
||||
export function test_EventInCodelessFragment() {
|
||||
var pageCode = (<any>global).loadModule('./xml-declaration/template-builder-tests/event-in-codeless-fragment', true);
|
||||
|
||||
var notified = false;
|
||||
pageCode.setCallback((args) => {
|
||||
notified = true;
|
||||
});
|
||||
|
||||
var page = Builder.load('./xml-declaration/template-builder-tests/event-in-codeless-fragment.xml', pageCode);
|
||||
TKUnit.assert(page, 'Expected the xml to generate a page');
|
||||
var templateView = <TemplateView>page.getViewById('template-view');
|
||||
TKUnit.assert(templateView, "Expected the page to have a TemplateView with 'temaplte-view' id.");
|
||||
templateView.parseTemplate();
|
||||
TKUnit.assertEqual(templateView.getChildrenCount(), 1, 'Expected TemplateView initially to have 1 child.');
|
||||
var childTemplateView = <TemplateView>templateView.getChildAt(0);
|
||||
TKUnit.assert(childTemplateView, "Expected the TemplateView's template to create a child TemplateView.");
|
||||
childTemplateView.notify({
|
||||
eventName: 'test',
|
||||
object: childTemplateView,
|
||||
});
|
||||
|
||||
TKUnit.assert(notified, 'Expected the child to raise the test event.');
|
||||
}
|
||||
|
||||
export function test_tabview_selectedindex_will_work_from_xml() {
|
||||
var p = <Page>Builder.parse('<Page>' + '<TabView selectedIndex= "1">' + '<TabView.items>' + '<TabViewItem title="First">' + '<TabViewItem.view>' + '<Label text="First View" />' + '</TabViewItem.view>' + '</TabViewItem>' + '<TabViewItem title= "Second">' + '<TabViewItem.view>' + '<Label text="Second View" />' + '</TabViewItem.view>' + '</TabViewItem>' + '</TabView.items>' + '</TabView>' + '</Page>');
|
||||
|
||||
function testAction(views: Array<View>) {
|
||||
let tab: TabView = <TabView>p.content;
|
||||
TKUnit.assertEqual(tab.selectedIndex, 1);
|
||||
}
|
||||
|
||||
helper.navigate(function () {
|
||||
return p;
|
||||
});
|
||||
testAction([p.content, p]);
|
||||
}
|
||||
|
||||
export function test_TabViewHasCorrectParentChain() {
|
||||
var testFunc = function (page: Page) {
|
||||
TKUnit.assert(page.bindingContext.get('testPassed'));
|
||||
};
|
||||
|
||||
var model = new Observable();
|
||||
model.set('testPassed', false);
|
||||
helper.navigateToModuleAndRunTest('xml-declaration/mymodulewithxml/TabViewParentChainPage', model, testFunc);
|
||||
}
|
||||
|
||||
export function test_hasSourceCodeLocations() {
|
||||
var basePath = 'xml-declaration/';
|
||||
var page = <Page>Builder.load(basePath + 'examples/test-page.xml');
|
||||
var grid = page.getViewById('grid');
|
||||
var gridSource = Utils.Source.get(grid);
|
||||
TKUnit.assertEqual(gridSource.toString(), basePath + 'examples/test-page.xml:2:3');
|
||||
var label = page.getViewById('label');
|
||||
var labelSource = Utils.Source.get(label);
|
||||
TKUnit.assertEqual(labelSource.toString(), basePath + 'examples/test-page.xml:3:5');
|
||||
}
|
||||
|
||||
export function test_Setting_digits_for_text_Label_is_not_converted_to_number() {
|
||||
var p = <Page>Builder.parse('<Page><Label id="testLabel" text="01234"/></Page>');
|
||||
var testLabel = <Label>p.getViewById('testLabel');
|
||||
TKUnit.assertEqual(testLabel.text, '01234');
|
||||
}
|
||||
|
||||
export function test_Setting_digits_for_text_Button_is_not_converted_to_number() {
|
||||
var p = <Page>Builder.parse('<Page><Button id="testButton" text="01234"/></Page>');
|
||||
var testButton = <Button>p.getViewById('testButton');
|
||||
TKUnit.assertEqual(testButton.text, '01234');
|
||||
}
|
||||
Reference in New Issue
Block a user