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

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

Issue 929953002: CachedMetadata support for ServiceWorker script. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: incorporated tkent's comment Created 5 years, 10 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
« no previous file with comments | « Source/core/fetch/Resource.cpp ('k') | Source/core/workers/WorkerGlobalScope.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "config.h" 5 #include "config.h"
6 #include "core/fetch/Resource.h" 6 #include "core/fetch/Resource.h"
7 7
8 #include "core/fetch/ResourcePtr.h" 8 #include "core/fetch/ResourcePtr.h"
9 #include "core/testing/URLTestHelpers.h" 9 #include "core/testing/URLTestHelpers.h"
10 #include "platform/network/ResourceRequest.h" 10 #include "platform/network/ResourceRequest.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 response->setURL(URLTestHelpers::toKURL("https://example.com/")); 67 response->setURL(URLTestHelpers::toKURL("https://example.com/"));
68 response->setHTTPStatusCode(200); 68 response->setHTTPStatusCode(200);
69 return response.release(); 69 return response.release();
70 } 70 }
71 71
72 void createTestResourceAndSetCachedMetadata(const ResourceResponse* response) 72 void createTestResourceAndSetCachedMetadata(const ResourceResponse* response)
73 { 73 {
74 const char testData[] = "test data"; 74 const char testData[] = "test data";
75 ResourcePtr<Resource> resource = new Resource(ResourceRequest(response->url( )), Resource::Raw); 75 ResourcePtr<Resource> resource = new Resource(ResourceRequest(response->url( )), Resource::Raw);
76 resource->setResponse(*response); 76 resource->setResponse(*response);
77 resource->setCachedMetadata(100, testData, sizeof(testData), Resource::SendT oPlatform); 77 resource->cacheHandler()->setCachedMetadata(100, testData, sizeof(testData), CachedMetadataHandler::SendToPlatform);
78 return; 78 return;
79 } 79 }
80 80
81 } // namespace 81 } // namespace
82 82
83 TEST(ResourceTest, SetCachedMetadata_SendsMetadataToPlatform) 83 TEST(ResourceTest, SetCachedMetadata_SendsMetadataToPlatform)
84 { 84 {
85 AutoInstallMockPlatform mock; 85 AutoInstallMockPlatform mock;
86 OwnPtr<ResourceResponse> response(createTestResourceResponse()); 86 OwnPtr<ResourceResponse> response(createTestResourceResponse());
87 createTestResourceAndSetCachedMetadata(response.get()); 87 createTestResourceAndSetCachedMetadata(response.get());
88 EXPECT_EQ(1u, mock.platform()->cachedURLs().size()); 88 EXPECT_EQ(1u, mock.platform()->cachedURLs().size());
89 } 89 }
90 90
91 TEST(ResourceTest, SetCachedMetadata_DoesNotSendMetadataToPlatformWhenFetchedVia ServiceWorker) 91 TEST(ResourceTest, SetCachedMetadata_DoesNotSendMetadataToPlatformWhenFetchedVia ServiceWorker)
92 { 92 {
93 AutoInstallMockPlatform mock; 93 AutoInstallMockPlatform mock;
94 OwnPtr<ResourceResponse> response(createTestResourceResponse()); 94 OwnPtr<ResourceResponse> response(createTestResourceResponse());
95 response->setWasFetchedViaServiceWorker(true); 95 response->setWasFetchedViaServiceWorker(true);
96 createTestResourceAndSetCachedMetadata(response.get()); 96 createTestResourceAndSetCachedMetadata(response.get());
97 EXPECT_EQ(0u, mock.platform()->cachedURLs().size()); 97 EXPECT_EQ(0u, mock.platform()->cachedURLs().size());
98 } 98 }
99 99
100 } // namespace blink 100 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/fetch/Resource.cpp ('k') | Source/core/workers/WorkerGlobalScope.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698