package Ġf tl . client . google . run . ios Ċ Ċ import Ġcom . google . testing . Testing Ċ import Ġcom . google . testing . model . Client Info Ċ import Ġcom . google . testing . model . Environment Matrix Ċ import Ġcom . google . testing . model . Google Cloud Storage Ċ import Ġcom . google . testing . model . I os Test Setup Ċ import Ġcom . google . testing . model . Result Storage Ċ import Ġcom . google . testing . model . Test Matrix Ċ import Ġcom . google . testing . model . Test Specification Ċ import Ġcom . google . testing . model . Tool Results History Ċ import Ġf tl . api . Test Matrix I os Ċ import Ġf tl . client . google . Gc Testing Ċ import Ġf tl . client . google . run . map G cs Paths ToFile Reference Ċ import Ġf tl . client . google . run . map To I os Device Files Ċ import Ġf tl . client . google . run . to Client Info Detail List Ċ import Ġf tl . client . google . run . to I os Device File Ċ import Ġf tl . http . execute With Retry Ċ import Ġf tl . run . exception . Fl ank General Error Ċ import Ġf tl . util . timeout To Seconds Ċ import Ġkotlinx . coroutines . Deferred Ċ import Ġkotlinx . coroutines . Dispatch ers Ċ import Ġkotlinx . coroutines . async Ċ import Ġkotlinx . coroutines . await All Ċ import Ġkotlinx . coroutines . coroutine Scope Ċ Ċ suspend Ġfun Ġexecute I os Tests ( ĊĠĠĠ Ġconfig : ĠTest Matrix I os . Config , ĊĠĠĠ Ġtest Matrix Types : ĠList < Test Matrix I os . Type >, Ċ ): ĠList < Test Matrix > Ġ= Ġtest Matrix Types ĊĠĠĠ Ġ. fold Indexed ( emptyList < Deferred < Test Matrix >> ()) Ġ{ Ġ_, Ġtest Mat rices , Ġtest Matrix Type Ġ-> ĊĠĠĠĠĠĠĠ Ġtest Mat rices Ġ+ Ġexecute I os Test Matrix Async ( test Matrix Type , Ġconfig ) ĊĠĠĠ Ġ}. await All () Ċ Ċ private Ġsuspend Ġfun Ġexecute I os Test Matrix Async ( ĊĠĠĠ Ġtype : ĠTest Matrix I os . Type , ĊĠĠĠ Ġconfig : ĠTest Matrix I os . Config Ċ ): ĠDeferred < Test Matrix > Ġ= Ġcoroutine Scope Ġ{ ĊĠĠĠ Ġasync ( Dispatch ers . IO ) Ġ{ ĊĠĠĠĠĠĠĠ Ġcreate I os Test Matrix ( type , Ġconfig ). execute With Retry () ĊĠĠĠ Ġ} Ċ } Ċ Ċ private Ġfun Ġcreate I os Test Matrix ( ĊĠĠĠ Ġtest Matrix Type : ĠTest Matrix I os . Type , ĊĠĠĠ Ġconfig : ĠTest Matrix I os . Config , Ċ ): ĠTesting . Projects . Test Mat rices . Create Ġ{ ĊĊĠĠĠ Ġval Ġtest Matrix Ġ= ĠTest Matrix () ĊĠĠĠĠĠĠĠ Ġ. set Client Info ( config . client Info ) ĊĠĠĠĠĠĠĠ Ġ. set Test Specification ( get I os Test Specification ( test Matrix Type , Ġconfig )) ĊĠĠĠĠĠĠĠ Ġ. set Environment Matrix ( config . environment Matrix ) ĊĠĠĠĠĠĠĠ Ġ. set Result Storage ( results Storage ( config , Ġtest Matrix Type )) ĊĠĠĠĠĠĠĠ Ġ. set Fl aky Test Attempts ( config . fl aky Test Attempts ) ĊĠĠĠĠĠĠĠ Ġ. set Fail Fast ( config . fail Fast ) ĊĊĠĠĠ Ġreturn Ġrun Catch ing Ġ{ ĊĠĠĠĠĠĠĠ ĠG c Testing . get . projects (). test Mat rices (). create ( config . project , Ġtest Matrix ) ĊĠĠĠ Ġ}. getOrElse Ġ{ Ġthrow ĠFl ank General Error ( it ) Ġ} Ċ } Ċ Ċ private Ġfun Ġresults Storage ( config : ĠTest Matrix I os . Config , Ġtype : ĠTest Matrix I os . Type ): ĠResult Storage Ġ{ ĊĠĠĠ Ġreturn ĠResult Storage (). set Google Cloud Storage ( ĊĠĠĠĠĠĠĠ ĠGoogle Cloud Storage (). set G cs Path ( type . matrix G cs Path ) ĊĠĠĠ Ġ). set Tool Results History ( ĊĠĠĠĠĠĠĠ ĠTool Results History (). set History Id ( config . results History Name ). set ProjectId ( config . project ) ĊĠĠĠ Ġ) Ċ } Ċ Ċ private Ġval ĠTest Matrix I os . Config . environment Matrix ĊĠĠĠ Ġget () Ġ= ĠEnvironment Matrix (). set I os Device List ( Gc I os Device . build ( devices )) Ċ Ċ private Ġfun Ġget I os Test Specification ( ĊĠĠĠ Ġtest Matrix Type : ĠTest Matrix I os . Type , ĊĠĠĠ Ġconfig : ĠTest Matrix I os . Config Ċ ): ĠTest Specification Ġ= ĠTest Specification () ĊĠĠĠ Ġ. set Disable Video Recording (! config . record Video ) ĊĠĠĠ Ġ. set Test Timeout ("${ timeout To Seconds ( config . test Timeout )} s ") ĊĠĠĠ Ġ. set I os Test Setup ( get I os Test Setup ( config )) ĊĠĠĠ Ġ. setup I os Test ( test Matrix Type ) Ċ Ċ private Ġfun Ġget I os Test Setup ( ĊĠĠĠ Ġconfig : ĠTest Matrix I os . Config Ċ ): ĠI os Test Setup Ġ= ĠI os Test Setup () ĊĠĠĠ Ġ. set Network Profile ( config . network Profile ) ĊĠĠĠ Ġ. set Push Files ( config . other Files . map To I os Device Files ()) ĊĠĠĠ Ġ. set Additional Ip as ( config . additional Ip as G cs Paths . map G cs Paths ToFile Reference ()) ĊĠĠĠ Ġ. set Pull Directories ( config . directories To Pull . to I os Device Files ()) Ċ Ċ private Ġfun ĠList < String >. to I os Device Files () Ġ= Ġmap Ġ{ Ġpath Ġ-> Ġto I os Device File ( path ) Ġ} Ċ Ċ private Ġval ĠTest Matrix I os . Config . client Info ĊĠĠĠ Ġget () Ġ= ĠClient Info (). setName (" Fl ank "). set Client Info Details ( client Details . to Client Info Detail List ()) Ċ