package Ġcom . so y wiz . k orge . ext . sw f Ċ Ċ /* Ċ class ĠSw f Test Ġ{ Ċ ĉ val Ġevent Loop Test Ġ= ĠEvent Loop Test () Ċ ĉ val Ġviews Log Ġ= ĠViews Log ( event Loop Test ) Ċ ĉ val Ġviews Ġ= Ġviews Log . views ĊĊ ĉ fun Ġsync Test ( block : Ġsuspend ĠEvent Loop Test . () Ġ-> ĠUnit ): ĠUnit Ġ{ Ċĉ ĉ sync ( el Ġ= Ġevent Loop Test , Ġstep Ġ= Ġ 1 0 , Ġblock Ġ= Ġblock ) Ċ ĉ } ĊĊ ĉ suspend Ġfun ĠV fs File . read SW F Deserial izing ( views : ĠViews , Ġconfig : ĠSW F Export Config ? Ġ= Ġnull ): ĠAn Library Ġ{ Ċĉ ĉ val Ġmem Ġ= ĠMemory V fs () ĊĊĉ ĉ val Ġan i Ġ= Ġif Ġ( config Ġ!= Ġnull ) Ġthis . read SW F ( views , Ġconfig ) Ġelse Ġthis . read SW F ( views ) Ċĉ ĉ ani . writeTo ( mem [" file . ani "], Ġan i . sw f Export Config . to An Library Serializer Config ( compression Ġ= Ġ 0 . 0 )) Ċĉ ĉ println (" AN I Ġsize :" Ġ+ Ġmem [" file . ani "]. size ()) Ċĉ ĉ return Ġmem [" file . ani "]. read An i ( views ) Ċ ĉ } ĊĊ ĉ fun Ġsw f Test ( callback : Ġsuspend ĠEvent Loop Test . () Ġ-> ĠUnit ) Ġ= Ġsuspend Test Ġ{ Ċĉ ĉ views Log . init () Ċĉ ĉ callback () Ċ ĉ } ĊĊ ĉ @ Test Ċ ĉ fun Ġname 3 () Ġ= Ġsw f Test Ġ{ Ċĉ ĉ val Ġlib Ġ= ĠResources V fs [" simple . sw f "]. read SW F Deserial izing ( views ) Ċĉ ĉ assertEquals (" 5 5 0 x 4 0 0 ", Ġ"${ lib . width } x ${ lib . height }") Ċĉ ĉ val Ġmc Ġ= Ġlib . create Main Time Line () ĊĊĉ ĉ println ( lib . fps ) Ċĉ ĉ println ( lib . ms Per Frame ) Ċĉ ĉ for Ġ( n Ġin Ġ 0 Ġuntil Ġ 1 0 ) Ġ{ Ċĉĉ ĉ println ( mc . dump ToString ()) Ċĉĉ ĉ mc . update ( 4 1 ) Ċĉ ĉ } Ċ ĉ } ĊĊ ĉ @ Test Ċ ĉ fun Ġname 5 () Ġ= Ġsw f Test Ġ{ Ċĉ ĉ // val Ġlib Ġ= ĠResources V fs [" test 1 . sw f "]. read SW F ( views ) Ċĉ ĉ // val Ġlib Ġ= ĠResources V fs [" test 2 . sw f "]. read SW F ( views ) Ċĉ ĉ val Ġlib Ġ= ĠResources V fs [" test 4 . sw f "]. read SW F Deserial izing ( views , ĠSW F Export Config ( debug Ġ= Ġtrue )) Ċĉ ĉ println ( lib ) Ċ ĉ } ĊĊ ĉ @ Test Ċ ĉ fun Ġname 6 () Ġ= Ġsw f Test Ġ{ Ċĉ ĉ val Ġlib Ġ= ĠResources V fs [" as 3 test . sw f "]. read SW F Deserial izing ( views , ĠSW F Export Config ( debug Ġ= Ġfalse )) Ċĉ ĉ assertEquals ( 6 , Ġlib . symbols ById . size ) Ċĉ ĉ println ( lib . symbols ById ) ĊĊĉ ĉ val Ġs 0 Ġ= Ġlib . symbols ById [ 0 ] Ġas ĠAn Symbol Movie Clip Ċĉ ĉ val Ġs 1 Ġ= Ġlib . symbols ById [ 1 ] Ġas ĠAn Symbol Shape Ċĉ ĉ val Ġs 2 Ġ= Ġlib . symbols ById [ 2 ] Ġas ĠAn Symbol Movie Clip Ċĉ ĉ val Ġs 3 Ġ= Ġlib . symbols ById [ 3 ] Ġas ĠAn Symbol Movie Clip Ċĉ ĉ val Ġs 4 Ġ= Ġlib . symbols ById [ 4 ] Ġas ĠAn Symbol Shape Ċĉ ĉ val Ġs 5 Ġ= Ġlib . symbols ById [ 5 ] Ġas ĠAn Symbol Movie Clip ĊĊĉ ĉ // assertEquals ( 2 , Ġs 0 . actions . size ) Ċĉ ĉ // assertEquals (" [( 0 , ĠAn Actions ( actions =[ An Flow Action ( goto Time = 4 1 , Ġstop = true )]) ), Ġ( 4 1 , ĠAn Actions ( actions =[ An Flow Action ( goto Time = 4 1 , Ġstop = true )])) ]", Ġs 0 . actions . entries . toString ()) Ċĉ ĉ // assertEquals ( 0 , Ġs 2 . actions . size ) Ċĉ ĉ // assertEquals ( 1 , Ġs 3 . actions . size ) Ċĉ ĉ // assertEquals ( 1 , Ġs 5 . actions . size ) ĊĊĉ ĉ println ( lib ) Ċ ĉ } ĊĊ ĉ @ Test Ċ ĉ fun Ġname 7 () Ġ= Ġsw f Test Ġ{ Ċĉ ĉ val Ġlib Ġ= ĠResources V fs [" sound test . sw f "]. read SW F Deserial izing ( views , ĠSW F Export Config ( debug Ġ= Ġfalse )) Ċĉ ĉ println ( lib ) Ċ ĉ } ĊĊ ĉ @ Test Ċ ĉ fun Ġname 8 () Ġ= Ġsw f Test Ġ{ Ċĉ ĉ val Ġlib Ġ= ĠResources V fs [" progressbar . sw f "]. read SW F Deserial izing ( views , ĠSW F Export Config ( debug Ġ= Ġfalse )) Ċĉ ĉ val Ġmc Ġ= Ġlib . symbols ById [ 0 ] Ġas ĠAn Symbol Movie Clip Ċĉ ĉ assertEquals ("[ frame 0 , Ġdefault , Ġprogress bar ]", Ġmc . states . keys . toList (). toString ()) Ċĉ ĉ val Ġprogress bar State Ġ= Ġmc . states [" progressbar "] !! Ċĉ ĉ assertEquals ( 0 , Ġprogress bar State . startTime ) Ċĉ ĉ // assertEquals (" default ", Ġprogress bar State . state . name ) Ċĉ ĉ // assertEquals ( 4 1 0 0 0 , Ġprogress bar State . state . loop StartTime ) Ċĉ ĉ assertEquals ( 8 3 0 0 0 , Ġprogress bar State . sub Timeline . total Time ) ĊĊĉ ĉ println ( lib ) Ċ ĉ } ĊĊ ĉ @ Test Ċ ĉ fun Ġexports () Ġ= Ġsw f Test Ġ{ Ċĉ ĉ val Ġlib Ġ= ĠResources V fs [" exports . sw f "]. read SW F Deserial izing ( views , ĠSW F Export Config ( debug Ġ= Ġfalse )) Ċĉ ĉ assertEquals ( listOf (" Main Time Line ", Ġ" Graphic 1 Export ", Ġ" MC 1 Export "), Ġlib . symbols ByName . keys . toList ()) Ċĉ ĉ val Ġsh Ġ= Ġlib . create Movie Clip (" Graphic 1 Export ") Ċĉ ĉ val Ġmc Ġ= Ġlib . create Movie Clip (" MC 1 Export ") ĊĊĉ ĉ // Animate Serializer . gen ( lib ). write ToFile (" c :/ temp / file . ani ") ĊĊĉ ĉ // Animate Deserializer . read ( Animate Serializer . gen ( lib ), Ġviews ) Ċ ĉ } ĊĊ ĉ @ Test Ċ ĉ fun Ġprops () Ġ= Ġsw f Test Ġ{ Ċĉ ĉ val Ġlib Ġ= ĠResources V fs [" props . sw f "]. read SW F Deserial izing ( views , ĠSW F Export Config ( debug Ġ= Ġfalse )) Ċĉ ĉ // val Ġlib Ġ= ĠResources V fs [" props . sw f "]. read SW F ( views , Ġdebug Ġ= Ġfalse ) Ċĉ ĉ val Ġmt Ġ= Ġlib . create Main Time Line () Ċĉ ĉ views . stage Ġ+= Ġmt Ċĉ ĉ assertEquals ( map Of (" gravity " Ġto Ġ" 9 . 8 "), Ġmt . children . first (). props ) Ċĉ ĉ assertEquals ( 1 , Ġviews . stage . desc endants With Prop (" gravity "). count ()) Ċĉ ĉ assertEquals ( 1 , Ġviews . stage . desc endants With Prop (" gravity ", Ġ" 9 . 8 "). count ()) Ċĉ ĉ assertEquals ( 0 , Ġviews . stage . desc endants With Prop (" gravity ", Ġ" 9 . 0 "). count ()) ĊĊĉ ĉ assertEquals ( 1 , Ġviews . stage . desc endants With Prop Double (" gravity "). count ()) Ċĉ ĉ assertEquals ( 1 , Ġviews . stage . desc endants With Prop Double (" gravity ", Ġ 9 . 8 ). count ()) Ċĉ ĉ assertEquals ( 0 , Ġviews . stage . desc endants With Prop Double (" gravity ", Ġ 9 . 0 ). count ()) Ċ ĉ } ĊĊ ĉ @ Test Ċ ĉ fun Ġshapes () Ġ= Ġsw f Test Ġ{ Ċĉ ĉ val Ġlib Ġ= ĠResources V fs [" shapes . sw f "]. read SW F Deserial izing ( views , ĠSW F Export Config ( debug Ġ= Ġfalse )) Ċĉ ĉ // val Ġlib Ġ= ĠResources V fs [" shapes . sw f "]. read SW F ( views , Ġdebug Ġ= Ġfalse ) Ċĉ ĉ val Ġmt Ġ= Ġlib . create Main Time Line () Ċĉ ĉ views . stage Ġ+= Ġmt Ċĉ ĉ val Ġshape Ġ= Ġmt [" shape "] Ġas ĠAn Movie Clip Ċĉ ĉ assertNotNull ( shape ) ĊĊĉ ĉ val Ġall Items Ġ= ĠlistOf (" f 1 2 ", Ġ" f 2 3 ", Ġ" f 3 4 ", Ġ" square ", Ġ" circle ") ĊĊĉ ĉ fun Ġassert Exists ( var arg Ġexists : ĠString ) Ġ{ Ċĉĉ ĉ val Ġexists 2 Ġ= Ġexists . toList () Ċĉĉ ĉ val Ġnot Exists Ġ= Ġall Items Ġ- Ġexists 2 ĊĊĉĉ ĉ val Ġavailable Names Ġ= Ġ( shape Ġas ĠContainer ). children . map Ġ{ Ġit . name Ġ}. filter NotNull () ĊĊĉĉ ĉ for Ġ( v Ġin Ġexists ) ĠassertNotNull ( shape [ v ], Ġ" Missing Ġelements : Ġ$ exists 2 Ġin Ġ$ available Names ") Ċĉĉ ĉ for Ġ( v Ġin Ġnot Exists ) ĠassertNull ( Ċĉĉĉ ĉ shape [ v ], Ċĉĉĉ ĉ " Elements Ġthat Ġshould Ġnot Ġexists : Ġ$ not Exists Ġin Ġ$ available Names " Ċĉĉ ĉ ) Ċĉ ĉ } ĊĊĉ ĉ assert Exists (" f 1 2 ") Ċĉ ĉ shape . play (" circle ") Ċĉ ĉ assert Exists (" f 1 2 ", Ġ" f 2 3 ", Ġ" circle ") Ċĉ ĉ shape . play (" square ") Ċĉ ĉ assert Exists (" f 2 3 ", Ġ" f 3 4 ", Ġ" square ") Ċĉ ĉ shape . play (" empty 2 ") Ċĉ ĉ assert Exists (" f 3 4 ") Ċ ĉ } ĊĊ ĉ @ Test Ċ ĉ fun Ġmorph () Ġ= Ġsw f Test Ġ{ Ċĉ ĉ val Ġlib Ġ= ĠResources V fs [" morph . sw f "]. read SW F Deserial izing ( views , ĠSW F Export Config ( debug Ġ= Ġfalse )) Ċĉ ĉ // val Ġlib Ġ= ĠResources V fs [" shapes . sw f "]. read SW F Deserial izing ( views , Ġdebug Ġ= Ġfalse ) Ċĉ ĉ // lib . writeTo ( Local V fs (" c :/ temp ") [" morph . ani "]) Ċ ĉ } ĊĊ ĉ @ Test Ċ ĉ fun Ġn ine patch () Ġ= Ġsw f Test Ġ{ Ċĉ ĉ val Ġlib Ġ= ĠResources V fs [" n ine patch . sw f "]. read SW F Deserial izing ( views , ĠSW F Export Config ( debug Ġ= Ġfalse )) Ċĉ ĉ // val Ġlib Ġ= ĠResources V fs [" shapes . sw f "]. read SW F Deserial izing ( views , Ġdebug Ġ= Ġfalse ) Ċĉ ĉ // lib . writeTo ( Local V fs (" c :/ temp ") [" n ine patch . ani "]) Ċ ĉ } ĊĊ ĉ @ Test Ċ ĉ fun Ġstop at the end () Ġ= Ġsw f Test Ġ{ Ċĉ ĉ val Ġlib Ġ= ĠResources V fs [" stop _ at _ the _ end . sw f "]. read SW F Deserial izing ( views , ĠSW F Export Config ( debug Ġ= Ġfalse )) Ċĉ ĉ val Ġc mt Ġ= Ġlib . create Main Time Line () Ċĉ ĉ assertEquals ( listOf (" box "), Ġc mt . all Desc endant Names ) Ċĉ ĉ for Ġ( n Ġin Ġ 0 Ġuntil Ġ 1 0 ) Ġc mt . update ( 1 0 ) Ċĉ ĉ assertEquals ( listOf (" circle "), Ġc mt . all Desc endant Names ) Ċĉ ĉ cmt [" circle "] ?. x Ġ= Ġ 9 0 0 . 0 Ċĉ ĉ assertEquals ( 9 0 0 . 0 , Ġc mt [" circle "] ?. x ) Ċĉ ĉ cmt . update ( 1 0 ) Ċĉ ĉ cmt . update ( 4 0 ) Ċĉ ĉ assertEquals ( 9 0 0 . 0 , Ġc mt [" circle "] ?. x ) Ċĉ ĉ assertEquals ( Ċĉĉ ĉ " IR ect angle ( x = 8 9 9 , Ġy = 9 6 , Ġwidth = 1 6 4 , Ġheight = 1 6 4 )", Ċĉĉ ĉ cmt [" circle "] !!. getGlobal Bounds (). toInt (). toString () Ċĉ ĉ ) Ċĉ ĉ // val Ġlib Ġ= ĠResources V fs [" shapes . sw f "]. read SW F Deserial izing ( views , Ġdebug Ġ= Ġfalse ) Ċĉ ĉ // lib . writeTo ( Local V fs (" c :/ temp ") [" n ine patch . ani "]) Ċ ĉ } ĊĊ ĉ @ Test Ċ ĉ fun Ġcamera Bounds () Ġ= Ġsw f Test Ġ{ Ċĉ ĉ val Ġlib Ġ= ĠResources V fs [" cam eras . sw f "]. read SW F Deserial izing ( views , ĠSW F Export Config ( debug Ġ= Ġfalse )) Ċĉ ĉ val Ġroot Ġ= Ġviews . stage Ċĉ ĉ root Ġ+= Ġlib . create Main Time Line () Ċĉ ĉ assertEquals ( Ċĉĉ ĉ " IR ect angle ( x =- 1 , Ġy =- 2 , Ġwidth = 7 2 1 , Ġheight = 1 2 8 2 )", Ċĉĉ ĉ root [" show Camera "] !!. getGlobal Bounds (). toInt (). toString () Ċĉ ĉ ) Ċĉ ĉ assertEquals ( Ċĉĉ ĉ " IR ect angle ( x = 1 3 7 , Ġy = 0 , Ġwidth = 4 4 4 , Ġheight = 7 9 0 )", Ċĉĉ ĉ root [" menu Camera "] !!. getGlobal Bounds (). toInt (). toString () Ċĉ ĉ ) Ċĉ ĉ assertEquals ( Ċĉĉ ĉ " IR ect angle ( x =- 3 5 9 , Ġy = 0 , Ġwidth = 1 4 3 9 , Ġheight = 2 5 5 9 )", Ċĉĉ ĉ root [" ing ame Camera "] !!. getGlobal Bounds (). toInt (). toString () Ċĉ ĉ ) ĊĊĉ ĉ // val Ġlib Ġ= ĠResources V fs [" shapes . sw f "]. read SW F Deserial izing ( views , Ġdebug Ġ= Ġfalse ) Ċĉ ĉ // lib . writeTo ( Local V fs (" c :/ temp ") [" n ine patch . ani "]) Ċ ĉ } ĊĊ ĉ @ Test Ċ ĉ // (" Fix Ġorder ") Ċ ĉ fun Ġevents () Ġ= Ġsw f Test Ġ{ Ċĉ ĉ // val Ġlib Ġ= ĠResources V fs [" cam eras . sw f "]. read SW F Deserial izing ( views , ĠSW F Export Config ( debug Ġ= Ġfalse )) Ċĉ ĉ val Ġlib Ġ= ĠResources V fs [" events . sw f "]. read SW F Deserial izing ( views , ĠSW F Export Config ( debug Ġ= Ġfalse )) Ċĉ ĉ val Ġroot Ġ= Ġviews . stage Ċĉ ĉ val Ġmtl Ġ= Ġlib . create Main Time Line () Ċĉ ĉ root Ġ+= Ġmtl Ċĉ ĉ val Ġstate Ġ= Ġgo Ġ{ Ċĉĉ ĉ println (" a ") Ċĉĉ ĉ val Ġresult Ġ= Ġmtl . play And Wait Event (" box ", Ġ" box _ back ") Ċĉĉ ĉ println (" -------------- ") Ċĉĉ ĉ assertEquals (" box _ back ", Ġresult ) Ċĉĉ ĉ // assertEquals ( 0 . 5 , Ġmtl [" box "] !!. alpha , Ġ 0 . 0 0 1 ) Ċĉĉ ĉ assertEquals ( 0 . 5 , Ġmtl [" box "] !!. alpha ) Ċĉĉ ĉ println (" b ") Ċĉ ĉ } Ċĉ ĉ for Ġ( n Ġin Ġ 0 Ġuntil Ġ 2 0 0 ) Ġ{ Ċĉĉ ĉ views . update ( 4 2 ) Ċĉĉ ĉ step ( 4 2 ) Ċĉ ĉ } Ċĉ ĉ state . await () Ċ ĉ } ĊĊ ĉ @ Test Ċ ĉ fun Ġbi gex ternal 1 () Ġ= Ġsw f Test Ġ{ Ċĉ ĉ val Ġlib Ġ= ĠLocal V fs (" c :/ temp / test 2 9 . sw f "). read SW F Deserial izing ( views , ĠSW F Export Config ( debug Ġ= Ġfalse )) Ċĉ ĉ // val Ġlib Ġ= ĠResources V fs [" shapes . sw f "]. read SW F Deserial izing ( views , Ġdebug Ġ= Ġfalse ) Ċĉ ĉ lib . writeTo ( Local V fs (" c :/ temp ") [" test 2 9 . ani "]) Ċ ĉ } ĊĊ ĉ @ Test Ċ ĉ fun Ġbi gex ternal 2 () Ġ= Ġsw f Test Ġ{ Ċĉ ĉ val Ġlib Ġ= ĠResources V fs [" c :/ temp / ui . sw f "]. read SW F Deserial izing ( views ) Ċĉ ĉ val Ġmc Ġ= Ġlib . create Main Time Line () ĊĊĉ ĉ println ( lib . fps ) Ċĉ ĉ println ( lib . ms Per Frame ) Ċĉ ĉ for Ġ( n Ġin Ġ 0 Ġuntil Ġ 1 0 ) Ġ{ Ċĉĉ ĉ println ( mc . dump ToString ()) Ċĉĉ ĉ mc . update ( 4 1 ) Ċĉ ĉ } Ċ ĉ } Ċ } Ċ */ Ċ