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

Side by Side Diff: printing/pdf_ps_metafile_cairo_unittest.cc

Issue 1520014: Linux: fix printing somewhat.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 8 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
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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_ps_metafile_cairo.h" 5 #include "printing/pdf_ps_metafile_cairo.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 12 matching lines...) Expand all
23 23
24 TEST_F(PdfPsTest, Pdf) { 24 TEST_F(PdfPsTest, Pdf) {
25 // Tests in-renderer constructor. 25 // Tests in-renderer constructor.
26 printing::PdfPsMetafile pdf(printing::PdfPsMetafile::PDF); 26 printing::PdfPsMetafile pdf(printing::PdfPsMetafile::PDF);
27 EXPECT_TRUE(pdf.Init()); 27 EXPECT_TRUE(pdf.Init());
28 28
29 // Renders page 1. 29 // Renders page 1.
30 cairo_t* context = pdf.StartPage(72, 72); 30 cairo_t* context = pdf.StartPage(72, 72);
31 EXPECT_TRUE(context != NULL); 31 EXPECT_TRUE(context != NULL);
32 // In theory, we should use Cairo to draw something on |context|. 32 // In theory, we should use Cairo to draw something on |context|.
33 EXPECT_TRUE(pdf.FinishPage(1.5)); 33 EXPECT_TRUE(pdf.FinishPage());
34 34
35 // Renders page 2. 35 // Renders page 2.
36 context = pdf.StartPage(64, 64); 36 context = pdf.StartPage(64, 64);
37 EXPECT_TRUE(context != NULL); 37 EXPECT_TRUE(context != NULL);
38 // In theory, we should use Cairo to draw something on |context|. 38 // In theory, we should use Cairo to draw something on |context|.
39 EXPECT_TRUE(pdf.FinishPage(0.5)); 39 EXPECT_TRUE(pdf.FinishPage());
40 40
41 // Closes the file. 41 // Closes the file.
42 pdf.Close(); 42 pdf.Close();
43 43
44 // Checks data size. 44 // Checks data size.
45 uint32 size = pdf.GetDataSize(); 45 uint32 size = pdf.GetDataSize();
46 EXPECT_GT(size, 0u); 46 EXPECT_GT(size, 0u);
47 47
48 // Gets resulting data. 48 // Gets resulting data.
49 std::vector<char> buffer(size, 0x00); 49 std::vector<char> buffer(size, 0x00);
(...skipping 17 matching lines...) Expand all
67 67
68 TEST_F(PdfPsTest, Ps) { 68 TEST_F(PdfPsTest, Ps) {
69 // Tests in-renderer constructor. 69 // Tests in-renderer constructor.
70 printing::PdfPsMetafile ps(printing::PdfPsMetafile::PS); 70 printing::PdfPsMetafile ps(printing::PdfPsMetafile::PS);
71 EXPECT_TRUE(ps.Init()); 71 EXPECT_TRUE(ps.Init());
72 72
73 // Renders page 1. 73 // Renders page 1.
74 cairo_t* context = ps.StartPage(72, 72); 74 cairo_t* context = ps.StartPage(72, 72);
75 EXPECT_TRUE(context != NULL); 75 EXPECT_TRUE(context != NULL);
76 // In theory, we should use Cairo to draw something on |context|. 76 // In theory, we should use Cairo to draw something on |context|.
77 EXPECT_TRUE(ps.FinishPage(1.5)); 77 EXPECT_TRUE(ps.FinishPage());
78 78
79 // Renders page 2. 79 // Renders page 2.
80 context = ps.StartPage(64, 64); 80 context = ps.StartPage(64, 64);
81 EXPECT_TRUE(context != NULL); 81 EXPECT_TRUE(context != NULL);
82 // In theory, we should use Cairo to draw something on |context|. 82 // In theory, we should use Cairo to draw something on |context|.
83 EXPECT_TRUE(ps.FinishPage(0.5)); 83 EXPECT_TRUE(ps.FinishPage());
84 84
85 // Closes the file. 85 // Closes the file.
86 ps.Close(); 86 ps.Close();
87 87
88 // Checks data size. 88 // Checks data size.
89 uint32 size = ps.GetDataSize(); 89 uint32 size = ps.GetDataSize();
90 EXPECT_GT(size, 0u); 90 EXPECT_GT(size, 0u);
91 91
92 // Gets resulting data. 92 // Gets resulting data.
93 std::vector<char> buffer(size, 0x00); 93 std::vector<char> buffer(size, 0x00);
94 ps.GetData(&buffer.front(), size); 94 ps.GetData(&buffer.front(), size);
95 95
96 // Tests another constructor. 96 // Tests another constructor.
97 printing::PdfPsMetafile ps2(printing::PdfPsMetafile::PS); 97 printing::PdfPsMetafile ps2(printing::PdfPsMetafile::PS);
98 EXPECT_TRUE(ps2.Init(&buffer.front(), size)); 98 EXPECT_TRUE(ps2.Init(&buffer.front(), size));
99 99
100 // Tries to get the first 4 characters from ps2. 100 // Tries to get the first 4 characters from ps2.
101 std::vector<char> buffer2(4, 0x00); 101 std::vector<char> buffer2(4, 0x00);
102 ps2.GetData(&buffer2.front(), 4); 102 ps2.GetData(&buffer2.front(), 4);
103 103
104 // Tests if the header begins with "%!PS". 104 // Tests if the header begins with "%!PS".
105 std::string header(&buffer2.front(), 4); 105 std::string header(&buffer2.front(), 4);
106 EXPECT_EQ(header.find("%!PS", 0), 0u); 106 EXPECT_EQ(header.find("%!PS", 0), 0u);
107 107
108 // Tests if we can save data. 108 // Tests if we can save data.
109 EXPECT_TRUE(ps.SaveTo(DevNullFD())); 109 EXPECT_TRUE(ps.SaveTo(DevNullFD()));
110 } 110 }
OLDNEW
« no previous file with comments | « printing/pdf_ps_metafile_cairo.cc ('k') | third_party/WebKit/WebKit/chromium/src/WebFrameImpl.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698