44import android .os .Bundle ;
55import android .util .Log ;
66import android .view .View ;
7- import android .widget .ArrayAdapter ;
8- import android .widget .ListView ;
7+ import android .widget .*;
98import net .zetetic .tests .ResultNotifier ;
109import net .zetetic .tests .TestResult ;
1110import net .zetetic .tests .TestSuiteRunner ;
@@ -18,6 +17,7 @@ public class TestSuiteActivity extends Activity implements ResultNotifier {
1817 private static String TAG = "net.zetetic.sqlcipher.test" ;
1918 ListView resultsView ;
2019 List <TestResult > results ;
20+ View statsView ;
2121
2222 public TestSuiteActivity (){
2323 results = new ArrayList <TestResult >();
@@ -32,6 +32,8 @@ public void onCreate(Bundle savedInstanceState) {
3232
3333 public void onButtonClick (View view ) {
3434
35+ results .clear ();
36+ hideStats ();
3537 findViewById (R .id .executeSuite ).setEnabled (false );
3638 resultsView = (ListView ) findViewById (R .id .test_suite_results );
3739 ZeteticApplication .getInstance ().setCurrentActivity (this );
@@ -42,16 +44,35 @@ public void onButtonClick(View view) {
4244 public void send (TestResult result ) {
4345
4446 results .add (result );
45- ArrayAdapter < TestResult > adapter = (ArrayAdapter < TestResult > ) resultsView .getAdapter ();
47+ HeaderViewListAdapter adapter = (HeaderViewListAdapter ) resultsView .getAdapter ();
4648 if (adapter == null ){
49+ statsView = View .inflate (this , R .layout .test_stats , null );
50+ resultsView .addHeaderView (statsView );
51+ hideStats ();
4752 resultsView .setAdapter (new TestResultAdapter (ZeteticApplication .getInstance (), results ));
4853 } else {
49- adapter .notifyDataSetChanged ();
54+ (( ArrayAdapter < TestResult >) adapter . getWrappedAdapter ()) .notifyDataSetChanged ();
5055 }
5156 }
5257
5358 @ Override
5459 public void complete () {
60+
61+ TextView stats = (TextView ) statsView .findViewById (R .id .stats );
62+ int successCount = 0 ;
63+ for (TestResult result : results ){
64+ if (result .isSuccess ()){
65+ successCount += 1 ;
66+ }
67+ }
68+ stats .setText (String .format ("Passed: %d Failed: %d" , successCount , results .size () - successCount ));
69+ stats .setVisibility (View .VISIBLE );
5570 findViewById (R .id .executeSuite ).setEnabled (true );
5671 }
72+
73+ private void hideStats (){
74+ if (statsView != null ){
75+ statsView .findViewById (R .id .stats ).setVisibility (View .GONE );
76+ }
77+ }
5778}
0 commit comments