Search in sources :

Example 6 with ShareLinkContent

use of com.facebook.share.model.ShareLinkContent in project facebook-android-sdk by facebook.

the class ShareContentValidationTest method testItValidatesNoHttpForShareLinkContentMessage.

// -LinkContent
@Test(expected = FacebookException.class)
public void testItValidatesNoHttpForShareLinkContentMessage() {
    Uri imageUri = Uri.parse("ftp://facebook.com/awesome-content.gif");
    ShareLinkContent linkContent = buildShareLinkContent(imageUri);
    ShareContentValidation.validateForMessage(linkContent);
}
Also used : ShareLinkContent(com.facebook.share.model.ShareLinkContent) Uri(android.net.Uri) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 7 with ShareLinkContent

use of com.facebook.share.model.ShareLinkContent in project facebook-android-sdk by facebook.

the class DeviceShareDialog method showImpl.

@Override
protected void showImpl(final ShareContent content, final Object mode) {
    if (content == null) {
        throw new FacebookException("Must provide non-null content to share");
    }
    if (!(content instanceof ShareLinkContent) && !(content instanceof ShareOpenGraphContent)) {
        throw new FacebookException(this.getClass().getSimpleName() + " only supports ShareLinkContent or ShareOpenGraphContent");
    }
    Intent intent = new Intent();
    intent.setClass(FacebookSdk.getApplicationContext(), FacebookActivity.class);
    intent.setAction(DeviceShareDialogFragment.TAG);
    intent.putExtra("content", content);
    startActivityForResult(intent, getRequestCode());
}
Also used : ShareLinkContent(com.facebook.share.model.ShareLinkContent) FacebookException(com.facebook.FacebookException) Intent(android.content.Intent) ShareOpenGraphContent(com.facebook.share.model.ShareOpenGraphContent)

Example 8 with ShareLinkContent

use of com.facebook.share.model.ShareLinkContent in project facebook-android-sdk by facebook.

the class ShareContentValidationTest method testItAcceptsHttpsForShareLinkContent.

@Test
public void testItAcceptsHttpsForShareLinkContent() {
    Uri imageUri = Uri.parse("https://facebook.com/awesome-content.gif");
    ShareLinkContent linkContent = buildShareLinkContent(imageUri);
    ShareContentValidation.validateForApiShare(linkContent);
    ShareContentValidation.validateForMessage(linkContent);
    ShareContentValidation.validateForNativeShare(linkContent);
    ShareContentValidation.validateForWebShare(linkContent);
}
Also used : ShareLinkContent(com.facebook.share.model.ShareLinkContent) Uri(android.net.Uri) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 9 with ShareLinkContent

use of com.facebook.share.model.ShareLinkContent in project facebook-android-sdk by facebook.

the class ShareContentValidationTest method testItAcceptNullImageForShareLinkContent.

// Valid Share Contents
@Test
public void testItAcceptNullImageForShareLinkContent() {
    ShareLinkContent nullImageContent = buildShareLinkContent(null);
    ShareContentValidation.validateForApiShare(nullImageContent);
    ShareContentValidation.validateForMessage(nullImageContent);
    ShareContentValidation.validateForNativeShare(nullImageContent);
    ShareContentValidation.validateForWebShare(nullImageContent);
}
Also used : ShareLinkContent(com.facebook.share.model.ShareLinkContent) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Aggregations

ShareLinkContent (com.facebook.share.model.ShareLinkContent)9 Test (org.junit.Test)5 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)5 Uri (android.net.Uri)4 FacebookException (com.facebook.FacebookException)3 ShareOpenGraphContent (com.facebook.share.model.ShareOpenGraphContent)3 Bundle (android.os.Bundle)2 SharePhotoContent (com.facebook.share.model.SharePhotoContent)2 ShareVideoContent (com.facebook.share.model.ShareVideoContent)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 JSONException (org.json.JSONException)2 JSONObject (org.json.JSONObject)2 Intent (android.content.Intent)1 ShareMediaContent (com.facebook.share.model.ShareMediaContent)1