use of com.facebook.share.model.ShareOpenGraphContent 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.ShareOpenGraphContent 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.ShareOpenGraphContent in project facebook-android-sdk by facebook.
the class ShareInternalUtilityTest method testJsonSerializationOfOpenGraph.
@Test
public void testJsonSerializationOfOpenGraph() {
String placeId = "1";
ShareOpenGraphContent content = new ShareOpenGraphContent.Builder().setAction(new ShareOpenGraphAction.Builder().putStringArrayList("tags", new ArrayList<String>() {
{
add("2");
add("4");
}
}).build()).setPeopleIds(new ArrayList<String>() {
{
add("1");
add("1");
add("2");
add("3");
}
}).setPlaceId(placeId).build();
try {
JSONObject object = ShareInternalUtility.toJSONObjectForCall(null, content);
List<String> peopleIds = Utility.jsonArrayToStringList(object.getJSONArray("tags"));
assertEquals(4, peopleIds.size());
for (int i = 1; i < 5; ++i) {
assertTrue(peopleIds.contains(Integer.valueOf(i).toString()));
}
assertEquals(placeId, object.getString("place"));
} catch (JSONException ex) {
// Fail
assertNotNull(ex);
return;
}
}
use of com.facebook.share.model.ShareOpenGraphContent 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