@@ -136,10 +136,53 @@ public void LoadSync ()
136136 assemblies . Clear ( ) ;
137137 }
138138
139+ public void SelectLastTestSuite ( )
140+ {
141+ var lastSuite = NSUserDefaults . StandardUserDefaults . StringForKey ( "CurrentTest" ) ;
142+
143+ if ( string . IsNullOrEmpty ( lastSuite ) )
144+ return ;
145+
146+ var hierarchy = new List < ITest > ( ) ;
147+ var test = Find ( suite , lastSuite , hierarchy ) ;
148+ if ( hierarchy . Count < 2 )
149+ return ;
150+ // Remove the last one, that's the main test suite
151+ hierarchy . RemoveAt ( hierarchy . Count - 1 ) ;
152+ for ( var i = hierarchy . Count - 1 ; i >= 0 ; i -- ) {
153+ if ( hierarchy [ i ] is TestSuite ts ) {
154+ Show ( ts ) ;
155+ } else {
156+ break ;
157+ }
158+ }
159+ }
160+
161+ ITest Find ( ITest parent , string fullname , List < ITest > hierarchy )
162+ {
163+ if ( parent . FullName == fullname ) {
164+ hierarchy . Add ( parent ) ;
165+ return parent ;
166+ }
167+
168+ foreach ( var test in parent . Tests ) {
169+ var rv = Find ( test , fullname , hierarchy ) ;
170+ if ( rv != null ) {
171+ hierarchy . Add ( parent ) ;
172+ return test ;
173+ }
174+ }
175+
176+ return null ;
177+ }
178+
179+
139180 public void AutoRun ( )
140181 {
141- if ( ! AutoStart )
182+ if ( ! AutoStart ) {
183+ SelectLastTestSuite ( ) ;
142184 return ;
185+ }
143186
144187 ExecuteOnMainThread ( ( ) => {
145188 Run ( ) ;
@@ -375,6 +418,10 @@ bool ShowConnectionErrorAlert (string hostname, int port, Exception ex)
375418
376419 protected abstract void WriteDeviceInformation ( TextWriter writer ) ;
377420
421+ public virtual void Show ( TestSuite suite )
422+ {
423+ }
424+
378425 public void CloseWriter ( )
379426 {
380427 int total = PassedCount + InconclusiveCount + FailedCount ; // ignored are *not* run
@@ -559,6 +606,11 @@ public ITest LoadedTest {
559606 }
560607 }
561608
609+ public void NotifySelectedTest ( ITest test )
610+ {
611+ NSUserDefaults . StandardUserDefaults . SetString ( test . FullName , "CurrentTest" ) ;
612+ }
613+
562614 public void TestOutput ( TestOutput testOutput )
563615 {
564616 }
@@ -694,7 +746,7 @@ void Credits ()
694746 Dictionary < TestSuite , TestSuiteElement > suite_elements = new Dictionary < TestSuite , TestSuiteElement > ( ) ;
695747 Dictionary < TestMethod , TestCaseElement > case_elements = new Dictionary < TestMethod , TestCaseElement > ( ) ;
696748
697- public void Show ( TestSuite suite )
749+ public override void Show ( TestSuite suite )
698750 {
699751 NavigationController . PushViewController ( suites_dvc [ suite ] , true ) ;
700752 }
@@ -734,7 +786,11 @@ TestSuiteElement Setup (TestSuite suite)
734786 } ;
735787 root . Add ( options ) ;
736788
737- suites_dvc . Add ( suite , new TouchViewController ( root ) ) ;
789+ var tvc = new TouchViewController ( root ) ;
790+ tvc . ViewAppearing += ( object sender , EventArgs ea ) => {
791+ NotifySelectedTest ( suite ) ;
792+ } ;
793+ suites_dvc . Add ( suite , tvc ) ;
738794 return tse ;
739795 }
740796
0 commit comments