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

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

Issue 2484633004: Change Lo-Fi bool to bitmask to support multiple Previews types (Closed)
Patch Set: nasko comments Created 4 years 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 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 EXPECT_FALSE(cachedImage->getContent()->getImage()->isNull()); 392 EXPECT_FALSE(cachedImage->getContent()->getImage()->isNull());
393 EXPECT_EQ(2, client->imageChangedCount()); 393 EXPECT_EQ(2, client->imageChangedCount());
394 EXPECT_TRUE(client->notifyFinishedCalled()); 394 EXPECT_TRUE(client->notifyFinishedCalled());
395 EXPECT_TRUE(cachedImage->getContent()->getImage()->isBitmapImage()); 395 EXPECT_TRUE(cachedImage->getContent()->getImage()->isBitmapImage());
396 } 396 }
397 397
398 TEST(ImageResourceTest, ReloadIfLoFiOrPlaceholderAfterFinished) { 398 TEST(ImageResourceTest, ReloadIfLoFiOrPlaceholderAfterFinished) {
399 KURL testURL(ParsedURLString, "http://www.test.com/cancelTest.html"); 399 KURL testURL(ParsedURLString, "http://www.test.com/cancelTest.html");
400 ScopedRegisteredURL scopedRegisteredURL(testURL); 400 ScopedRegisteredURL scopedRegisteredURL(testURL);
401 ResourceRequest request = ResourceRequest(testURL); 401 ResourceRequest request = ResourceRequest(testURL);
402 request.setLoFiState(WebURLRequest::LoFiOn); 402 request.setPreviewsState(WebURLRequest::ServerLoFiOn);
403 ImageResource* cachedImage = ImageResource::create(request); 403 ImageResource* cachedImage = ImageResource::create(request);
404 cachedImage->setStatus(Resource::Pending); 404 cachedImage->setStatus(Resource::Pending);
405 405
406 Persistent<MockImageResourceClient> client = 406 Persistent<MockImageResourceClient> client =
407 new MockImageResourceClient(cachedImage); 407 new MockImageResourceClient(cachedImage);
408 ResourceFetcher* fetcher = 408 ResourceFetcher* fetcher =
409 ResourceFetcher::create(ImageResourceTestMockFetchContext::create()); 409 ResourceFetcher::create(ImageResourceTestMockFetchContext::create());
410 410
411 // Send the image response. 411 // Send the image response.
412 ResourceResponse resourceResponse(KURL(), "image/jpeg", sizeof(kJpegImage), 412 ResourceResponse resourceResponse(KURL(), "image/jpeg", sizeof(kJpegImage),
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 EXPECT_TRUE(cachedImage->getContent()->getImage()->isBitmapImage()); 459 EXPECT_TRUE(cachedImage->getContent()->getImage()->isBitmapImage());
460 EXPECT_EQ(50, cachedImage->getContent()->getImage()->width()); 460 EXPECT_EQ(50, cachedImage->getContent()->getImage()->width());
461 EXPECT_EQ(50, cachedImage->getContent()->getImage()->height()); 461 EXPECT_EQ(50, cachedImage->getContent()->getImage()->height());
462 } 462 }
463 463
464 TEST(ImageResourceTest, ReloadIfLoFiOrPlaceholderDuringFetch) { 464 TEST(ImageResourceTest, ReloadIfLoFiOrPlaceholderDuringFetch) {
465 KURL testURL(ParsedURLString, "http://www.test.com/cancelTest.html"); 465 KURL testURL(ParsedURLString, "http://www.test.com/cancelTest.html");
466 ScopedRegisteredURL scopedRegisteredURL(testURL); 466 ScopedRegisteredURL scopedRegisteredURL(testURL);
467 467
468 ResourceRequest request(testURL); 468 ResourceRequest request(testURL);
469 request.setLoFiState(WebURLRequest::LoFiOn); 469 request.setPreviewsState(WebURLRequest::ServerLoFiOn);
470 FetchRequest fetchRequest(request, FetchInitiatorInfo()); 470 FetchRequest fetchRequest(request, FetchInitiatorInfo());
471 ResourceFetcher* fetcher = 471 ResourceFetcher* fetcher =
472 ResourceFetcher::create(ImageResourceTestMockFetchContext::create()); 472 ResourceFetcher::create(ImageResourceTestMockFetchContext::create());
473 473
474 ImageResource* cachedImage = ImageResource::fetch(fetchRequest, fetcher); 474 ImageResource* cachedImage = ImageResource::fetch(fetchRequest, fetcher);
475 Persistent<MockImageResourceClient> client = 475 Persistent<MockImageResourceClient> client =
476 new MockImageResourceClient(cachedImage); 476 new MockImageResourceClient(cachedImage);
477 477
478 // Send the image response. 478 // Send the image response.
479 ResourceResponse initialResourceResponse( 479 ResourceResponse initialResourceResponse(
(...skipping 727 matching lines...) Expand 10 before | Expand all | Expand 10 after
1207 EXPECT_TRUE(client->notifyFinishedCalled()); 1207 EXPECT_TRUE(client->notifyFinishedCalled());
1208 EXPECT_TRUE(cachedImage->getContent()->getImage()->isBitmapImage()); 1208 EXPECT_TRUE(cachedImage->getContent()->getImage()->isBitmapImage());
1209 EXPECT_EQ(50, cachedImage->getContent()->getImage()->width()); 1209 EXPECT_EQ(50, cachedImage->getContent()->getImage()->width());
1210 EXPECT_EQ(50, cachedImage->getContent()->getImage()->height()); 1210 EXPECT_EQ(50, cachedImage->getContent()->getImage()->height());
1211 1211
1212 WTF::setTimeFunctionsForTesting(nullptr); 1212 WTF::setTimeFunctionsForTesting(nullptr);
1213 } 1213 }
1214 1214
1215 } // namespace 1215 } // namespace
1216 } // namespace blink 1216 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698