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

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

Issue 956333002: Refactor TimeBase to post tasks. Workers to use real Idle tasks. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase Created 5 years, 8 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/CachingCorrectnessTest.cpp ('k') | Source/core/frame/DOMTimerCoordinator.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 14
15 #include <gtest/gtest.h> 15 #include <gtest/gtest.h>
16 16
17 using namespace blink; 17 using namespace blink;
18 18
19 namespace blink { 19 namespace blink {
20 20
21 namespace { 21 namespace {
22 22
23 class MockPlatform final : public Platform { 23 class MockPlatform final : public Platform {
24 public: 24 public:
25 MockPlatform() { } 25 MockPlatform() : m_oldPlatform(Platform::current()) { }
26 ~MockPlatform() override { } 26 ~MockPlatform() override { }
27 27
28 // From blink::Platform: 28 // From blink::Platform:
29 void cacheMetadata(const WebURL& url, int64, const char*, size_t) override 29 void cacheMetadata(const WebURL& url, int64, const char*, size_t) override
30 { 30 {
31 m_cachedURLs.append(url); 31 m_cachedURLs.append(url);
32 } 32 }
33 void cryptographicallyRandomValues(unsigned char* buffer, size_t length) ove rride 33 void cryptographicallyRandomValues(unsigned char* buffer, size_t length) ove rride
34 { 34 {
35 ASSERT_NOT_REACHED(); 35 ASSERT_NOT_REACHED();
36 } 36 }
37 37
38 const Vector<WebURL>& cachedURLs() const 38 const Vector<WebURL>& cachedURLs() const
39 { 39 {
40 return m_cachedURLs; 40 return m_cachedURLs;
41 } 41 }
42 42
43 WebThread* currentThread() override
44 {
45 return m_oldPlatform->currentThread();
46 }
47
43 private: 48 private:
49 Platform* m_oldPlatform; // NOT OWNED.
44 Vector<WebURL> m_cachedURLs; 50 Vector<WebURL> m_cachedURLs;
45 }; 51 };
46 52
47 class AutoInstallMockPlatform { 53 class AutoInstallMockPlatform {
48 public: 54 public:
49 AutoInstallMockPlatform() 55 AutoInstallMockPlatform()
50 { 56 {
51 m_oldPlatform = Platform::current(); 57 m_oldPlatform = Platform::current();
52 Platform::initialize(&m_mockPlatform); 58 Platform::initialize(&m_mockPlatform);
53 } 59 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 TEST(ResourceTest, SetCachedMetadata_DoesNotSendMetadataToPlatformWhenFetchedVia ServiceWorker) 97 TEST(ResourceTest, SetCachedMetadata_DoesNotSendMetadataToPlatformWhenFetchedVia ServiceWorker)
92 { 98 {
93 AutoInstallMockPlatform mock; 99 AutoInstallMockPlatform mock;
94 OwnPtr<ResourceResponse> response(createTestResourceResponse()); 100 OwnPtr<ResourceResponse> response(createTestResourceResponse());
95 response->setWasFetchedViaServiceWorker(true); 101 response->setWasFetchedViaServiceWorker(true);
96 createTestResourceAndSetCachedMetadata(response.get()); 102 createTestResourceAndSetCachedMetadata(response.get());
97 EXPECT_EQ(0u, mock.platform()->cachedURLs().size()); 103 EXPECT_EQ(0u, mock.platform()->cachedURLs().size());
98 } 104 }
99 105
100 } // namespace blink 106 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/fetch/CachingCorrectnessTest.cpp ('k') | Source/core/frame/DOMTimerCoordinator.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698