/soc/2012/michael/android: ba4b2b99e83c: Added a project for jun...

Michael Zangl michael at soc.pidgin.im
Wed Jul 18 06:29:28 EDT 2012


Changeset: ba4b2b99e83c31432af2bf486406a553540f1695
Author:	 Michael Zangl <michael at soc.pidgin.im>
Date:	 2012-07-18 12:28 +0200
Branch:	 soc.2012.android
URL: http://hg.pidgin.im/soc/2012/michael/android/rev/ba4b2b99e83c

Description:

Added a project for junit test cases.

diffstat:

 android/workspace/tests/.classpath                                             |   8 +
 android/workspace/tests/.project                                               |  17 +++
 android/workspace/tests/.settings/org.eclipse.jdt.core.prefs                   |  11 ++
 android/workspace/tests/src/im/pidgin/libpurple/tests/account/AccountTest.java |  25 +++++
 android/workspace/tests/src/im/pidgin/libpurple/tests/setup/PurpleTest.java    |  43 ++++++++++
 5 files changed, 104 insertions(+), 0 deletions(-)

diffs (129 lines):

diff --git a/android/workspace/tests/.classpath b/android/workspace/tests/.classpath
new file mode 100644
--- /dev/null
+++ b/android/workspace/tests/.classpath
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+	<classpathentry combineaccessrules="false" kind="src" path="/im.pidgin.libpurple"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
+	<classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/android/workspace/tests/.project b/android/workspace/tests/.project
new file mode 100644
--- /dev/null
+++ b/android/workspace/tests/.project
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>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/android/workspace/tests/.settings/org.eclipse.jdt.core.prefs b/android/workspace/tests/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
--- /dev/null
+++ b/android/workspace/tests/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,11 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
diff --git a/android/workspace/tests/src/im/pidgin/libpurple/tests/account/AccountTest.java b/android/workspace/tests/src/im/pidgin/libpurple/tests/account/AccountTest.java
new file mode 100644
--- /dev/null
+++ b/android/workspace/tests/src/im/pidgin/libpurple/tests/account/AccountTest.java
@@ -0,0 +1,25 @@
+package im.pidgin.libpurple.tests.account;
+
+import static org.junit.Assert.assertTrue;
+import im.pidgin.libpurple.plugin.PurpleProtocolPlugin;
+import im.pidgin.libpurple.tests.setup.PurpleTest;
+
+import java.io.File;
+
+import org.junit.Test;
+
+public class AccountTest extends PurpleTest {
+
+	@Test(timeout=15000)
+	public void test() throws InterruptedException {
+		for (PurpleProtocolPlugin protocol : instance.getPluginList()
+				.getProtocolPlugins()) {
+			instance.getAccountList().addAccount("abc", protocol);
+		}
+		
+		Thread.sleep(7000);
+		
+		assertTrue("Accounts saved", new File(purpleDir, "accounts.xml").exists());
+	}
+
+}
diff --git a/android/workspace/tests/src/im/pidgin/libpurple/tests/setup/PurpleTest.java b/android/workspace/tests/src/im/pidgin/libpurple/tests/setup/PurpleTest.java
new file mode 100644
--- /dev/null
+++ b/android/workspace/tests/src/im/pidgin/libpurple/tests/setup/PurpleTest.java
@@ -0,0 +1,43 @@
+package im.pidgin.libpurple.tests.setup;
+
+import im.pidgin.libpurple.core.PurpleInstance;
+import im.pidgin.libpurple.core.PurpleLibraryLoader;
+
+import java.io.File;
+
+import org.junit.After;
+import org.junit.Before;
+
+public class PurpleTest {
+
+	protected PurpleInstance instance;
+	protected File purpleDir;
+
+	@Before
+	public void setUp() throws Exception {
+		System.loadLibrary("purple");
+		System.loadLibrary("im.pidgin.libpurple");
+		PurpleLibraryLoader.fakeLoad();
+		
+		purpleDir = File.createTempFile("purpletest_", "");
+		purpleDir.delete();
+		purpleDir.mkdirs();
+		instance = PurpleInstance.createInstance("test", purpleDir);
+	}
+
+	@After
+	public void tearDown() throws Exception {
+		delete(purpleDir);
+	}
+
+	private void delete(File dir) {
+		if (dir.isDirectory()) {
+			for (File c : dir.listFiles()) {
+				delete(c);
+			}
+		}
+
+		dir.delete();
+	}
+
+}



More information about the Commits mailing list