This source file includes following definitions.
- TEST
- TEST
#include "config.h"
#include "core/fetch/RawResource.h"
#include "core/fetch/ImageResourceClient.h"
#include "core/fetch/MemoryCache.h"
#include "core/fetch/MockImageResourceClient.h"
#include "core/fetch/ResourceFetcher.h"
#include "core/fetch/ResourcePtr.h"
#include "core/loader/DocumentLoader.h"
#include "core/testing/DummyPageHolder.h"
#include "core/testing/UnitTestHelpers.h"
#include "platform/SharedBuffer.h"
#include "public/platform/Platform.h"
#include "public/platform/WebURL.h"
#include "public/platform/WebURLResponse.h"
#include "public/platform/WebUnitTestSupport.h"
using namespace WebCore;
namespace {
TEST(RawResourceTest, DontIgnoreAcceptForCacheReuse)
{
ResourceRequest jpegRequest;
jpegRequest.setHTTPAccept("image/jpeg");
RawResource jpegResource(jpegRequest, Resource::Raw);
ResourceRequest pngRequest;
pngRequest.setHTTPAccept("image/png");
ASSERT_FALSE(jpegResource.canReuse(pngRequest));
}
TEST(RawResourceTest, RevalidationSucceeded)
{
RawResource* oldResourcePointer = new RawResource(ResourceRequest("data:text/html,"), Resource::Raw);
RawResource* newResourcePointer = new RawResource(ResourceRequest("data:text/html,"), Resource::Raw);
newResourcePointer->setResourceToRevalidate(oldResourcePointer);
ResourcePtr<Resource> oldResource = oldResourcePointer;
ResourcePtr<Resource> newResource = newResourcePointer;
memoryCache()->add(oldResource.get());
memoryCache()->remove(oldResource.get());
memoryCache()->add(newResource.get());
ResourceResponse response;
response.setHTTPStatusCode(304);
newResource->responseReceived(response);
EXPECT_EQ(memoryCache()->resourceForURL(KURL(ParsedURLString, "data:text/html,")), oldResource.get());
EXPECT_EQ(oldResource.get(), newResource.get());
EXPECT_NE(newResource.get(), newResourcePointer);
}
}