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

Side by Side Diff: printing/pdf_metafile_cg_mac_unittest.cc

Issue 1343593002: Cleanup code in printing/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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
« no previous file with comments | « printing/pdf_metafile_cg_mac.cc ('k') | printing/pdf_metafile_skia.h » ('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_metafile_cg_mac.h" 5 #include "printing/pdf_metafile_cg_mac.h"
6 6
7 #import <ApplicationServices/ApplicationServices.h> 7 #import <ApplicationServices/ApplicationServices.h>
8 8
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 17 matching lines...) Expand all
28 28
29 // Render page 2. 29 // Render page 2.
30 gfx::Rect rect_2(10, 10, 520, 700); 30 gfx::Rect rect_2(10, 10, 520, 700);
31 gfx::Size size_2(720, 540); 31 gfx::Size size_2(720, 540);
32 pdf.StartPage(size_2, rect_2, 2.0); 32 pdf.StartPage(size_2, rect_2, 2.0);
33 pdf.FinishPage(); 33 pdf.FinishPage();
34 34
35 pdf.FinishDocument(); 35 pdf.FinishDocument();
36 36
37 // Check data size. 37 // Check data size.
38 uint32 size = pdf.GetDataSize(); 38 uint32_t size = pdf.GetDataSize();
39 EXPECT_GT(size, 0U); 39 EXPECT_GT(size, 0U);
40 40
41 // Get resulting data. 41 // Get resulting data.
42 std::vector<char> buffer(size, 0); 42 std::vector<char> buffer(size, 0);
43 pdf.GetData(&buffer.front(), size); 43 pdf.GetData(&buffer.front(), size);
44 44
45 // Test browser-side constructor. 45 // Test browser-side constructor.
46 PdfMetafileCg pdf2; 46 PdfMetafileCg pdf2;
47 EXPECT_TRUE(pdf2.InitFromData(&buffer.front(), size)); 47 EXPECT_TRUE(pdf2.InitFromData(&buffer.front(), size));
48 48
49 // Get the first 4 characters from pdf2. 49 // Get the first 4 characters from pdf2.
50 std::vector<char> buffer2(4, 0); 50 std::vector<char> buffer2(4, 0);
51 pdf2.GetData(&buffer2.front(), 4); 51 pdf2.GetData(&buffer2.front(), 4);
52 52
53 // Test that the header begins with "%PDF". 53 // Test that the header begins with "%PDF".
54 std::string header(&buffer2.front(), 4); 54 std::string header(&buffer2.front(), 4);
55 EXPECT_EQ(0U, header.find("%PDF", 0)); 55 EXPECT_EQ(0U, header.find("%PDF", 0));
56 56
57 // Test that the PDF is correctly reconstructed. 57 // Test that the PDF is correctly reconstructed.
58 EXPECT_EQ(2U, pdf2.GetPageCount()); 58 EXPECT_EQ(2U, pdf2.GetPageCount());
59 gfx::Size page_size = pdf2.GetPageBounds(1).size(); 59 gfx::Size page_size = pdf2.GetPageBounds(1).size();
60 EXPECT_EQ(540, page_size.width()); 60 EXPECT_EQ(540, page_size.width());
61 EXPECT_EQ(720, page_size.height()); 61 EXPECT_EQ(720, page_size.height());
62 page_size = pdf2.GetPageBounds(2).size(); 62 page_size = pdf2.GetPageBounds(2).size();
63 EXPECT_EQ(720, page_size.width()); 63 EXPECT_EQ(720, page_size.width());
64 EXPECT_EQ(540, page_size.height()); 64 EXPECT_EQ(540, page_size.height());
65 } 65 }
66 66
67 } // namespace printing 67 } // namespace printing
OLDNEW
« no previous file with comments | « printing/pdf_metafile_cg_mac.cc ('k') | printing/pdf_metafile_skia.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698