Fix the last several errors

This commit is contained in:
PanayotCankov
2016-12-20 13:24:32 +02:00
parent 6122c44126
commit d10ca1da03
26 changed files with 147 additions and 158 deletions

View File

@@ -1,6 +1,5 @@
import * as style from "ui/styling/style";
import {PropertyMetadata, PropertyMetadataSettings} from "ui/core/dependency-observable";
import * as styleProperty from "ui/styling/style-property";
import * as view from "ui/core/view";
import * as buttonModule from "ui/button";
import * as pages from "ui/page";
@@ -10,46 +9,46 @@ import {isAndroid} from "platform";
// on Android we explicitly set propertySettings to None because android will invalidate its layout (skip unnecessary native call).
let AffectsLayout = isAndroid ? PropertyMetadataSettings.None : PropertyMetadataSettings.AffectsLayout;
export var fontFamilyProperty = new styleProperty.Property("fontFamily", "font-family", new PropertyMetadata(undefined, AffectsLayout));
// export var fontFamilyProperty = new styleProperty.Property("fontFamily", "font-family", new PropertyMetadata(undefined, AffectsLayout));
export class MyTextViewStyler implements style.Styler {
public static setFontFamilyProperty(view: view.View, newValue: any) {
if (view.android) {
(<android.widget.TextView>view.android).setTypeface(android.graphics.Typeface.create(newValue, android.graphics.Typeface.NORMAL));
}
else if (view.ios) {
var fontSize = (<UIButton>view._nativeView).titleLabel.font.pointSize;
(<UIButton>view._nativeView).titleLabel.font = UIFont.fontWithNameSize(newValue, fontSize);
}
}
// export class MyTextViewStyler implements style.Styler {
// public static setFontFamilyProperty(view: view.View, newValue: any) {
// if (view.android) {
// (<android.widget.TextView>view.android).setTypeface(android.graphics.Typeface.create(newValue, android.graphics.Typeface.NORMAL));
// }
// else if (view.ios) {
// var fontSize = (<UIButton>view._nativeView).titleLabel.font.pointSize;
// (<UIButton>view._nativeView).titleLabel.font = UIFont.fontWithNameSize(newValue, fontSize);
// }
// }
public static resetFontFamilyProperty(view: view.View, nativeValue: any) {
if (view.android) {
(<android.widget.TextView>view.android).setTypeface(android.graphics.Typeface.create(nativeValue, android.graphics.Typeface.NORMAL));
}
else if (view.ios) {
var fontSize = (<UIButton>view._nativeView).titleLabel.font.pointSize;
(<UIButton>view._nativeView).titleLabel.font = UIFont.fontWithNameSize(nativeValue, fontSize);;
}
}
// public static resetFontFamilyProperty(view: view.View, nativeValue: any) {
// if (view.android) {
// (<android.widget.TextView>view.android).setTypeface(android.graphics.Typeface.create(nativeValue, android.graphics.Typeface.NORMAL));
// }
// else if (view.ios) {
// var fontSize = (<UIButton>view._nativeView).titleLabel.font.pointSize;
// (<UIButton>view._nativeView).titleLabel.font = UIFont.fontWithNameSize(nativeValue, fontSize);;
// }
// }
public static getNativeFontFamilyValue = function (view: view.View): any {
if (view.android) {
return (<android.widget.TextView>view.android).getTypeface();
}
else if (view.ios) {
return (<UIButton>view._nativeView).titleLabel.font.fontName;
}
return null;
}
// public static getNativeFontFamilyValue = function (view: view.View): any {
// if (view.android) {
// return (<android.widget.TextView>view.android).getTypeface();
// }
// else if (view.ios) {
// return (<UIButton>view._nativeView).titleLabel.font.fontName;
// }
// return null;
// }
public static registerHandlers() {
style.registerHandler(fontFamilyProperty, new style.StylePropertyChangedHandler(
MyTextViewStyler.setFontFamilyProperty,
MyTextViewStyler.resetFontFamilyProperty,
MyTextViewStyler.getNativeFontFamilyValue), "MyButton");
}
}
// public static registerHandlers() {
// style.registerHandler(fontFamilyProperty, new style.StylePropertyChangedHandler(
// MyTextViewStyler.setFontFamilyProperty,
// MyTextViewStyler.resetFontFamilyProperty,
// MyTextViewStyler.getNativeFontFamilyValue), "MyButton");
// }
// }
//export class MyStyle extends styles.Style {
// get fontFamily(): string {
@@ -75,7 +74,7 @@ export class MyButton extends buttonModule.Button {
}
MyTextViewStyler.registerHandlers();
// MyTextViewStyler.registerHandlers();
export function createPage() {
var stackLayout = new stackLayoutDef.StackLayout();

View File

@@ -1,5 +1,6 @@
import * as stack from "ui/layouts/stack-layout";
import * as style from "ui/styling/style";
import {unsetValue} from "ui/core/view";
export function buttonTap(args) {
var stackLayout = <stack.StackLayout>args.object.parent;

View File

@@ -23,7 +23,7 @@ export function createPage() {
return page;
}
function addButton(layout: layout.StackLayout, text: "left" | "center" | "middle" | "right" | "stretch") {
function addButton(layout: layout.StackLayout, text: "left" | "center" | "right" | "stretch") {
var btn = new btns.Button();
btn.text = text;
btn.horizontalAlignment = text;

View File

@@ -17,7 +17,7 @@ export function createPage() {
var btn2 = new buttonModule.Button();
btn2.horizontalAlignment = "center";
btn2.verticalAlignment = "center";
btn2.verticalAlignment = "middle";
btn2.text = "center, center";
var btn3 = new buttonModule.Button();

View File

@@ -1,5 +1,6 @@
import * as pages from "ui/page";
import * as buttons from "ui/button";
import { VerticalAlignment } from "ui/core/view";
export function createPage() {
var page = new pages.Page();
@@ -9,7 +10,7 @@ export function createPage() {
btn.height = 60;
btn.text = "test";
var vAligns = ["stretch", "top", "center", "bottom"];
var vAligns: VerticalAlignment[] = ["stretch", "top", "middle", "bottom"];
//var hAligns = ["stretch", "left", "center", "right"];
var count = 0;
btn.on(buttons.Button.tapEvent, function () {

View File

@@ -308,7 +308,7 @@ export function test_AnimationCurveInKeyframes() {
TKUnit.assertEqual(animation.keyframes[0].curve, enums.AnimationCurve.linear);
TKUnit.assertEqual(animation.keyframes[1].curve, undefined);
TKUnit.assertEqual(animation.keyframes[1].curve, undefined);
let realAnimation = keyframeAnimation.KeyframeAnimation.keyframeAnimationFromInfo(animation, 2);
let realAnimation = keyframeAnimation.KeyframeAnimation.keyframeAnimationFromInfo(animation);
TKUnit.assertEqual(realAnimation.animations[1].curve, enums.AnimationCurve.linear);
TKUnit.assertEqual(realAnimation.animations[2].curve, enums.AnimationCurve.easeIn);
}

View File

@@ -28,7 +28,6 @@ export var test_Bindable_Members = function () {
var obj = new bindable.Bindable();
TKUnit.assert(types.isDefined(obj.bind), "Bindable.bind not defined");
TKUnit.assert(types.isDefined(obj.unbind), "Bindable.unbind not defined");
TKUnit.assert(types.isDefined(obj._updateTwoWayBinding), "Bindable.updateTwoWayBinding not defined");
}
export var test_Bindable_Bind_ToTarget_OneWay = function () {
@@ -155,7 +154,6 @@ export var test_bindingContext_ValueSource_IsInherited = function () {
var context = {};
views[0].bindingContext = context;
TKUnit.assert(views[1].bindingContext === context, "bindingContext not inherited.");
TKUnit.assert(views[1]._getValueSource(bindable.Bindable.bindingContextProperty) === dependencyObservableModule.ValueSource.Inherited, "bindingContext should be propagated as Inherited.");
}
helper.do_PageTest_WithButton(test);

View File

@@ -235,7 +235,7 @@ var _testNativeBackgroundColorFromLocal = function (views: Array<viewModule.View
TKUnit.assert(actualResult === expectedBackgroundColorHex, "Actual: " + actualResult + "; Expected: " + expectedBackgroundColorHex);
}
var expectedTextAlignment = enums.TextAlignment.right;
var expectedTextAlignment: "right" = "right";
export var testLocalTextAlignmentFromCss = function () {
helper.buildUIAndRunTest(_createButtonFunc(), function (views: Array<viewModule.View>) {
var view = <buttonModule.Button>views[0];

View File

@@ -101,7 +101,7 @@ export function percent_support_children_test(test: testModule.UITest<LayoutBase
TKUnit.assertEqual(bounds.bottom, 120, "TopLeft layout BOTTOM incorrect");
btn.horizontalAlignment = "center";
btn.verticalAlignment = "center";
btn.verticalAlignment = "middle";
test.waitUntilTestElementLayoutIsValid();
bounds = btn._getCurrentLayoutBounds();

View File

@@ -10,7 +10,7 @@ import {
} from "ui/layouts/flexbox-layout";
// << flexbox-layout-require
import {View, unsetValue} from "ui/core/view";
import {View, unsetValue, Length} from "ui/core/view";
import {Label} from "ui/label";
import * as TKUnit from "../../TKUnit";
import * as helper from "../helper";
@@ -494,8 +494,8 @@ export const testJustifyContent_flexStart_withParentPadding = test(
({root, flexbox, text1, text2, text3}) => {
isRightOf(text2, text1);
isRightOf(text3, text2);
equal(left(text1), dipToDp(flexbox.style.paddingLeft.value), `Expected ${text1}.left to equal ${flexbox}.paddingLeft`);
equal(top(text1), dipToDp(flexbox.style.paddingTop.value), `Expected ${text1}.top to equal ${flexbox}.paddingTop`);
equal(left(text1), Length.toDevicePixels(flexbox.style.paddingLeft, 0), `Expected ${text1}.left to equal ${flexbox}.paddingLeft`);
equal(top(text1), Length.toDevicePixels(flexbox.style.paddingTop, 0), `Expected ${text1}.top to equal ${flexbox}.paddingTop`);
}
);
@@ -516,8 +516,8 @@ export const testJustifyContent_flexEnd_withParentPadding = test(
({root, flexbox, text1, text2, text3}) => {
isLeftOf(text2, text3);
isLeftOf(text1, text2);
closeEnough(width(flexbox) - right(text3), dipToDp(flexbox.style.paddingRight.value));
closeEnough(top(text3), dipToDp(flexbox.style.paddingTop.value));
closeEnough(width(flexbox) - right(text3), Length.toDevicePixels(flexbox.style.paddingRight, 0));
closeEnough(top(text3), Length.toDevicePixels(flexbox.style.paddingTop, 0));
}
);
@@ -544,10 +544,10 @@ export const testJustifyContent_center_withParentPadding = test(
({root, flexbox, text1, text2, text3}) => {
isRightOf(text2, text1);
isRightOf(text3, text2);
let space = width(flexbox) - width(text1) - width(text2) - width(text3) - dipToDp(flexbox.style.paddingLeft.value) - dipToDp(flexbox.style.paddingRight.value);
let space = width(flexbox) - width(text1) - width(text2) - width(text3) - Length.toDevicePixels(flexbox.style.paddingLeft, 0) - Length.toDevicePixels(flexbox.style.paddingRight, 0);
space = space / 2;
check(space - 1 <= left(text1) - dipToDp(flexbox.style.paddingLeft.value) && left(text1) - dipToDp(flexbox.style.paddingLeft.value) <= space + 1);
check(space - 1 <= width(flexbox) - right(text3) - dipToDp(flexbox.style.paddingRight.value) && width(flexbox) - right(text3) - dipToDp(flexbox.style.paddingRight.value) <= space + 1);
check(space - 1 <= left(text1) - Length.toDevicePixels(flexbox.style.paddingLeft, 0) && left(text1) - Length.toDevicePixels(flexbox.style.paddingLeft, 0) <= space + 1);
check(space - 1 <= width(flexbox) - right(text3) - Length.toDevicePixels(flexbox.style.paddingRight, 0) && width(flexbox) - right(text3) - Length.toDevicePixels(flexbox.style.paddingRight, 0) <= space + 1);
}
);
@@ -870,7 +870,7 @@ export const testAlignContent_flexEnd_parentPadding = test(
isAbove(text1, text3);
isAbove(text2, text3);
closeEnough(bottom(text3), height(flexbox) - dipToDp(flexbox.style.paddingBottom.value));
closeEnough(bottom(text3), height(flexbox) - Length.toDevicePixels(flexbox.style.paddingBottom, 0));
}
);
@@ -886,7 +886,7 @@ export const testAlignContent_flexEnd_parentPadding_column = test(
isLeftOf(text2, text3);
let { bounds1, bounds2 } = comparableBounds(text3, flexbox);
closeEnough(bounds1.right, bounds2.right - dipToDp(flexbox.style.paddingRight.value));
closeEnough(bounds1.right, bounds2.right - Length.toDevicePixels(flexbox.style.paddingRight, 0));
}
);
@@ -1249,8 +1249,8 @@ export const testAlignItems_flexEnd_parentPadding = test(
({flexbox}) => flexbox.alignItems = AlignItems.FLEX_END,
({root, flexbox, text1, text2, text3}) => {
isRightOf(text2, text1);
closeEnough(bottom(text1), height(flexbox) - dipToDp(flexbox.style.paddingBottom.value));
closeEnough(bottom(text2), height(flexbox) - dipToDp(flexbox.style.paddingBottom.value));
closeEnough(bottom(text1), height(flexbox) - Length.toDevicePixels(flexbox.style.paddingBottom, 0));
closeEnough(bottom(text2), height(flexbox) - Length.toDevicePixels(flexbox.style.paddingBottom, 0));
}
);
@@ -1262,8 +1262,8 @@ export const testAlignItems_flexEnd_parentPadding_column = test(
},
({root, flexbox, text1, text2, text3}) => {
isBelow(text2, text1);
closeEnough(right(text1), width(flexbox) - dipToDp(flexbox.style.paddingRight.value));
closeEnough(right(text2), width(flexbox) - dipToDp(flexbox.style.paddingRight.value));
closeEnough(right(text1), width(flexbox) - Length.toDevicePixels(flexbox.style.paddingRight, 0));
closeEnough(right(text2), width(flexbox) - Length.toDevicePixels(flexbox.style.paddingRight, 0));
}
);
@@ -1808,7 +1808,7 @@ export const testWrap_parentPadding_horizontal = test(
({flexbox, text1, text2, text3}) => {
isBelow(text2, text1);
isRightOf(text3, text2);
closeEnough(height(flexbox), dipToDp(flexbox.style.paddingTop.value) + dipToDp(flexbox.style.paddingBottom.value) + height(text1) + height(text2));
closeEnough(height(flexbox), Length.toDevicePixels(flexbox.style.paddingTop, 0) + Length.toDevicePixels(flexbox.style.paddingBottom, 0) + height(text1) + height(text2));
}
);
@@ -1826,7 +1826,7 @@ export const testWrap_parentPadding_vertical = test(
({flexbox, text1, text2, text3}) => {
isRightOf(text2, text1);
isBelow(text3, text2);
closeEnough(width(flexbox), dipToDp(flexbox.style.paddingLeft.value) + dipToDp(flexbox.style.paddingRight.value) + width(text1) + width(text2));
closeEnough(width(flexbox), Length.toDevicePixels(flexbox.style.paddingLeft, 0) + Length.toDevicePixels(flexbox.style.paddingRight, 0) + width(text1) + width(text2));
}
);
@@ -1844,7 +1844,7 @@ export const testWrap_childMargin_horizontal = test(
({flexbox, text1, text2, text3}) => {
isBelow(text2, text1);
isRightOf(text3, text2);
closeEnough(height(flexbox), height(text1) + height(text2) + dipToDp(text2.style.marginTop.value) + dipToDp(text2.style.marginBottom.value));
closeEnough(height(flexbox), height(text1) + height(text2) + Length.toDevicePixels(text2.style.marginTop, 0) + Length.toDevicePixels(text2.style.marginBottom, 0));
}
);
@@ -1907,7 +1907,7 @@ export const testWrap_childMargin_vertical = test(
isRightOf(text2, text1);
isBelow(text3, text2);
// dips anyone?
closeEnough(width(flexbox), width(text1) + width(text2) + dipToDp(text2.marginLeft.value) + dipToDp(text2.marginRight.value));
closeEnough(width(flexbox), width(text1) + width(text2) + Length.toDevicePixels(text2.marginLeft, 0) + Length.toDevicePixels(text2.marginRight, 0));
}
);

View File

@@ -219,7 +219,7 @@ export class StackLayoutTest extends testModule.UITest<StackLayout> {
TKUnit.assertEqual(bounds.bottom, 120, "TopLeft layout BOTTOM incorrect");
btn.horizontalAlignment = "center";
btn.verticalAlignment = "center";
btn.verticalAlignment = "middle";
this.waitUntilTestElementLayoutIsValid();
bounds = btn._getCurrentLayoutBounds();
@@ -264,7 +264,7 @@ export class StackLayoutTest extends testModule.UITest<StackLayout> {
TKUnit.assertEqual(bounds.bottom, 120, "TopLeft layout BOTTOM incorrect");
btn.horizontalAlignment = "center";
btn.verticalAlignment = "center";
btn.verticalAlignment = "middle";
this.waitUntilTestElementLayoutIsValid();
bounds = btn._getCurrentLayoutBounds();

View File

@@ -289,7 +289,7 @@ export class WrapLayoutTest extends testModule.UITest<wrapLayoutModule.WrapLayou
TKUnit.assertEqual(bounds.bottom, 120, "TopLeft layout BOTTOM incorrect");
btn.horizontalAlignment = "center";
btn.verticalAlignment = "center";
btn.verticalAlignment = "middle";
this.waitUntilTestElementLayoutIsValid();
bounds = btn._getCurrentLayoutBounds();

View File

@@ -57,7 +57,6 @@ export class ListViewTest extends testModule.UITest<listViewModule.ListView> {
var listView = new listViewModule.ListView();
// << article-create-listview
TKUnit.assertEqual(listView.isScrolling, false, "Default listView.isScrolling");
TKUnit.assert(types.isUndefined(listView.items), "Default listView.items should be undefined");
}

View File

@@ -609,36 +609,6 @@ function testButtonPressedStateIsRed(btn: buttonModule.Button) {
TKUnit.assert(btn.style.color === undefined, "Color should not have a value after returned to normal state.");
}
export function test_styling_converters_are_defined() {
TKUnit.assert(types.isDefined(styling.converters), "converters module is not defined");
TKUnit.assert(types.isFunction(styling.converters.colorConverter), "colorConverter function is not defined");
TKUnit.assert(types.isFunction(styling.converters.fontSizeConverter), "fontSizeConverter function is not defined");
TKUnit.assert(types.isFunction(styling.converters.textAlignConverter), "textAlignConverter function is not defined");
}
export function test_styling_properties_are_defined() {
TKUnit.assert(types.isDefined(styling.properties), "properties module is not defined");
TKUnit.assert(types.isDefined(styling.properties.backgroundColorProperty), "backgroundColorProperty property is not defined");
TKUnit.assert(types.isDefined(styling.properties.colorProperty), "colorProperty property is not defined");
TKUnit.assert(types.isDefined(styling.properties.fontSizeProperty), "fontSizeProperty property is not defined");
TKUnit.assert(types.isDefined(styling.properties.textAlignmentProperty), "textAlignmentProperty property is not defined");
TKUnit.assert(types.isFunction(styling.properties.eachInheritableProperty), "properties.eachInheritableProperty function is not defined");
TKUnit.assert(types.isFunction(styling.properties.eachProperty), "properties.eachProperty function is not defined");
TKUnit.assert(types.isFunction(styling.properties.getPropertyByCssName), "properties.getPropertyByCssName function is not defined");
TKUnit.assert(types.isFunction(styling.properties.getPropertyByName), "properties.getPropertyByName function is not defined");
}
export function test_styling_stylers_are_defined() {
TKUnit.assert(types.isFunction(styleModule.registerHandler), "registerHandler function is not defined");
TKUnit.assert(types.isFunction(styleModule.StylePropertyChangedHandler), "StylePropertyChangedHandler class is not defined");
}
export function test_styling_classes_are_defined() {
TKUnit.assert(types.isFunction(styling.Style), "Style class is not defined");
TKUnit.assert(types.isFunction(styling.Property), "Property class is not defined");
}
export function test_setInlineStyle_setsLocalValues() {
var testButton = new buttonModule.Button();
testButton.text = "Test";
@@ -647,7 +617,7 @@ export function test_setInlineStyle_setsLocalValues() {
helper.buildUIAndRunTest(stack, function (views: Array<viewModule.View>) {
(<any>testButton)._applyInlineStyle("color: red;");
helper.assertViewColor(testButton, "#FF0000", dependencyObservableModule.ValueSource.Local);
helper.assertViewColor(testButton, "#FF0000");
});
}

View File

@@ -642,8 +642,8 @@ export var testIsVisible = function () {
TKUnit.assertEqual(lbl.visibility, "collapse");
TKUnit.assertEqual(lbl.isCollapsed, true);
lbl.visibility = "collapsed";
TKUnit.assertEqual(lbl.visibility, "collapsed");
lbl.visibility = "collapse";
TKUnit.assertEqual(lbl.visibility, "collapse");
TKUnit.assertEqual(lbl.isCollapsed, true);
});
}

View File

@@ -11,12 +11,12 @@ import * as types from "utils/types";
import * as fs from "file-system";
import * as observable from "data/observable";
import * as stackLayoutModule from "ui/layouts/stack-layout";
import {Label} from "ui/label";
import {Page} from "ui/page";
import {Button} from "ui/button";
import {TabView} from "ui/tab-view";
import {Observable} from "data/observable";
import {TemplateView} from "./template-builder-tests/template-view";
import { Label } from "ui/label";
import { Page } from "ui/page";
import { Button } from "ui/button";
import { TabView } from "ui/tab-view";
import { Observable } from "data/observable";
import { TemplateView } from "./template-builder-tests/template-view";
import * as myCustomControlWithoutXml from "./mymodule/MyControl";
import * as listViewModule from "ui/list-view";
import * as helper from "../ui/helper";
@@ -25,6 +25,7 @@ import * as platform from "platform";
import * as gesturesModule from "ui/gestures";
import * as segmentedBar from "ui/segmented-bar";
import { Source } from "utils/debug";
import { PercentLength } from "ui/core/view";
export function test_load_IsDefined() {
TKUnit.assertTrue(types.isFunction(builder.load), "ui/builder should have load method!");
@@ -307,8 +308,7 @@ export function test_parse_ShouldSetCanvasAttachedProperties() {
export function test_parse_ShouldParseNumberProperties() {
var p = <Page>builder.parse("<Page width='100' />");
TKUnit.assertEqual(p.width.value, 100);
TKUnit.assertEqual(p.width.unit, "dip");
TKUnit.assertTrue(PercentLength.equals(p.width, 100));
};
export function test_parse_ShouldParseBooleanProperties() {
@@ -451,7 +451,7 @@ export function test_parse_ShouldParseSubProperties() {
p.bindingContext = obj;
var sw = <switchModule.Switch>p.content;
TKUnit.assert(sw.visibility === "collapsed", "Expected result: collapsed; Actual result: " + sw.visibility + "; type: " + typeof (sw.visibility));
TKUnit.assert(sw.visibility === "collapse", "Expected result: collapsed; Actual result: " + sw.visibility + "; type: " + typeof (sw.visibility));
};
export function test_parse_ShouldParseBindingToSpecialProperty() {