File tree Expand file tree Collapse file tree
tns-core-modules/ui/image Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -16,5 +16,5 @@ set timeout 600
1616#spawn (adb logcat | tee ./__TESTRESULT__.txt)
1717log_file -noappend $outfile
1818eval spawn $cmd
19- expect "=== ALL TESTS COMPLETE === "
19+ expect "Tests EOF! "
2020send \003
Original file line number Diff line number Diff line change @@ -153,17 +153,20 @@ function printRunTestStats() {
153153
154154 testFileContent = testFileContent . concat ( testCases ) ;
155155
156- // DO NOT CHANGE THE FIRST ROW! Used as an indicator for test run pass detection.
157- let finalMessage = `=== ALL TESTS COMPLETE ===\n` +
156+ let finalMessage = `\n=== ALL TESTS COMPLETE ===\n` +
158157 `${ ( allTests . length - failedTestCount ) } OK, ${ failedTestCount } failed\n` +
159- `DURATION: ${ totalTime } ms` ;
158+ `DURATION: ${ totalTime } ms\n ` ;
160159 TKUnit . write ( finalMessage , messageType . info ) ;
160+
161161 for ( j = 0 ; j < failedTestInfo . length ; j ++ ) {
162162 let failureMessage = failedTestInfo [ j ] ;
163163 TKUnit . write ( failureMessage , messageType . error ) ;
164164 finalMessage += "\n" + failureMessage ;
165165 }
166166
167+ // DO NOT CHANGE THE FIRST ROW! Used as an indicator for test run pass detection.
168+ TKUnit . write ( `Tests EOF!` , messageType . info ) ;
169+
167170 testFileContent . push ( "</testsuite>" ) ;
168171 testFileContent . push ( "</testsuites>" ) ;
169172
Original file line number Diff line number Diff line change 22import { StackLayout } from "ui/layouts/stack-layout" ;
33import { GridLayout } from "ui/layouts/grid-layout" ;
44import { isIOS } from "platform" ;
5+ import { PropertyChangeData } from "data/observable" ;
6+
57// import {target} from "../../TKUnit";
68
79import TKUnit = require( "../../TKUnit" ) ;
@@ -133,6 +135,28 @@ export var test_SettingImageSrcToDataURIAsync = function (done) {
133135 runImageTest ( done , image , image . src )
134136}
135137
138+ // NOTE: This tests that setting multiple times src will not show the imageSource of a previous src value.
139+ // It however will never be reliable as to properly detect failure we need to use somewhat large timeout
140+ // waiting for imageSource to be set to the wrong value.
141+ export var __test_SettingImageSrcTwiceMustNotMismatch = function ( done ) {
142+ var image = new Image ( ) ;
143+ image . on ( "propertyChange" , ( args : PropertyChangeData ) => {
144+ if ( args . propertyName === "isLoading" && args . value === false ) {
145+ setTimeout ( ( ) => {
146+ if ( image . imageSource ) {
147+ done ( new Error ( "Images source set from previous async src setting" ) ) ;
148+ } else {
149+ done ( ) ;
150+ }
151+ } , 50 ) ; /* Slow! */
152+ }
153+ } ) ;
154+ image . loadMode = "async" ;
155+ image . src = "~/logo.png" ;
156+ image . src = null ;
157+ // At somepoint image.imageSource was set to "~/logo.png";
158+ }
159+
136160export var test_SettingStretch_AspectFit = function ( ) {
137161 // >> img-set-stretch
138162 var image = new ImageModule . Image ( ) ;
Original file line number Diff line number Diff line change @@ -97,6 +97,9 @@ export class Image extends view.View implements definition.Image {
9797
9898 var source = new imageSource . ImageSource ( ) ;
9999 var imageLoaded = ( ) => {
100+ if ( value !== this . src ) {
101+ return ;
102+ }
100103 this . imageSource = source ;
101104 this . _setValue ( Image . isLoadingProperty , false ) ;
102105 }
@@ -143,9 +146,11 @@ export class Image extends view.View implements definition.Image {
143146 else if ( value instanceof imageSource . ImageSource ) {
144147 // Support binding the imageSource trough the src property
145148 this . imageSource = value ;
149+ this . _setValue ( Image . isLoadingProperty , false ) ;
146150 }
147151 else {
148152 this . imageSource = imageSource . fromNativeSource ( value ) ;
153+ this . _setValue ( Image . isLoadingProperty , false ) ;
149154 }
150155 }
151156}
You can’t perform that action at this time.
0 commit comments