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

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

Issue 2124453002: Unit test: confirm the image is updated after ImageResource::reloadIfLoFi() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix Created 4 years, 5 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 347
348 cachedImage->responseReceived(resourceResponse, nullptr); 348 cachedImage->responseReceived(resourceResponse, nullptr);
349 cachedImage->appendData(reinterpret_cast<const char*>(jpeg.data()), jpeg.siz e()); 349 cachedImage->appendData(reinterpret_cast<const char*>(jpeg.data()), jpeg.siz e());
350 cachedImage->finish(); 350 cachedImage->finish();
351 ASSERT_FALSE(cachedImage->errorOccurred()); 351 ASSERT_FALSE(cachedImage->errorOccurred());
352 ASSERT_TRUE(cachedImage->hasImage()); 352 ASSERT_TRUE(cachedImage->hasImage());
353 ASSERT_FALSE(cachedImage->getImage()->isNull()); 353 ASSERT_FALSE(cachedImage->getImage()->isNull());
354 ASSERT_EQ(client->imageChangedCount(), 2); 354 ASSERT_EQ(client->imageChangedCount(), 2);
355 ASSERT_TRUE(client->notifyFinishedCalled()); 355 ASSERT_TRUE(client->notifyFinishedCalled());
356 ASSERT_TRUE(cachedImage->getImage()->isBitmapImage()); 356 ASSERT_TRUE(cachedImage->getImage()->isBitmapImage());
357 EXPECT_EQ(1, cachedImage->getImage()->width());
358 EXPECT_EQ(1, cachedImage->getImage()->height());
357 359
358 cachedImage->reloadIfLoFi(fetcher); 360 cachedImage->reloadIfLoFi(fetcher);
359 ASSERT_FALSE(cachedImage->errorOccurred()); 361 ASSERT_FALSE(cachedImage->errorOccurred());
360 ASSERT_FALSE(cachedImage->resourceBuffer()); 362 ASSERT_FALSE(cachedImage->resourceBuffer());
361 ASSERT_TRUE(cachedImage->hasImage()); 363 ASSERT_FALSE(cachedImage->hasImage());
362 ASSERT_EQ(client->imageChangedCount(), 3); 364 ASSERT_EQ(client->imageChangedCount(), 3);
363 365
366 Vector<unsigned char> jpeg2 = jpegImage2();
364 cachedImage->loader()->didReceiveResponse(nullptr, WrappedResourceResponse(r esourceResponse), nullptr); 367 cachedImage->loader()->didReceiveResponse(nullptr, WrappedResourceResponse(r esourceResponse), nullptr);
365 cachedImage->loader()->didReceiveData(nullptr, reinterpret_cast<const char*> (jpeg.data()), jpeg.size(), jpeg.size()); 368 cachedImage->loader()->didReceiveData(nullptr, reinterpret_cast<const char*> (jpeg2.data()), jpeg2.size(), jpeg2.size());
366 cachedImage->loader()->didFinishLoading(nullptr, 0.0, jpeg.size()); 369 cachedImage->loader()->didFinishLoading(nullptr, 0.0, jpeg2.size());
367 ASSERT_FALSE(cachedImage->errorOccurred()); 370 ASSERT_FALSE(cachedImage->errorOccurred());
368 ASSERT_TRUE(cachedImage->hasImage()); 371 ASSERT_TRUE(cachedImage->hasImage());
369 ASSERT_FALSE(cachedImage->getImage()->isNull()); 372 ASSERT_FALSE(cachedImage->getImage()->isNull());
370 ASSERT_TRUE(client->notifyFinishedCalled()); 373 ASSERT_TRUE(client->notifyFinishedCalled());
371 ASSERT_TRUE(cachedImage->getImage()->isBitmapImage()); 374 ASSERT_TRUE(cachedImage->getImage()->isBitmapImage());
375 EXPECT_EQ(50, cachedImage->getImage()->width());
376 EXPECT_EQ(50, cachedImage->getImage()->height());
372 } 377 }
373 378
374 TEST(ImageResourceTest, SVGImage) 379 TEST(ImageResourceTest, SVGImage)
375 { 380 {
376 KURL url(ParsedURLString, "http://127.0.0.1:8000/foo"); 381 KURL url(ParsedURLString, "http://127.0.0.1:8000/foo");
377 ImageResource* imageResource = ImageResource::create(ResourceRequest(url)); 382 ImageResource* imageResource = ImageResource::create(ResourceRequest(url));
378 Persistent<MockImageResourceClient> client = new MockImageResourceClient(ima geResource); 383 Persistent<MockImageResourceClient> client = new MockImageResourceClient(ima geResource);
379 384
380 receiveResponse(imageResource, url, "image/svg+xml", svgImage()); 385 receiveResponse(imageResource, url, "image/svg+xml", svgImage());
381 386
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 ASSERT_TRUE(imageResource->hasImage()); 573 ASSERT_TRUE(imageResource->hasImage());
569 EXPECT_FALSE(imageResource->getImage()->isNull()); 574 EXPECT_FALSE(imageResource->getImage()->isNull());
570 EXPECT_EQ(2, client->imageChangedCount()); 575 EXPECT_EQ(2, client->imageChangedCount());
571 EXPECT_TRUE(client->notifyFinishedCalled()); 576 EXPECT_TRUE(client->notifyFinishedCalled());
572 EXPECT_FALSE(imageResource->getImage()->isBitmapImage()); 577 EXPECT_FALSE(imageResource->getImage()->isBitmapImage());
573 EXPECT_EQ(300, imageResource->getImage()->width()); 578 EXPECT_EQ(300, imageResource->getImage()->width());
574 EXPECT_EQ(300, imageResource->getImage()->height()); 579 EXPECT_EQ(300, imageResource->getImage()->height());
575 } 580 }
576 581
577 } // namespace blink 582 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698