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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 // Initialize it. | 91 // Initialize it. |
92 PrintingContextWin context(this); | 92 PrintingContextWin context(this); |
93 EXPECT_EQ(PrintingContext::OK, context.InitWithSettingsForTest(settings)); | 93 EXPECT_EQ(PrintingContext::OK, context.InitWithSettingsForTest(settings)); |
94 | 94 |
95 base::FilePath emf_file; | 95 base::FilePath emf_file; |
96 EXPECT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &emf_file)); | 96 EXPECT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &emf_file)); |
97 emf_file = emf_file.Append(FILE_PATH_LITERAL("printing")) | 97 emf_file = emf_file.Append(FILE_PATH_LITERAL("printing")) |
98 .Append(FILE_PATH_LITERAL("test")) | 98 .Append(FILE_PATH_LITERAL("test")) |
99 .Append(FILE_PATH_LITERAL("data")) | 99 .Append(FILE_PATH_LITERAL("data")) |
100 .Append(FILE_PATH_LITERAL("test4.emf")); | 100 .Append(FILE_PATH_LITERAL("test4.emf")); |
| 101 |
101 // Load any EMF with an image. | 102 // Load any EMF with an image. |
102 Emf emf; | |
103 std::string emf_data; | 103 std::string emf_data; |
104 base::ReadFileToString(emf_file, &emf_data); | 104 base::ReadFileToString(emf_file, &emf_data); |
105 ASSERT_TRUE(emf_data.size()); | 105 ASSERT_TRUE(emf_data.size()); |
| 106 |
| 107 Emf emf; |
106 EXPECT_TRUE(emf.InitFromData(&emf_data[0], emf_data.size())); | 108 EXPECT_TRUE(emf.InitFromData(&emf_data[0], emf_data.size())); |
107 | 109 |
108 // This will print to file. The reason is that when running inside a | 110 // This will print to file. The reason is that when running inside a |
109 // unit_test, PrintingContext automatically dumps its files to the | 111 // unit_test, PrintingContext automatically dumps its files to the |
110 // current directory. | 112 // current directory. |
111 // TODO(maruel): Clean the .PRN file generated in current directory. | 113 // TODO(maruel): Clean the .PRN file generated in current directory. |
112 context.NewDocument(L"EmfTest.Enumerate"); | 114 context.NewDocument(L"EmfTest.Enumerate"); |
113 context.NewPage(); | 115 context.NewPage(); |
114 // Process one at a time. | 116 // Process one at a time. |
115 RECT page_bounds = emf.GetPageBounds(1).ToRECT(); | 117 RECT page_bounds = emf.GetPageBounds(1).ToRECT(); |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 EXPECT_EQ(emf.GetPageBounds(1), raster->GetPageBounds(1)); | 230 EXPECT_EQ(emf.GetPageBounds(1), raster->GetPageBounds(1)); |
229 | 231 |
230 raster = emf.RasterizeMetafile(16 * ONE_MB); | 232 raster = emf.RasterizeMetafile(16 * ONE_MB); |
231 // Expected size about 64MB. | 233 // Expected size about 64MB. |
232 EXPECT_LE(abs(static_cast<int>(raster->GetDataSize()) - 64 * ONE_MB), ONE_MB); | 234 EXPECT_LE(abs(static_cast<int>(raster->GetDataSize()) - 64 * ONE_MB), ONE_MB); |
233 // Bounds should still be the same. | 235 // Bounds should still be the same. |
234 EXPECT_EQ(emf.GetPageBounds(1), raster->GetPageBounds(1)); | 236 EXPECT_EQ(emf.GetPageBounds(1), raster->GetPageBounds(1)); |
235 } | 237 } |
236 | 238 |
237 } // namespace printing | 239 } // namespace printing |
OLD | NEW |