| OLD | NEW |
| 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 Loading... |
| 392 EXPECT_FALSE(cachedImage->getImage()->isNull()); | 392 EXPECT_FALSE(cachedImage->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->getImage()->isBitmapImage()); | 395 EXPECT_TRUE(cachedImage->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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 460 EXPECT_TRUE(cachedImage->getImage()->isBitmapImage()); | 460 EXPECT_TRUE(cachedImage->getImage()->isBitmapImage()); |
| 461 EXPECT_EQ(50, cachedImage->getImage()->width()); | 461 EXPECT_EQ(50, cachedImage->getImage()->width()); |
| 462 EXPECT_EQ(50, cachedImage->getImage()->height()); | 462 EXPECT_EQ(50, cachedImage->getImage()->height()); |
| 463 } | 463 } |
| 464 | 464 |
| 465 TEST(ImageResourceTest, ReloadIfLoFiOrPlaceholderDuringFetch) { | 465 TEST(ImageResourceTest, ReloadIfLoFiOrPlaceholderDuringFetch) { |
| 466 KURL testURL(ParsedURLString, "http://www.test.com/cancelTest.html"); | 466 KURL testURL(ParsedURLString, "http://www.test.com/cancelTest.html"); |
| 467 ScopedRegisteredURL scopedRegisteredURL(testURL); | 467 ScopedRegisteredURL scopedRegisteredURL(testURL); |
| 468 | 468 |
| 469 ResourceRequest request(testURL); | 469 ResourceRequest request(testURL); |
| 470 request.setLoFiState(WebURLRequest::LoFiOn); | 470 request.setPreviewsState(WebURLRequest::ServerLoFiOn); |
| 471 FetchRequest fetchRequest(request, FetchInitiatorInfo()); | 471 FetchRequest fetchRequest(request, FetchInitiatorInfo()); |
| 472 ResourceFetcher* fetcher = | 472 ResourceFetcher* fetcher = |
| 473 ResourceFetcher::create(ImageResourceTestMockFetchContext::create()); | 473 ResourceFetcher::create(ImageResourceTestMockFetchContext::create()); |
| 474 | 474 |
| 475 ImageResource* cachedImage = ImageResource::fetch(fetchRequest, fetcher); | 475 ImageResource* cachedImage = ImageResource::fetch(fetchRequest, fetcher); |
| 476 Persistent<MockImageResourceClient> client = | 476 Persistent<MockImageResourceClient> client = |
| 477 new MockImageResourceClient(cachedImage); | 477 new MockImageResourceClient(cachedImage); |
| 478 | 478 |
| 479 // Send the image response. | 479 // Send the image response. |
| 480 ResourceResponse initialResourceResponse( | 480 ResourceResponse initialResourceResponse( |
| (...skipping 732 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1213 EXPECT_TRUE(client->notifyFinishedCalled()); | 1213 EXPECT_TRUE(client->notifyFinishedCalled()); |
| 1214 EXPECT_TRUE(cachedImage->getImage()->isBitmapImage()); | 1214 EXPECT_TRUE(cachedImage->getImage()->isBitmapImage()); |
| 1215 EXPECT_EQ(50, cachedImage->getImage()->width()); | 1215 EXPECT_EQ(50, cachedImage->getImage()->width()); |
| 1216 EXPECT_EQ(50, cachedImage->getImage()->height()); | 1216 EXPECT_EQ(50, cachedImage->getImage()->height()); |
| 1217 | 1217 |
| 1218 WTF::setTimeFunctionsForTesting(nullptr); | 1218 WTF::setTimeFunctionsForTesting(nullptr); |
| 1219 } | 1219 } |
| 1220 | 1220 |
| 1221 } // namespace | 1221 } // namespace |
| 1222 } // namespace blink | 1222 } // namespace blink |
| OLD | NEW |