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

Side by Side Diff: printing/emf_win_unittest.cc

Issue 2458513003: Addressing C4267 warnings for printing. (Closed)
Patch Set: same as patch set 3, to see today's try bot output Created 4 years, 1 month 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
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 <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
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
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
OLDNEW
« no previous file with comments | « printing/emf_win.cc ('k') | printing/metafile.h » ('j') | printing/pdf_metafile_cg_mac.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698