Methods Summary |
---|
protected void | setUp()
super.setUp();
mCacheQueue = new WaitableQueue();
mNetworkQueue = new WaitableQueue();
mCache = new MockCache();
mDelivery = new MockResponseDelivery();
mRequest = new MockRequest();
mDispatcher = new CacheDispatcher(mCacheQueue, mNetworkQueue, mCache, mDelivery);
mDispatcher.start();
|
protected void | tearDown()
super.tearDown();
mDispatcher.quit();
mDispatcher.join();
|
public void | testCacheMiss()
mCacheQueue.add(mRequest);
mCacheQueue.waitUntilEmpty(TIMEOUT_MILLIS);
assertFalse(mDelivery.wasEitherResponseCalled());
assertTrue(mNetworkQueue.size() > 0);
Request request = mNetworkQueue.take();
assertNull(request.getCacheEntry());
|
public void | testCancelledRequest()
mRequest.cancel();
mCacheQueue.add(mRequest);
mCacheQueue.waitUntilEmpty(TIMEOUT_MILLIS);
assertFalse(mCache.getCalled);
assertFalse(mDelivery.wasEitherResponseCalled());
|
public void | testExpiredCacheHit()
Cache.Entry entry = CacheTestUtils.makeRandomCacheEntry(null, true, true);
mCache.setEntryToReturn(entry);
mCacheQueue.add(mRequest);
mCacheQueue.waitUntilEmpty(TIMEOUT_MILLIS);
assertFalse(mDelivery.wasEitherResponseCalled());
assertTrue(mNetworkQueue.size() > 0);
Request request = mNetworkQueue.take();
assertSame(entry, request.getCacheEntry());
|
public void | testNonExpiredCacheHit()
Cache.Entry entry = CacheTestUtils.makeRandomCacheEntry(null, false, false);
mCache.setEntryToReturn(entry);
mCacheQueue.add(mRequest);
mCacheQueue.waitUntilEmpty(TIMEOUT_MILLIS);
assertTrue(mDelivery.postResponse_called);
assertFalse(mDelivery.postError_called);
|
public void | testSoftExpiredCacheHit()
Cache.Entry entry = CacheTestUtils.makeRandomCacheEntry(null, false, true);
mCache.setEntryToReturn(entry);
mCacheQueue.add(mRequest);
mCacheQueue.waitUntilEmpty(TIMEOUT_MILLIS);
assertTrue(mDelivery.postResponse_called);
assertFalse(mDelivery.postError_called);
assertTrue(mNetworkQueue.size() > 0);
Request request = mNetworkQueue.take();
assertSame(entry, request.getCacheEntry());
|