| 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 <stdint.h> | 8 #include <stdint.h> |
| 9 #include <wingdi.h> | 9 #include <wingdi.h> |
| 10 #include <winspool.h> | 10 #include <winspool.h> |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 ::SetJob(printer, job_id, 0, NULL, JOB_CONTROL_DELETE); | 170 ::SetJob(printer, job_id, 0, NULL, JOB_CONTROL_DELETE); |
| 171 ClosePrinter(printer); | 171 ClosePrinter(printer); |
| 172 } | 172 } |
| 173 } | 173 } |
| 174 | 174 |
| 175 TEST(EmfTest, FileBackedEmf) { | 175 TEST(EmfTest, FileBackedEmf) { |
| 176 // Simplest use case. | 176 // Simplest use case. |
| 177 base::ScopedTempDir scratch_metafile_dir; | 177 base::ScopedTempDir scratch_metafile_dir; |
| 178 ASSERT_TRUE(scratch_metafile_dir.CreateUniqueTempDir()); | 178 ASSERT_TRUE(scratch_metafile_dir.CreateUniqueTempDir()); |
| 179 base::FilePath metafile_path; | 179 base::FilePath metafile_path; |
| 180 EXPECT_TRUE(base::CreateTemporaryFileInDir(scratch_metafile_dir.path(), | 180 EXPECT_TRUE(base::CreateTemporaryFileInDir(scratch_metafile_dir.GetPath(), |
| 181 &metafile_path)); | 181 &metafile_path)); |
| 182 uint32_t size; | 182 uint32_t size; |
| 183 std::vector<char> data; | 183 std::vector<char> data; |
| 184 { | 184 { |
| 185 Emf emf; | 185 Emf emf; |
| 186 EXPECT_TRUE(emf.InitToFile(metafile_path)); | 186 EXPECT_TRUE(emf.InitToFile(metafile_path)); |
| 187 EXPECT_TRUE(emf.context()); | 187 EXPECT_TRUE(emf.context()); |
| 188 // An empty EMF is invalid, so we put at least a rectangle in it. | 188 // An empty EMF is invalid, so we put at least a rectangle in it. |
| 189 ::Rectangle(emf.context(), 10, 10, 190, 190); | 189 ::Rectangle(emf.context(), 10, 10, 190, 190); |
| 190 EXPECT_TRUE(emf.FinishDocument()); | 190 EXPECT_TRUE(emf.FinishDocument()); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 EXPECT_EQ(emf.GetPageBounds(1), raster->GetPageBounds(1)); | 226 EXPECT_EQ(emf.GetPageBounds(1), raster->GetPageBounds(1)); |
| 227 | 227 |
| 228 raster = emf.RasterizeMetafile(16 * ONE_MB); | 228 raster = emf.RasterizeMetafile(16 * ONE_MB); |
| 229 // Expected size about 64MB. | 229 // Expected size about 64MB. |
| 230 EXPECT_LE(abs(static_cast<int>(raster->GetDataSize()) - 64 * ONE_MB), ONE_MB); | 230 EXPECT_LE(abs(static_cast<int>(raster->GetDataSize()) - 64 * ONE_MB), ONE_MB); |
| 231 // Bounds should still be the same. | 231 // Bounds should still be the same. |
| 232 EXPECT_EQ(emf.GetPageBounds(1), raster->GetPageBounds(1)); | 232 EXPECT_EQ(emf.GetPageBounds(1), raster->GetPageBounds(1)); |
| 233 } | 233 } |
| 234 | 234 |
| 235 } // namespace printing | 235 } // namespace printing |
| OLD | NEW |