use of android.webkit.CookieManager in project robolectric by robolectric.
the class ShadowCookieManagerTest method shouldGetCookieForHostInDomain.
@Test
public void shouldGetCookieForHostInDomain() {
CookieManager cookieManager = CookieManager.getInstance();
String value1 = "my cookie";
cookieManager.setCookie("foo.com/this%20is%20a%20test", value1);
assertThat(cookieManager.getCookie(".foo.com")).isEqualTo(value1);
}
use of android.webkit.CookieManager in project robolectric by robolectric.
the class ShadowCookieManagerTest method shouldGetCookieForHostInDomainDefinedWithProtocol.
@Test
public void shouldGetCookieForHostInDomainDefinedWithProtocol() {
CookieManager cookieManager = CookieManager.getInstance();
String value1 = "my cookie";
cookieManager.setCookie("qutz.com/", value1);
assertThat(cookieManager.getCookie("http://.qutz.com")).isEqualTo(value1);
}
use of android.webkit.CookieManager in project robolectric by robolectric.
the class ShadowCookieManagerTest method shouldSetAndGetACookie.
@Test
public void shouldSetAndGetACookie() {
CookieManager cookieManager = CookieManager.getInstance();
String url = "http://www.google.com";
String value = "my cookie";
cookieManager.setCookie(url, value);
assertThat(cookieManager.getCookie(url)).isEqualTo(value);
}
use of android.webkit.CookieManager in project AgentWeb by Justson.
the class AgentWebConfig method syncCookieToWebView.
/**
* cookie同步
*/
private void syncCookieToWebView(Context context, List<String> cookies, String url) {
if (CookieSyncManager.getInstance() == null)
CookieSyncManager.createInstance(context);
CookieManager cm = CookieManager.getInstance();
cm.removeAllCookie();
cm.setAcceptCookie(true);
if (cookies != null) {
for (String cookie : cookies) {
cm.setCookie(url, cookie);
}
}
CookieSyncManager.getInstance().sync();
}
use of android.webkit.CookieManager in project Lightning-Browser by anthonycr.
the class WebUtils method clearCookies.
public static void clearCookies(@NonNull Context context) {
CookieManager c = CookieManager.getInstance();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
c.removeAllCookies(null);
} else {
//noinspection deprecation
CookieSyncManager.createInstance(context);
//noinspection deprecation
c.removeAllCookie();
}
}
Aggregations