[Android] TestCase implementation

Geoffrey Métais git at videolan.org
Tue May 12 14:40:50 CEST 2015


vlc-ports/android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon May 11 14:55:05 2015 +0200| [a342f479ab029263c4064c8c66eb3bbb038c09ef] | committer: Geoffrey Métais

TestCase implementation

Only run tests for 2 utils method for now.

> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=a342f479ab029263c4064c8c66eb3bbb038c09ef
---

 .../src/org/videolan/vlc/tests/VLCTests.java       |   59 ++++++++++++++++++++
 1 file changed, 59 insertions(+)

diff --git a/vlc-android/src/org/videolan/vlc/tests/VLCTests.java b/vlc-android/src/org/videolan/vlc/tests/VLCTests.java
new file mode 100644
index 0000000..6c4af61
--- /dev/null
+++ b/vlc-android/src/org/videolan/vlc/tests/VLCTests.java
@@ -0,0 +1,59 @@
+package org.videolan.vlc.tests;
+
+import android.annotation.TargetApi;
+import android.os.Build;
+import android.test.ActivityInstrumentationTestCase2;
+
+import org.videolan.vlc.gui.MainActivity;
+import org.videolan.vlc.util.Strings;
+
+/**
+ * Created by geoffrey on 08/05/15.
+ */
+public class VLCTests extends ActivityInstrumentationTestCase2<MainActivity>{
+
+//    private MainActivity mFirstTestActivity;
+//
+//    @TargetApi(Build.VERSION_CODES.FROYO)
+//    public VLCTests(Class<MainActivity> activityClass) {
+//        super(activityClass);
+//    }
+
+    @TargetApi(Build.VERSION_CODES.FROYO)
+    public VLCTests(){
+        super(MainActivity.class);
+    }
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+//        mFirstTestActivity = getActivity();
+    }
+
+    public void testGetName(){
+        String path = "/home/folder/file.txt";
+        assertEquals("", Strings.getName(null));
+        assertEquals("", Strings.getName("/"));
+        assertEquals("file.txt", Strings.getName(path));
+    }
+
+    public void testGetParent() {
+        String result = Strings.getParent("");
+        assertEquals("", result);
+
+        result = Strings.getParent("/");
+        assertEquals("/", result);
+
+        result = Strings.getParent("/folder");
+        assertEquals("/", result);
+
+        result = Strings.getParent("/folder/");
+        assertEquals("/", result);
+
+        result = Strings.getParent("/folder/sub");
+        assertEquals("/folder", result);
+
+        result = Strings.getParent("/folder/sub/");
+        assertEquals("/folder", result);
+    }
+}



More information about the Android mailing list