Initial import of gitter Android test project
authorReto Buerki <reet@codelabs.ch>
Tue, 13 Mar 2012 09:07:54 +0000 (10:07 +0100)
committerReto Buerki <reet@codelabs.ch>
Tue, 13 Mar 2012 09:08:12 +0000 (10:08 +0100)
.classpath [new file with mode: 0644]
.gitignore [new file with mode: 0644]
.project [new file with mode: 0644]
AndroidManifest.xml [new file with mode: 0644]
project.properties [new file with mode: 0644]
res/drawable-hdpi/ic_launcher.png [new file with mode: 0644]
res/drawable-ldpi/ic_launcher.png [new file with mode: 0644]
res/drawable-mdpi/ic_launcher.png [new file with mode: 0644]
res/layout/main.xml [new file with mode: 0644]
res/values/strings.xml [new file with mode: 0644]
src/ch/codelabs/gitter/test/CommitDbAdapterTest.java [new file with mode: 0644]

diff --git a/.classpath b/.classpath
new file mode 100644 (file)
index 0000000..5e43bca
--- /dev/null
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+       <classpathentry kind="src" path="src"/>
+       <classpathentry kind="src" path="gen"/>
+       <classpathentry combineaccessrules="false" kind="src" path="/gitter"/>
+       <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
+       <classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
+       <classpathentry kind="output" path="bin/classes"/>
+</classpath>
diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..e614fbb
--- /dev/null
@@ -0,0 +1,2 @@
+bin
+gen
diff --git a/.project b/.project
new file mode 100644 (file)
index 0000000..e4524b2
--- /dev/null
+++ b/.project
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>gitter-tests</name>
+       <comment></comment>
+       <projects>
+               <project>gitter</project>
+       </projects>
+       <buildSpec>
+               <buildCommand>
+                       <name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.jdt.core.javabuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>com.android.ide.eclipse.adt.ApkBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+       </buildSpec>
+       <natures>
+               <nature>com.android.ide.eclipse.adt.AndroidNature</nature>
+               <nature>org.eclipse.jdt.core.javanature</nature>
+       </natures>
+</projectDescription>
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
new file mode 100644 (file)
index 0000000..3fe12f7
--- /dev/null
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+    package="ch.codelabs.gitter.test"
+    android:versionCode="1"
+    android:versionName="1.0" >
+
+    <uses-sdk android:minSdkVersion="8" />
+
+    <instrumentation
+        android:name="android.test.InstrumentationTestRunner"
+        android:targetPackage="ch.codelabs.gitter" />
+
+    <application
+        android:icon="@drawable/ic_launcher"
+        android:label="@string/app_name" >
+        <uses-library android:name="android.test.runner" />
+    </application>
+
+</manifest>
\ No newline at end of file
diff --git a/project.properties b/project.properties
new file mode 100644 (file)
index 0000000..ea89160
--- /dev/null
@@ -0,0 +1,11 @@
+# This file is automatically generated by Android Tools.
+# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
+#
+# This file must be checked in Version Control Systems.
+#
+# To customize properties used by the Ant build system use,
+# "ant.properties", and override values to adapt the script to your
+# project structure.
+
+# Project target.
+target=android-8
diff --git a/res/drawable-hdpi/ic_launcher.png b/res/drawable-hdpi/ic_launcher.png
new file mode 100644 (file)
index 0000000..8074c4c
Binary files /dev/null and b/res/drawable-hdpi/ic_launcher.png differ
diff --git a/res/drawable-ldpi/ic_launcher.png b/res/drawable-ldpi/ic_launcher.png
new file mode 100644 (file)
index 0000000..1095584
Binary files /dev/null and b/res/drawable-ldpi/ic_launcher.png differ
diff --git a/res/drawable-mdpi/ic_launcher.png b/res/drawable-mdpi/ic_launcher.png
new file mode 100644 (file)
index 0000000..a07c69f
Binary files /dev/null and b/res/drawable-mdpi/ic_launcher.png differ
diff --git a/res/layout/main.xml b/res/layout/main.xml
new file mode 100644 (file)
index 0000000..bc12cd8
--- /dev/null
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="fill_parent"
+    android:layout_height="fill_parent"
+    android:orientation="vertical" >
+
+    <TextView
+        android:layout_width="fill_parent"
+        android:layout_height="wrap_content"
+        android:text="@string/hello" />
+
+</LinearLayout>
\ No newline at end of file
diff --git a/res/values/strings.xml b/res/values/strings.xml
new file mode 100644 (file)
index 0000000..906e32b
--- /dev/null
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+
+    <string name="hello">Hello World!</string>
+    <string name="app_name">Gitter-testsTest</string>
+
+</resources>
\ No newline at end of file
diff --git a/src/ch/codelabs/gitter/test/CommitDbAdapterTest.java b/src/ch/codelabs/gitter/test/CommitDbAdapterTest.java
new file mode 100644 (file)
index 0000000..1512c87
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2012 Martin Kempf <mkempf@hsr.ch>
+ * Copyright (C) 2012 Reto Buerki <reet@codelabs.ch>
+ * Copyright (C) 2012 Adrian-Ken Rueegsegger <ken@codelabs.ch>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.  See <http://www.fsf.org/copyleft/gpl.txt>.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * for more details.
+ */
+
+package ch.codelabs.gitter.test;
+
+import android.database.Cursor;
+import android.test.AndroidTestCase;
+
+import ch.codelabs.gitter.CommitDbAdapter;
+
+public class CommitDbAdapterTest extends AndroidTestCase {
+
+       /*
+        * Register tests.
+        */
+       public CommitDbAdapterTest() {
+               super();
+       }
+
+       /*
+        * Insert commit into database.
+        */
+       public void testInsertCommit() {
+               CommitDbAdapter commitDbAdapter = new CommitDbAdapter(getContext());
+               commitDbAdapter.open();
+
+               long id = commitDbAdapter.insertCommit("Update TODO",
+                               "John Doe doe@example.com", "http://1.com/abc", "testdata");
+
+               Cursor c = commitDbAdapter.fetchAllCommits();
+               assertTrue(c.getCount() > 0);
+
+               c.moveToFirst();
+               assertEquals("Update TODO", c.getString
+                               (c.getColumnIndexOrThrow(CommitDbAdapter.KEY_TITLE)));
+               assertEquals("John Doe doe@example.com", c.getString
+                               (c.getColumnIndexOrThrow(CommitDbAdapter.KEY_AUTHOR)));
+               assertEquals("http://1.com/abc", c.getString
+                               (c.getColumnIndexOrThrow(CommitDbAdapter.KEY_DIFFLINK)));
+               assertEquals("testdata", c.getString
+                               (c.getColumnIndexOrThrow(CommitDbAdapter.KEY_CONTENT)));
+
+               commitDbAdapter.deleteCommit(id);
+               c.close();
+               commitDbAdapter.close();
+       }
+}