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

Side by Side Diff: printing/emf_win_unittest.cc

Issue 2538133003: Remove unused printing::Emf code. (Closed)
Patch Set: more Created 3 years, 7 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 unified diff | Download patch
« no previous file with comments | « printing/emf_win.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 29 matching lines...) Expand all
40 DeleteDC(hdc); 40 DeleteDC(hdc);
41 return false; 41 return false;
42 } 42 }
43 43
44 // PrintingContext::Delegate methods. 44 // PrintingContext::Delegate methods.
45 gfx::NativeView GetParentView() override { return nullptr; } 45 gfx::NativeView GetParentView() override { return nullptr; }
46 std::string GetAppLocale() override { return std::string(); } 46 std::string GetAppLocale() override { return std::string(); }
47 }; 47 };
48 48
49 const uint32_t EMF_HEADER_SIZE = 128; 49 const uint32_t EMF_HEADER_SIZE = 128;
50 const int ONE_MB = 1024 * 1024;
51 50
52 } // namespace 51 } // namespace
53 52
54 TEST(EmfTest, DC) { 53 TEST(EmfTest, DC) {
55 // Simplest use case. 54 // Simplest use case.
56 uint32_t size; 55 uint32_t size;
57 std::vector<char> data; 56 std::vector<char> data;
58 { 57 {
59 Emf emf; 58 Emf emf;
60 EXPECT_TRUE(emf.Init()); 59 EXPECT_TRUE(emf.Init());
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 // Playback the data. 203 // Playback the data.
205 HDC hdc = CreateCompatibleDC(nullptr); 204 HDC hdc = CreateCompatibleDC(nullptr);
206 EXPECT_TRUE(hdc); 205 EXPECT_TRUE(hdc);
207 Emf emf; 206 Emf emf;
208 EXPECT_TRUE(emf.InitFromFile(metafile_path)); 207 EXPECT_TRUE(emf.InitFromFile(metafile_path));
209 RECT output_rect = {0, 0, 10, 10}; 208 RECT output_rect = {0, 0, 10, 10};
210 EXPECT_TRUE(emf.Playback(hdc, &output_rect)); 209 EXPECT_TRUE(emf.Playback(hdc, &output_rect));
211 EXPECT_TRUE(DeleteDC(hdc)); 210 EXPECT_TRUE(DeleteDC(hdc));
212 } 211 }
213 212
214 TEST(EmfTest, RasterizeMetafile) {
215 Emf emf;
216 EXPECT_TRUE(emf.Init());
217 EXPECT_TRUE(emf.context());
218 HBRUSH brush = static_cast<HBRUSH>(GetStockObject(BLACK_BRUSH));
219 for (int i = 0; i < 4; ++i) {
220 RECT rect = { 5 + i, 5 + i, 5 + i + 1, 5 + i + 2};
221 FillRect(emf.context(), &rect, brush);
222 }
223 EXPECT_TRUE(emf.FinishDocument());
224
225 std::unique_ptr<Emf> raster(emf.RasterizeMetafile(1));
226 // Just 1px bitmap but should be stretched to the same bounds.
227 EXPECT_EQ(emf.GetPageBounds(1), raster->GetPageBounds(1));
228
229 raster = emf.RasterizeMetafile(20);
230 EXPECT_EQ(emf.GetPageBounds(1), raster->GetPageBounds(1));
231
232 raster = emf.RasterizeMetafile(16 * ONE_MB);
233 // Expected size about 64MB.
234 EXPECT_LE(abs(static_cast<int>(raster->GetDataSize()) - 64 * ONE_MB), ONE_MB);
235 // Bounds should still be the same.
236 EXPECT_EQ(emf.GetPageBounds(1), raster->GetPageBounds(1));
237 }
238
239 } // namespace printing 213 } // namespace printing
OLDNEW
« no previous file with comments | « printing/emf_win.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698