Search in sources :

Example 1 with ContentAttachment

use of i2p.bote.android.util.ContentAttachment in project i2p.i2p-bote by i2p.

the class AttachmentProviderTests method queryWithValidTextUri.

@Test
public void queryWithValidTextUri() throws Exception {
    ContentAttachment attachment = createTextAttachment();
    Uri uri = createEmailWithAttachment(attachment);
    Cursor c = getMockContentResolver().query(uri, null, null, null, null);
    assertThat(c.getCount(), is(1));
    int nameIndex = c.getColumnIndex(OpenableColumns.DISPLAY_NAME);
    int sizeIndex = c.getColumnIndex(OpenableColumns.SIZE);
    c.moveToFirst();
    assertThat(c.getString(nameIndex), is(equalTo(attachment.getFileName())));
    assertThat(c.getLong(sizeIndex), is(equalTo(attachment.getSize())));
}
Also used : ContentAttachment(i2p.bote.android.util.ContentAttachment) Cursor(android.database.Cursor) Uri(android.net.Uri) LargeTest(android.test.suitebuilder.annotation.LargeTest) Test(org.junit.Test)

Example 2 with ContentAttachment

use of i2p.bote.android.util.ContentAttachment in project i2p.i2p-bote by i2p.

the class AttachmentProviderTests method getTypeWithValidTextUri.

@Test
public void getTypeWithValidTextUri() throws Exception {
    ContentAttachment attachment = createTextAttachment();
    Uri uri = createEmailWithAttachment(attachment);
    String type = getMockContentResolver().getType(uri);
    assertThat("Type was not correct", type, is("text/plain"));
}
Also used : ContentAttachment(i2p.bote.android.util.ContentAttachment) Uri(android.net.Uri) LargeTest(android.test.suitebuilder.annotation.LargeTest) Test(org.junit.Test)

Example 3 with ContentAttachment

use of i2p.bote.android.util.ContentAttachment in project i2p.i2p-bote by i2p.

the class AttachmentProviderTests method getTypeWithValidImageUri.

@Test
public void getTypeWithValidImageUri() throws Exception {
    ContentAttachment attachment = createImageAttachment();
    Uri uri = createEmailWithAttachment(attachment);
    String type = getMockContentResolver().getType(uri);
    assertThat("Type was not correct", type, is("image/png"));
}
Also used : ContentAttachment(i2p.bote.android.util.ContentAttachment) Uri(android.net.Uri) LargeTest(android.test.suitebuilder.annotation.LargeTest) Test(org.junit.Test)

Example 4 with ContentAttachment

use of i2p.bote.android.util.ContentAttachment in project i2p.i2p-bote by i2p.

the class AttachmentProviderTests method openFileWithValidTextUri.

@Test
public void openFileWithValidTextUri() throws Exception {
    ContentAttachment attachment = createTextAttachment();
    Uri uri = createEmailWithAttachment(attachment);
    openFileWithValidUri(attachment, uri);
}
Also used : ContentAttachment(i2p.bote.android.util.ContentAttachment) Uri(android.net.Uri) LargeTest(android.test.suitebuilder.annotation.LargeTest) Test(org.junit.Test)

Example 5 with ContentAttachment

use of i2p.bote.android.util.ContentAttachment in project i2p.i2p-bote by i2p.

the class AttachmentProviderTests method openFileWithValidImageUri.

@Test
public void openFileWithValidImageUri() throws Exception {
    ContentAttachment attachment = createImageAttachment();
    Uri uri = createEmailWithAttachment(attachment);
    openFileWithValidUri(attachment, uri);
    assertThat("Image could not be decoded", BitmapFactory.decodeStream(getMockContentResolver().openInputStream(uri)), is(notNullValue()));
}
Also used : ContentAttachment(i2p.bote.android.util.ContentAttachment) Uri(android.net.Uri) LargeTest(android.test.suitebuilder.annotation.LargeTest) Test(org.junit.Test)

Aggregations

ContentAttachment (i2p.bote.android.util.ContentAttachment)8 Uri (android.net.Uri)5 LargeTest (android.test.suitebuilder.annotation.LargeTest)5 Test (org.junit.Test)5 View (android.view.View)2 ImageView (android.widget.ImageView)2 TextView (android.widget.TextView)2 IconicsDrawable (com.mikepenz.iconics.IconicsDrawable)2 IOException (java.io.IOException)2 Part (javax.mail.Part)2 Intent (android.content.Intent)1 Cursor (android.database.Cursor)1 Bitmap (android.graphics.Bitmap)1 PopupMenu (android.support.v7.widget.PopupMenu)1 MenuItem (android.view.MenuItem)1 LinearLayout (android.widget.LinearLayout)1 ContactsCompletionView (i2p.bote.android.widget.ContactsCompletionView)1 PasswordException (i2p.bote.fileencryption.PasswordException)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 FileNotFoundException (java.io.FileNotFoundException)1