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

Side by Side Diff: printing/pdf_metafile_cairo_linux_unittest.cc

Issue 6879098: Fix print preview clipping issues due to scaling. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Fix mac build. Created 9 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 | Annotate | Revision Log
« no previous file with comments | « printing/pdf_metafile_cairo_linux.cc ('k') | printing/pdf_metafile_cg_mac.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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "printing/pdf_metafile_cairo_linux.h" 5 #include "printing/pdf_metafile_cairo_linux.h"
6 6
7 #include <fcntl.h> 7 #include <fcntl.h>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 14 matching lines...) Expand all
25 } // namespace 25 } // namespace
26 26
27 namespace printing { 27 namespace printing {
28 28
29 TEST_F(PdfMetafileCairoTest, Pdf) { 29 TEST_F(PdfMetafileCairoTest, Pdf) {
30 // Tests in-renderer constructor. 30 // Tests in-renderer constructor.
31 printing::PdfMetafileCairo pdf; 31 printing::PdfMetafileCairo pdf;
32 EXPECT_TRUE(pdf.Init()); 32 EXPECT_TRUE(pdf.Init());
33 33
34 // Renders page 1. 34 // Renders page 1.
35 EXPECT_TRUE(pdf.StartPage(gfx::Size(72, 73), gfx::Point(4, 5), 1)); 35 EXPECT_TRUE(pdf.StartPage(gfx::Size(72, 73), gfx::Rect(4, 5, 64, 63), 1));
36 // In theory, we should use Cairo to draw something on |context|. 36 // In theory, we should use Cairo to draw something on |context|.
37 EXPECT_TRUE(pdf.FinishPage()); 37 EXPECT_TRUE(pdf.FinishPage());
38 38
39 // Renders page 2. 39 // Renders page 2.
40 EXPECT_TRUE(pdf.StartPage(gfx::Size(72, 73), gfx::Point(4, 5), 1)); 40 EXPECT_TRUE(pdf.StartPage(gfx::Size(72, 73), gfx::Rect(4, 5, 64, 63), 1));
41 // In theory, we should use Cairo to draw something on |context|. 41 // In theory, we should use Cairo to draw something on |context|.
42 EXPECT_TRUE(pdf.FinishPage()); 42 EXPECT_TRUE(pdf.FinishPage());
43 43
44 // Closes the file. 44 // Closes the file.
45 pdf.FinishDocument(); 45 pdf.FinishDocument();
46 46
47 // Checks data size. 47 // Checks data size.
48 uint32 size = pdf.GetDataSize(); 48 uint32 size = pdf.GetDataSize();
49 EXPECT_GT(size, 0u); 49 EXPECT_GT(size, 0u);
50 50
(...skipping 12 matching lines...) Expand all
63 // Tests if the header begins with "%PDF". 63 // Tests if the header begins with "%PDF".
64 std::string header(&buffer2.front(), 4); 64 std::string header(&buffer2.front(), 4);
65 EXPECT_EQ(header.find("%PDF", 0), 0u); 65 EXPECT_EQ(header.find("%PDF", 0), 0u);
66 66
67 // Tests if we can save data. 67 // Tests if we can save data.
68 EXPECT_TRUE(pdf.SaveTo(FilePath("/dev/null"))); 68 EXPECT_TRUE(pdf.SaveTo(FilePath("/dev/null")));
69 69
70 // Test overriding the metafile with raw data. 70 // Test overriding the metafile with raw data.
71 printing::PdfMetafileCairo pdf3; 71 printing::PdfMetafileCairo pdf3;
72 EXPECT_TRUE(pdf3.Init()); 72 EXPECT_TRUE(pdf3.Init());
73 EXPECT_TRUE(pdf3.StartPage(gfx::Size(72, 73), gfx::Point(4, 5), 1)); 73 EXPECT_TRUE(pdf3.StartPage(gfx::Size(72, 73), gfx::Rect(4, 5, 64, 63), 1));
74 std::string test_raw_data = "Dummy PDF"; 74 std::string test_raw_data = "Dummy PDF";
75 EXPECT_TRUE(pdf3.InitFromData(test_raw_data.c_str(), test_raw_data.size())); 75 EXPECT_TRUE(pdf3.InitFromData(test_raw_data.c_str(), test_raw_data.size()));
76 EXPECT_TRUE(pdf3.FinishPage()); 76 EXPECT_TRUE(pdf3.FinishPage());
77 pdf3.FinishDocument(); 77 pdf3.FinishDocument();
78 size = pdf3.GetDataSize(); 78 size = pdf3.GetDataSize();
79 EXPECT_EQ(test_raw_data.size(), size); 79 EXPECT_EQ(test_raw_data.size(), size);
80 std::string output; 80 std::string output;
81 pdf3.GetData(WriteInto(&output, size + 1), size); 81 pdf3.GetData(WriteInto(&output, size + 1), size);
82 EXPECT_EQ(test_raw_data, output); 82 EXPECT_EQ(test_raw_data, output);
83 } 83 }
84 84
85 } // namespace printing 85 } // namespace printing
OLDNEW
« no previous file with comments | « printing/pdf_metafile_cairo_linux.cc ('k') | printing/pdf_metafile_cg_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698