Java Code Examples for com.facebook.internal.Utility#arrayList()
The following examples show how to use
com.facebook.internal.Utility#arrayList() .
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: AccessTokenTests.java From FacebookImageShareIntent with MIT License | 6 votes |
@SmallTest @MediumTest @LargeTest public void testFromDialog() { List<String> permissions = Utility.arrayList("stream_publish", "go_outside_and_play"); String token = "AnImaginaryTokenValue"; Bundle bundle = new Bundle(); bundle.putString("access_token", token); bundle.putString("expires_in", "60"); AccessToken accessToken = AccessToken.createFromWebBundle(permissions, bundle, AccessTokenSource.WEB_VIEW); TestUtils.assertSamePermissions(permissions, accessToken); assertEquals(token, accessToken.getToken()); assertEquals(AccessTokenSource.WEB_VIEW, accessToken.getSource()); assertTrue(!accessToken.isInvalid()); }
Example 2
Source File: AccessTokenTests.java From FacebookImageShareIntent with MIT License | 6 votes |
@SmallTest @MediumTest @LargeTest public void testFromSSOWithExpiresString() { List<String> permissions = Utility.arrayList("stream_publish", "go_outside_and_play"); String token = "AnImaginaryTokenValue"; Intent intent = new Intent(); intent.putExtra("access_token", token); intent.putExtra("expires_in", "60"); intent.putExtra("extra_extra", "Something unrelated"); AccessToken accessToken = AccessToken .createFromWebBundle(permissions, intent.getExtras(), AccessTokenSource.FACEBOOK_APPLICATION_WEB); TestUtils.assertSamePermissions(permissions, accessToken); assertEquals(token, accessToken.getToken()); assertEquals(AccessTokenSource.FACEBOOK_APPLICATION_WEB, accessToken.getSource()); assertTrue(!accessToken.isInvalid()); }
Example 3
Source File: AccessTokenTests.java From FacebookImageShareIntent with MIT License | 6 votes |
@SmallTest @MediumTest @LargeTest public void testFromSSOWithExpiresLong() { List<String> permissions = Utility.arrayList("stream_publish", "go_outside_and_play"); String token = "AnImaginaryTokenValue"; Intent intent = new Intent(); intent.putExtra("access_token", token); intent.putExtra("expires_in", 60L); intent.putExtra("extra_extra", "Something unrelated"); AccessToken accessToken = AccessToken .createFromWebBundle(permissions, intent.getExtras(), AccessTokenSource.FACEBOOK_APPLICATION_WEB); TestUtils.assertSamePermissions(permissions, accessToken); assertEquals(token, accessToken.getToken()); assertEquals(AccessTokenSource.FACEBOOK_APPLICATION_WEB, accessToken.getSource()); assertTrue(!accessToken.isInvalid()); }
Example 4
Source File: AccessTokenTests.java From FacebookImageShareIntent with MIT License | 6 votes |
@SmallTest @MediumTest @LargeTest public void testFromNativeLogin() { ArrayList<String> permissions = Utility.arrayList("stream_publish", "go_outside_and_play"); String token = "AnImaginaryTokenValue"; long nowSeconds = new Date().getTime() / 1000; Intent intent = new Intent(); intent.putExtra(NativeProtocol.EXTRA_ACCESS_TOKEN, token); intent.putExtra(NativeProtocol.EXTRA_EXPIRES_SECONDS_SINCE_EPOCH, nowSeconds + 60L); intent.putExtra(NativeProtocol.EXTRA_PERMISSIONS, permissions); AccessToken accessToken = AccessToken.createFromNativeLogin( intent.getExtras(), AccessTokenSource.FACEBOOK_APPLICATION_NATIVE); TestUtils.assertSamePermissions(permissions, accessToken); assertEquals(token, accessToken.getToken()); assertEquals(AccessTokenSource.FACEBOOK_APPLICATION_NATIVE, accessToken.getSource()); assertTrue(!accessToken.isInvalid()); }
Example 5
Source File: AccessTokenTests.java From FacebookImageShareIntent with MIT License | 6 votes |
@SmallTest @MediumTest @LargeTest public void testCacheRoundtrip() { ArrayList<String> permissions = Utility.arrayList("stream_publish", "go_outside_and_play"); String token = "AnImaginaryTokenValue"; Date later = TestUtils.nowPlusSeconds(60); Date earlier = TestUtils.nowPlusSeconds(-60); Bundle bundle = new Bundle(); TokenCachingStrategy.putToken(bundle, token); TokenCachingStrategy.putExpirationDate(bundle, later); TokenCachingStrategy.putSource(bundle, AccessTokenSource.FACEBOOK_APPLICATION_WEB); TokenCachingStrategy.putLastRefreshDate(bundle, earlier); TokenCachingStrategy.putPermissions(bundle, permissions); AccessToken accessToken = AccessToken.createFromCache(bundle); TestUtils.assertSamePermissions(permissions, accessToken); assertEquals(token, accessToken.getToken()); assertEquals(AccessTokenSource.FACEBOOK_APPLICATION_WEB, accessToken.getSource()); assertTrue(!accessToken.isInvalid()); Bundle cache = accessToken.toCacheBundle(); TestUtils.assertEqualContents(bundle, cache); }
Example 6
Source File: AccessTokenTests.java From FacebookImageShareIntent with MIT License | 5 votes |
@SmallTest @MediumTest @LargeTest public void testEmptyToken() { List<String> permissions = Utility.arrayList(); AccessToken token = AccessToken.createEmptyToken(permissions); TestUtils.assertSamePermissions(permissions, token); assertEquals("", token.getToken()); assertTrue(token.isInvalid()); assertTrue(token.getExpires().before(new Date())); }
Example 7
Source File: AccessTokenTests.java From FacebookImageShareIntent with MIT License | 5 votes |
@SmallTest @MediumTest @LargeTest public void testEmptyTokenWithPermissions() { List<String> permissions = Utility.arrayList("stream_publish"); AccessToken token = AccessToken.createEmptyToken(permissions); TestUtils.assertSamePermissions(permissions, token); assertEquals("", token.getToken()); assertTrue(token.isInvalid()); assertTrue(token.getExpires().before(new Date())); }
Example 8
Source File: SharedPreferencesTokenCacheTests.java From FacebookImageShareIntent with MIT License | 5 votes |
@SmallTest @MediumTest @LargeTest public void testCacheRoundtrip() { ArrayList<String> permissions = Utility.arrayList("stream_publish", "go_outside_and_play"); String token = "AnImaginaryTokenValue"; Date later = TestUtils.nowPlusSeconds(60); Date earlier = TestUtils.nowPlusSeconds(-60); SharedPreferencesTokenCachingStrategy cache = new SharedPreferencesTokenCachingStrategy(getContext()); cache.clear(); Bundle bundle = new Bundle(); TokenCachingStrategy.putToken(bundle, token); TokenCachingStrategy.putExpirationDate(bundle, later); TokenCachingStrategy.putSource(bundle, AccessTokenSource.FACEBOOK_APPLICATION_NATIVE); TokenCachingStrategy.putLastRefreshDate(bundle, earlier); TokenCachingStrategy.putPermissions(bundle, permissions); cache.save(bundle); bundle = cache.load(); AccessToken accessToken = AccessToken.createFromCache(bundle); TestUtils.assertSamePermissions(permissions, accessToken); assertEquals(token, accessToken.getToken()); assertEquals(AccessTokenSource.FACEBOOK_APPLICATION_NATIVE, accessToken.getSource()); assertTrue(!accessToken.isInvalid()); Bundle cachedBundle = accessToken.toCacheBundle(); TestUtils.assertEqualContents(bundle, cachedBundle); }