summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorChristopher Wiley <wiley@google.com>2016-03-09 09:22:35 -0800
committerChristopher Wiley <wiley@google.com>2016-03-10 15:32:57 -0800
commit6bde2e9c8fd5082201a6bd1c1097017dc315078c (patch)
tree4923fbdb505c4302ff851079830ed93077f2c873 /tests
parent33375d7e672c854b3691ae5fd17af782ff49b3aa (diff)
downloadandroid_system_tools_aidl-6bde2e9c8fd5082201a6bd1c1097017dc315078c.tar.gz
android_system_tools_aidl-6bde2e9c8fd5082201a6bd1c1097017dc315078c.tar.bz2
android_system_tools_aidl-6bde2e9c8fd5082201a6bd1c1097017dc315078c.zip
Refactor Java test components into separate files
This will help us split tests into multiple files for ease of maintenance. Bug: 27156495 Change-Id: Ie0198380942dbbad37bca319e90344c98467c146 Test: integration tests pass
Diffstat (limited to 'tests')
-rw-r--r--tests/java_app/src/android/aidl/tests/TestFailException.java24
-rw-r--r--tests/java_app/src/android/aidl/tests/TestLogger.java53
-rw-r--r--tests/java_app/src/android/aidl/tests/TestServiceClient.java44
3 files changed, 81 insertions, 40 deletions
diff --git a/tests/java_app/src/android/aidl/tests/TestFailException.java b/tests/java_app/src/android/aidl/tests/TestFailException.java
new file mode 100644
index 0000000..de000fa
--- /dev/null
+++ b/tests/java_app/src/android/aidl/tests/TestFailException.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright (C) 2016, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.aidl.tests;
+
+public class TestFailException extends Exception {
+ public TestFailException(String message) {
+ super(message);
+ }
+}
+
diff --git a/tests/java_app/src/android/aidl/tests/TestLogger.java b/tests/java_app/src/android/aidl/tests/TestLogger.java
new file mode 100644
index 0000000..4cafe52
--- /dev/null
+++ b/tests/java_app/src/android/aidl/tests/TestLogger.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2016, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.aidl.tests;
+
+import android.util.Log;
+import java.io.PrintWriter;
+import java.io.IOException;
+import android.content.Context;
+
+public class TestLogger {
+ private static final String TAG = "TestServiceClient";
+ private PrintWriter mLogFile;
+
+ public TestLogger(Context context) {
+ try {
+ mLogFile = new PrintWriter(context.openFileOutput(
+ "test-client.log", Context.MODE_WORLD_READABLE));
+ } catch (IOException ex) {
+ throw new RuntimeException("Failed to open log file for writing.");
+ }
+ }
+
+ public void log(String line) {
+ Log.i(TAG, line);
+ mLogFile.println(line);
+ }
+
+ public void logAndThrow(String line) throws TestFailException {
+ Log.e(TAG, line);
+ mLogFile.println(line);
+ throw new TestFailException(line);
+ }
+
+ public void close() {
+ if (mLogFile != null) {
+ mLogFile.close();
+ }
+ }
+}
diff --git a/tests/java_app/src/android/aidl/tests/TestServiceClient.java b/tests/java_app/src/android/aidl/tests/TestServiceClient.java
index 1494dd2..f09a7fa 100644
--- a/tests/java_app/src/android/aidl/tests/TestServiceClient.java
+++ b/tests/java_app/src/android/aidl/tests/TestServiceClient.java
@@ -17,6 +17,8 @@
package android.aidl.tests;
import android.aidl.tests.SimpleParcelable;
+import android.aidl.tests.TestFailException;
+import android.aidl.tests.TestLogger;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
@@ -32,7 +34,6 @@ import java.io.FileDescriptor;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
-import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -45,50 +46,13 @@ import android.aidl.tests.ITestService;
public class TestServiceClient extends Activity {
private static final String TAG = "TestServiceClient";
- public class TestFailException extends Exception {
- public TestFailException(String message) {
- super(message);
- }
- }
-
- private class Logger {
- private PrintWriter mLogFile;
-
- public Logger() {
- try {
- mLogFile = new PrintWriter(openFileOutput(
- "test-client.log", Context.MODE_WORLD_READABLE));
- } catch (IOException ex) {
- throw new RuntimeException("Failed to open log file for writing.");
- }
- }
-
- public void log(String line) {
- Log.i(TAG, line);
- mLogFile.println(line);
- }
-
- public void logAndThrow(String line) throws TestFailException {
- Log.e(TAG, line);
- mLogFile.println(line);
- throw new TestFailException(line);
- }
-
- public void close() {
- if (mLogFile != null) {
- mLogFile.close();
- }
- }
- }
-
-
- private Logger mLog;
+ private TestLogger mLog;
private String mSuccessSentinel;
private String mFailureSentinel;
private void init() {
Intent intent = getIntent();
- mLog = new Logger();
+ mLog = new TestLogger(this);
mLog.log("Reading sentinels from intent...");
mSuccessSentinel = intent.getStringExtra("sentinel.success");
mFailureSentinel = intent.getStringExtra("sentinel.failure");