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

Side by Side Diff: printing/emf_win_unittest.cc

Issue 6709009: Stop overloading Init() in NativeMetafile. (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/emf_win.cc ('k') | printing/image.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/emf_win.h" 5 #include "printing/emf_win.h"
6 6
7 // For quick access. 7 // For quick access.
8 #include <wingdi.h> 8 #include <wingdi.h>
9 #include <winspool.h> 9 #include <winspool.h>
10 10
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 EXPECT_EQ(size, EMF_HEADER_SIZE); 55 EXPECT_EQ(size, EMF_HEADER_SIZE);
56 std::vector<BYTE> data; 56 std::vector<BYTE> data;
57 EXPECT_TRUE(emf.GetData(&data)); 57 EXPECT_TRUE(emf.GetData(&data));
58 EXPECT_EQ(data.size(), size); 58 EXPECT_EQ(data.size(), size);
59 emf.CloseEmf(); 59 emf.CloseEmf();
60 EXPECT_TRUE(DeleteDC(hdc)); 60 EXPECT_TRUE(DeleteDC(hdc));
61 61
62 // Playback the data. 62 // Playback the data.
63 hdc = CreateCompatibleDC(NULL); 63 hdc = CreateCompatibleDC(NULL);
64 EXPECT_TRUE(hdc); 64 EXPECT_TRUE(hdc);
65 EXPECT_TRUE(emf.Init(&data.front(), size)); 65 EXPECT_TRUE(emf.InitFromData(&data.front(), size));
66 RECT output_rect = {0, 0, 10, 10}; 66 RECT output_rect = {0, 0, 10, 10};
67 EXPECT_TRUE(emf.Playback(hdc, &output_rect)); 67 EXPECT_TRUE(emf.Playback(hdc, &output_rect));
68 EXPECT_TRUE(DeleteDC(hdc)); 68 EXPECT_TRUE(DeleteDC(hdc));
69 } 69 }
70 70
71 // Disabled if no "UnitTest printer" exist. Useful to reproduce bug 1186598. 71 // Disabled if no "UnitTest printer" exist. Useful to reproduce bug 1186598.
72 TEST_F(EmfPrintingTest, Enumerate) { 72 TEST_F(EmfPrintingTest, Enumerate) {
73 if (IsTestCaseDisabled()) 73 if (IsTestCaseDisabled())
74 return; 74 return;
75 75
(...skipping 11 matching lines...) Expand all
87 EXPECT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &emf_file)); 87 EXPECT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &emf_file));
88 emf_file = emf_file.Append(FILE_PATH_LITERAL("printing")) 88 emf_file = emf_file.Append(FILE_PATH_LITERAL("printing"))
89 .Append(FILE_PATH_LITERAL("test")) 89 .Append(FILE_PATH_LITERAL("test"))
90 .Append(FILE_PATH_LITERAL("data")) 90 .Append(FILE_PATH_LITERAL("data"))
91 .Append(FILE_PATH_LITERAL("test4.emf")); 91 .Append(FILE_PATH_LITERAL("test4.emf"));
92 // Load any EMF with an image. 92 // Load any EMF with an image.
93 printing::Emf emf; 93 printing::Emf emf;
94 std::string emf_data; 94 std::string emf_data;
95 file_util::ReadFileToString(emf_file, &emf_data); 95 file_util::ReadFileToString(emf_file, &emf_data);
96 ASSERT_TRUE(emf_data.size()); 96 ASSERT_TRUE(emf_data.size());
97 EXPECT_TRUE(emf.Init(&emf_data[0], emf_data.size())); 97 EXPECT_TRUE(emf.InitFromData(&emf_data[0], emf_data.size()));
98 98
99 // This will print to file. The reason is that when running inside a 99 // This will print to file. The reason is that when running inside a
100 // unit_test, printing::PrintingContext automatically dumps its files to the 100 // unit_test, printing::PrintingContext automatically dumps its files to the
101 // current directory. 101 // current directory.
102 // TODO(maruel): Clean the .PRN file generated in current directory. 102 // TODO(maruel): Clean the .PRN file generated in current directory.
103 context->NewDocument(L"EmfTest.Enumerate"); 103 context->NewDocument(L"EmfTest.Enumerate");
104 context->NewPage(); 104 context->NewPage();
105 // Process one at a time. 105 // Process one at a time.
106 printing::Emf::Enumerator emf_enum(emf, context->context(), 106 printing::Emf::Enumerator emf_enum(emf, context->context(),
107 &emf.GetPageBounds(1).ToRECT()); 107 &emf.GetPageBounds(1).ToRECT());
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 std::vector<BYTE> data; 141 std::vector<BYTE> data;
142 EXPECT_TRUE(emf.GetData(&data)); 142 EXPECT_TRUE(emf.GetData(&data));
143 EXPECT_EQ(data.size(), size); 143 EXPECT_EQ(data.size(), size);
144 emf.CloseEmf(); 144 emf.CloseEmf();
145 145
146 // Playback the data. 146 // Playback the data.
147 DOCINFO di = {0}; 147 DOCINFO di = {0};
148 di.cbSize = sizeof(DOCINFO); 148 di.cbSize = sizeof(DOCINFO);
149 di.lpszDocName = L"Test Job"; 149 di.lpszDocName = L"Test Job";
150 int job_id = ::StartDoc(dc.Get(), &di); 150 int job_id = ::StartDoc(dc.Get(), &di);
151 EXPECT_TRUE(emf.Init(&data.front(), size)); 151 EXPECT_TRUE(emf.InitFromData(&data.front(), size));
152 EXPECT_TRUE(emf.SafePlayback(dc.Get())); 152 EXPECT_TRUE(emf.SafePlayback(dc.Get()));
153 ::EndDoc(dc.Get()); 153 ::EndDoc(dc.Get());
154 // Since presumably the printer is not real, let us just delete the job from 154 // Since presumably the printer is not real, let us just delete the job from
155 // the queue. 155 // the queue.
156 HANDLE printer = NULL; 156 HANDLE printer = NULL;
157 if (::OpenPrinter(L"UnitTest Printer", &printer, NULL)) { 157 if (::OpenPrinter(L"UnitTest Printer", &printer, NULL)) {
158 ::SetJob(printer, job_id, 0, NULL, JOB_CONTROL_DELETE); 158 ::SetJob(printer, job_id, 0, NULL, JOB_CONTROL_DELETE);
159 ClosePrinter(printer); 159 ClosePrinter(printer);
160 } 160 }
161 } 161 }
(...skipping 29 matching lines...) Expand all
191 hdc = CreateCompatibleDC(NULL); 191 hdc = CreateCompatibleDC(NULL);
192 EXPECT_TRUE(hdc); 192 EXPECT_TRUE(hdc);
193 EXPECT_TRUE(emf.CreateFromFile(metafile_path)); 193 EXPECT_TRUE(emf.CreateFromFile(metafile_path));
194 RECT output_rect = {0, 0, 10, 10}; 194 RECT output_rect = {0, 0, 10, 10};
195 EXPECT_TRUE(emf.Playback(hdc, &output_rect)); 195 EXPECT_TRUE(emf.Playback(hdc, &output_rect));
196 EXPECT_TRUE(DeleteDC(hdc)); 196 EXPECT_TRUE(DeleteDC(hdc));
197 emf.CloseEmf(); 197 emf.CloseEmf();
198 } 198 }
199 199
200 } // namespace printing 200 } // namespace printing
OLDNEW
« no previous file with comments | « printing/emf_win.cc ('k') | printing/image.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698