Hhristov/ios background image crash fix (#4214)

* uiColorFromImage should return if there is no image.

* added unit-test
This commit is contained in:
Hristo Hristov
2017-05-17 15:40:14 +03:00
committed by GitHub
parent cbbee3bbe7
commit 0d21f52c99
2 changed files with 10 additions and 1 deletions

View File

@ -249,7 +249,7 @@ export function test_InheritableStylePropertiesWhenUsedWithExtendedClass_AreInhe
page.content = newButton; page.content = newButton;
TKUnit.assertEqual(newButton.style.color, redColor); TKUnit.assertEqual(newButton.style.color, redColor);
}; }
// TestView definition START // TestView definition START
const customCssProperty = new CssProperty<Style, string>({ name: "customCssProperty", cssName: "custom-css-property" }); const customCssProperty = new CssProperty<Style, string>({ name: "customCssProperty", cssName: "custom-css-property" });
@ -919,3 +919,11 @@ export function test_getActualSize() {
TKUnit.assertAreClose(actualSize.height, 200, delta, "actualSize.height"); TKUnit.assertAreClose(actualSize.height, 200, delta, "actualSize.height");
}); });
}; };
export function test_background_image_doesnt_throw() {
var btn = new Button();
btn.style.backgroundImage = 'https://www.bodybuilding.com/images/2016/june/8-benefits-to-working-out-in-the-morning-header-v2-830x467.jpg';
helper.buildUIAndRunTest(btn, function (views: Array<View>) {
TKUnit.waitUntilReady(() => btn.isLayoutValid);
});
}

View File

@ -262,6 +262,7 @@ function getDrawParams(this: void, image: UIImage, background: BackgroundDefinit
function uiColorFromImage(img: UIImage, view: View, callback: (uiColor: UIColor) => void, flip?: boolean): void { function uiColorFromImage(img: UIImage, view: View, callback: (uiColor: UIColor) => void, flip?: boolean): void {
if (!img) { if (!img) {
callback(null); callback(null);
return;
} }
const nativeView = view.nativeView as UIView; const nativeView = view.nativeView as UIView;