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

Side by Side Diff: printing/emf_win_unittest.cc

Issue 149288: Re-enable test (disabled while moving printing functionality to printing libr... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « chrome/test/data/printing/test4.emf ('k') | printing/printing_context_win.cc » ('j') | 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/file_path.h"
11 #include "base/file_util.h" 12 #include "base/file_util.h"
12 #include "base/path_service.h" 13 #include "base/path_service.h"
14 #include "printing/printing_context.h"
13 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
14 16
15 namespace { 17 namespace {
16 18
17 // This test is automatically disabled if no printer named "UnitTest Printer" is 19 // This test is automatically disabled if no printer named "UnitTest Printer" is
18 // available. 20 // available.
19 class EmfPrintingTest : public testing::Test { 21 class EmfPrintingTest : public testing::Test {
20 public: 22 public:
21 typedef testing::Test Parent; 23 typedef testing::Test Parent;
22 static bool IsTestCaseDisabled() { 24 static bool IsTestCaseDisabled() {
(...skipping 30 matching lines...) Expand all
53 55
54 // Playback the data. 56 // Playback the data.
55 hdc = CreateCompatibleDC(NULL); 57 hdc = CreateCompatibleDC(NULL);
56 EXPECT_TRUE(hdc); 58 EXPECT_TRUE(hdc);
57 EXPECT_TRUE(emf.CreateFromData(&data.front(), size)); 59 EXPECT_TRUE(emf.CreateFromData(&data.front(), size));
58 RECT output_rect = {0, 0, 10, 10}; 60 RECT output_rect = {0, 0, 10, 10};
59 EXPECT_TRUE(emf.Playback(hdc, &output_rect)); 61 EXPECT_TRUE(emf.Playback(hdc, &output_rect));
60 EXPECT_TRUE(DeleteDC(hdc)); 62 EXPECT_TRUE(DeleteDC(hdc));
61 } 63 }
62 64
63 // TODO(sverrir): Re-enable after win_printing_context has been moved here.
64 /*
65
66 // DEPS check fails even if include is in a multi line comment:
67 // #include "printing/printing_context.h"
68 // #include "chrome/common/chrome_paths.h"
69
70 // Disabled if no "UnitTest printer" exist. Useful to reproduce bug 1186598. 65 // Disabled if no "UnitTest printer" exist. Useful to reproduce bug 1186598.
71 TEST_F(EmfPrintingTest, Enumerate) { 66 TEST_F(EmfPrintingTest, Enumerate) {
72 if (IsTestCaseDisabled()) 67 if (IsTestCaseDisabled())
73 return; 68 return;
74 69
75 printing::PrintSettings settings; 70 printing::PrintSettings settings;
76 71
77 // My test case is a HP Color LaserJet 4550 PCL. 72 // My test case is a HP Color LaserJet 4550 PCL.
78 settings.set_device_name(L"UnitTest Printer"); 73 settings.set_device_name(L"UnitTest Printer");
79 74
80 // Initialize it. 75 // Initialize it.
81 printing::PrintingContext context; 76 printing::PrintingContext context;
82 EXPECT_EQ(context.InitWithSettings(settings), printing::PrintingContext::OK); 77 EXPECT_EQ(context.InitWithSettings(settings), printing::PrintingContext::OK);
83 78
84 std::wstring test_file; 79 FilePath emf_file;
85 PathService::Get(chrome::DIR_TEST_DATA, &test_file); 80 EXPECT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &emf_file));
86 81 emf_file = emf_file.Append(FILE_PATH_LITERAL("printing"))
82 .Append(FILE_PATH_LITERAL("test"))
83 .Append(FILE_PATH_LITERAL("data"))
84 .Append(FILE_PATH_LITERAL("test4.emf"));
87 // Load any EMF with an image. 85 // Load any EMF with an image.
88 printing::Emf emf; 86 printing::Emf emf;
89 file_util::AppendToPath(&test_file, L"printing");
90 file_util::AppendToPath(&test_file, L"test4.emf");
91 std::string emf_data; 87 std::string emf_data;
92 file_util::ReadFileToString(test_file, &emf_data); 88 file_util::ReadFileToString(emf_file, &emf_data);
93 ASSERT_TRUE(emf_data.size()); 89 ASSERT_TRUE(emf_data.size());
94 EXPECT_TRUE(emf.CreateFromData(&emf_data[0], emf_data.size())); 90 EXPECT_TRUE(emf.CreateFromData(&emf_data[0], emf_data.size()));
95 91
96 // This will print to file. The reason is that when running inside a 92 // This will print to file. The reason is that when running inside a
97 // unit_test, printing::PrintingContext automatically dumps its files to the 93 // unit_test, printing::PrintingContext automatically dumps its files to the
98 // current directory. 94 // current directory.
99 // TODO(maruel): Clean the .PRN file generated in current directory. 95 // TODO(maruel): Clean the .PRN file generated in current directory.
100 context.NewDocument(L"EmfTest.Enumerate"); 96 context.NewDocument(L"EmfTest.Enumerate");
101 context.NewPage(); 97 context.NewPage();
102 // Process one at a time. 98 // Process one at a time.
103 printing::Emf::Enumerator emf_enum(emf, context.context(), 99 printing::Emf::Enumerator emf_enum(emf, context.context(),
104 &emf.GetBounds().ToRECT()); 100 &emf.GetBounds().ToRECT());
105 for (printing::Emf::Enumerator::const_iterator itr = emf_enum.begin(); 101 for (printing::Emf::Enumerator::const_iterator itr = emf_enum.begin();
106 itr != emf_enum.end(); 102 itr != emf_enum.end();
107 ++itr) { 103 ++itr) {
108 // To help debugging. 104 // To help debugging.
109 ptrdiff_t index = itr - emf_enum.begin(); 105 ptrdiff_t index = itr - emf_enum.begin();
110 // If you get this assert, you need to lookup iType in wingdi.h. It starts 106 // If you get this assert, you need to lookup iType in wingdi.h. It starts
111 // with EMR_HEADER. 107 // with EMR_HEADER.
112 EMR_HEADER; 108 EMR_HEADER;
113 EXPECT_TRUE(itr->SafePlayback(NULL)) << 109 EXPECT_TRUE(itr->SafePlayback(NULL)) <<
114 " index: " << index << " type: " << itr->record()->iType; 110 " index: " << index << " type: " << itr->record()->iType;
115 } 111 }
116 context.PageDone(); 112 context.PageDone();
117 context.DocumentDone(); 113 context.DocumentDone();
118 } 114 }
119 */ 115
OLDNEW
« no previous file with comments | « chrome/test/data/printing/test4.emf ('k') | printing/printing_context_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698