| 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 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 cachedImage->appendData(reinterpret_cast<const char*>(jpeg.data()), jpeg.siz
e()); | 213 cachedImage->appendData(reinterpret_cast<const char*>(jpeg.data()), jpeg.siz
e()); |
| 214 cachedImage->finish(); | 214 cachedImage->finish(); |
| 215 ASSERT_FALSE(cachedImage->errorOccurred()); | 215 ASSERT_FALSE(cachedImage->errorOccurred()); |
| 216 ASSERT_TRUE(cachedImage->hasImage()); | 216 ASSERT_TRUE(cachedImage->hasImage()); |
| 217 ASSERT_FALSE(cachedImage->image()->isNull()); | 217 ASSERT_FALSE(cachedImage->image()->isNull()); |
| 218 ASSERT_EQ(client.imageChangedCount(), 2); | 218 ASSERT_EQ(client.imageChangedCount(), 2); |
| 219 ASSERT_TRUE(client.notifyFinishedCalled()); | 219 ASSERT_TRUE(client.notifyFinishedCalled()); |
| 220 ASSERT_TRUE(cachedImage->image()->isBitmapImage()); | 220 ASSERT_TRUE(cachedImage->image()->isBitmapImage()); |
| 221 } | 221 } |
| 222 | 222 |
| 223 TEST(ImageResourceTest, ReloadIfLoFi) |
| 224 { |
| 225 KURL testURL(ParsedURLString, "http://www.test.com/cancelTest.html"); |
| 226 URLTestHelpers::registerMockedURLLoad(testURL, "cancelTest.html", "text/html
"); |
| 227 ResourcePtr<ImageResource> cachedImage = new ImageResource(ResourceRequest(t
estURL), nullptr); |
| 228 cachedImage->setLoading(true); |
| 229 |
| 230 MockImageResourceClient client(cachedImage); |
| 231 ResourceFetcher* fetcher = ResourceFetcher::create(nullptr); |
| 232 |
| 233 // Send the image response. |
| 234 Vector<unsigned char> jpeg = jpegImage(); |
| 235 ResourceResponse resourceResponse(KURL(), "image/jpeg", jpeg.size(), nullAto
m, String()); |
| 236 resourceResponse.addHTTPHeaderField("chrome-proxy", "q=low"); |
| 237 |
| 238 cachedImage->responseReceived(resourceResponse, nullptr); |
| 239 cachedImage->appendData(reinterpret_cast<const char*>(jpeg.data()), jpeg.siz
e()); |
| 240 cachedImage->finish(); |
| 241 ASSERT_FALSE(cachedImage->errorOccurred()); |
| 242 ASSERT_TRUE(cachedImage->hasImage()); |
| 243 ASSERT_FALSE(cachedImage->image()->isNull()); |
| 244 ASSERT_EQ(client.imageChangedCount(), 2); |
| 245 ASSERT_TRUE(client.notifyFinishedCalled()); |
| 246 ASSERT_TRUE(cachedImage->image()->isBitmapImage()); |
| 247 |
| 248 cachedImage->reloadIfLoFi(fetcher); |
| 249 ASSERT_FALSE(cachedImage->errorOccurred()); |
| 250 ASSERT_FALSE(cachedImage->resourceBuffer()); |
| 251 ASSERT_FALSE(cachedImage->hasImage()); |
| 252 ASSERT_EQ(client.imageChangedCount(), 3); |
| 253 |
| 254 cachedImage->responseReceived(resourceResponse, nullptr); |
| 255 cachedImage->appendData(reinterpret_cast<const char*>(jpeg.data()), jpeg.siz
e()); |
| 256 cachedImage->finish(); |
| 257 ASSERT_FALSE(cachedImage->errorOccurred()); |
| 258 ASSERT_TRUE(cachedImage->hasImage()); |
| 259 ASSERT_FALSE(cachedImage->image()->isNull()); |
| 260 ASSERT_TRUE(client.notifyFinishedCalled()); |
| 261 ASSERT_TRUE(cachedImage->image()->isBitmapImage()); |
| 262 } |
| 263 |
| 223 } // namespace blink | 264 } // namespace blink |
| OLD | NEW |