Java Code Examples for com.facebook.model.OpenGraphAction#setProperty()
The following examples show how to use
com.facebook.model.OpenGraphAction#setProperty() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FacebookDialogTests.java From FacebookImageShareIntent with MIT License | 6 votes |
public void testOpenGraphActionImageAttachments() throws JSONException { OpenGraphAction action = OpenGraphAction.Factory.createForPost("foo"); action.setProperty("foo", "bar"); FacebookDialog.OpenGraphActionDialogBuilder builder = new FacebookDialog.OpenGraphActionDialogBuilder(getActivity(), action, "foo"); Bitmap bitmap = Bitmap.createBitmap(20, 20, Bitmap.Config.ALPHA_8); builder.setImageAttachmentsForAction(Arrays.asList(bitmap)); List<JSONObject> images = action.getImage(); assertNotNull(images); assertTrue(images.size() == 1); List<String> attachmentNames = builder.getImageAttachmentNames(); assertNotNull(attachmentNames); assertTrue(attachmentNames.size() == 1); String attachmentName = getAttachmentNameFromContentUri(images.get(0).getString("url")); assertEquals(attachmentNames.get(0), attachmentName); }
Example 2
Source File: FacebookDialogTests.java From FacebookImageShareIntent with MIT License | 6 votes |
public void testOpenGraphObjectImageAttachments() throws JSONException { OpenGraphAction action = OpenGraphAction.Factory.createForPost("foo"); OpenGraphObject object = OpenGraphObject.Factory.createForPost("bar"); action.setProperty("foo", object); FacebookDialog.OpenGraphActionDialogBuilder builder = new FacebookDialog.OpenGraphActionDialogBuilder(getActivity(), action, "foo"); Bitmap bitmap = Bitmap.createBitmap(20, 20, Bitmap.Config.ALPHA_8); builder.setImageAttachmentsForObject("foo", Arrays.asList(bitmap)); List<GraphObject> images = object.getImage(); assertNotNull(images); assertTrue(images.size() == 1); List<String> attachmentNames = builder.getImageAttachmentNames(); assertNotNull(attachmentNames); assertTrue(attachmentNames.size() == 1); String attachmentName = getAttachmentNameFromContentUri((String) images.get(0).getProperty("url")); assertEquals(attachmentNames.get(0), attachmentName); }
Example 3
Source File: FacebookDialogTests.java From FacebookImageShareIntent with MIT License | 5 votes |
public void testCantSetAttachmentsWithNullBitmaps() { try { OpenGraphAction action = OpenGraphAction.Factory.createForPost("foo"); action.setProperty("foo", "bar"); FacebookDialog.OpenGraphActionDialogBuilder builder = new FacebookDialog.OpenGraphActionDialogBuilder(getActivity(), action, "foo"); builder.setImageAttachmentsForAction(Arrays.asList((Bitmap)null)); fail("expected exception"); } catch (NullPointerException exception) { } }
Example 4
Source File: FacebookDialogTests.java From FacebookImageShareIntent with MIT License | 5 votes |
public void testCantSetObjectAttachmentsWithNonGraphObjectProperty() { try { OpenGraphAction action = OpenGraphAction.Factory.createForPost("foo"); FacebookDialog.OpenGraphActionDialogBuilder builder = new FacebookDialog.OpenGraphActionDialogBuilder(getActivity(), action, "foo"); action.setProperty("foo", "bar"); builder.setImageAttachmentsForObject("foo", new ArrayList<Bitmap>()); fail("expected exception"); } catch (IllegalArgumentException exception) { } }
Example 5
Source File: FacebookDialogTests.java From FacebookImageShareIntent with MIT License | 5 votes |
public void testCantSetObjectAttachmentsWithNullBitmaps() { try { OpenGraphAction action = OpenGraphAction.Factory.createForPost("foo"); action.setProperty("foo", OpenGraphObject.Factory.createForPost("bar")); FacebookDialog.OpenGraphActionDialogBuilder builder = new FacebookDialog.OpenGraphActionDialogBuilder(getActivity(), action, "foo"); builder.setImageAttachmentsForObject("foo", Arrays.asList((Bitmap)null)); fail("expected exception"); } catch (NullPointerException exception) { } }
Example 6
Source File: FacebookDialogTests.java From FacebookImageShareIntent with MIT License | 5 votes |
public void testOpenGraphActionAndObjectImageAttachments() throws JSONException { OpenGraphAction action = OpenGraphAction.Factory.createForPost("foo"); OpenGraphObject object = OpenGraphObject.Factory.createForPost("bar"); action.setProperty("foo", object); FacebookDialog.OpenGraphActionDialogBuilder builder = new FacebookDialog.OpenGraphActionDialogBuilder(getActivity(), action, "foo"); Bitmap bitmap = Bitmap.createBitmap(20, 20, Bitmap.Config.ALPHA_8); builder.setImageAttachmentsForAction(Arrays.asList(bitmap)); builder.setImageAttachmentsForObject("foo", Arrays.asList(bitmap)); List<String> attachmentNames = builder.getImageAttachmentNames(); assertNotNull(attachmentNames); assertTrue(attachmentNames.size() == 2); List<GraphObject> objectImages = object.getImage(); assertNotNull(objectImages); assertTrue(objectImages.size() == 1); String attachmentName = getAttachmentNameFromContentUri((String) objectImages.get(0).getProperty("url")); assertTrue(attachmentNames.contains(attachmentName)); List<JSONObject> actionImages = action.getImage(); assertNotNull(actionImages); assertTrue(actionImages.size() == 1); attachmentName = getAttachmentNameFromContentUri((String) actionImages.get(0).getString("url")); assertTrue(attachmentNames.contains(attachmentName)); }
Example 7
Source File: FacebookDialogTests.java From FacebookImageShareIntent with MIT License | 5 votes |
@SuppressWarnings("deprecation") public void testOpenGraphDialogBuilderDeprecatedConstructorRequiresActionType() { try { OpenGraphAction action = OpenGraphAction.Factory.createForPost(); OpenGraphObject object = OpenGraphObject.Factory.createForPost("bar"); action.setProperty("object", object); FacebookDialog.OpenGraphActionDialogBuilder builder = new FacebookDialog.OpenGraphActionDialogBuilder(getActivity(), action, "", "object"); builder.build(); fail("expected exception"); } catch (IllegalArgumentException exception) { } }
Example 8
Source File: FacebookDialogTests.java From FacebookImageShareIntent with MIT License | 5 votes |
@SuppressWarnings("deprecation") public void testOpenGraphDialogBuilderDeprecatedConstructorRequiresActionTypeMatches() { try { OpenGraphAction action = OpenGraphAction.Factory.createForPost("foo"); OpenGraphObject object = OpenGraphObject.Factory.createForPost("bar"); action.setProperty("object", object); FacebookDialog.OpenGraphActionDialogBuilder builder = new FacebookDialog.OpenGraphActionDialogBuilder(getActivity(), action, "notfoo", "object"); builder.build(); fail("expected exception"); } catch (IllegalArgumentException exception) { } }