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

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

Issue 1170503003: Remove resource type-specific fetching logic from ResourceFetcher (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Null-check Document::loader() before calling startPreload() 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/ResourceFetcher.cpp ('k') | Source/core/fetch/ScriptResource.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 /* 1 /*
2 * Copyright (c) 2013, Google Inc. All rights reserved. 2 * Copyright (c) 2013, Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 28 matching lines...) Expand all
39 #include "platform/heap/Handle.h" 39 #include "platform/heap/Handle.h"
40 #include "platform/network/ResourceRequest.h" 40 #include "platform/network/ResourceRequest.h"
41 #include "platform/weborigin/KURL.h" 41 #include "platform/weborigin/KURL.h"
42 #include <gtest/gtest.h> 42 #include <gtest/gtest.h>
43 43
44 namespace blink { 44 namespace blink {
45 45
46 class ResourceFetcherTest : public ::testing::Test { 46 class ResourceFetcherTest : public ::testing::Test {
47 }; 47 };
48 48
49 class TestResourceFactory : public ResourceFactory {
50 public:
51 TestResourceFactory()
52 : ResourceFactory(Resource::Image) { }
53
54 Resource* create(const ResourceRequest& request, const String& charset) cons t override
55 {
56 return new Resource(request, Resource::Image);
57 }
58 };
59
49 TEST_F(ResourceFetcherTest, StartLoadAfterFrameDetach) 60 TEST_F(ResourceFetcherTest, StartLoadAfterFrameDetach)
50 { 61 {
51 KURL secureURL(ParsedURLString, "https://secureorigin.test/image.png"); 62 KURL secureURL(ParsedURLString, "https://secureorigin.test/image.png");
52 // Try to request a url. The request should fail, no resource should be retu rned, 63 // Try to request a url. The request should fail, no resource should be retu rned,
53 // and no resource should be present in the cache. 64 // and no resource should be present in the cache.
54 RefPtrWillBeRawPtr<ResourceFetcher> fetcher = ResourceFetcher::create(nullpt r); 65 RefPtrWillBeRawPtr<ResourceFetcher> fetcher = ResourceFetcher::create(nullpt r);
55 FetchRequest fetchRequest = FetchRequest(ResourceRequest(secureURL), FetchIn itiatorInfo()); 66 FetchRequest fetchRequest = FetchRequest(ResourceRequest(secureURL), FetchIn itiatorInfo());
56 ResourcePtr<ImageResource> image = fetcher->fetchImage(fetchRequest); 67 ResourcePtr<Resource> resource = fetcher->requestResource(fetchRequest, Test ResourceFactory());
57 EXPECT_EQ(image.get(), static_cast<ImageResource*>(0)); 68 EXPECT_EQ(resource.get(), static_cast<Resource*>(nullptr));
58 EXPECT_EQ(memoryCache()->resourceForURL(secureURL), static_cast<Resource*>(0 )); 69 EXPECT_EQ(memoryCache()->resourceForURL(secureURL), static_cast<Resource*>(n ullptr));
59 } 70 }
60 71
61 } // namespace blink 72 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/fetch/ResourceFetcher.cpp ('k') | Source/core/fetch/ScriptResource.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698