| 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 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 EXPECT_FALSE(cachedImage->getImage()->isNull()); | 391 EXPECT_FALSE(cachedImage->getImage()->isNull()); |
| 392 EXPECT_EQ(2, client->imageChangedCount()); | 392 EXPECT_EQ(2, client->imageChangedCount()); |
| 393 EXPECT_TRUE(client->notifyFinishedCalled()); | 393 EXPECT_TRUE(client->notifyFinishedCalled()); |
| 394 EXPECT_TRUE(cachedImage->getImage()->isBitmapImage()); | 394 EXPECT_TRUE(cachedImage->getImage()->isBitmapImage()); |
| 395 } | 395 } |
| 396 | 396 |
| 397 TEST(ImageResourceTest, ReloadIfLoFiOrPlaceholderAfterFinished) { | 397 TEST(ImageResourceTest, ReloadIfLoFiOrPlaceholderAfterFinished) { |
| 398 KURL testURL(ParsedURLString, "http://www.test.com/cancelTest.html"); | 398 KURL testURL(ParsedURLString, "http://www.test.com/cancelTest.html"); |
| 399 ScopedRegisteredURL scopedRegisteredURL(testURL); | 399 ScopedRegisteredURL scopedRegisteredURL(testURL); |
| 400 ResourceRequest request = ResourceRequest(testURL); | 400 ResourceRequest request = ResourceRequest(testURL); |
| 401 request.setLoFiState(WebURLRequest::LoFiOn); | 401 request.setPreviewsState(WebURLRequest::ServerLoFiOn); |
| 402 ImageResource* cachedImage = ImageResource::create(request); | 402 ImageResource* cachedImage = ImageResource::create(request); |
| 403 cachedImage->setStatus(Resource::Pending); | 403 cachedImage->setStatus(Resource::Pending); |
| 404 | 404 |
| 405 Persistent<MockImageResourceClient> client = | 405 Persistent<MockImageResourceClient> client = |
| 406 new MockImageResourceClient(cachedImage); | 406 new MockImageResourceClient(cachedImage); |
| 407 ResourceFetcher* fetcher = | 407 ResourceFetcher* fetcher = |
| 408 ResourceFetcher::create(ImageResourceTestMockFetchContext::create()); | 408 ResourceFetcher::create(ImageResourceTestMockFetchContext::create()); |
| 409 | 409 |
| 410 // Send the image response. | 410 // Send the image response. |
| 411 ResourceResponse resourceResponse(KURL(), "image/jpeg", sizeof(kJpegImage), | 411 ResourceResponse resourceResponse(KURL(), "image/jpeg", sizeof(kJpegImage), |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 459 EXPECT_TRUE(cachedImage->getImage()->isBitmapImage()); | 459 EXPECT_TRUE(cachedImage->getImage()->isBitmapImage()); |
| 460 EXPECT_EQ(50, cachedImage->getImage()->width()); | 460 EXPECT_EQ(50, cachedImage->getImage()->width()); |
| 461 EXPECT_EQ(50, cachedImage->getImage()->height()); | 461 EXPECT_EQ(50, cachedImage->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 732 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1212 EXPECT_TRUE(client->notifyFinishedCalled()); | 1212 EXPECT_TRUE(client->notifyFinishedCalled()); |
| 1213 EXPECT_TRUE(cachedImage->getImage()->isBitmapImage()); | 1213 EXPECT_TRUE(cachedImage->getImage()->isBitmapImage()); |
| 1214 EXPECT_EQ(50, cachedImage->getImage()->width()); | 1214 EXPECT_EQ(50, cachedImage->getImage()->width()); |
| 1215 EXPECT_EQ(50, cachedImage->getImage()->height()); | 1215 EXPECT_EQ(50, cachedImage->getImage()->height()); |
| 1216 | 1216 |
| 1217 WTF::setTimeFunctionsForTesting(nullptr); | 1217 WTF::setTimeFunctionsForTesting(nullptr); |
| 1218 } | 1218 } |
| 1219 | 1219 |
| 1220 } // namespace | 1220 } // namespace |
| 1221 } // namespace blink | 1221 } // namespace blink |
| OLD | NEW |