mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-18 22:01:42 +08:00
Merge pull request #3371 from NativeScript/cankov/modules30-button-tests
Button tests now run except for those on TextBase
This commit is contained in:
@ -54,7 +54,7 @@ allTests["WEAK-EVENTS"] = require("./weak-event-listener-tests");
|
|||||||
allTests["CONNECTIVITY"] = require("./connectivity-tests");
|
allTests["CONNECTIVITY"] = require("./connectivity-tests");
|
||||||
|
|
||||||
// allTests["PROXY-VIEW-CONTAINER"] = require("./ui/proxy-view-container/proxy-view-container-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["SCROLL-VIEW"] = require("./ui/scroll-view/scroll-view-tests");
|
||||||
// allTests["ACTION-BAR"] = require("./ui/action-bar/action-bar-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["DOCKLAYOUT"] = require("./ui/layouts/dock-layout-tests");
|
||||||
@ -71,7 +71,7 @@ allTests["SCROLL-VIEW"] = require("./ui/scroll-view/scroll-view-tests");
|
|||||||
// allTests["VALUE-SOURCE"] = require("./ui/styling/value-source-tests");
|
// allTests["VALUE-SOURCE"] = require("./ui/styling/value-source-tests");
|
||||||
// allTests["CSS-SELECTOR-PARSER"] = require("./ui/styling/css-selector-parser");
|
// allTests["CSS-SELECTOR-PARSER"] = require("./ui/styling/css-selector-parser");
|
||||||
// allTests["CSS-SELECTOR"] = require("./ui/styling/css-selector");
|
// allTests["CSS-SELECTOR"] = require("./ui/styling/css-selector");
|
||||||
// allTests["BUTTON"] = require("./ui/button/button-tests");
|
allTests["BUTTON"] = require("./ui/button/button-tests");
|
||||||
// allTests["BORDER"] = require("./ui/border/border-tests");
|
// allTests["BORDER"] = require("./ui/border/border-tests");
|
||||||
// allTests["LABEL"] = require("./ui/label/label-tests");
|
// allTests["LABEL"] = require("./ui/label/label-tests");
|
||||||
// allTests["TAB-VIEW"] = require("./ui/tab-view/tab-view-tests");
|
// allTests["TAB-VIEW"] = require("./ui/tab-view/tab-view-tests");
|
||||||
|
@ -310,61 +310,62 @@ export var testNativeTextAlignmentFromLocal = function () {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export var test_WhenFormattedTextPropertyChanges_TextIsUpdated_Button = function () {
|
// TODO: Enable these when.
|
||||||
var firstSpan = new spanModule.Span();
|
// export var test_WhenFormattedTextPropertyChanges_TextIsUpdated_Button = function () {
|
||||||
firstSpan.fontSize = 10;
|
// var firstSpan = new spanModule.Span();
|
||||||
firstSpan.text = "First";
|
// firstSpan.fontSize = 10;
|
||||||
var secondSpan = new spanModule.Span();
|
// firstSpan.text = "First";
|
||||||
secondSpan.fontSize = 15;
|
// var secondSpan = new spanModule.Span();
|
||||||
secondSpan.text = "Second";
|
// secondSpan.fontSize = 15;
|
||||||
var thirdSpan = new spanModule.Span();
|
// secondSpan.text = "Second";
|
||||||
thirdSpan.fontSize = 20;
|
// var thirdSpan = new spanModule.Span();
|
||||||
thirdSpan.text = "Third";
|
// thirdSpan.fontSize = 20;
|
||||||
var formattedString1 = new formattedStringModule.FormattedString();
|
// thirdSpan.text = "Third";
|
||||||
formattedString1.spans.push(firstSpan);
|
// var formattedString1 = new formattedStringModule.FormattedString();
|
||||||
var formattedString2 = new formattedStringModule.FormattedString();
|
// formattedString1.spans.push(firstSpan);
|
||||||
formattedString2.spans.push(secondSpan);
|
// var formattedString2 = new formattedStringModule.FormattedString();
|
||||||
formattedString2.spans.push(thirdSpan);
|
// formattedString2.spans.push(secondSpan);
|
||||||
|
// formattedString2.spans.push(thirdSpan);
|
||||||
|
|
||||||
var view = new buttonModule.Button();
|
// var view = new buttonModule.Button();
|
||||||
helper.buildUIAndRunTest(view, function (views: Array<viewModule.View>) {
|
// helper.buildUIAndRunTest(view, function (views: Array<viewModule.View>) {
|
||||||
TKUnit.assertEqual(view.text, "");
|
// TKUnit.assertEqual(view.text, "");
|
||||||
|
|
||||||
view.formattedText = formattedString1;
|
// view.formattedText = formattedString1;
|
||||||
TKUnit.assertEqual(view.text, "First");
|
// TKUnit.assertEqual(view.text, "First");
|
||||||
|
|
||||||
view.formattedText = formattedString2;
|
// view.formattedText = formattedString2;
|
||||||
TKUnit.assertEqual(view.text, "SecondThird");
|
// TKUnit.assertEqual(view.text, "SecondThird");
|
||||||
|
|
||||||
formattedString2.spans.getItem(0).text = "Mecond";
|
// formattedString2.spans.getItem(0).text = "Mecond";
|
||||||
TKUnit.assertEqual(view.text, "MecondThird");
|
// TKUnit.assertEqual(view.text, "MecondThird");
|
||||||
|
|
||||||
view.formattedText = null;
|
// view.formattedText = null;
|
||||||
TKUnit.assertEqual(view.text, "");
|
// TKUnit.assertEqual(view.text, "");
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
|
|
||||||
export function test_IntegrationTest_Transform_Decoration_Spacing_WithoutFormattedText_DoesNotCrash() {
|
// export function test_IntegrationTest_Transform_Decoration_Spacing_WithoutFormattedText_DoesNotCrash() {
|
||||||
let view = new buttonModule.Button();
|
// let view = new buttonModule.Button();
|
||||||
helper.buildUIAndRunTest(view, function (views: Array<viewModule.View>) {
|
// helper.buildUIAndRunTest(view, function (views: Array<viewModule.View>) {
|
||||||
view.text = "NormalText";
|
// view.text = "NormalText";
|
||||||
view.setInlineStyle("text-transform: uppercase; text-decoration: underline; letter-spacing: 1;");
|
// view.setInlineStyle("text-transform: uppercase; text-decoration: underline; letter-spacing: 1;");
|
||||||
|
|
||||||
TKUnit.assertEqual(view.style.textTransform, enums.TextTransform.uppercase, "TextTransform");
|
// TKUnit.assertEqual(view.style.textTransform, enums.TextTransform.uppercase, "TextTransform");
|
||||||
TKUnit.assertEqual(view.style.textDecoration, enums.TextDecoration.underline, "TextDecoration");
|
// TKUnit.assertEqual(view.style.textDecoration, enums.TextDecoration.underline, "TextDecoration");
|
||||||
TKUnit.assertEqual(view.style.letterSpacing, 1, "LetterSpacing");
|
// TKUnit.assertEqual(view.style.letterSpacing, 1, "LetterSpacing");
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
|
|
||||||
export function test_IntegrationTest_Transform_Decoration_Spacing_WithFormattedText_DoesNotCrash() {
|
// export function test_IntegrationTest_Transform_Decoration_Spacing_WithFormattedText_DoesNotCrash() {
|
||||||
let view = new buttonModule.Button();
|
// let view = new buttonModule.Button();
|
||||||
let formattedString = helper._generateFormattedString();
|
// let formattedString = helper._generateFormattedString();
|
||||||
helper.buildUIAndRunTest(view, function (views: Array<viewModule.View>) {
|
// helper.buildUIAndRunTest(view, function (views: Array<viewModule.View>) {
|
||||||
view.formattedText = formattedString;
|
// view.formattedText = formattedString;
|
||||||
view.setInlineStyle("text-transform: uppercase; text-decoration: underline; letter-spacing: 1;");
|
// view.setInlineStyle("text-transform: uppercase; text-decoration: underline; letter-spacing: 1;");
|
||||||
|
|
||||||
TKUnit.assertEqual(view.style.textTransform, enums.TextTransform.uppercase, "TextTransform");
|
// TKUnit.assertEqual(view.style.textTransform, enums.TextTransform.uppercase, "TextTransform");
|
||||||
TKUnit.assertEqual(view.style.textDecoration, enums.TextDecoration.underline, "TextDecoration");
|
// TKUnit.assertEqual(view.style.textDecoration, enums.TextDecoration.underline, "TextDecoration");
|
||||||
TKUnit.assertEqual(view.style.letterSpacing, 1, "LetterSpacing");
|
// TKUnit.assertEqual(view.style.letterSpacing, 1, "LetterSpacing");
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
|
@ -32,12 +32,12 @@ const enum ValueSource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface PropertyOptions<T, U> {
|
export interface PropertyOptions<T, U> {
|
||||||
name: string,
|
name: string;
|
||||||
defaultValue?: U,
|
defaultValue?: U;
|
||||||
affectsLayout?: boolean,
|
affectsLayout?: boolean;
|
||||||
equalityComparer?: (x: U, y: U) => boolean,
|
equalityComparer?(this: void, x: U, y: U): boolean;
|
||||||
valueChanged?: (target: T, oldValue: U, newValue: U) => void,
|
valueChanged?(this: void, target: T, oldValue: U, newValue: U): void;
|
||||||
valueConverter?: (value: string) => U
|
valueConverter?(this: void, value: string): U;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface CoerciblePropertyOptions<T, U> extends PropertyOptions<T, U> {
|
export interface CoerciblePropertyOptions<T, U> extends PropertyOptions<T, U> {
|
||||||
@ -45,10 +45,10 @@ export interface CoerciblePropertyOptions<T, U> extends PropertyOptions<T, U> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface ShorthandPropertyOptions {
|
export interface ShorthandPropertyOptions {
|
||||||
name: string,
|
name: string;
|
||||||
cssName: string;
|
cssName: string;
|
||||||
converter: (value: string) => [CssProperty<any, any>, any][],
|
converter(this: void, value: string): [CssProperty<any, any>, any][];
|
||||||
getter: (this: Style) => string
|
getter(this: Style): string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface CssPropertyOptions<T extends Style, U> extends PropertyOptions<T, U> {
|
export interface CssPropertyOptions<T extends Style, U> extends PropertyOptions<T, U> {
|
||||||
@ -834,6 +834,19 @@ export function clearInheritedProperties(view: ViewBase): void {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function resetCSSProperties(style: Style): void {
|
||||||
|
let symbols = (<any>Object).getOwnPropertySymbols(style);
|
||||||
|
const view = style.view;
|
||||||
|
for (let symbol of symbols) {
|
||||||
|
const cssProperty = cssSymbolPropertyMap[symbol];
|
||||||
|
if (!cssProperty) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
style[cssProperty.cssName] = unsetValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export function resetStyleProperties(style: Style): void {
|
export function resetStyleProperties(style: Style): void {
|
||||||
let symbols = (<any>Object).getOwnPropertySymbols(style);
|
let symbols = (<any>Object).getOwnPropertySymbols(style);
|
||||||
const view = style.view;
|
const view = style.view;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { ViewBase as ViewBaseDefinition } from "ui/core/view-base";
|
import { ViewBase as ViewBaseDefinition } from "ui/core/view-base";
|
||||||
import { Observable, EventData } from "data/observable";
|
import { Observable, EventData } from "data/observable";
|
||||||
import { Property, InheritedProperty, Style, clearInheritedProperties, propagateInheritedProperties, resetStyleProperties } from "./properties";
|
import { Property, InheritedProperty, Style, clearInheritedProperties, propagateInheritedProperties, resetCSSProperties } from "./properties";
|
||||||
import { Binding, BindingOptions, Bindable } from "ui/core/bindable";
|
import { Binding, BindingOptions, Bindable } from "ui/core/bindable";
|
||||||
import { isIOS, isAndroid } from "platform";
|
import { isIOS, isAndroid } from "platform";
|
||||||
import { fromString as gestureFromString } from "ui/gestures";
|
import { fromString as gestureFromString } from "ui/gestures";
|
||||||
@ -504,22 +504,24 @@ export class ViewBase extends Observable implements ViewBaseDefinition {
|
|||||||
export const bindingContextProperty = new InheritedProperty<ViewBase, any>({ name: "bindingContext" });
|
export const bindingContextProperty = new InheritedProperty<ViewBase, any>({ name: "bindingContext" });
|
||||||
bindingContextProperty.register(ViewBase);
|
bindingContextProperty.register(ViewBase);
|
||||||
|
|
||||||
function onCssClassPropertyChanged(view: ViewBase, oldValue: string, newValue: string) {
|
export const classNameProperty = new Property<ViewBase, string>({
|
||||||
|
name: "className",
|
||||||
|
valueChanged(view: ViewBase, oldValue: string, newValue: string) {
|
||||||
let classes = view.cssClasses;
|
let classes = view.cssClasses;
|
||||||
classes.clear();
|
classes.clear();
|
||||||
if (typeof newValue === "string") {
|
if (typeof newValue === "string") {
|
||||||
newValue.split(" ").forEach(c => classes.add(c));
|
newValue.split(" ").forEach(c => classes.add(c));
|
||||||
}
|
}
|
||||||
}
|
resetStyles(view);
|
||||||
|
}
|
||||||
export const classNameProperty = new Property<ViewBase, string>({ name: "className", valueChanged: onCssClassPropertyChanged });
|
});
|
||||||
classNameProperty.register(ViewBase);
|
classNameProperty.register(ViewBase);
|
||||||
|
|
||||||
function resetStyles(view: ViewBase): void {
|
function resetStyles(view: ViewBase): void {
|
||||||
|
view._cancelAllAnimations();
|
||||||
|
resetCSSProperties(view.style);
|
||||||
|
view._applyStyleFromScope();
|
||||||
view.eachChild((child) => {
|
view.eachChild((child) => {
|
||||||
child._cancelAllAnimations();
|
|
||||||
resetStyleProperties(child.style);
|
|
||||||
child._applyStyleFromScope();
|
|
||||||
resetStyles(child);
|
resetStyles(child);
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
@ -1143,7 +1143,14 @@ originXProperty.register(ViewCommon);
|
|||||||
export const originYProperty = new Property<ViewCommon, number>({ name: "originY", defaultValue: 0.5, valueConverter: (v) => parseFloat(v) });
|
export const originYProperty = new Property<ViewCommon, number>({ name: "originY", defaultValue: 0.5, valueConverter: (v) => parseFloat(v) });
|
||||||
originYProperty.register(ViewCommon);
|
originYProperty.register(ViewCommon);
|
||||||
|
|
||||||
export const isEnabledProperty = new Property<ViewCommon, boolean>({ name: "isEnabled", defaultValue: true, valueConverter: booleanConverter });
|
export const isEnabledProperty = new Property<ViewCommon, boolean>({
|
||||||
|
name: "isEnabled",
|
||||||
|
defaultValue: true,
|
||||||
|
valueConverter: booleanConverter,
|
||||||
|
valueChanged(this: void, target, oldValue, newValue): void {
|
||||||
|
target._goToVisualState(newValue ? "normal" : "disabled");
|
||||||
|
}
|
||||||
|
});
|
||||||
isEnabledProperty.register(ViewCommon);
|
isEnabledProperty.register(ViewCommon);
|
||||||
|
|
||||||
export const isUserInteractionEnabledProperty = new Property<ViewCommon, boolean>({ name: "isUserInteractionEnabled", defaultValue: true, valueConverter: booleanConverter });
|
export const isUserInteractionEnabledProperty = new Property<ViewCommon, boolean>({ name: "isUserInteractionEnabled", defaultValue: true, valueConverter: booleanConverter });
|
||||||
@ -1326,7 +1333,7 @@ function parseThickness(value: string): Thickness {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function convertToMargins(this: Style, value: string): [CssProperty<any, any>, any][] {
|
function convertToMargins(this: void, value: string): [CssProperty<any, any>, any][] {
|
||||||
let thickness = parseThickness(value);
|
let thickness = parseThickness(value);
|
||||||
return [
|
return [
|
||||||
[marginTopProperty, Length.parse(thickness.top)],
|
[marginTopProperty, Length.parse(thickness.top)],
|
||||||
@ -1336,7 +1343,7 @@ function convertToMargins(this: Style, value: string): [CssProperty<any, any>, a
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
function convertToPaddings(this: Style, value: string): [CssProperty<any, any>, any][] {
|
function convertToPaddings(this: void, value: string): [CssProperty<any, any>, any][] {
|
||||||
let thickness = parseThickness(value);
|
let thickness = parseThickness(value);
|
||||||
return [
|
return [
|
||||||
[paddingTopProperty, Length.parse(thickness.top)],
|
[paddingTopProperty, Length.parse(thickness.top)],
|
||||||
|
@ -38,8 +38,8 @@ export class GesturesObserver extends GesturesObserverBase {
|
|||||||
this._detach();
|
this._detach();
|
||||||
};
|
};
|
||||||
|
|
||||||
this.target.on(View.loadedEvent, this._onTargetLoaded);
|
this.target.on("loaded", this._onTargetLoaded);
|
||||||
this.target.on(View.unloadedEvent, this._onTargetUnloaded);
|
this.target.on("unloaded", this._onTargetUnloaded);
|
||||||
|
|
||||||
if (this.target.isLoaded) {
|
if (this.target.isLoaded) {
|
||||||
this._attach(this.target, type);
|
this._attach(this.target, type);
|
||||||
@ -51,8 +51,8 @@ export class GesturesObserver extends GesturesObserverBase {
|
|||||||
this._detach();
|
this._detach();
|
||||||
|
|
||||||
if (this.target) {
|
if (this.target) {
|
||||||
this.target.off(View.loadedEvent, this._onTargetLoaded);
|
this.target.off("loaded", this._onTargetLoaded);
|
||||||
this.target.off(View.unloadedEvent, this._onTargetUnloaded);
|
this.target.off("unloaded", this._onTargetUnloaded);
|
||||||
|
|
||||||
this._onTargetLoaded = null;
|
this._onTargetLoaded = null;
|
||||||
this._onTargetUnloaded = null;
|
this._onTargetUnloaded = null;
|
||||||
|
Reference in New Issue
Block a user