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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/DeferredImageDecoderTest.cpp

Issue 1571233003: Fix errors caused by unsafe conversions to/from size_t (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: improved ALLOW_NUMERIC_ARG_TYPES_PROMOTABLE_TO Created 4 years, 11 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) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 m_status = ImageFrame::FramePartial; 241 m_status = ImageFrame::FramePartial;
242 m_lazyDecoder->setData(*m_data, false); 242 m_lazyDecoder->setData(*m_data, false);
243 EXPECT_FALSE(m_lazyDecoder->frameIsCompleteAtIndex(0)); 243 EXPECT_FALSE(m_lazyDecoder->frameIsCompleteAtIndex(0));
244 RefPtr<SkImage> image = m_lazyDecoder->createFrameAtIndex(0); 244 RefPtr<SkImage> image = m_lazyDecoder->createFrameAtIndex(0);
245 ASSERT_TRUE(image); 245 ASSERT_TRUE(image);
246 unsigned firstId = image->uniqueID(); 246 unsigned firstId = image->uniqueID();
247 EXPECT_FALSE(m_lazyDecoder->frameIsCompleteAtIndex(0)); 247 EXPECT_FALSE(m_lazyDecoder->frameIsCompleteAtIndex(0));
248 EXPECT_TRUE(m_actualDecoder); 248 EXPECT_TRUE(m_actualDecoder);
249 249
250 m_status = ImageFrame::FrameComplete; 250 m_status = ImageFrame::FrameComplete;
251 m_data->append(" ", 1); 251 m_data->append(" ", 1u);
252 m_lazyDecoder->setData(*m_data, true); 252 m_lazyDecoder->setData(*m_data, true);
253 EXPECT_FALSE(m_actualDecoder); 253 EXPECT_FALSE(m_actualDecoder);
254 EXPECT_TRUE(m_lazyDecoder->frameIsCompleteAtIndex(0)); 254 EXPECT_TRUE(m_lazyDecoder->frameIsCompleteAtIndex(0));
255 255
256 image = m_lazyDecoder->createFrameAtIndex(0); 256 image = m_lazyDecoder->createFrameAtIndex(0);
257 ASSERT_TRUE(image); 257 ASSERT_TRUE(image);
258 unsigned secondId = image->uniqueID(); 258 unsigned secondId = image->uniqueID();
259 EXPECT_FALSE(m_decodeRequestCount); 259 EXPECT_FALSE(m_decodeRequestCount);
260 EXPECT_NE(firstId, secondId); 260 EXPECT_NE(firstId, secondId);
261 } 261 }
262 262
263 TEST_F(DeferredImageDecoderTest, multiFrameImageLoading) 263 TEST_F(DeferredImageDecoderTest, multiFrameImageLoading)
264 { 264 {
265 m_repetitionCount = 10; 265 m_repetitionCount = 10;
266 m_frameCount = 1; 266 m_frameCount = 1;
267 m_frameDuration = 10; 267 m_frameDuration = 10;
268 m_status = ImageFrame::FramePartial; 268 m_status = ImageFrame::FramePartial;
269 m_lazyDecoder->setData(*m_data, false); 269 m_lazyDecoder->setData(*m_data, false);
270 270
271 RefPtr<SkImage> image = m_lazyDecoder->createFrameAtIndex(0); 271 RefPtr<SkImage> image = m_lazyDecoder->createFrameAtIndex(0);
272 ASSERT_TRUE(image); 272 ASSERT_TRUE(image);
273 unsigned firstId = image->uniqueID(); 273 unsigned firstId = image->uniqueID();
274 EXPECT_FALSE(m_lazyDecoder->frameIsCompleteAtIndex(0)); 274 EXPECT_FALSE(m_lazyDecoder->frameIsCompleteAtIndex(0));
275 EXPECT_EQ(10.0f, m_lazyDecoder->frameDurationAtIndex(0)); 275 EXPECT_EQ(10.0f, m_lazyDecoder->frameDurationAtIndex(0));
276 276
277 m_frameCount = 2; 277 m_frameCount = 2;
278 m_frameDuration = 20; 278 m_frameDuration = 20;
279 m_status = ImageFrame::FrameComplete; 279 m_status = ImageFrame::FrameComplete;
280 m_data->append(" ", 1); 280 m_data->append(" ", 1u);
281 m_lazyDecoder->setData(*m_data, false); 281 m_lazyDecoder->setData(*m_data, false);
282 282
283 image = m_lazyDecoder->createFrameAtIndex(0); 283 image = m_lazyDecoder->createFrameAtIndex(0);
284 ASSERT_TRUE(image); 284 ASSERT_TRUE(image);
285 unsigned secondId = image->uniqueID(); 285 unsigned secondId = image->uniqueID();
286 EXPECT_NE(firstId, secondId); 286 EXPECT_NE(firstId, secondId);
287 EXPECT_TRUE(m_lazyDecoder->frameIsCompleteAtIndex(0)); 287 EXPECT_TRUE(m_lazyDecoder->frameIsCompleteAtIndex(0));
288 EXPECT_TRUE(m_lazyDecoder->frameIsCompleteAtIndex(1)); 288 EXPECT_TRUE(m_lazyDecoder->frameIsCompleteAtIndex(1));
289 EXPECT_EQ(20.0f, m_lazyDecoder->frameDurationAtIndex(1)); 289 EXPECT_EQ(20.0f, m_lazyDecoder->frameDurationAtIndex(1));
290 EXPECT_TRUE(m_actualDecoder); 290 EXPECT_TRUE(m_actualDecoder);
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 // After decoding, the frame is known to be opaque. 359 // After decoding, the frame is known to be opaque.
360 frame = decoder->createFrameAtIndex(0); 360 frame = decoder->createFrameAtIndex(0);
361 ASSERT_TRUE(frame); 361 ASSERT_TRUE(frame);
362 EXPECT_TRUE(frame->isOpaque()); 362 EXPECT_TRUE(frame->isOpaque());
363 363
364 // Re-generating the opaque-marked frame should not fail. 364 // Re-generating the opaque-marked frame should not fail.
365 EXPECT_TRUE(frame->readPixels(pixels, 0, 0)); 365 EXPECT_TRUE(frame->readPixels(pixels, 0, 0));
366 } 366 }
367 367
368 } // namespace blink 368 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698