-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Expand file tree
/
Copy pathAttachmentsHelperTest.java
More file actions
51 lines (42 loc) · 1.52 KB
/
AttachmentsHelperTest.java
File metadata and controls
51 lines (42 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package it.feio.android.omninotes.helpers;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import android.net.Uri;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import it.feio.android.omninotes.models.Attachment;
import java.io.File;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@RunWith(AndroidJUnit4.class)
public class AttachmentsHelperTest {
private Attachment testAttachment;
@Before
public void setUp() {
Uri uri = Uri.fromFile(new File("/path/to/test/file"));
testAttachment = new Attachment(uri, "image/jpeg");
testAttachment.setSize(1024); // Set size to 1KB for testing
}
@Test
public void testGetSize() {
String expectedSize = "1 KB";
String actualSize = AttachmentsHelper.getSize(testAttachment);
assertEquals("The size should be 1 KB", expectedSize, actualSize);
}
@Test
public void testGetSizeWithZeroSize() {
testAttachment.setSize(0); // Simulate a zero size
String actualSize = AttachmentsHelper.getSize(testAttachment);
assertTrue("The size should be greater than 0", actualSize.contains("bytes"));
}
@Test
public void testTypeOf() {
assertTrue("The attachment should be of type image/jpeg",
AttachmentsHelper.typeOf(testAttachment, "image/jpeg"));
}
@Test
public void testTypeOfWithMultipleMimeTypes() {
assertTrue("The attachment should be of type image/jpeg or image/png",
AttachmentsHelper.typeOf(testAttachment, "image/jpeg", "image/png"));
}
}