1 package com.xtremelabs.robolectric.shadows; 2 3 import static org.hamcrest.CoreMatchers.notNullValue; 4 import static org.hamcrest.CoreMatchers.equalTo; 5 import static org.junit.Assert.assertThat; 6 7 import org.junit.Before; 8 import org.junit.Test; 9 import org.junit.runner.RunWith; 10 11 import android.app.Activity; 12 import android.webkit.CookieSyncManager; 13 14 import com.xtremelabs.robolectric.Robolectric; 15 import com.xtremelabs.robolectric.WithTestDefaultsRunner; 16 17 @RunWith(WithTestDefaultsRunner.class) 18 public class CookieSyncManagerTest { 19 20 @Test testCreateInstance()21 public void testCreateInstance() { 22 assertThat( CookieSyncManager.createInstance( new Activity() ) , notNullValue() ); 23 } 24 25 @Test testGetInstance()26 public void testGetInstance() { 27 CookieSyncManager.createInstance( new Activity() ); 28 assertThat( CookieSyncManager.getInstance(), notNullValue() ); 29 } 30 31 @Test testSyncAndReset()32 public void testSyncAndReset() { 33 CookieSyncManager.createInstance( new Activity() ); 34 CookieSyncManager mgr = CookieSyncManager.getInstance(); 35 36 ShadowCookieSyncManager shadowMgr = Robolectric.shadowOf( mgr ); 37 assertThat( shadowMgr.synced(), equalTo( false ) ); 38 mgr.sync(); 39 assertThat( shadowMgr.synced(), equalTo( true ) ); 40 shadowMgr.reset(); 41 assertThat( shadowMgr.synced(), equalTo( false ) ); 42 } 43 } 44