aboutsummaryrefslogtreecommitdiffstats
path: root/testutils/tests
diff options
context:
space:
mode:
Diffstat (limited to 'testutils/tests')
-rw-r--r--testutils/tests/.classpath9
-rw-r--r--testutils/tests/.project17
-rw-r--r--testutils/tests/Android.mk27
-rw-r--r--testutils/tests/src/com/android/testutils/SdkTestCaseTest.java161
4 files changed, 214 insertions, 0 deletions
diff --git a/testutils/tests/.classpath b/testutils/tests/.classpath
new file mode 100644
index 0000000..0ac1351
--- /dev/null
+++ b/testutils/tests/.classpath
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/sdktestutils"/>
+ <classpathentry kind="var" path="ANDROID_SRC/prebuilts/tools/common/guava-tools/guava-13.0.1.jar" sourcepath="/ANDROID_SRC/prebuilts/tools/common/guava-tools/src.zip"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/testutils/tests/.project b/testutils/tests/.project
new file mode 100644
index 0000000..3191084
--- /dev/null
+++ b/testutils/tests/.project
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>testutils-tests</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/testutils/tests/Android.mk b/testutils/tests/Android.mk
new file mode 100644
index 0000000..e203ab4
--- /dev/null
+++ b/testutils/tests/Android.mk
@@ -0,0 +1,27 @@
+# Copyright (C) 2012 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.
+
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+
+# Only compile source java files in this lib.
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
+
+LOCAL_MODULE := sdktestutils-tests
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_JAVA_LIBRARIES := common sdktestutils junit
+
+include $(BUILD_HOST_JAVA_LIBRARY)
diff --git a/testutils/tests/src/com/android/testutils/SdkTestCaseTest.java b/testutils/tests/src/com/android/testutils/SdkTestCaseTest.java
new file mode 100644
index 0000000..9ab1a68
--- /dev/null
+++ b/testutils/tests/src/com/android/testutils/SdkTestCaseTest.java
@@ -0,0 +1,161 @@
+/*
+ * Copyright (C) 2012 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 com.android.testutils;
+
+import junit.framework.TestCase;
+
+@SuppressWarnings("javadoc")
+public class SdkTestCaseTest extends TestCase {
+ public void testDiff() throws Exception {
+ assertEquals(
+ "",
+ SdkTestCase.getDiff(
+ "",
+ ""));
+ assertEquals(
+ "",
+ SdkTestCase.getDiff(
+ "aaa",
+ "aaa"));
+ assertEquals(
+ "@@ -1 +1\n" +
+ "- aaa\n" +
+ "@@ -2 +1\n" +
+ "+ bbb\n",
+ SdkTestCase.getDiff(
+ "aaa",
+ "bbb"));
+ assertEquals(
+ "@@ -1 +1\n" +
+ "- this\n" +
+ "@@ -4 +3\n" +
+ "+ new\n",
+ SdkTestCase.getDiff(
+ "this\n" +
+ "is\n" +
+ "a\n" +
+ "test\n",
+
+ "is\n" +
+ "a\n" +
+ "new\n" +
+ "test\n"));
+ assertEquals(
+ "@@ -4 +4\n" +
+ "- line4\n" +
+ "- line5\n" +
+ "@@ -8 +6\n" +
+ "- line8\n" +
+ "+ line7.5\n",
+ SdkTestCase.getDiff(
+ "line1\n" +
+ "line2\n" +
+ "line3\n" +
+ "line4\n" +
+ "line5\n" +
+ "line6\n" +
+ "line7\n" +
+ "line8\n" +
+ "line9\n",
+
+ "line1\n" +
+ "line2\n" +
+ "line3\n" +
+ "line6\n" +
+ "line7\n" +
+ "line7.5\n" +
+ "line9\n"));
+ assertEquals(
+ "@@ -8 +8\n" +
+ "- android:id=\"@+id/textView1\"\n" +
+ "+ android:id=\"@+id/output\"\n" +
+ "@@ -19 +19\n" +
+ "- android:layout_alignLeft=\"@+id/textView1\"\n" +
+ "- android:layout_below=\"@+id/textView1\"\n" +
+ "+ android:layout_alignLeft=\"@+id/output\"\n" +
+ "+ android:layout_below=\"@+id/output\"\n",
+
+ SdkTestCase.getDiff(
+ "<RelativeLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n" +
+ " xmlns:tools=\"http://schemas.android.com/tools\"\n" +
+ " android:layout_width=\"match_parent\"\n" +
+ " android:layout_height=\"match_parent\"\n" +
+ " tools:context=\".MainActivity\" >\n" +
+ "\n" +
+ " <TextView\n" +
+ " android:id=\"@+id/textView1\"\n" +
+ " android:layout_width=\"wrap_content\"\n" +
+ " android:layout_height=\"wrap_content\"\n" +
+ " android:layout_centerVertical=\"true\"\n" +
+ " android:layout_toRightOf=\"@+id/button2\"\n" +
+ " android:text=\"@string/hello_world\" />\n" +
+ "\n" +
+ " <Button\n" +
+ " android:id=\"@+id/button1\"\n" +
+ " android:layout_width=\"wrap_content\"\n" +
+ " android:layout_height=\"wrap_content\"\n" +
+ " android:layout_alignLeft=\"@+id/textView1\"\n" +
+ " android:layout_below=\"@+id/textView1\"\n" +
+ " android:layout_marginLeft=\"22dp\"\n" +
+ " android:layout_marginTop=\"24dp\"\n" +
+ " android:text=\"Button\" />\n" +
+ "\n" +
+ " <Button\n" +
+ " android:id=\"@+id/button2\"\n" +
+ " android:layout_width=\"wrap_content\"\n" +
+ " android:layout_height=\"wrap_content\"\n" +
+ " android:layout_alignParentLeft=\"true\"\n" +
+ " android:layout_alignParentTop=\"true\"\n" +
+ " android:text=\"Button\" />\n" +
+ "\n" +
+ "</RelativeLayout>",
+
+ "<RelativeLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n" +
+ " xmlns:tools=\"http://schemas.android.com/tools\"\n" +
+ " android:layout_width=\"match_parent\"\n" +
+ " android:layout_height=\"match_parent\"\n" +
+ " tools:context=\".MainActivity\" >\n" +
+ "\n" +
+ " <TextView\n" +
+ " android:id=\"@+id/output\"\n" +
+ " android:layout_width=\"wrap_content\"\n" +
+ " android:layout_height=\"wrap_content\"\n" +
+ " android:layout_centerVertical=\"true\"\n" +
+ " android:layout_toRightOf=\"@+id/button2\"\n" +
+ " android:text=\"@string/hello_world\" />\n" +
+ "\n" +
+ " <Button\n" +
+ " android:id=\"@+id/button1\"\n" +
+ " android:layout_width=\"wrap_content\"\n" +
+ " android:layout_height=\"wrap_content\"\n" +
+ " android:layout_alignLeft=\"@+id/output\"\n" +
+ " android:layout_below=\"@+id/output\"\n" +
+ " android:layout_marginLeft=\"22dp\"\n" +
+ " android:layout_marginTop=\"24dp\"\n" +
+ " android:text=\"Button\" />\n" +
+ "\n" +
+ " <Button\n" +
+ " android:id=\"@+id/button2\"\n" +
+ " android:layout_width=\"wrap_content\"\n" +
+ " android:layout_height=\"wrap_content\"\n" +
+ " android:layout_alignParentLeft=\"true\"\n" +
+ " android:layout_alignParentTop=\"true\"\n" +
+ " android:text=\"Button\" />\n" +
+ "\n" +
+ "</RelativeLayout>"));
+ }
+}