summaryrefslogtreecommitdiffstats
path: root/printing/pdf_ps_metafile_linux_unittest.cc
diff options
context:
space:
mode:
authormaruel@chromium.org <maruel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-26 18:13:12 +0000
committermaruel@chromium.org <maruel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-26 18:13:12 +0000
commit83e45ed8b9b14dc54ecafd5a8c70e048bc57b967 (patch)
tree152e474d684926f46f8c508f838e2f36ba8223ef /printing/pdf_ps_metafile_linux_unittest.cc
parent126b1347e4d6b01cee1f0876c8cde6a192ecbc02 (diff)
downloadchromium_src-83e45ed8b9b14dc54ecafd5a8c70e048bc57b967.zip
chromium_src-83e45ed8b9b14dc54ecafd5a8c70e048bc57b967.tar.gz
chromium_src-83e45ed8b9b14dc54ecafd5a8c70e048bc57b967.tar.bz2
Revised PdfPsMetafile.
The interface is more reasonable, and the code is robuster. TEST=unit test BUG=none Review URL: http://codereview.chromium.org/174468 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@24474 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'printing/pdf_ps_metafile_linux_unittest.cc')
-rw-r--r--printing/pdf_ps_metafile_linux_unittest.cc48
1 files changed, 14 insertions, 34 deletions
diff --git a/printing/pdf_ps_metafile_linux_unittest.cc b/printing/pdf_ps_metafile_linux_unittest.cc
index 8728ba3..3ef0822 100644
--- a/printing/pdf_ps_metafile_linux_unittest.cc
+++ b/printing/pdf_ps_metafile_linux_unittest.cc
@@ -15,31 +15,22 @@ typedef struct _cairo cairo_t;
TEST(PdfTest, Basic) {
// Tests in-renderer constructor.
printing::PdfPsMetafile pdf(printing::PdfPsMetafile::PDF);
- cairo_t* context = pdf.GetPageContext();
- EXPECT_TRUE(context == NULL);
+ EXPECT_TRUE(pdf.Init());
// Renders page 1.
- EXPECT_TRUE(pdf.StartPage(72, 72));
- context = pdf.GetPageContext();
+ cairo_t* context = pdf.StartPage(72, 72);
EXPECT_TRUE(context != NULL);
// In theory, we should use Cairo to draw something on |context|.
- pdf.FinishPage(1.5);
- context = pdf.GetPageContext();
- EXPECT_TRUE(context == NULL);
+ EXPECT_TRUE(pdf.FinishPage(1.5));
// Renders page 2.
- EXPECT_TRUE(pdf.StartPage(64, 64));
- context = pdf.GetPageContext();
+ context = pdf.StartPage(64, 64);
EXPECT_TRUE(context != NULL);
// In theory, we should use Cairo to draw something on |context|.
- pdf.FinishPage(0.5);
- context = pdf.GetPageContext();
- EXPECT_TRUE(context == NULL);
+ EXPECT_TRUE(pdf.FinishPage(0.5));
// Closes the file.
pdf.Close();
- context = pdf.GetPageContext();
- EXPECT_TRUE(context == NULL);
// Checks data size.
unsigned int size = pdf.GetDataSize();
@@ -50,9 +41,8 @@ TEST(PdfTest, Basic) {
pdf.GetData(&buffer.front(), size);
// Tests another constructor.
- printing::PdfPsMetafile pdf2(printing::PdfPsMetafile::PDF,
- &buffer.front(),
- size);
+ printing::PdfPsMetafile pdf2(printing::PdfPsMetafile::PDF);
+ EXPECT_TRUE(pdf2.Init(&buffer.front(), size));
// Tries to get the first 4 characters from pdf2.
std::vector<char> buffer2(4, 0x00);
@@ -69,31 +59,22 @@ TEST(PdfTest, Basic) {
TEST(PsTest, Basic) {
// Tests in-renderer constructor.
printing::PdfPsMetafile ps(printing::PdfPsMetafile::PS);
- cairo_t* context = ps.GetPageContext();
- EXPECT_TRUE(context == NULL);
+ EXPECT_TRUE(ps.Init());
// Renders page 1.
- EXPECT_TRUE(ps.StartPage(72, 72));
- context = ps.GetPageContext();
+ cairo_t* context = ps.StartPage(72, 72);
EXPECT_TRUE(context != NULL);
// In theory, we should use Cairo to draw something on |context|.
- ps.FinishPage(1.5);
- context = ps.GetPageContext();
- EXPECT_TRUE(context == NULL);
+ EXPECT_TRUE(ps.FinishPage(1.5));
// Renders page 2.
- EXPECT_TRUE(ps.StartPage(64, 64));
- context = ps.GetPageContext();
+ context = ps.StartPage(64, 64);
EXPECT_TRUE(context != NULL);
// In theory, we should use Cairo to draw something on |context|.
- ps.FinishPage(0.5);
- context = ps.GetPageContext();
- EXPECT_TRUE(context == NULL);
+ EXPECT_TRUE(ps.FinishPage(0.5));
// Closes the file.
ps.Close();
- context = ps.GetPageContext();
- EXPECT_TRUE(context == NULL);
// Checks data size.
unsigned int size = ps.GetDataSize();
@@ -104,9 +85,8 @@ TEST(PsTest, Basic) {
ps.GetData(&buffer.front(), size);
// Tests another constructor.
- printing::PdfPsMetafile ps2(printing::PdfPsMetafile::PS,
- &buffer.front(),
- size);
+ printing::PdfPsMetafile ps2(printing::PdfPsMetafile::PS);
+ EXPECT_TRUE(ps2.Init(&buffer.front(), size));
// Tries to get the first 4 characters from ps2.
std::vector<char> buffer2(4, 0x00);