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

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

Issue 1923003002: Clear Resource::m_loader in Resource::finish() and Resource::error() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase, comment in background.js Created 4 years, 7 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
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 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 ASSERT_FALSE(cachedImage->hasImage()); 159 ASSERT_FALSE(cachedImage->hasImage());
160 ASSERT_EQ(client.imageChangedCount(), 0); 160 ASSERT_EQ(client.imageChangedCount(), 0);
161 ASSERT_FALSE(client.notifyFinishedCalled()); 161 ASSERT_FALSE(client.notifyFinishedCalled());
162 162
163 const char thirdPart[] = "--boundary"; 163 const char thirdPart[] = "--boundary";
164 cachedImage->appendData(thirdPart, strlen(thirdPart)); 164 cachedImage->appendData(thirdPart, strlen(thirdPart));
165 ASSERT_TRUE(cachedImage->resourceBuffer()); 165 ASSERT_TRUE(cachedImage->resourceBuffer());
166 ASSERT_EQ(cachedImage->resourceBuffer()->size(), strlen(secondPart) - 1); 166 ASSERT_EQ(cachedImage->resourceBuffer()->size(), strlen(secondPart) - 1);
167 167
168 // This part finishes. The image is created, callbacks are sent, and the dat a buffer is cleared. 168 // This part finishes. The image is created, callbacks are sent, and the dat a buffer is cleared.
169 cachedImage->finish(); 169 cachedImage->loader()->didFinishLoading(nullptr, 0.0, 0);
170 ASSERT_FALSE(cachedImage->resourceBuffer()); 170 ASSERT_FALSE(cachedImage->resourceBuffer());
171 ASSERT_FALSE(cachedImage->errorOccurred()); 171 ASSERT_FALSE(cachedImage->errorOccurred());
172 ASSERT_TRUE(cachedImage->hasImage()); 172 ASSERT_TRUE(cachedImage->hasImage());
173 ASSERT_FALSE(cachedImage->getImage()->isNull()); 173 ASSERT_FALSE(cachedImage->getImage()->isNull());
174 ASSERT_EQ(cachedImage->getImage()->width(), 1); 174 ASSERT_EQ(cachedImage->getImage()->width(), 1);
175 ASSERT_EQ(cachedImage->getImage()->height(), 1); 175 ASSERT_EQ(cachedImage->getImage()->height(), 1);
176 ASSERT_EQ(client.imageChangedCount(), 1); 176 ASSERT_EQ(client.imageChangedCount(), 1);
177 ASSERT_TRUE(client.notifyFinishedCalled()); 177 ASSERT_TRUE(client.notifyFinishedCalled());
178 } 178 }
179 179
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 ASSERT_EQ(client.imageChangedCount(), 2); 284 ASSERT_EQ(client.imageChangedCount(), 2);
285 ASSERT_TRUE(client.notifyFinishedCalled()); 285 ASSERT_TRUE(client.notifyFinishedCalled());
286 ASSERT_TRUE(cachedImage->getImage()->isBitmapImage()); 286 ASSERT_TRUE(cachedImage->getImage()->isBitmapImage());
287 287
288 cachedImage->reloadIfLoFi(fetcher); 288 cachedImage->reloadIfLoFi(fetcher);
289 ASSERT_FALSE(cachedImage->errorOccurred()); 289 ASSERT_FALSE(cachedImage->errorOccurred());
290 ASSERT_FALSE(cachedImage->resourceBuffer()); 290 ASSERT_FALSE(cachedImage->resourceBuffer());
291 ASSERT_TRUE(cachedImage->hasImage()); 291 ASSERT_TRUE(cachedImage->hasImage());
292 ASSERT_EQ(client.imageChangedCount(), 3); 292 ASSERT_EQ(client.imageChangedCount(), 3);
293 293
294 cachedImage->responseReceived(resourceResponse, nullptr); 294 cachedImage->loader()->didReceiveResponse(nullptr, WrappedResourceResponse(r esourceResponse), nullptr);
295 cachedImage->appendData(reinterpret_cast<const char*>(jpeg.data()), jpeg.siz e()); 295 cachedImage->loader()->didReceiveData(nullptr, reinterpret_cast<const char*> (jpeg.data()), jpeg.size(), jpeg.size());
296 cachedImage->finish(); 296 cachedImage->loader()->didFinishLoading(nullptr, 0.0, jpeg.size());
297 ASSERT_FALSE(cachedImage->errorOccurred()); 297 ASSERT_FALSE(cachedImage->errorOccurred());
298 ASSERT_TRUE(cachedImage->hasImage()); 298 ASSERT_TRUE(cachedImage->hasImage());
299 ASSERT_FALSE(cachedImage->getImage()->isNull()); 299 ASSERT_FALSE(cachedImage->getImage()->isNull());
300 ASSERT_TRUE(client.notifyFinishedCalled()); 300 ASSERT_TRUE(client.notifyFinishedCalled());
301 ASSERT_TRUE(cachedImage->getImage()->isBitmapImage()); 301 ASSERT_TRUE(cachedImage->getImage()->isBitmapImage());
302 } 302 }
303 303
304 } // namespace blink 304 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698