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

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

Issue 2588403002: TestingPlatformSupport: register Platform instance correctly (Closed)
Patch Set: review #32 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 "core/fetch/Resource.h"
6 6
7 #include "core/fetch/MemoryCache.h" 7 #include "core/fetch/MemoryCache.h"
8 #include "core/fetch/RawResource.h" 8 #include "core/fetch/RawResource.h"
9 #include "platform/SharedBuffer.h" 9 #include "platform/SharedBuffer.h"
10 #include "platform/network/ResourceRequest.h" 10 #include "platform/network/ResourceRequest.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 RawResource::create(ResourceRequest(response.url()), Resource::Raw); 48 RawResource::create(ResourceRequest(response.url()), Resource::Raw);
49 resource->setResponse(response); 49 resource->setResponse(response);
50 resource->cacheHandler()->setCachedMetadata( 50 resource->cacheHandler()->setCachedMetadata(
51 100, testData, sizeof(testData), CachedMetadataHandler::SendToPlatform); 51 100, testData, sizeof(testData), CachedMetadataHandler::SendToPlatform);
52 return; 52 return;
53 } 53 }
54 54
55 } // anonymous namespace 55 } // anonymous namespace
56 56
57 TEST(ResourceTest, SetCachedMetadata_SendsMetadataToPlatform) { 57 TEST(ResourceTest, SetCachedMetadata_SendsMetadataToPlatform) {
58 MockPlatform mock; 58 ScopedTestingPlatformSupport<MockPlatform> mock;
59 ResourceResponse response(createTestResourceResponse()); 59 ResourceResponse response(createTestResourceResponse());
60 createTestResourceAndSetCachedMetadata(response); 60 createTestResourceAndSetCachedMetadata(response);
61 EXPECT_EQ(1u, mock.cachedURLs().size()); 61 EXPECT_EQ(1u, mock->cachedURLs().size());
62 } 62 }
63 63
64 TEST( 64 TEST(
65 ResourceTest, 65 ResourceTest,
66 SetCachedMetadata_DoesNotSendMetadataToPlatformWhenFetchedViaServiceWorker) { 66 SetCachedMetadata_DoesNotSendMetadataToPlatformWhenFetchedViaServiceWorker) {
67 MockPlatform mock; 67 ScopedTestingPlatformSupport<MockPlatform> mock;
68 ResourceResponse response(createTestResourceResponse()); 68 ResourceResponse response(createTestResourceResponse());
69 response.setWasFetchedViaServiceWorker(true); 69 response.setWasFetchedViaServiceWorker(true);
70 createTestResourceAndSetCachedMetadata(response); 70 createTestResourceAndSetCachedMetadata(response);
71 EXPECT_EQ(0u, mock.cachedURLs().size()); 71 EXPECT_EQ(0u, mock->cachedURLs().size());
72 } 72 }
73 73
74 TEST(ResourceTest, RevalidateWithFragment) { 74 TEST(ResourceTest, RevalidateWithFragment) {
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