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

Side by Side Diff: chrome/browser/printing/print_preview_pdf_generated_browsertest.cc

Issue 431403002: Print Preview end to end browser test uses correct DPI when converting PDF to PNG. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <algorithm> 5 #include <algorithm>
6 #include <fstream> 6 #include <fstream>
7 #include <iostream> 7 #include <iostream>
8 #include <iterator> 8 #include <iterator>
9 #include <limits> 9 #include <limits>
10 #include <string> 10 #include <string>
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 std::string pdf_data; 361 std::string pdf_data;
362 362
363 ASSERT_TRUE(base::ReadFileToString(pdf_file_save_path_, &pdf_data)); 363 ASSERT_TRUE(base::ReadFileToString(pdf_file_save_path_, &pdf_data));
364 ASSERT_TRUE(pdf_doc_info_func_(pdf_data.data(), 364 ASSERT_TRUE(pdf_doc_info_func_(pdf_data.data(),
365 pdf_data.size(), 365 pdf_data.size(),
366 &num_pages, 366 &num_pages,
367 &max_width_in_points)); 367 &max_width_in_points));
368 368
369 ASSERT_GT(num_pages, 0); 369 ASSERT_GT(num_pages, 0);
370 double max_width_in_pixels = 370 double max_width_in_pixels =
371 ConvertPointsToPixelDouble(max_width_in_points); 371 ConvertUnitDouble(max_width_in_points, kPointsPerInch, kDpi);
372 372
373 for (int i = 0; i < num_pages; ++i) { 373 for (int i = 0; i < num_pages; ++i) {
374 double width_in_points, height_in_points; 374 double width_in_points, height_in_points;
375 ASSERT_TRUE(pdf_page_size_func_(pdf_data.data(), 375 ASSERT_TRUE(pdf_page_size_func_(pdf_data.data(),
376 pdf_data.size(), 376 pdf_data.size(),
377 i, 377 i,
378 &width_in_points, 378 &width_in_points,
379 &height_in_points)); 379 &height_in_points));
380 380
381 double width_in_pixels = ConvertPointsToPixelDouble(width_in_points); 381 double width_in_pixels = ConvertUnitDouble(
382 double height_in_pixels = ConvertPointsToPixelDouble(height_in_points); 382 width_in_points, kPointsPerInch, kDpi);
383 double height_in_pixels = ConvertUnitDouble(
384 height_in_points, kPointsPerInch, kDpi);
383 385
384 // The image will be rotated if |width_in_pixels| is greater than 386 // The image will be rotated if |width_in_pixels| is greater than
385 // |height_in_pixels|. This is because the page will be rotated to fit 387 // |height_in_pixels|. This is because the page will be rotated to fit
386 // within a piece of paper. Therefore, |width_in_pixels| and 388 // within a piece of paper. Therefore, |width_in_pixels| and
387 // |height_in_pixels| have to be swapped or else they won't reflect the 389 // |height_in_pixels| have to be swapped or else they won't reflect the
388 // dimensions of the rotated page. 390 // dimensions of the rotated page.
389 if (width_in_pixels > height_in_pixels) 391 if (width_in_pixels > height_in_pixels)
390 std::swap(width_in_pixels, height_in_pixels); 392 std::swap(width_in_pixels, height_in_pixels);
391 393
392 total_height_in_pixels += height_in_pixels; 394 total_height_in_pixels += height_in_pixels;
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
692 // waiting for this message and start waiting for the image data. 694 // waiting for this message and start waiting for the image data.
693 std::cout << "#EOF\n"; 695 std::cout << "#EOF\n";
694 std::cout.flush(); 696 std::cout.flush();
695 697
696 SendPng(); 698 SendPng();
697 Reset(); 699 Reset();
698 } 700 }
699 } 701 }
700 702
701 } // namespace printing 703 } // namespace printing
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698