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