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

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

Issue 1164413003: Fix unit test style in core/{animation,css,fetch,frame,layout,style,timing}/. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: anonymous Created 5 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/fetch/RawResourceTest.cpp ('k') | Source/core/frame/OriginsUsingFeaturesTest.cpp » ('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 "platform/network/ResourceRequest.h" 9 #include "platform/network/ResourceRequest.h"
10 #include "platform/network/ResourceResponse.h" 10 #include "platform/network/ResourceResponse.h"
11 #include "platform/testing/URLTestHelpers.h" 11 #include "platform/testing/URLTestHelpers.h"
12 #include "public/platform/Platform.h" 12 #include "public/platform/Platform.h"
13 #include "wtf/Vector.h" 13 #include "wtf/Vector.h"
14
15 #include <gtest/gtest.h> 14 #include <gtest/gtest.h>
16 15
17 using namespace blink;
18
19 namespace blink { 16 namespace blink {
20 17
21 namespace { 18 namespace {
22 19
23 class MockPlatform final : public Platform { 20 class MockPlatform final : public Platform {
24 public: 21 public:
25 MockPlatform() : m_oldPlatform(Platform::current()) { } 22 MockPlatform() : m_oldPlatform(Platform::current()) { }
26 ~MockPlatform() override { } 23 ~MockPlatform() override { }
27 24
28 // From blink::Platform: 25 // From blink::Platform:
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 74
78 void createTestResourceAndSetCachedMetadata(const ResourceResponse* response) 75 void createTestResourceAndSetCachedMetadata(const ResourceResponse* response)
79 { 76 {
80 const char testData[] = "test data"; 77 const char testData[] = "test data";
81 ResourcePtr<Resource> resource = new Resource(ResourceRequest(response->url( )), Resource::Raw); 78 ResourcePtr<Resource> resource = new Resource(ResourceRequest(response->url( )), Resource::Raw);
82 resource->setResponse(*response); 79 resource->setResponse(*response);
83 resource->cacheHandler()->setCachedMetadata(100, testData, sizeof(testData), CachedMetadataHandler::SendToPlatform); 80 resource->cacheHandler()->setCachedMetadata(100, testData, sizeof(testData), CachedMetadataHandler::SendToPlatform);
84 return; 81 return;
85 } 82 }
86 83
87 } // namespace 84 } // anonymous namespace
88 85
89 TEST(ResourceTest, SetCachedMetadata_SendsMetadataToPlatform) 86 TEST(ResourceTest, SetCachedMetadata_SendsMetadataToPlatform)
90 { 87 {
91 AutoInstallMockPlatform mock; 88 AutoInstallMockPlatform mock;
92 OwnPtr<ResourceResponse> response(createTestResourceResponse()); 89 OwnPtr<ResourceResponse> response(createTestResourceResponse());
93 createTestResourceAndSetCachedMetadata(response.get()); 90 createTestResourceAndSetCachedMetadata(response.get());
94 EXPECT_EQ(1u, mock.platform()->cachedURLs().size()); 91 EXPECT_EQ(1u, mock.platform()->cachedURLs().size());
95 } 92 }
96 93
97 TEST(ResourceTest, SetCachedMetadata_DoesNotSendMetadataToPlatformWhenFetchedVia ServiceWorker) 94 TEST(ResourceTest, SetCachedMetadata_DoesNotSendMetadataToPlatformWhenFetchedVia ServiceWorker)
98 { 95 {
99 AutoInstallMockPlatform mock; 96 AutoInstallMockPlatform mock;
100 OwnPtr<ResourceResponse> response(createTestResourceResponse()); 97 OwnPtr<ResourceResponse> response(createTestResourceResponse());
101 response->setWasFetchedViaServiceWorker(true); 98 response->setWasFetchedViaServiceWorker(true);
102 createTestResourceAndSetCachedMetadata(response.get()); 99 createTestResourceAndSetCachedMetadata(response.get());
103 EXPECT_EQ(0u, mock.platform()->cachedURLs().size()); 100 EXPECT_EQ(0u, mock.platform()->cachedURLs().size());
104 } 101 }
105 102
106 } // namespace blink 103 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/fetch/RawResourceTest.cpp ('k') | Source/core/frame/OriginsUsingFeaturesTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698