| OLD | NEW |
| 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 Loading... |
| 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 |
| OLD | NEW |