diff options
author | daniel oeh <daniel.oeh@gmail.com> | 2013-08-11 12:52:41 +0200 |
---|---|---|
committer | daniel oeh <daniel.oeh@gmail.com> | 2013-08-11 12:52:41 +0200 |
commit | b0fdb2e8f1ae8ef90c937fb473015e5fde90276b (patch) | |
tree | 20d03b418430a9d0f1325d132cdfce637f97f63a /src/instrumentationTest/de/test/antennapod/util | |
parent | 8e16ad08c883615f64c21fcc4c54c1a565bf0b1b (diff) | |
download | AntennaPod-b0fdb2e8f1ae8ef90c937fb473015e5fde90276b.zip |
Restructured unit test folders to support the new build system
Diffstat (limited to 'src/instrumentationTest/de/test/antennapod/util')
-rw-r--r-- | src/instrumentationTest/de/test/antennapod/util/FilenameGeneratorTest.java | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/src/instrumentationTest/de/test/antennapod/util/FilenameGeneratorTest.java b/src/instrumentationTest/de/test/antennapod/util/FilenameGeneratorTest.java new file mode 100644 index 000000000..552d34941 --- /dev/null +++ b/src/instrumentationTest/de/test/antennapod/util/FilenameGeneratorTest.java @@ -0,0 +1,59 @@ +package instrumentationTest.de.test.antennapod.util; + +import java.io.File; +import java.io.IOException; + +import de.danoeh.antennapod.util.FileNameGenerator; +import android.test.AndroidTestCase; + +public class FilenameGeneratorTest extends AndroidTestCase { + + private static final String VALID1 = "abc abc"; + private static final String INVALID1 = "ab/c: <abc"; + private static final String INVALID2 = "abc abc "; + + public FilenameGeneratorTest() { + super(); + } + + public void testGenerateFileName() throws IOException { + String result = FileNameGenerator.generateFileName(VALID1); + assertEquals(result, VALID1); + createFiles(result); + } + + public void testGenerateFileName1() throws IOException { + String result = FileNameGenerator.generateFileName(INVALID1); + assertEquals(result, VALID1); + createFiles(result); + } + + public void testGenerateFileName2() throws IOException { + String result = FileNameGenerator.generateFileName(INVALID2); + assertEquals(result, VALID1); + createFiles(result); + } + + /** + * Tests if files can be created. + * + * @throws IOException + */ + private void createFiles(String name) throws IOException { + File cache = getContext().getExternalCacheDir(); + File testFile = new File(cache, name); + testFile.mkdir(); + assertTrue(testFile.exists()); + testFile.delete(); + assertTrue(testFile.createNewFile()); + + } + + @Override + protected void tearDown() throws Exception { + super.tearDown(); + File f = new File(getContext().getExternalCacheDir(), VALID1); + f.delete(); + } + +} |