use of com.facebook.share.model.ShareOpenGraphAction in project facebook-android-sdk by facebook.
the class ShareContentValidationTest method testItValidatesShareOpenGraphWithPreviewPropertyNameByMessage.
@Test(expected = FacebookException.class)
public void testItValidatesShareOpenGraphWithPreviewPropertyNameByMessage() {
ShareOpenGraphAction shareOpenGraphAction = new ShareOpenGraphAction.Builder().setActionType("foo").build();
ShareOpenGraphContent shareOpenGraphContent = new ShareOpenGraphContent.Builder().setAction(shareOpenGraphAction).build();
ShareContentValidation.validateForMessage(shareOpenGraphContent);
}
use of com.facebook.share.model.ShareOpenGraphAction in project facebook-android-sdk by facebook.
the class ShareContentValidationTest method testItValidateShareOpenGraphWithNoTypeByMessage.
@Test(expected = FacebookException.class)
public void testItValidateShareOpenGraphWithNoTypeByMessage() {
ShareOpenGraphAction shareOpenGraphAction = new ShareOpenGraphAction.Builder().setActionType(null).build();
ShareOpenGraphContent shareOpenGraphContent = new ShareOpenGraphContent.Builder().setAction(shareOpenGraphAction).build();
ShareContentValidation.validateForMessage(shareOpenGraphContent);
}
use of com.facebook.share.model.ShareOpenGraphAction in project facebook-android-sdk by facebook.
the class ShareContentValidationTest method testItAcceptsShareOpenGraphContent.
@Test
public void testItAcceptsShareOpenGraphContent() {
String actionKey = "foo";
String actionValue = "fooValue";
ShareOpenGraphAction shareOpenGraphAction = new ShareOpenGraphAction.Builder().putString(actionKey, actionValue).setActionType(actionKey).build();
ShareOpenGraphContent shareOpenGraphContent = new ShareOpenGraphContent.Builder().setPreviewPropertyName(actionKey).setAction(shareOpenGraphAction).build();
ShareContentValidation.validateForMessage(shareOpenGraphContent);
ShareContentValidation.validateForNativeShare(shareOpenGraphContent);
ShareContentValidation.validateForApiShare(shareOpenGraphContent);
ShareContentValidation.validateForWebShare(shareOpenGraphContent);
}
use of com.facebook.share.model.ShareOpenGraphAction in project react-native-fbsdk by facebook.
the class Utility method buildShareOpenGraphAction.
public static ShareOpenGraphAction buildShareOpenGraphAction(ReadableMap shareOpenGraphActionMap) {
ShareOpenGraphAction.Builder contentBuilder = new ShareOpenGraphAction.Builder();
contentBuilder.setActionType(shareOpenGraphActionMap.getString("actionType"));
ReadableMap properties = shareOpenGraphActionMap.getMap("_properties");
ReadableMapKeySetIterator keySetIterator = properties.keySetIterator();
while (keySetIterator.hasNextKey()) {
String key = keySetIterator.nextKey();
ReadableMap entry = properties.getMap(key);
contentBuilder.putObject(key, buildShareOpenGraphObject(entry.getMap("value")));
}
return contentBuilder.build();
}
use of com.facebook.share.model.ShareOpenGraphAction in project facebook-android-sdk by facebook.
the class RequestTests method testShareOpenGraphContent.
@LargeTest
public void testShareOpenGraphContent() throws Exception {
ShareOpenGraphObject ogObject = new ShareOpenGraphObject.Builder().putString("og:title", "a title").putString("og:type", TEST_OG_OBJECT_TYPE).putString("og:description", "a description").build();
ShareOpenGraphAction ogAction = new ShareOpenGraphAction.Builder().setActionType(TEST_OG_ACTION_TYPE).putObject("test", ogObject).build();
ShareOpenGraphContent content = new ShareOpenGraphContent.Builder().setAction(ogAction).setPreviewPropertyName("test").build();
final ShareApi shareApi = new ShareApi(content);
final AtomicReference<String> actionId = new AtomicReference<>(null);
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
shareApi.share(new FacebookCallback<Sharer.Result>() {
@Override
public void onSuccess(Sharer.Result result) {
actionId.set(result.getPostId());
notifyShareFinished();
}
@Override
public void onCancel() {
notifyShareFinished();
}
@Override
public void onError(FacebookException error) {
notifyShareFinished();
}
private void notifyShareFinished() {
synchronized (shareApi) {
shareApi.notifyAll();
}
}
});
}
});
synchronized (shareApi) {
shareApi.wait(REQUEST_TIMEOUT_MILLIS);
}
assertNotNull(actionId.get());
}
Aggregations