summaryrefslogtreecommitdiffstats
path: root/printing/pdf_ps_metafile_linux_unittest.cc
diff options
context:
space:
mode:
authortony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-26 21:26:37 +0000
committertony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-26 21:26:37 +0000
commitc28a6aac0d9687b43781bb21fdef3b6849c0d398 (patch)
tree1c9898bdacfdb9bd29bff5af7f9ad18d355a21c2 /printing/pdf_ps_metafile_linux_unittest.cc
parent10c7b06e59f615c00dedd95a758cbbcc679db7fa (diff)
downloadchromium_src-c28a6aac0d9687b43781bb21fdef3b6849c0d398.zip
chromium_src-c28a6aac0d9687b43781bb21fdef3b6849c0d398.tar.gz
chromium_src-c28a6aac0d9687b43781bb21fdef3b6849c0d398.tar.bz2
Fix memory leak problem in PdfPsMetafile.
The one committed in revision 24474 has a memory-leak problem. The cause is that we forgot to do CleanUpSurface(&page_surface_) near the end of PdfPsMetafile::FinishPage(). Original patch by Min-yu Huang <minyu.huang@gmail.com> via http://codereview.chromium.org/173516 Review URL: http://codereview.chromium.org/174559 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@24533 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);