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

Side by Side Diff: ui/gfx/codec/chromeos/jpeg_codec_robust_slow_unittest.cc

Issue 2755563002: Move ui/gfx/codec/ into its own component. (Closed)
Patch Set: none Created 3 years, 9 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 | « ui/gfx/codec/chromeos/jpeg_codec_robust_slow.cc ('k') | ui/gfx/codec/codec_export.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <math.h> 5 #include <math.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "ui/gfx/chromeos/codec/jpeg_codec_robust_slow.h" 10 #include "ui/gfx/codec/chromeos/jpeg_codec_robust_slow.h"
11 11
12 namespace { 12 namespace {
13 13
14 // A JPEG image used by TopSitesMigrationTest, whose size is 1x1. 14 // A JPEG image used by TopSitesMigrationTest, whose size is 1x1.
15 // This image causes an invalid-read error to libjpeg-turbo 1.0.1. 15 // This image causes an invalid-read error to libjpeg-turbo 1.0.1.
16 const uint8_t kTopSitesMigrationTestImage[] = 16 const uint8_t kTopSitesMigrationTestImage[] =
17 "\xff\xd8\xff\xe0\x00\x10\x4a\x46\x49\x46\x00\x01\x01\x00\x00\x01" 17 "\xff\xd8\xff\xe0\x00\x10\x4a\x46\x49\x46\x00\x01\x01\x00\x00\x01"
18 "\x00\x01\x00\x00\xff\xdb\x00\x43\x00\x03\x02\x02\x03\x02\x02\x03" 18 "\x00\x01\x00\x00\xff\xdb\x00\x43\x00\x03\x02\x02\x03\x02\x02\x03"
19 "\x03\x03\x03\x04\x03\x03\x04\x05\x08\x05\x05\x04\x04\x05\x0a\x07" 19 "\x03\x03\x03\x04\x03\x03\x04\x05\x08\x05\x05\x04\x04\x05\x0a\x07"
20 "\x07\x06\x08\x0c\x0a\x0c\x0c\x0b\x0a\x0b\x0b\x0d\x0e\x12\x10\x0d" 20 "\x07\x06\x08\x0c\x0a\x0c\x0c\x0b\x0a\x0b\x0b\x0d\x0e\x12\x10\x0d"
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 JPEGCodecRobustSlow::FORMAT_RGB, 86 JPEGCodecRobustSlow::FORMAT_RGB,
87 &output, &outw, &outh)); 87 &output, &outw, &outh));
88 } 88 }
89 89
90 // Test that we can decode JPEG images without invalid-read errors on valgrind. 90 // Test that we can decode JPEG images without invalid-read errors on valgrind.
91 // This test decodes a 1x1 JPEG image and writes the decoded RGB (or RGBA) pixel 91 // This test decodes a 1x1 JPEG image and writes the decoded RGB (or RGBA) pixel
92 // to the output buffer without OOB reads. 92 // to the output buffer without OOB reads.
93 TEST(JPEGCodecRobustSlow, InvalidRead) { 93 TEST(JPEGCodecRobustSlow, InvalidRead) {
94 std::vector<unsigned char> output; 94 std::vector<unsigned char> output;
95 int outw, outh; 95 int outw, outh;
96 ASSERT_TRUE( 96 ASSERT_TRUE(JPEGCodecRobustSlow::Decode(
97 JPEGCodecRobustSlow::Decode(kTopSitesMigrationTestImage, 97 kTopSitesMigrationTestImage, arraysize(kTopSitesMigrationTestImage),
98 arraysize(kTopSitesMigrationTestImage), 98 JPEGCodecRobustSlow::FORMAT_RGB, &output, &outw, &outh));
99 JPEGCodecRobustSlow::FORMAT_RGB, &output, 99 ASSERT_TRUE(JPEGCodecRobustSlow::Decode(
100 &outw, &outh)); 100 kTopSitesMigrationTestImage, arraysize(kTopSitesMigrationTestImage),
101 ASSERT_TRUE( 101 JPEGCodecRobustSlow::FORMAT_RGBA, &output, &outw, &outh));
102 JPEGCodecRobustSlow::Decode(kTopSitesMigrationTestImage,
103 arraysize(kTopSitesMigrationTestImage),
104 JPEGCodecRobustSlow::FORMAT_RGBA, &output,
105 &outw, &outh));
106 } 102 }
107 103
108 } // namespace gfx 104 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/codec/chromeos/jpeg_codec_robust_slow.cc ('k') | ui/gfx/codec/codec_export.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698