use of android.webkit.CookieManager in project robolectric by robolectric.
the class ShadowCookieManagerTest method shouldRecordAcceptCookie.
@Test
public void shouldRecordAcceptCookie() {
CookieManager cookieManager = CookieManager.getInstance();
cookieManager.setCookie("foo", "bar");
cookieManager.setCookie("baz", "qux");
assertThat(cookieManager.getCookie("foo")).isNotNull();
cookieManager.removeAllCookie();
assertThat(cookieManager.getCookie("foo")).isNull();
assertThat(cookieManager.getCookie("baz")).isNull();
}
use of android.webkit.CookieManager in project robolectric by robolectric.
the class ShadowCookieManagerTest method shouldNotGetCookieForHostNotInDomain.
@Test
public void shouldNotGetCookieForHostNotInDomain() {
CookieManager cookieManager = CookieManager.getInstance();
String value1 = "my cookie";
cookieManager.setCookie("bar.foo.com/this%20is%20a%20test", value1);
assertThat(cookieManager.getCookie(".bar.com")).isNull();
}
use of android.webkit.CookieManager in project robolectric by robolectric.
the class ShadowCookieManagerTest method shouldGetCookieForHostInSubDomain.
@Test
public void shouldGetCookieForHostInSubDomain() {
CookieManager cookieManager = CookieManager.getInstance();
String value1 = "my cookie";
cookieManager.setCookie("host.in.subdomain.bar.com", value1);
assertThat(cookieManager.getCookie(".bar.com")).isEqualTo(value1);
}
use of android.webkit.CookieManager in project Notes by lguipeng.
the class EvernoteUtil method removeAllCookiesV21.
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private static void removeAllCookiesV21() {
final CookieManager cookieManager = CookieManager.getInstance();
Looper looper = Looper.myLooper();
boolean prepared = false;
if (looper == null) {
Looper.prepare();
prepared = true;
}
// requires a looper
cookieManager.removeAllCookies(new ValueCallback<Boolean>() {
@Override
public void onReceiveValue(Boolean value) {
Thread thread = new Thread() {
@Override
public void run() {
// is synchronous, run in background
cookieManager.flush();
}
};
thread.start();
}
});
if (prepared) {
looper = Looper.myLooper();
if (looper != null) {
looper.quit();
}
}
}
use of android.webkit.CookieManager in project AndroidTwitter by lorensiuswlt.
the class TwitterDialog method setUpWebView.
@SuppressLint("SetJavaScriptEnabled")
private void setUpWebView() {
CookieSyncManager.createInstance(getContext());
CookieManager cookieManager = CookieManager.getInstance();
cookieManager.removeAllCookie();
mWebView = new WebView(getContext());
mWebView.setVerticalScrollBarEnabled(false);
mWebView.setHorizontalScrollBarEnabled(false);
mWebView.setWebViewClient(new TwitterWebViewClient());
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.loadUrl(mUrl);
mWebView.setLayoutParams(FILL);
mContent.addView(mWebView);
}
Aggregations