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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « printing/emf_win.cc ('k') | skia/ext/platform_device.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: printing/emf_win_unittest.cc
diff --git a/printing/emf_win_unittest.cc b/printing/emf_win_unittest.cc
index 8d0721322850660c103b205102433612f014f5ed..ac30fd0c4b59259d5d8f048dde82daabc8ab1c1a 100644
--- a/printing/emf_win_unittest.cc
+++ b/printing/emf_win_unittest.cc
@@ -202,4 +202,29 @@ TEST(EmfTest, FileBackedEmf) {
EXPECT_TRUE(DeleteDC(hdc));
}
+TEST(EmfTest, RasterizeMetafile) {
+ Emf emf;
+ EXPECT_TRUE(emf.Init());
+ EXPECT_TRUE(emf.context() != NULL);
+ HBRUSH brush = static_cast<HBRUSH>(GetStockObject(BLACK_BRUSH));
+ for (int i = 0; i < 4; ++i) {
+ RECT rect = { 5 + i, 5 + i, 5 + i + 1, 5 + i + 2};
+ FillRect(emf.context(), &rect, brush);
+ }
+ EXPECT_TRUE(emf.FinishDocument());
+
+ scoped_ptr<Emf> raster(emf.RasterizeMetafile(1));
+ // Just 1px bitmap but should be stretched to the same bounds.
+ EXPECT_EQ(emf.GetPageBounds(1), raster->GetPageBounds(1));
+
+ raster.reset(emf.RasterizeMetafile(20));
+ EXPECT_EQ(emf.GetPageBounds(1), raster->GetPageBounds(1));
+
+ raster.reset(emf.RasterizeMetafile(16*1024*1024));
+ // Expected size about 64MB.
+ EXPECT_LE(abs(int(raster->GetDataSize()) - 64*1024*1024), 1024*1024);
+ // Bounds should still be the same.
+ EXPECT_EQ(emf.GetPageBounds(1), raster->GetPageBounds(1));
+}
+
} // namespace printing
« 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