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

Side by Side Diff: chrome/browser/image_decoder_browsertest.cc

Issue 2715153006: Set desired_image_size when decoding images for NTP Tile icons. (Closed)
Patch Set: ios test fixes 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 | « chrome/browser/image_decoder.cc ('k') | chrome/browser/search/suggestions/image_decoder_impl.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 "chrome/browser/image_decoder.h" 5 #include "chrome/browser/image_decoder.h"
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "build/build_config.h" 8 #include "build/build_config.h"
9 #include "chrome/grit/generated_resources.h" 9 #include "chrome/grit/generated_resources.h"
10 #include "chrome/test/base/in_process_browser_test.h" 10 #include "chrome/test/base/in_process_browser_test.h"
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 ImageDecoder::ROBUST_PNG_CODEC, 180 ImageDecoder::ROBUST_PNG_CODEC,
181 false /* shrink_to_fit */); 181 false /* shrink_to_fit */);
182 runner->Run(); 182 runner->Run();
183 EXPECT_TRUE(test_request.decode_succeeded()); 183 EXPECT_TRUE(test_request.decode_succeeded());
184 } 184 }
185 185
186 IN_PROC_BROWSER_TEST_F(ImageDecoderBrowserTest, RobustJpegCodecWithJpegData) { 186 IN_PROC_BROWSER_TEST_F(ImageDecoderBrowserTest, RobustJpegCodecWithJpegData) {
187 scoped_refptr<content::MessageLoopRunner> runner = 187 scoped_refptr<content::MessageLoopRunner> runner =
188 new content::MessageLoopRunner; 188 new content::MessageLoopRunner;
189 TestImageRequest test_request(runner->QuitClosure()); 189 TestImageRequest test_request(runner->QuitClosure());
190 ImageDecoder::StartWithOptions(&test_request, GetValidJpgData(), 190 ImageDecoder::StartWithOptions(
191 ImageDecoder::ROBUST_JPEG_CODEC, 191 &test_request, GetValidJpgData(), ImageDecoder::ROBUST_JPEG_CODEC,
192 false /* shrink_to_fit */); 192 false /* shrink_to_fit */, gfx::Size() /* desired_image_frame_size */);
Nico 2017/03/02 14:17:11 nit: can you change the /**/ comments to look like
tschumann 2017/03/02 16:25:51 I left the comment for desired_image_frame_size fo
193 runner->Run(); 193 runner->Run();
194 EXPECT_TRUE(test_request.decode_succeeded()); 194 EXPECT_TRUE(test_request.decode_succeeded());
195 } 195 }
196 196
197 IN_PROC_BROWSER_TEST_F(ImageDecoderBrowserTest, RobustJpegCodecWithPngData) { 197 IN_PROC_BROWSER_TEST_F(ImageDecoderBrowserTest, RobustJpegCodecWithPngData) {
198 scoped_refptr<content::MessageLoopRunner> runner = 198 scoped_refptr<content::MessageLoopRunner> runner =
199 new content::MessageLoopRunner; 199 new content::MessageLoopRunner;
200 TestImageRequest test_request(runner->QuitClosure()); 200 TestImageRequest test_request(runner->QuitClosure());
201 ImageDecoder::StartWithOptions(&test_request, GetValidPngData(), 201 ImageDecoder::StartWithOptions(
202 ImageDecoder::ROBUST_JPEG_CODEC, 202 &test_request, GetValidPngData(), ImageDecoder::ROBUST_JPEG_CODEC,
203 false /* shrink_to_fit */); 203 false /* shrink_to_fit */, gfx::Size() /* desired_image_frame_size */);
204 runner->Run(); 204 runner->Run();
205 // Should fail with PNG data because only JPEG data is allowed. 205 // Should fail with PNG data because only JPEG data is allowed.
206 EXPECT_FALSE(test_request.decode_succeeded()); 206 EXPECT_FALSE(test_request.decode_succeeded());
207 } 207 }
208 208
209 IN_PROC_BROWSER_TEST_F(ImageDecoderBrowserTest, RobustPngCodecWithPngData) { 209 IN_PROC_BROWSER_TEST_F(ImageDecoderBrowserTest, RobustPngCodecWithPngData) {
210 scoped_refptr<content::MessageLoopRunner> runner = 210 scoped_refptr<content::MessageLoopRunner> runner =
211 new content::MessageLoopRunner; 211 new content::MessageLoopRunner;
212 TestImageRequest test_request(runner->QuitClosure()); 212 TestImageRequest test_request(runner->QuitClosure());
213 ImageDecoder::StartWithOptions(&test_request, GetValidPngData(), 213 ImageDecoder::StartWithOptions(
214 ImageDecoder::ROBUST_PNG_CODEC, 214 &test_request, GetValidPngData(), ImageDecoder::ROBUST_PNG_CODEC,
215 false /* shrink_to_fit */); 215 false /* shrink_to_fit */, gfx::Size() /* desired_image_frame_size */);
216 runner->Run(); 216 runner->Run();
217 EXPECT_TRUE(test_request.decode_succeeded()); 217 EXPECT_TRUE(test_request.decode_succeeded());
218 } 218 }
219 219
220 IN_PROC_BROWSER_TEST_F(ImageDecoderBrowserTest, RobustPngCodecWithJpegData) { 220 IN_PROC_BROWSER_TEST_F(ImageDecoderBrowserTest, RobustPngCodecWithJpegData) {
221 scoped_refptr<content::MessageLoopRunner> runner = 221 scoped_refptr<content::MessageLoopRunner> runner =
222 new content::MessageLoopRunner; 222 new content::MessageLoopRunner;
223 TestImageRequest test_request(runner->QuitClosure()); 223 TestImageRequest test_request(runner->QuitClosure());
224 ImageDecoder::StartWithOptions(&test_request, GetValidJpgData(), 224 ImageDecoder::StartWithOptions(
225 ImageDecoder::ROBUST_PNG_CODEC, 225 &test_request, GetValidJpgData(), ImageDecoder::ROBUST_PNG_CODEC,
226 false /* shrink_to_fit */); 226 false /* shrink_to_fit */, gfx::Size() /* desired_image_frame_size */);
227 runner->Run(); 227 runner->Run();
228 // Should fail with JPEG data because only PNG data is allowed. 228 // Should fail with JPEG data because only PNG data is allowed.
229 EXPECT_FALSE(test_request.decode_succeeded()); 229 EXPECT_FALSE(test_request.decode_succeeded());
230 } 230 }
231 231
232 #endif // defined(OS_CHROMEOS) 232 #endif // defined(OS_CHROMEOS)
233 233
234 IN_PROC_BROWSER_TEST_F(ImageDecoderBrowserTest, BasicDecode) { 234 IN_PROC_BROWSER_TEST_F(ImageDecoderBrowserTest, BasicDecode) {
235 scoped_refptr<content::MessageLoopRunner> runner = 235 scoped_refptr<content::MessageLoopRunner> runner =
236 new content::MessageLoopRunner; 236 new content::MessageLoopRunner;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 new content::MessageLoopRunner; 272 new content::MessageLoopRunner;
273 TestImageRequest test_request(runner->QuitClosure()); 273 TestImageRequest test_request(runner->QuitClosure());
274 ImageDecoder::Start(&test_request, GetValidPngData()); 274 ImageDecoder::Start(&test_request, GetValidPngData());
275 runner->Run(); 275 runner->Run();
276 if (!test_request.decode_succeeded()) { 276 if (!test_request.decode_succeeded()) {
277 // The UI thread won the race. Make sure the utility process did get killed. 277 // The UI thread won the race. Make sure the utility process did get killed.
278 EXPECT_TRUE(observer.did_kill()); 278 EXPECT_TRUE(observer.did_kill());
279 } 279 }
280 // Else the IO thread won the race and the image got decoded. Oh well. 280 // Else the IO thread won the race and the image got decoded. Oh well.
281 } 281 }
OLDNEW
« no previous file with comments | « chrome/browser/image_decoder.cc ('k') | chrome/browser/search/suggestions/image_decoder_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698