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

Side by Side Diff: printing/pdf_ps_metafile_cairo_unittest.cc

Issue 6594121: Revert 76553 - Applying factory pattern (through NativeMetafileFactory class)... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 9 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_ps_metafile_cairo.h ('k') | printing/print_settings_initializer_gtk.cc » ('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_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
20 class PdfPsTest : public testing::Test { 18 class PdfPsTest : public testing::Test {
21 protected: 19 protected:
22 base::FileDescriptor DevNullFD() { 20 base::FileDescriptor DevNullFD() {
23 return base::FileDescriptor(open("/dev/null", O_WRONLY), true); 21 return base::FileDescriptor(open("/dev/null", O_WRONLY), true);
24 } 22 }
25 }; 23 };
26 24
27 } // namespace
28
29 namespace printing {
30
31 TEST_F(PdfPsTest, Pdf) { 25 TEST_F(PdfPsTest, Pdf) {
32 // Tests in-renderer constructor. 26 // Tests in-renderer constructor.
33 printing::PdfPsMetafile pdf; 27 printing::PdfPsMetafile pdf;
34 EXPECT_TRUE(pdf.Init()); 28 EXPECT_TRUE(pdf.Init());
35 29
36 // Renders page 1. 30 // Renders page 1.
37 cairo_t* context = pdf.StartPage(72, 72, 1, 2, 3, 4); 31 cairo_t* context = pdf.StartPage(72, 72, 1, 2, 3, 4);
38 EXPECT_TRUE(context != NULL); 32 EXPECT_TRUE(context != NULL);
39 EXPECT_EQ(printing::PdfPsMetafile::FromCairoContext(context), &pdf); 33 EXPECT_EQ(printing::PdfPsMetafile::FromCairoContext(context), &pdf);
40 // In theory, we should use Cairo to draw something on |context|. 34 // In theory, we should use Cairo to draw something on |context|.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 std::string test_raw_data = "Dummy PDF"; 74 std::string test_raw_data = "Dummy PDF";
81 EXPECT_TRUE(pdf3.SetRawData(test_raw_data.c_str(), test_raw_data.size())); 75 EXPECT_TRUE(pdf3.SetRawData(test_raw_data.c_str(), test_raw_data.size()));
82 EXPECT_TRUE(pdf3.FinishPage()); 76 EXPECT_TRUE(pdf3.FinishPage());
83 pdf3.Close(); 77 pdf3.Close();
84 size = pdf3.GetDataSize(); 78 size = pdf3.GetDataSize();
85 EXPECT_EQ(test_raw_data.size(), size); 79 EXPECT_EQ(test_raw_data.size(), size);
86 std::string output; 80 std::string output;
87 pdf3.GetData(WriteInto(&output, size + 1), size); 81 pdf3.GetData(WriteInto(&output, size + 1), size);
88 EXPECT_EQ(test_raw_data, output); 82 EXPECT_EQ(test_raw_data, output);
89 } 83 }
90
91 } // namespace printing
OLDNEW
« no previous file with comments | « printing/pdf_ps_metafile_cairo.h ('k') | printing/print_settings_initializer_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698