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

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

Issue 2484633004: Change Lo-Fi bool to bitmask to support multiple Previews types (Closed)
Patch Set: fix ContentResourceProviderTest Created 3 years, 11 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 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 EXPECT_FALSE(imageResource->getContent()->getImage()->isNull()); 395 EXPECT_FALSE(imageResource->getContent()->getImage()->isNull());
396 EXPECT_EQ(2, client->imageChangedCount()); 396 EXPECT_EQ(2, client->imageChangedCount());
397 EXPECT_TRUE(client->notifyFinishedCalled()); 397 EXPECT_TRUE(client->notifyFinishedCalled());
398 EXPECT_TRUE(imageResource->getContent()->getImage()->isBitmapImage()); 398 EXPECT_TRUE(imageResource->getContent()->getImage()->isBitmapImage());
399 } 399 }
400 400
401 TEST(ImageResourceTest, ReloadIfLoFiOrPlaceholderAfterFinished) { 401 TEST(ImageResourceTest, ReloadIfLoFiOrPlaceholderAfterFinished) {
402 KURL testURL(ParsedURLString, "http://www.test.com/cancelTest.html"); 402 KURL testURL(ParsedURLString, "http://www.test.com/cancelTest.html");
403 ScopedRegisteredURL scopedRegisteredURL(testURL); 403 ScopedRegisteredURL scopedRegisteredURL(testURL);
404 ResourceRequest request = ResourceRequest(testURL); 404 ResourceRequest request = ResourceRequest(testURL);
405 request.setLoFiState(WebURLRequest::LoFiOn); 405 request.setPreviewsState(WebURLRequest::ServerLoFiOn);
406 ImageResource* imageResource = ImageResource::create(request); 406 ImageResource* imageResource = ImageResource::create(request);
407 imageResource->setStatus(Resource::Pending); 407 imageResource->setStatus(Resource::Pending);
408 408
409 Persistent<MockImageResourceClient> client = 409 Persistent<MockImageResourceClient> client =
410 new MockImageResourceClient(imageResource); 410 new MockImageResourceClient(imageResource);
411 ResourceFetcher* fetcher = 411 ResourceFetcher* fetcher =
412 ResourceFetcher::create(ImageResourceTestMockFetchContext::create()); 412 ResourceFetcher::create(ImageResourceTestMockFetchContext::create());
413 413
414 // Send the image response. 414 // Send the image response.
415 ResourceResponse resourceResponse(KURL(), "image/jpeg", sizeof(kJpegImage), 415 ResourceResponse resourceResponse(KURL(), "image/jpeg", sizeof(kJpegImage),
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 EXPECT_TRUE(imageResource->getContent()->getImage()->isBitmapImage()); 463 EXPECT_TRUE(imageResource->getContent()->getImage()->isBitmapImage());
464 EXPECT_EQ(50, imageResource->getContent()->getImage()->width()); 464 EXPECT_EQ(50, imageResource->getContent()->getImage()->width());
465 EXPECT_EQ(50, imageResource->getContent()->getImage()->height()); 465 EXPECT_EQ(50, imageResource->getContent()->getImage()->height());
466 } 466 }
467 467
468 TEST(ImageResourceTest, ReloadIfLoFiOrPlaceholderDuringFetch) { 468 TEST(ImageResourceTest, ReloadIfLoFiOrPlaceholderDuringFetch) {
469 KURL testURL(ParsedURLString, "http://www.test.com/cancelTest.html"); 469 KURL testURL(ParsedURLString, "http://www.test.com/cancelTest.html");
470 ScopedRegisteredURL scopedRegisteredURL(testURL); 470 ScopedRegisteredURL scopedRegisteredURL(testURL);
471 471
472 ResourceRequest request(testURL); 472 ResourceRequest request(testURL);
473 request.setLoFiState(WebURLRequest::LoFiOn); 473 request.setPreviewsState(WebURLRequest::ServerLoFiOn);
474 FetchRequest fetchRequest(request, FetchInitiatorInfo()); 474 FetchRequest fetchRequest(request, FetchInitiatorInfo());
475 ResourceFetcher* fetcher = 475 ResourceFetcher* fetcher =
476 ResourceFetcher::create(ImageResourceTestMockFetchContext::create()); 476 ResourceFetcher::create(ImageResourceTestMockFetchContext::create());
477 477
478 ImageResource* imageResource = ImageResource::fetch(fetchRequest, fetcher); 478 ImageResource* imageResource = ImageResource::fetch(fetchRequest, fetcher);
479 Persistent<MockImageResourceClient> client = 479 Persistent<MockImageResourceClient> client =
480 new MockImageResourceClient(imageResource); 480 new MockImageResourceClient(imageResource);
481 481
482 // Send the image response. 482 // Send the image response.
483 ResourceResponse initialResourceResponse( 483 ResourceResponse initialResourceResponse(
(...skipping 757 matching lines...) Expand 10 before | Expand all | Expand 10 after
1241 EXPECT_TRUE(client->notifyFinishedCalled()); 1241 EXPECT_TRUE(client->notifyFinishedCalled());
1242 EXPECT_TRUE(imageResource->getContent()->getImage()->isBitmapImage()); 1242 EXPECT_TRUE(imageResource->getContent()->getImage()->isBitmapImage());
1243 EXPECT_EQ(50, imageResource->getContent()->getImage()->width()); 1243 EXPECT_EQ(50, imageResource->getContent()->getImage()->width());
1244 EXPECT_EQ(50, imageResource->getContent()->getImage()->height()); 1244 EXPECT_EQ(50, imageResource->getContent()->getImage()->height());
1245 1245
1246 WTF::setTimeFunctionsForTesting(nullptr); 1246 WTF::setTimeFunctionsForTesting(nullptr);
1247 } 1247 }
1248 1248
1249 } // namespace 1249 } // namespace
1250 } // namespace blink 1250 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698