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

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

Issue 2389643002: Reflow comments in core/fetch (Closed)
Patch Set: yoavs comments Created 4 years, 2 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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 119
120 Resource* create(const ResourceRequest& request, 120 Resource* create(const ResourceRequest& request,
121 const ResourceLoaderOptions& options, 121 const ResourceLoaderOptions& options,
122 const String& charset) const override { 122 const String& charset) const override {
123 return Resource::create(request, type(), options); 123 return Resource::create(request, type(), options);
124 } 124 }
125 }; 125 };
126 126
127 TEST_F(ResourceFetcherTest, StartLoadAfterFrameDetach) { 127 TEST_F(ResourceFetcherTest, StartLoadAfterFrameDetach) {
128 KURL secureURL(ParsedURLString, "https://secureorigin.test/image.png"); 128 KURL secureURL(ParsedURLString, "https://secureorigin.test/image.png");
129 // Try to request a url. The request should fail, no resource should be return ed, 129 // Try to request a url. The request should fail, no resource should be
130 // and no resource should be present in the cache. 130 // returned, and no resource should be present in the cache.
131 ResourceFetcher* fetcher = ResourceFetcher::create(nullptr); 131 ResourceFetcher* fetcher = ResourceFetcher::create(nullptr);
132 FetchRequest fetchRequest = 132 FetchRequest fetchRequest =
133 FetchRequest(ResourceRequest(secureURL), FetchInitiatorInfo()); 133 FetchRequest(ResourceRequest(secureURL), FetchInitiatorInfo());
134 Resource* resource = 134 Resource* resource =
135 fetcher->requestResource(fetchRequest, TestResourceFactory()); 135 fetcher->requestResource(fetchRequest, TestResourceFactory());
136 EXPECT_FALSE(resource); 136 EXPECT_FALSE(resource);
137 EXPECT_FALSE(memoryCache()->resourceForURL(secureURL)); 137 EXPECT_FALSE(memoryCache()->resourceForURL(secureURL));
138 138
139 // Start by calling startLoad() directly, rather than via requestResource(). 139 // Start by calling startLoad() directly, rather than via requestResource().
140 // This shouldn't crash. 140 // This shouldn't crash.
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 // Fetch the same resource again before actual load operation starts. 349 // Fetch the same resource again before actual load operation starts.
350 ResourceRequest request3(url); 350 ResourceRequest request3(url);
351 FetchRequest fetchRequest3 = FetchRequest(request3, FetchInitiatorInfo()); 351 FetchRequest fetchRequest3 = FetchRequest(request3, FetchInitiatorInfo());
352 Resource* resource3 = fetcher->requestResource( 352 Resource* resource3 = fetcher->requestResource(
353 fetchRequest3, TestResourceFactory(Resource::Font)); 353 fetchRequest3, TestResourceFactory(Resource::Font));
354 ASSERT_TRUE(resource3); 354 ASSERT_TRUE(resource3);
355 EXPECT_EQ(resource2, resource3); 355 EXPECT_EQ(resource2, resource3);
356 EXPECT_TRUE(resource3->isCacheValidator()); 356 EXPECT_TRUE(resource3->isCacheValidator());
357 EXPECT_TRUE(resource3->stillNeedsLoad()); 357 EXPECT_TRUE(resource3->stillNeedsLoad());
358 358
359 // startLoad() can be called from any initiator. Here, call it from the latter . 359 // startLoad() can be called from any initiator. Here, call it from the
360 // latter.
360 fetcher->startLoad(resource3); 361 fetcher->startLoad(resource3);
361 Platform::current()->getURLLoaderMockFactory()->serveAsynchronousRequests(); 362 Platform::current()->getURLLoaderMockFactory()->serveAsynchronousRequests();
362 EXPECT_TRUE(resource3->isLoaded()); 363 EXPECT_TRUE(resource3->isLoaded());
363 EXPECT_FALSE(resource3->errorOccurred()); 364 EXPECT_FALSE(resource3->errorOccurred());
364 EXPECT_TRUE(resource2->isLoaded()); 365 EXPECT_TRUE(resource2->isLoaded());
365 EXPECT_FALSE(resource2->errorOccurred()); 366 EXPECT_FALSE(resource2->errorOccurred());
366 367
367 memoryCache()->remove(resource1); 368 memoryCache()->remove(resource1);
368 } 369 }
369 370
(...skipping 16 matching lines...) Expand all
386 class ServeRequestsOnCompleteClient final 387 class ServeRequestsOnCompleteClient final
387 : public GarbageCollectedFinalized<ServeRequestsOnCompleteClient>, 388 : public GarbageCollectedFinalized<ServeRequestsOnCompleteClient>,
388 public RawResourceClient { 389 public RawResourceClient {
389 USING_GARBAGE_COLLECTED_MIXIN(ServeRequestsOnCompleteClient); 390 USING_GARBAGE_COLLECTED_MIXIN(ServeRequestsOnCompleteClient);
390 391
391 public: 392 public:
392 void notifyFinished(Resource*) override { 393 void notifyFinished(Resource*) override {
393 Platform::current()->getURLLoaderMockFactory()->serveAsynchronousRequests(); 394 Platform::current()->getURLLoaderMockFactory()->serveAsynchronousRequests();
394 } 395 }
395 396
396 // No callbacks should be received except for the notifyFinished() 397 // No callbacks should be received except for the notifyFinished() triggered
397 // triggered by ResourceLoader::cancel(). 398 // by ResourceLoader::cancel().
398 void dataSent(Resource*, unsigned long long, unsigned long long) override { 399 void dataSent(Resource*, unsigned long long, unsigned long long) override {
399 ASSERT_TRUE(false); 400 ASSERT_TRUE(false);
400 } 401 }
401 void responseReceived(Resource*, 402 void responseReceived(Resource*,
402 const ResourceResponse&, 403 const ResourceResponse&,
403 std::unique_ptr<WebDataConsumerHandle>) override { 404 std::unique_ptr<WebDataConsumerHandle>) override {
404 ASSERT_TRUE(false); 405 ASSERT_TRUE(false);
405 } 406 }
406 void setSerializedCachedMetadata(Resource*, const char*, size_t) override { 407 void setSerializedCachedMetadata(Resource*, const char*, size_t) override {
407 ASSERT_TRUE(false); 408 ASSERT_TRUE(false);
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
743 url, WebURLResponse(), ""); 744 url, WebURLResponse(), "");
744 Resource* newResource = fetcher->requestResource( 745 Resource* newResource = fetcher->requestResource(
745 fetchRequest, TestResourceFactory(Resource::Raw)); 746 fetchRequest, TestResourceFactory(Resource::Raw));
746 fetcher->stopFetching(); 747 fetcher->stopFetching();
747 Platform::current()->getURLLoaderMockFactory()->unregisterURL(url); 748 Platform::current()->getURLLoaderMockFactory()->unregisterURL(url);
748 749
749 EXPECT_NE(resource, newResource); 750 EXPECT_NE(resource, newResource);
750 } 751 }
751 752
752 } // namespace blink 753 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/fetch/ResourceFetcher.cpp ('k') | third_party/WebKit/Source/core/fetch/ResourceLoaderOptions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698