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

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

Issue 1889973002: Refactoring starting a resource load (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 { 106 {
107 KURL secureURL(ParsedURLString, "https://secureorigin.test/image.png"); 107 KURL secureURL(ParsedURLString, "https://secureorigin.test/image.png");
108 // Try to request a url. The request should fail, no resource should be retu rned, 108 // Try to request a url. The request should fail, no resource should be retu rned,
109 // and no resource should be present in the cache. 109 // and no resource should be present in the cache.
110 ResourceFetcher* fetcher = ResourceFetcher::create(nullptr); 110 ResourceFetcher* fetcher = ResourceFetcher::create(nullptr);
111 FetchRequest fetchRequest = FetchRequest(ResourceRequest(secureURL), FetchIn itiatorInfo()); 111 FetchRequest fetchRequest = FetchRequest(ResourceRequest(secureURL), FetchIn itiatorInfo());
112 Resource* resource = fetcher->requestResource(fetchRequest, TestResourceFact ory()); 112 Resource* resource = fetcher->requestResource(fetchRequest, TestResourceFact ory());
113 EXPECT_EQ(resource, static_cast<Resource*>(nullptr)); 113 EXPECT_EQ(resource, static_cast<Resource*>(nullptr));
114 EXPECT_EQ(memoryCache()->resourceForURL(secureURL), static_cast<Resource*>(n ullptr)); 114 EXPECT_EQ(memoryCache()->resourceForURL(secureURL), static_cast<Resource*>(n ullptr));
115 115
116 // Try calling Resource::load directly. This shouldn't crash. 116 // Start by calling startLoad() directly, rather than via requestResource().
117 Resource* resource2 = Resource::create(secureURL, Resource::Raw); 117 // This shouldn't crash.
118 resource2->load(fetcher); 118 fetcher->startLoad(Resource::create(secureURL, Resource::Raw));
119 } 119 }
120 120
121 TEST_F(ResourceFetcherTest, UseExistingResource) 121 TEST_F(ResourceFetcherTest, UseExistingResource)
122 { 122 {
123 ResourceFetcher* fetcher = ResourceFetcher::create(ResourceFetcherTestMockFe tchContext::create()); 123 ResourceFetcher* fetcher = ResourceFetcher::create(ResourceFetcherTestMockFe tchContext::create());
124 124
125 KURL url(ParsedURLString, "http://127.0.0.1:8000/foo.html"); 125 KURL url(ParsedURLString, "http://127.0.0.1:8000/foo.html");
126 Resource* resource = Resource::create(url, Resource::Image); 126 Resource* resource = Resource::create(url, Resource::Image);
127 memoryCache()->add(resource); 127 memoryCache()->add(resource);
128 ResourceResponse response; 128 ResourceResponse response;
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 ResourceFetcher* fetcher = ResourceFetcher::create(ResourceFetcherTestMockFe tchContext::create()); 294 ResourceFetcher* fetcher = ResourceFetcher::create(ResourceFetcherTestMockFe tchContext::create());
295 FetchRequest fetchRequest = FetchRequest(url, FetchInitiatorInfo()); 295 FetchRequest fetchRequest = FetchRequest(url, FetchInitiatorInfo());
296 Resource* resource = fetcher->requestResource(fetchRequest, TestResourceFact ory(Resource::Raw)); 296 Resource* resource = fetcher->requestResource(fetchRequest, TestResourceFact ory(Resource::Raw));
297 ServeRequestsOnCompleteClient client; 297 ServeRequestsOnCompleteClient client;
298 resource->addClient(&client); 298 resource->addClient(&client);
299 resource->loader()->cancel(); 299 resource->loader()->cancel();
300 Platform::current()->getURLLoaderMockFactory()->unregisterURL(url); 300 Platform::current()->getURLLoaderMockFactory()->unregisterURL(url);
301 } 301 }
302 302
303 } // namespace blink 303 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698