Skip to content

Commit 7c622a8

Browse files
author
maskara
committed
Upload tests
1 parent c926437 commit 7c622a8

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package fr.free.nrw.commons.upload;
2+
3+
import android.net.Uri;
4+
import android.support.test.InstrumentationRegistry;
5+
import android.support.test.runner.AndroidJUnit4;
6+
7+
import org.junit.Test;
8+
import org.junit.runner.RunWith;
9+
10+
import static org.hamcrest.CoreMatchers.is;
11+
import static org.junit.Assert.assertThat;
12+
13+
@RunWith(AndroidJUnit4.class)
14+
public class FileUtilsTest {
15+
@Test
16+
public void isSelfOwned() throws Exception {
17+
Uri uri = Uri.parse("content://fr.free.nrw.commons.provider/document/1");
18+
boolean selfOwned = FileUtils.isSelfOwned(InstrumentationRegistry.getTargetContext(), uri);
19+
assertThat(selfOwned, is(true));
20+
}
21+
22+
@Test
23+
public void isNotSelfOwned() throws Exception {
24+
Uri uri = Uri.parse("content://com.android.providers.media.documents/document/1");
25+
boolean selfOwned = FileUtils.isSelfOwned(InstrumentationRegistry.getTargetContext(), uri);
26+
assertThat(selfOwned, is(false));
27+
}
28+
29+
@Test
30+
public void getPathWithExternalImage() throws Exception {
31+
String expectedPath = "/storage/emulated/0/ZetaTemp/IMG_20170703_133510.625.jpeg";
32+
Uri uri = Uri.parse("content://com.android.providers.media.documents/document/image:68");
33+
String path = FileUtils.getPath(InstrumentationRegistry.getTargetContext(), uri);
34+
assertThat(path, is(expectedPath));
35+
}
36+
37+
@Test
38+
public void getPathWithDownloadedImage() throws Exception {
39+
String expectedPath = "/storage/emulated/0/Download/mathematics.jpg";
40+
Uri uri = Uri.parse("content://com.android.providers.downloads.documents/document/43");
41+
String path = FileUtils.getPath(InstrumentationRegistry.getTargetContext(), uri);
42+
assertThat(path, is(expectedPath));
43+
}
44+
45+
@Test
46+
public void getDataColumn() throws Exception {
47+
}
48+
}

0 commit comments

Comments
 (0)