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

Side by Side Diff: printing/pdf_metafile_cairo_linux_unittest.cc

Issue 7847002: Removed unneeded cairo code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removed unneeded include Created 9 years, 3 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/printing.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "printing/pdf_metafile_cairo_linux.h"
6
7 #include <fcntl.h>
8 #include <string>
9 #include <vector>
10
11 #include "base/file_descriptor_posix.h"
12 #include "base/file_path.h"
13 #include "base/file_util.h"
14 #include "base/string_util.h"
15 #include "testing/gtest/include/gtest/gtest.h"
16 #include "ui/gfx/rect.h"
17 #include "ui/gfx/size.h"
18
19 typedef struct _cairo cairo_t;
20
21 namespace {
22
23 class PdfMetafileCairoTest : public testing::Test {};
24
25 } // namespace
26
27 namespace printing {
28
29 TEST_F(PdfMetafileCairoTest, Pdf) {
30 // Tests in-renderer constructor.
31 printing::PdfMetafileCairo pdf;
32 EXPECT_TRUE(pdf.Init());
33
34 // Renders page 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|.
37 EXPECT_TRUE(pdf.FinishPage());
38
39 // Renders page 2.
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|.
42 EXPECT_TRUE(pdf.FinishPage());
43
44 // Closes the file.
45 pdf.FinishDocument();
46
47 // Checks data size.
48 uint32 size = pdf.GetDataSize();
49 EXPECT_GT(size, 0u);
50
51 // Gets resulting data.
52 std::vector<char> buffer(size, 0x00);
53 pdf.GetData(&buffer.front(), size);
54
55 // Tests another constructor.
56 printing::PdfMetafileCairo pdf2;
57 EXPECT_TRUE(pdf2.InitFromData(&buffer.front(), size));
58
59 // Tries to get the first 4 characters from pdf2.
60 std::vector<char> buffer2(4, 0x00);
61 pdf2.GetData(&buffer2.front(), 4);
62
63 // Tests if the header begins with "%PDF".
64 std::string header(&buffer2.front(), 4);
65 EXPECT_EQ(header.find("%PDF", 0), 0u);
66
67 // Tests if we can save data.
68 EXPECT_TRUE(pdf.SaveTo(FilePath("/dev/null")));
69
70 // Test overriding the metafile with raw data.
71 printing::PdfMetafileCairo pdf3;
72 EXPECT_TRUE(pdf3.Init());
73 EXPECT_TRUE(pdf3.StartPage(gfx::Size(72, 73), gfx::Rect(4, 5, 64, 63), 1));
74 std::string test_raw_data = "Dummy PDF";
75 EXPECT_TRUE(pdf3.InitFromData(test_raw_data.c_str(), test_raw_data.size()));
76 EXPECT_TRUE(pdf3.FinishPage());
77 pdf3.FinishDocument();
78 size = pdf3.GetDataSize();
79 EXPECT_EQ(test_raw_data.size(), size);
80 std::string output;
81 pdf3.GetData(WriteInto(&output, size + 1), size);
82 EXPECT_EQ(test_raw_data, output);
83 }
84
85 } // namespace printing
OLDNEW
« no previous file with comments | « printing/pdf_metafile_cairo_linux.cc ('k') | printing/printing.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698