Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(73)

Side by Side Diff: third_party/WebKit/Source/platform/loader/fetch/ResourceTest.cpp

Issue 2584423002: Loading: move core/fetch to platform/loader/fetch (Closed)
Patch Set: another try Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/fetch/Resource.h" 5 #include "platform/loader/fetch/Resource.h"
6 6
7 #include "core/fetch/MemoryCache.h"
8 #include "core/fetch/RawResource.h"
9 #include "platform/SharedBuffer.h" 7 #include "platform/SharedBuffer.h"
8 #include "platform/loader/fetch/RawResource.h"
10 #include "platform/network/ResourceRequest.h" 9 #include "platform/network/ResourceRequest.h"
11 #include "platform/network/ResourceResponse.h" 10 #include "platform/network/ResourceResponse.h"
12 #include "platform/testing/TestingPlatformSupport.h" 11 #include "platform/testing/TestingPlatformSupport.h"
13 #include "platform/testing/URLTestHelpers.h" 12 #include "platform/testing/URLTestHelpers.h"
14 #include "public/platform/Platform.h" 13 #include "public/platform/Platform.h"
15 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
16 #include "wtf/Vector.h" 15 #include "wtf/Vector.h"
17 16
18 namespace blink { 17 namespace blink {
19 18
20 namespace { 19 namespace {
21 20
22 class MockPlatform final : public TestingPlatformSupport { 21 class MockPlatform final : public TestingPlatformSupportWithMockScheduler {
23 public: 22 public:
24 MockPlatform() {} 23 MockPlatform() {}
25 ~MockPlatform() override {} 24 ~MockPlatform() override {}
26 25
27 // From blink::Platform: 26 // From blink::Platform:
28 void cacheMetadata(const WebURL& url, int64_t, const char*, size_t) override { 27 void cacheMetadata(const WebURL& url, int64_t, const char*, size_t) override {
29 m_cachedURLs.push_back(url); 28 m_cachedURLs.push_back(url);
30 } 29 }
31 30
32 const Vector<WebURL>& cachedURLs() const { return m_cachedURLs; } 31 const Vector<WebURL>& cachedURLs() const { return m_cachedURLs; }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 ResourceTest, 64 ResourceTest,
66 SetCachedMetadata_DoesNotSendMetadataToPlatformWhenFetchedViaServiceWorker) { 65 SetCachedMetadata_DoesNotSendMetadataToPlatformWhenFetchedViaServiceWorker) {
67 ScopedTestingPlatformSupport<MockPlatform> mock; 66 ScopedTestingPlatformSupport<MockPlatform> mock;
68 ResourceResponse response(createTestResourceResponse()); 67 ResourceResponse response(createTestResourceResponse());
69 response.setWasFetchedViaServiceWorker(true); 68 response.setWasFetchedViaServiceWorker(true);
70 createTestResourceAndSetCachedMetadata(response); 69 createTestResourceAndSetCachedMetadata(response);
71 EXPECT_EQ(0u, mock->cachedURLs().size()); 70 EXPECT_EQ(0u, mock->cachedURLs().size());
72 } 71 }
73 72
74 TEST(ResourceTest, RevalidateWithFragment) { 73 TEST(ResourceTest, RevalidateWithFragment) {
74 ScopedTestingPlatformSupport<MockPlatform> mock;
75 KURL url(ParsedURLString, "http://127.0.0.1:8000/foo.html"); 75 KURL url(ParsedURLString, "http://127.0.0.1:8000/foo.html");
76 ResourceResponse response; 76 ResourceResponse response;
77 response.setURL(url); 77 response.setURL(url);
78 response.setHTTPStatusCode(200); 78 response.setHTTPStatusCode(200);
79 Resource* resource = RawResource::create(url, Resource::Raw); 79 Resource* resource = RawResource::create(url, Resource::Raw);
80 resource->responseReceived(response, nullptr); 80 resource->responseReceived(response, nullptr);
81 resource->finish(); 81 resource->finish();
82 82
83 // Revalidating with a url that differs by only the fragment 83 // Revalidating with a url that differs by only the fragment
84 // shouldn't trigger a securiy check. 84 // shouldn't trigger a securiy check.
85 url.setFragmentIdentifier("bar"); 85 url.setFragmentIdentifier("bar");
86 resource->setRevalidatingRequest(ResourceRequest(url)); 86 resource->setRevalidatingRequest(ResourceRequest(url));
87 ResourceResponse revalidatingResponse; 87 ResourceResponse revalidatingResponse;
88 revalidatingResponse.setURL(url); 88 revalidatingResponse.setURL(url);
89 revalidatingResponse.setHTTPStatusCode(304); 89 revalidatingResponse.setHTTPStatusCode(304);
90 resource->responseReceived(revalidatingResponse, nullptr); 90 resource->responseReceived(revalidatingResponse, nullptr);
91 } 91 }
92 92
93 } // namespace blink 93 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698