| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2013, Google Inc. All rights reserved. | 2 * Copyright (c) 2013, Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 #include "core/fetch/MockImageResourceClient.h" | 36 #include "core/fetch/MockImageResourceClient.h" |
| 37 #include "core/fetch/ResourceFetcher.h" | 37 #include "core/fetch/ResourceFetcher.h" |
| 38 #include "core/fetch/ResourcePtr.h" | 38 #include "core/fetch/ResourcePtr.h" |
| 39 #include "platform/SharedBuffer.h" | 39 #include "platform/SharedBuffer.h" |
| 40 #include "platform/testing/UnitTestHelpers.h" | 40 #include "platform/testing/UnitTestHelpers.h" |
| 41 #include "public/platform/Platform.h" | 41 #include "public/platform/Platform.h" |
| 42 #include "public/platform/WebURL.h" | 42 #include "public/platform/WebURL.h" |
| 43 #include "public/platform/WebURLResponse.h" | 43 #include "public/platform/WebURLResponse.h" |
| 44 #include "public/platform/WebUnitTestSupport.h" | 44 #include "public/platform/WebUnitTestSupport.h" |
| 45 | 45 |
| 46 #include <gtest/gtest.h> |
| 47 |
| 46 namespace blink { | 48 namespace blink { |
| 47 | 49 |
| 48 TEST(RawResourceTest, DontIgnoreAcceptForCacheReuse) | 50 TEST(RawResourceTest, DontIgnoreAcceptForCacheReuse) |
| 49 { | 51 { |
| 50 ResourceRequest jpegRequest; | 52 ResourceRequest jpegRequest; |
| 51 jpegRequest.setHTTPAccept("image/jpeg"); | 53 jpegRequest.setHTTPAccept("image/jpeg"); |
| 52 | 54 |
| 53 ResourcePtr<RawResource> jpegResource(new RawResource(jpegRequest, Resource:
:Raw)); | 55 ResourcePtr<RawResource> jpegResource(new RawResource(jpegRequest, Resource:
:Raw)); |
| 54 | 56 |
| 55 ResourceRequest pngRequest; | 57 ResourceRequest pngRequest; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 73 // Simulate a successful revalidation. | 75 // Simulate a successful revalidation. |
| 74 // The revalidated resource (oldResource) should now be in the cache, newRes
ource | 76 // The revalidated resource (oldResource) should now be in the cache, newRes
ource |
| 75 // should have been sliently switched to point to the revalidated resource,
and | 77 // should have been sliently switched to point to the revalidated resource,
and |
| 76 // we shouldn't hit any ASSERTs. | 78 // we shouldn't hit any ASSERTs. |
| 77 ResourceResponse response; | 79 ResourceResponse response; |
| 78 response.setHTTPStatusCode(304); | 80 response.setHTTPStatusCode(304); |
| 79 newResource->responseReceived(response, nullptr); | 81 newResource->responseReceived(response, nullptr); |
| 80 EXPECT_EQ(memoryCache()->resourceForURL(KURL(ParsedURLString, "data:text/htm
l,")), oldResource.get()); | 82 EXPECT_EQ(memoryCache()->resourceForURL(KURL(ParsedURLString, "data:text/htm
l,")), oldResource.get()); |
| 81 EXPECT_EQ(oldResource.get(), newResource.get()); | 83 EXPECT_EQ(oldResource.get(), newResource.get()); |
| 82 EXPECT_NE(newResource.get(), newResourcePointer); | 84 EXPECT_NE(newResource.get(), newResourcePointer); |
| 85 memoryCache()->remove(newResource.get()); |
| 83 } | 86 } |
| 84 | 87 |
| 85 class DummyClient : public RawResourceClient { | 88 class DummyClient : public RawResourceClient { |
| 86 public: | 89 public: |
| 87 DummyClient() : m_called(false) {} | 90 DummyClient() : m_called(false) {} |
| 88 ~DummyClient() override {} | 91 ~DummyClient() override {} |
| 89 | 92 |
| 90 // ResourceClient implementation. | 93 // ResourceClient implementation. |
| 91 virtual void notifyFinished(Resource* resource) | 94 virtual void notifyFinished(Resource* resource) |
| 92 { | 95 { |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 | 180 |
| 178 OwnPtr<DummyClient> dummyClient = adoptPtr(new DummyClient()); | 181 OwnPtr<DummyClient> dummyClient = adoptPtr(new DummyClient()); |
| 179 OwnPtr<RemovingClient> removingClient = adoptPtr(new RemovingClient(dummyCli
ent.get())); | 182 OwnPtr<RemovingClient> removingClient = adoptPtr(new RemovingClient(dummyCli
ent.get())); |
| 180 raw->addClient(dummyClient.get()); | 183 raw->addClient(dummyClient.get()); |
| 181 raw->addClient(removingClient.get()); | 184 raw->addClient(removingClient.get()); |
| 182 testing::runPendingTasks(); | 185 testing::runPendingTasks(); |
| 183 EXPECT_FALSE(raw->hasClients()); | 186 EXPECT_FALSE(raw->hasClients()); |
| 184 } | 187 } |
| 185 | 188 |
| 186 } // namespace blink | 189 } // namespace blink |
| OLD | NEW |