diff --git a/tests/app/image-source/image-source-tests.ts b/tests/app/image-source/image-source-tests.ts index 1209a3390..0bf3e373d 100644 --- a/tests/app/image-source/image-source-tests.ts +++ b/tests/app/image-source/image-source-tests.ts @@ -15,7 +15,7 @@ export function testFromResource() { // >> imagesource-resname const img = imageSource.fromResource("icon"); // << imagesource-resname - + TKUnit.assert(img.height > 0, "image.fromResource failed"); } @@ -149,6 +149,22 @@ export function testFromAssetWithScalingAndAspectRatio(done) { }); } +export function testFromAssetWithScalingAndDefaultAspectRatio(done) { + let asset = new imageAssetModule.ImageAsset(splashscreenPath); + let scaleWidth = 10; + let scaleHeight = 11; + asset.options.width = scaleWidth; + asset.options.height = scaleHeight; + + let img = imageSource.fromAsset(asset).then((source) => { + TKUnit.assertEqual(source.width, 18); + TKUnit.assertEqual(source.height, scaleHeight); + done(); + }, (error) => { + done(error); + }); +} + export function testFromAssetWithBiggerScaling(done) { let asset = new imageAssetModule.ImageAsset(splashscreenPath); let scaleWidth = 600; diff --git a/tns-core-modules/image-asset/image-asset-common.ts b/tns-core-modules/image-asset/image-asset-common.ts index 56dac6850..52cbb5a42 100644 --- a/tns-core-modules/image-asset/image-asset-common.ts +++ b/tns-core-modules/image-asset/image-asset-common.ts @@ -9,6 +9,11 @@ export class ImageAsset extends observable.Observable implements definition.Ima ios: PHAsset; android: string; + constructor () { + super(); + this._options = { keepAspectRatio: true }; + } + get options(): definition.ImageAssetOptions { return this._options; }