OLD | NEW |
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_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 |
11 #include "base/file_descriptor_posix.h" | 11 #include "base/file_descriptor_posix.h" |
12 #include "base/file_util.h" | 12 #include "base/file_util.h" |
13 #include "base/string_util.h" | 13 #include "base/string_util.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
15 | 15 |
16 typedef struct _cairo cairo_t; | 16 typedef struct _cairo cairo_t; |
17 | 17 |
| 18 namespace { |
| 19 |
18 class PdfPsTest : public testing::Test { | 20 class PdfPsTest : public testing::Test { |
19 protected: | 21 protected: |
20 base::FileDescriptor DevNullFD() { | 22 base::FileDescriptor DevNullFD() { |
21 return base::FileDescriptor(open("/dev/null", O_WRONLY), true); | 23 return base::FileDescriptor(open("/dev/null", O_WRONLY), true); |
22 } | 24 } |
23 }; | 25 }; |
24 | 26 |
| 27 } // namespace |
| 28 |
| 29 namespace printing { |
| 30 |
25 TEST_F(PdfPsTest, Pdf) { | 31 TEST_F(PdfPsTest, Pdf) { |
26 // Tests in-renderer constructor. | 32 // Tests in-renderer constructor. |
27 printing::PdfPsMetafile pdf; | 33 printing::PdfPsMetafile pdf; |
28 EXPECT_TRUE(pdf.Init()); | 34 EXPECT_TRUE(pdf.Init()); |
29 | 35 |
30 // Renders page 1. | 36 // Renders page 1. |
31 cairo_t* context = pdf.StartPage(72, 72, 1, 2, 3, 4); | 37 cairo_t* context = pdf.StartPage(72, 72, 1, 2, 3, 4); |
32 EXPECT_TRUE(context != NULL); | 38 EXPECT_TRUE(context != NULL); |
33 EXPECT_EQ(printing::PdfPsMetafile::FromCairoContext(context), &pdf); | 39 EXPECT_EQ(printing::PdfPsMetafile::FromCairoContext(context), &pdf); |
34 // In theory, we should use Cairo to draw something on |context|. | 40 // In theory, we should use Cairo to draw something on |context|. |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 std::string test_raw_data = "Dummy PDF"; | 80 std::string test_raw_data = "Dummy PDF"; |
75 EXPECT_TRUE(pdf3.SetRawData(test_raw_data.c_str(), test_raw_data.size())); | 81 EXPECT_TRUE(pdf3.SetRawData(test_raw_data.c_str(), test_raw_data.size())); |
76 EXPECT_TRUE(pdf3.FinishPage()); | 82 EXPECT_TRUE(pdf3.FinishPage()); |
77 pdf3.Close(); | 83 pdf3.Close(); |
78 size = pdf3.GetDataSize(); | 84 size = pdf3.GetDataSize(); |
79 EXPECT_EQ(test_raw_data.size(), size); | 85 EXPECT_EQ(test_raw_data.size(), size); |
80 std::string output; | 86 std::string output; |
81 pdf3.GetData(WriteInto(&output, size + 1), size); | 87 pdf3.GetData(WriteInto(&output, size + 1), size); |
82 EXPECT_EQ(test_raw_data, output); | 88 EXPECT_EQ(test_raw_data, output); |
83 } | 89 } |
| 90 |
| 91 } // namespace printing |
OLD | NEW |