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

Side by Side Diff: printing/emf_win_unittest.cc

Issue 10836330: Rasterize page before printing. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 4 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/emf_win.cc ('k') | skia/ext/platform_device.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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 // Playback the data. 195 // Playback the data.
196 HDC hdc = CreateCompatibleDC(NULL); 196 HDC hdc = CreateCompatibleDC(NULL);
197 EXPECT_TRUE(hdc); 197 EXPECT_TRUE(hdc);
198 Emf emf; 198 Emf emf;
199 EXPECT_TRUE(emf.InitFromFile(metafile_path)); 199 EXPECT_TRUE(emf.InitFromFile(metafile_path));
200 RECT output_rect = {0, 0, 10, 10}; 200 RECT output_rect = {0, 0, 10, 10};
201 EXPECT_TRUE(emf.Playback(hdc, &output_rect)); 201 EXPECT_TRUE(emf.Playback(hdc, &output_rect));
202 EXPECT_TRUE(DeleteDC(hdc)); 202 EXPECT_TRUE(DeleteDC(hdc));
203 } 203 }
204 204
205 TEST(EmfTest, RasterizeMetafile) {
206 Emf emf;
207 EXPECT_TRUE(emf.Init());
208 EXPECT_TRUE(emf.context() != NULL);
209 HBRUSH brush = static_cast<HBRUSH>(GetStockObject(BLACK_BRUSH));
210 for (int i = 0; i < 4; ++i) {
211 RECT rect = { 5 + i, 5 + i, 5 + i + 1, 5 + i + 2};
212 FillRect(emf.context(), &rect, brush);
213 }
214 EXPECT_TRUE(emf.FinishDocument());
215
216 scoped_ptr<Emf> raster(emf.RasterizeMetafile(1));
217 // Just 1px bitmap but should be stretched to the same bounds.
218 EXPECT_EQ(emf.GetPageBounds(1), raster->GetPageBounds(1));
219
220 raster.reset(emf.RasterizeMetafile(20));
221 EXPECT_EQ(emf.GetPageBounds(1), raster->GetPageBounds(1));
222
223 raster.reset(emf.RasterizeMetafile(16*1024*1024));
224 // Expected size about 64MB.
225 EXPECT_LE(abs(int(raster->GetDataSize()) - 64*1024*1024), 1024*1024);
226 // Bounds should still be the same.
227 EXPECT_EQ(emf.GetPageBounds(1), raster->GetPageBounds(1));
228 }
229
205 } // namespace printing 230 } // namespace printing
OLDNEW
« no previous file with comments | « printing/emf_win.cc ('k') | skia/ext/platform_device.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698