mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
Fix for Button padding in android.
Fix for types - isString and isNumber. Modified several tests to pass on VS Emulator for Android. Fix page background to be applied in onLoaded method. Enhancements for dependency-observable - it is now possible to add defaultValueGetter function to extract default value for a property. It can also be cached or not. Remove android_constants because they are per theme and we cannot use them safely. Fix for SearchBar reseColorProperty method.
This commit is contained in:
@@ -10,7 +10,6 @@ export function buttonTap(args) {
|
||||
v.style._resetValue(style.fontSizeProperty);
|
||||
v.style._resetValue(style.fontStyleProperty);
|
||||
v.style._resetValue(style.fontWeightProperty);
|
||||
v.style._resetValue(style.fontProperty);
|
||||
|
||||
v.style._resetValue(style.colorProperty);
|
||||
v.style._resetValue(style.textAlignmentProperty);
|
||||
|
||||
@@ -124,7 +124,7 @@ export function test_scrollabeHeight_vertical_orientation_when_content_is_big()
|
||||
scrollView.content = btn;
|
||||
|
||||
waitForLayout();
|
||||
TKUnit.assertEqual(scrollView.scrollableHeight, 200, "scrollView.scrollableHeight");
|
||||
TKUnit.assertAreClose(scrollView.scrollableHeight, 200, 0.4, "scrollView.scrollableHeight");
|
||||
TKUnit.assertEqual(scrollView.scrollableWidth, 0, "scrollView.scrollableWidth");
|
||||
|
||||
}
|
||||
@@ -157,7 +157,7 @@ export function test_scrollabeWidth_horizontal_orientation_when_content_is_big()
|
||||
|
||||
waitForLayout();
|
||||
TKUnit.assertEqual(scrollView.scrollableHeight, 0, "scrollView.scrollableHeight");
|
||||
TKUnit.assertEqual(scrollView.scrollableWidth, 300, "scrollView.scrollableWidth");
|
||||
TKUnit.assertAreClose(scrollView.scrollableWidth, 300, 0.4, "scrollView.scrollableWidth");
|
||||
}
|
||||
|
||||
export function test_scrollToVerticalOffset_no_animation() {
|
||||
@@ -174,7 +174,7 @@ export function test_scrollToVerticalOffset_no_animation() {
|
||||
|
||||
TKUnit.assertEqual(scrollView.verticalOffset, 0, "scrollView.verticalOffset");
|
||||
scrollView.scrollToVerticalOffset(100, false);
|
||||
TKUnit.assertEqual(scrollView.verticalOffset, 100, "scrollView.verticalOffset");
|
||||
TKUnit.assertAreClose(scrollView.verticalOffset, 100, 0.1, "scrollView.verticalOffset");
|
||||
}
|
||||
|
||||
export function test_scrollToVerticalOffset_with_animation() {
|
||||
@@ -198,7 +198,7 @@ export function test_scrollToVerticalOffset_with_animation() {
|
||||
TKUnit.waitUntilReady(() => { return scrollView.verticalOffset === 100 }, ASYNC);
|
||||
|
||||
// The scrolling animation should be finished by now
|
||||
TKUnit.assertEqual(scrollView.verticalOffset, 100, "scrollView.verticalOffset");
|
||||
TKUnit.assertAreClose(scrollView.verticalOffset, 100, 0.1, "scrollView.verticalOffset");
|
||||
}
|
||||
|
||||
export function test_scrollToHorizontalOffset_no_animation() {
|
||||
@@ -215,7 +215,7 @@ export function test_scrollToHorizontalOffset_no_animation() {
|
||||
|
||||
TKUnit.assertEqual(scrollView.horizontalOffset, 0, "scrollView.horizontalOffset");
|
||||
scrollView.scrollToHorizontalOffset(100, false);
|
||||
TKUnit.assertEqual(scrollView.horizontalOffset, 100, "scrollView.horizontalOffset");
|
||||
TKUnit.assertAreClose(scrollView.horizontalOffset, 100, 0.1, "scrollView.horizontalOffset");
|
||||
}
|
||||
|
||||
export function test_scrollToHorizontalOffset_with_animation() {
|
||||
@@ -239,7 +239,7 @@ export function test_scrollToHorizontalOffset_with_animation() {
|
||||
TKUnit.waitUntilReady(() => { return scrollView.horizontalOffset === 100 }, ASYNC);
|
||||
|
||||
// The scrolling animation should be finished by now
|
||||
TKUnit.assertEqual(scrollView.horizontalOffset, 100, "scrollView.horizontalOffset");
|
||||
TKUnit.assertAreClose(scrollView.horizontalOffset, 100, 0.1, "scrollView.horizontalOffset");
|
||||
}
|
||||
|
||||
export function test_scrollView_persistsState_vertical() {
|
||||
@@ -256,7 +256,7 @@ export function test_scrollView_persistsState_vertical() {
|
||||
|
||||
scrollView.scrollToVerticalOffset(100, false);
|
||||
|
||||
TKUnit.assertEqual(scrollView.verticalOffset, 100, "scrollView.verticalOffset before navigation");
|
||||
TKUnit.assertAreClose(scrollView.verticalOffset, 100, 0.1, "scrollView.verticalOffset before navigation");
|
||||
|
||||
helper.do_PageTest_WithButton((t) => {
|
||||
// Just navigate forward and back.
|
||||
@@ -264,11 +264,11 @@ export function test_scrollView_persistsState_vertical() {
|
||||
|
||||
// Wait for the page to reload.
|
||||
TKUnit.waitUntilReady(function () {
|
||||
return scrollView.verticalOffset === 100;
|
||||
return Math.abs(scrollView.verticalOffset - 100) < 0.1;
|
||||
}, ASYNC);
|
||||
|
||||
// Check verticalOffset after navigation
|
||||
TKUnit.assertEqual(scrollView.verticalOffset, 100, "scrollView.verticalOffset after navigation");
|
||||
TKUnit.assertAreClose(scrollView.verticalOffset, 100, 0.1, "scrollView.verticalOffset after navigation");
|
||||
}
|
||||
|
||||
export function test_scrollView_persistsState_horizontal() {
|
||||
@@ -285,7 +285,7 @@ export function test_scrollView_persistsState_horizontal() {
|
||||
|
||||
scrollView.scrollToHorizontalOffset(100, false);
|
||||
|
||||
TKUnit.assertEqual(scrollView.horizontalOffset, 100, "scrollView.horizontalOffset before navigation");
|
||||
TKUnit.assertAreClose(scrollView.horizontalOffset, 100, 0.1, "scrollView.horizontalOffset before navigation");
|
||||
|
||||
helper.do_PageTest_WithButton((t) => {
|
||||
// Just navigate forward and back.
|
||||
@@ -293,9 +293,9 @@ export function test_scrollView_persistsState_horizontal() {
|
||||
|
||||
// Wait for the page to reload.
|
||||
TKUnit.waitUntilReady(function () {
|
||||
return scrollView.horizontalOffset === 100;
|
||||
return Math.abs(scrollView.horizontalOffset - 100) < 0.1;
|
||||
}, ASYNC);
|
||||
|
||||
// Check verticalOffset after navigation
|
||||
TKUnit.assertEqual(scrollView.horizontalOffset, 100, "scrollView.horizontalOffset after navigation");
|
||||
TKUnit.assertAreClose(scrollView.horizontalOffset, 100, 0.1, "scrollView.horizontalOffset after navigation");
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ export var testSearchBarFontSize = function () {
|
||||
|
||||
searchBar.style.fontSize = expectedValue;
|
||||
actualValue = searchBarTestsNative.getNativeFontSize(searchBar);
|
||||
TKUnit.assert(actualValue === expectedValue, "Actual: " + actualValue + "; Expected: " + expectedValue);
|
||||
TKUnit.assertAreClose(actualValue, expectedValue, 0.2);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -407,11 +407,11 @@ function property_binding_test(propName: string, firstValue: any, secondValue: a
|
||||
view.bind(options, model);
|
||||
|
||||
actualResult = view.get(propName);
|
||||
TKUnit.assert(actualResult === firstValue, "Actual result: " + actualResult + "; Expected result: " + firstValue);
|
||||
TKUnit.assertEqual(actualResult, firstValue);
|
||||
|
||||
model.set(propName, secondValue);
|
||||
actualResult = view.get(propName);
|
||||
TKUnit.assert(actualResult === secondValue, "Actual result: " + actualResult + "; Expected result: " + secondValue);
|
||||
TKUnit.assertEqual(actualResult, secondValue);
|
||||
}
|
||||
|
||||
function property_binding_style_test(propName: string, firstValue: any, secondValue: any, view?: viewModule.View) {
|
||||
@@ -431,11 +431,11 @@ function property_binding_style_test(propName: string, firstValue: any, secondVa
|
||||
view.bind(options, model);
|
||||
|
||||
actualResult = view.style.get(propName);
|
||||
TKUnit.assert(actualResult === firstValue, "Actual result: " + actualResult + "; Expected result: " + firstValue);
|
||||
TKUnit.assertEqual(actualResult, firstValue);
|
||||
|
||||
model.set(propName, secondValue);
|
||||
actualResult = view.style.get(propName);
|
||||
TKUnit.assert(actualResult === secondValue, "Actual result: " + actualResult + "; Expected result: " + secondValue);
|
||||
TKUnit.assertEqual(actualResult, secondValue);
|
||||
}
|
||||
|
||||
export var test_binding_width = function () {
|
||||
@@ -531,7 +531,7 @@ export var test_binding_style_minHeight = function () {
|
||||
}
|
||||
|
||||
export var test_binding_style_margin = function () {
|
||||
property_binding_style_test("margin", "1,1,1,1", "2,2,2,2");
|
||||
property_binding_style_test("margin", "1 1 1 1", "2 2 2 2");
|
||||
}
|
||||
|
||||
export var test_binding_style_marginLeft = function () {
|
||||
@@ -551,7 +551,7 @@ export var test_binding_style_marginBottom = function () {
|
||||
}
|
||||
|
||||
export var test_binding_style_padding = function () {
|
||||
property_binding_style_test("padding", "1,1,1,1", "2,2,2,2");
|
||||
property_binding_style_test("padding", "1 1 1 1", "2 2 2 2");
|
||||
}
|
||||
|
||||
export var test_binding_style_paddingLeft = function () {
|
||||
@@ -600,16 +600,16 @@ export var testIsVisible = function () {
|
||||
var lbl = new label.Label();
|
||||
|
||||
helper.buildUIAndRunTest(lbl, function (views: Array<viewModule.View>) {
|
||||
TKUnit.assert(lbl.visibility === enums.Visibility.visible, "Actual: " + lbl.visibility + "; Expected: " + enums.Visibility.visible);
|
||||
TKUnit.assert(lbl._isVisible, "Actual: " + lbl._isVisible + "; Expected: true;");
|
||||
TKUnit.assertEqual(lbl.visibility, enums.Visibility.visible);
|
||||
TKUnit.assertEqual(lbl._isVisible, true);
|
||||
|
||||
lbl.visibility = enums.Visibility.collapse;
|
||||
TKUnit.assert(lbl.visibility === enums.Visibility.collapse, "Actual: " + lbl.visibility + "; Expected: " + enums.Visibility.collapse);
|
||||
TKUnit.assert(!lbl._isVisible, "Actual: " + lbl._isVisible + "; Expected: false;");
|
||||
TKUnit.assertEqual(lbl.visibility, enums.Visibility.collapse);
|
||||
TKUnit.assertEqual(lbl._isVisible, false);
|
||||
|
||||
lbl.visibility = enums.Visibility.collapsed;
|
||||
TKUnit.assert(lbl.visibility === enums.Visibility.collapsed, "Actual: " + lbl.visibility + "; Expected: " + enums.Visibility.collapsed);
|
||||
TKUnit.assert(!lbl._isVisible, "Actual: " + lbl._isVisible + "; Expected: false;");
|
||||
TKUnit.assertEqual(lbl.visibility, enums.Visibility.collapsed);
|
||||
TKUnit.assertEqual(lbl._isVisible, false);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -632,7 +632,7 @@ export var testBorderWidth = function () {
|
||||
var lbl = <label.Label>views[0];
|
||||
var expectedValue = lbl.borderWidth;
|
||||
var actualValue = definition.getNativeBorderWidth(lbl);
|
||||
TKUnit.assert(actualValue === expectedValue, "Actual: " + actualValue + "; Expected: " + expectedValue);
|
||||
TKUnit.assertEqual(actualValue, expectedValue);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -641,21 +641,21 @@ export var testCornerRadius = function () {
|
||||
var lbl = <label.Label>views[0];
|
||||
var expectedValue = lbl.borderRadius;
|
||||
var actualValue = definition.getNativeCornerRadius(lbl);
|
||||
TKUnit.assert(actualValue === expectedValue, "Actual: " + actualValue + "; Expected: " + expectedValue);
|
||||
TKUnit.assertEqual(actualValue, expectedValue);
|
||||
});
|
||||
}
|
||||
|
||||
export var testBorderColor = function () {
|
||||
helper.buildUIAndRunTest(_createLabelWithBorder(), function (views: Array<viewModule.View>) {
|
||||
var lbl = <label.Label>views[0];
|
||||
TKUnit.assert(definition.checkNativeBorderColor(lbl), "BorderColor not applied correctly!");
|
||||
TKUnit.assertEqual(definition.checkNativeBorderColor(lbl), true, "BorderColor not applied correctly!");
|
||||
});
|
||||
}
|
||||
|
||||
export var testBackgroundColor = function () {
|
||||
helper.buildUIAndRunTest(_createLabelWithBorder(), function (views: Array<viewModule.View>) {
|
||||
var lbl = <label.Label>views[0];
|
||||
TKUnit.assert(definition.checkNativeBackgroundColor(lbl), "BackgroundColor not applied correctly!");
|
||||
TKUnit.assertEqual(definition.checkNativeBackgroundColor(lbl), true, "BackgroundColor not applied correctly!");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -665,7 +665,6 @@ export var testBackgroundImage = function () {
|
||||
helper.buildUIAndRunTest(lbl, function (views: Array<viewModule.View>) {
|
||||
var page = <page.Page>views[1];
|
||||
page.css = ".myClass { background-image: url('~/logo.png') }";
|
||||
|
||||
TKUnit.assert(definition.checkNativeBackgroundImage(lbl), "Style background-image not loaded correctly.");
|
||||
TKUnit.assertEqual(definition.checkNativeBackgroundImage(lbl), true, "Style background-image not loaded correctly.");
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user