diff options
author | Jose <jose@zeroc.com> | 2012-11-15 23:25:45 +0100 |
---|---|---|
committer | Jose <jose@zeroc.com> | 2012-11-15 23:25:45 +0100 |
commit | 6c2684c66a1cfe4977c458d0d10fc0c5a88e4519 (patch) | |
tree | 85600f0d1aa6c9437209a89303e6067652a09cea /java/test/android/src/com/zeroc/testsuite/TestContainer.java | |
parent | Update SSL certificates to be compatible with IOS (diff) | |
download | ice-6c2684c66a1cfe4977c458d0d10fc0c5a88e4519.tar.bz2 ice-6c2684c66a1cfe4977c458d0d10fc0c5a88e4519.tar.xz ice-6c2684c66a1cfe4977c458d0d10fc0c5a88e4519.zip |
Android test & demo fixes
Diffstat (limited to 'java/test/android/src/com/zeroc/testsuite/TestContainer.java')
-rw-r--r-- | java/test/android/src/com/zeroc/testsuite/TestContainer.java | 113 |
1 files changed, 113 insertions, 0 deletions
diff --git a/java/test/android/src/com/zeroc/testsuite/TestContainer.java b/java/test/android/src/com/zeroc/testsuite/TestContainer.java new file mode 100644 index 00000000000..6344d20bc5c --- /dev/null +++ b/java/test/android/src/com/zeroc/testsuite/TestContainer.java @@ -0,0 +1,113 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2011 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +package com.zeroc.testsuite; + +import java.util.LinkedList; + +import android.app.ListActivity; +import android.os.Bundle; +import android.widget.ArrayAdapter; +import android.widget.Button; + +public class TestContainer extends ListActivity implements TestApp.TestListener +{ + private LinkedList<String> _strings = new LinkedList<String>(); + private ArrayAdapter<String> _adapter; + private boolean _partial = false; + private Button _next; + + /** Called when the activity is first created. */ + @Override + public void onCreate(Bundle savedInstanceState) + { + super.onCreate(savedInstanceState); + setContentView(R.layout.container); + _adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, _strings); + setListAdapter(_adapter); + + _next = (Button)findViewById(R.id.next); + _next.setOnClickListener(new android.view.View.OnClickListener() + { + public void onClick(android.view.View v) + { + TestApp app = (TestApp)getApplication(); + app.startNextTest(); + } + }); + _next.setEnabled(false); + } + + @Override + public void onResume() + { + super.onResume(); + TestApp app = (TestApp)getApplication(); + app.setTestListener(this); + } + + @Override + public void onStop() + { + super.onStop(); + TestApp app = (TestApp)getApplication(); + app.setTestListener(null); + } + + public void onStartTest(String test) + { + setTitle(test); + _partial = false; + _strings.clear(); + _adapter.notifyDataSetChanged(); + _next.setEnabled(false); + } + + public void onComplete(int status) + { + _next.setEnabled(true); + } + + public void onOutput(String s) + { + int start = 0; + int end = s.length(); + int pos; + do + { + pos = s.indexOf('\n', start); + if(pos != -1) + { + addData(s.substring(start, pos), false); + start = pos+1; + } + } + while(start < end && pos != -1); + if(start < end) + { + addData(s.substring(start, end), true); + } + } + + private void addData(String s, boolean partialLine) + { + if(_partial) + { + String last = _strings.removeLast(); + last = last + s; + _strings.add(last); + _adapter.notifyDataSetChanged(); + } + else + { + _adapter.add(s); + } + _partial = partialLine; + } +} |