diff options
author | stuartmorgan@chromium.org <stuartmorgan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-12 18:45:31 +0000 |
---|---|---|
committer | stuartmorgan@chromium.org <stuartmorgan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-12 18:45:31 +0000 |
commit | 14b210798a1e50d673088484ca19852407d8ff3c (patch) | |
tree | 48a604a3389d4cbc7c6d97da0fd885fde83bff7f /printing/pdf_metafile_mac_unittest.cc | |
parent | 5cfe3a579e12a2fa7ef2a6607fa9749cf377be8f (diff) | |
download | chromium_src-14b210798a1e50d673088484ca19852407d8ff3c.zip chromium_src-14b210798a1e50d673088484ca19852407d8ff3c.tar.gz chromium_src-14b210798a1e50d673088484ca19852407d8ff3c.tar.bz2 |
Implement a version of NativeMetafile for the Mac
This is the first of series of patches to implement printing on the Mac.
This API is based heavily on the Linux version; although it doesn't end up abstracting very much on the Mac, having a NativeMetafile implementation makes it easy to pass data through the existing print architecture.
BUG=13158
TEST=Printing unit tests; no effect in the application yet.
Review URL: http://codereview.chromium.org/269041
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@28722 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'printing/pdf_metafile_mac_unittest.cc')
-rw-r--r-- | printing/pdf_metafile_mac_unittest.cc | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/printing/pdf_metafile_mac_unittest.cc b/printing/pdf_metafile_mac_unittest.cc new file mode 100644 index 0000000..1a1bf44 --- /dev/null +++ b/printing/pdf_metafile_mac_unittest.cc @@ -0,0 +1,49 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "printing/pdf_metafile_mac.h" + +#import <ApplicationServices/ApplicationServices.h> + +#include <string> +#include <vector> + +#include "testing/gtest/include/gtest/gtest.h" + +TEST(PdfMetafileTest, Pdf) { + // Test in-renderer constructor. + printing::PdfMetafile pdf; + CGContextRef context = pdf.Init(); + EXPECT_TRUE(context != NULL); + + // Render page 1. + pdf.StartPage(540, 720, 1.25); + pdf.FinishPage(); + + // Render page 2. + pdf.StartPage(720, 540, 2.0); + pdf.FinishPage(); + + pdf.Close(); + + // Check data size. + unsigned int size = pdf.GetDataSize(); + EXPECT_GT(size, 0U); + + // Get resulting data. + std::vector<char> buffer(size, 0); + pdf.GetData(&buffer.front(), size); + + // Test browser-side constructor. + printing::PdfMetafile pdf2; + EXPECT_TRUE(pdf2.Init(&buffer.front(), size)); + + // Get the first 4 characters from pdf2. + std::vector<char> buffer2(4, 0); + pdf2.GetData(&buffer2.front(), 4); + + // Test that the header begins with "%PDF". + std::string header(&buffer2.front(), 4); + EXPECT_EQ(0U, header.find("%PDF", 0)); +} |