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

Side by Side Diff: chrome/renderer/printing/print_web_view_helper_browsertest.cc

Issue 517193003: More System Dialog printing code disabled on Windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@522493002
Patch Set: Mon Sep 8 01:10:20 PDT 2014 Created 6 years, 3 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 | « chrome/renderer/printing/print_web_view_helper.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 "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/run_loop.h" 6 #include "base/run_loop.h"
7 #include "chrome/common/chrome_switches.h" 7 #include "chrome/common/chrome_switches.h"
8 #include "chrome/common/print_messages.h" 8 #include "chrome/common/print_messages.h"
9 #include "chrome/renderer/printing/mock_printer.h" 9 #include "chrome/renderer/printing/mock_printer.h"
10 #include "chrome/renderer/printing/print_web_view_helper.h" 10 #include "chrome/renderer/printing/print_web_view_helper.h"
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 PrintHostMsg_DidPrintPage::ID); 181 PrintHostMsg_DidPrintPage::ID);
182 bool did_print_msg = (NULL != print_msg); 182 bool did_print_msg = (NULL != print_msg);
183 ASSERT_EQ(printed, did_print_msg); 183 ASSERT_EQ(printed, did_print_msg);
184 if (printed) { 184 if (printed) {
185 PrintHostMsg_DidPrintPage::Param post_did_print_page_param; 185 PrintHostMsg_DidPrintPage::Param post_did_print_page_param;
186 PrintHostMsg_DidPrintPage::Read(print_msg, &post_did_print_page_param); 186 PrintHostMsg_DidPrintPage::Read(print_msg, &post_did_print_page_param);
187 EXPECT_EQ(0, post_did_print_page_param.a.page_number); 187 EXPECT_EQ(0, post_did_print_page_param.a.page_number);
188 } 188 }
189 #endif // defined(OS_CHROMEOS) 189 #endif // defined(OS_CHROMEOS)
190 } 190 }
191
192 #if !defined(DISABLE_BASIC_PRINTING)
191 void OnPrintPages() { 193 void OnPrintPages() {
192 PrintWebViewHelper::Get(view_)->OnPrintPages(); 194 PrintWebViewHelper::Get(view_)->OnPrintPages();
193 ProcessPendingMessages(); 195 ProcessPendingMessages();
194 } 196 }
197 #endif // !DISABLE_BASIC_PRINTING
195 198
196 void VerifyPreviewRequest(bool requested) { 199 void VerifyPreviewRequest(bool requested) {
197 const IPC::Message* print_msg = 200 const IPC::Message* print_msg =
198 render_thread_->sink().GetUniqueMessageMatching( 201 render_thread_->sink().GetUniqueMessageMatching(
199 PrintHostMsg_SetupScriptedPrintPreview::ID); 202 PrintHostMsg_SetupScriptedPrintPreview::ID);
200 bool did_print_msg = (NULL != print_msg); 203 bool did_print_msg = (NULL != print_msg);
201 ASSERT_EQ(requested, did_print_msg); 204 ASSERT_EQ(requested, did_print_msg);
202 } 205 }
203 206
204 void OnPrintPreview(const base::DictionaryValue& dict) { 207 void OnPrintPreview(const base::DictionaryValue& dict) {
(...skipping 21 matching lines...) Expand all
226 virtual ~PrintWebViewHelperTest() {} 229 virtual ~PrintWebViewHelperTest() {}
227 230
228 virtual void SetUp() OVERRIDE { 231 virtual void SetUp() OVERRIDE {
229 ChromeRenderViewTest::SetUp(); 232 ChromeRenderViewTest::SetUp();
230 } 233 }
231 234
232 protected: 235 protected:
233 DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelperTest); 236 DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelperTest);
234 }; 237 };
235 238
239 #if !defined(DISABLE_BASIC_PRINTING)
236 // Tests that printing pages work and sending and receiving messages through 240 // Tests that printing pages work and sending and receiving messages through
237 // that channel all works. 241 // that channel all works.
238 TEST_F(PrintWebViewHelperTest, OnPrintPages) { 242 TEST_F(PrintWebViewHelperTest, OnPrintPages) {
239 LoadHTML(kHelloWorldHTML); 243 LoadHTML(kHelloWorldHTML);
240 OnPrintPages(); 244 OnPrintPages();
241 245
242 VerifyPageCount(1); 246 VerifyPageCount(1);
243 VerifyPagesPrinted(true); 247 VerifyPagesPrinted(true);
244 } 248 }
249 #endif // !DISABLE_BASIC_PRINTING
245 250
246 #if defined(OS_MACOSX) 251 #if defined(OS_MACOSX) && !defined(DISABLE_BASIC_PRINTING)
247 // TODO(estade): I don't think this test is worth porting to Linux. We will have 252 // TODO(estade): I don't think this test is worth porting to Linux. We will have
248 // to rip out and replace most of the IPC code if we ever plan to improve 253 // to rip out and replace most of the IPC code if we ever plan to improve
249 // printing, and the comment below by sverrir suggests that it doesn't do much 254 // printing, and the comment below by sverrir suggests that it doesn't do much
250 // for us anyway. 255 // for us anyway.
251 TEST_F(PrintWebViewHelperTest, PrintWithIframe) { 256 TEST_F(PrintWebViewHelperTest, PrintWithIframe) {
252 // Document that populates an iframe. 257 // Document that populates an iframe.
253 const char html[] = 258 const char html[] =
254 "<html><body>Lorem Ipsum:" 259 "<html><body>Lorem Ipsum:"
255 "<iframe name=\"sub1\" id=\"sub1\"></iframe><script>" 260 "<iframe name=\"sub1\" id=\"sub1\"></iframe><script>"
256 " document.write(frames['sub1'].name);" 261 " document.write(frames['sub1'].name);"
(...skipping 20 matching lines...) Expand all
277 const MockPrinter* printer(chrome_render_thread_->printer()); 282 const MockPrinter* printer(chrome_render_thread_->printer());
278 ASSERT_EQ(1, printer->GetPrintedPages()); 283 ASSERT_EQ(1, printer->GetPrintedPages());
279 const Image& image1(printer->GetPrintedPage(0)->image()); 284 const Image& image1(printer->GetPrintedPage(0)->image());
280 285
281 // TODO(sverrir): Figure out a way to improve this test to actually print 286 // TODO(sverrir): Figure out a way to improve this test to actually print
282 // only the content of the iframe. Currently image1 will contain the full 287 // only the content of the iframe. Currently image1 will contain the full
283 // page. 288 // page.
284 EXPECT_NE(0, image1.size().width()); 289 EXPECT_NE(0, image1.size().width());
285 EXPECT_NE(0, image1.size().height()); 290 EXPECT_NE(0, image1.size().height());
286 } 291 }
287 #endif // OS_MACOSX 292 #endif // OS_MACOSX && !DISABLE_BASIC_PRINTING
288 293
289 // Tests if we can print a page and verify its results. 294 // Tests if we can print a page and verify its results.
290 // This test prints HTML pages into a pseudo printer and check their outputs, 295 // This test prints HTML pages into a pseudo printer and check their outputs,
291 // i.e. a simplified version of the PrintingLayoutTextTest UI test. 296 // i.e. a simplified version of the PrintingLayoutTextTest UI test.
292 namespace { 297 namespace {
293 // Test cases used in this test. 298 // Test cases used in this test.
294 struct TestPageData { 299 struct TestPageData {
295 const char* page; 300 const char* page;
296 size_t printed_pages; 301 size_t printed_pages;
297 int width; 302 int width;
(...skipping 25 matching lines...) Expand all
323 NULL, 328 NULL,
324 }, 329 },
325 }; 330 };
326 #endif // defined(OS_WIN) || defined(OS_MACOSX) 331 #endif // defined(OS_WIN) || defined(OS_MACOSX)
327 } // namespace 332 } // namespace
328 333
329 // TODO(estade): need to port MockPrinter to get this on Linux. This involves 334 // TODO(estade): need to port MockPrinter to get this on Linux. This involves
330 // hooking up Cairo to read a pdf stream, or accessing the cairo surface in the 335 // hooking up Cairo to read a pdf stream, or accessing the cairo surface in the
331 // metafile directly. 336 // metafile directly.
332 // Same for printing via PDF on Windows. 337 // Same for printing via PDF on Windows.
333 #if defined(OS_MACOSX) 338 #if defined(OS_MACOSX) && !defined(DISABLE_BASIC_PRINTING)
334 TEST_F(PrintWebViewHelperTest, PrintLayoutTest) { 339 TEST_F(PrintWebViewHelperTest, PrintLayoutTest) {
335 bool baseline = false; 340 bool baseline = false;
336 341
337 EXPECT_TRUE(chrome_render_thread_->printer() != NULL); 342 EXPECT_TRUE(chrome_render_thread_->printer() != NULL);
338 for (size_t i = 0; i < arraysize(kTestPages); ++i) { 343 for (size_t i = 0; i < arraysize(kTestPages); ++i) {
339 // Load an HTML page and print it. 344 // Load an HTML page and print it.
340 LoadHTML(kTestPages[i].page); 345 LoadHTML(kTestPages[i].page);
341 OnPrintPages(); 346 OnPrintPages();
342 VerifyPagesPrinted(true); 347 VerifyPagesPrinted(true);
343 348
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 base::FilePath source_path; 381 base::FilePath source_path;
377 base::CreateTemporaryFile(&source_path); 382 base::CreateTemporaryFile(&source_path);
378 chrome_render_thread_->printer()->SaveSource(0, source_path); 383 chrome_render_thread_->printer()->SaveSource(0, source_path);
379 384
380 base::FilePath bitmap_path; 385 base::FilePath bitmap_path;
381 base::CreateTemporaryFile(&bitmap_path); 386 base::CreateTemporaryFile(&bitmap_path);
382 chrome_render_thread_->printer()->SaveBitmap(0, bitmap_path); 387 chrome_render_thread_->printer()->SaveBitmap(0, bitmap_path);
383 } 388 }
384 } 389 }
385 } 390 }
386 #endif // OS_MACOSX 391 #endif // OS_MACOSX && !DISABLE_BASIC_PRINTING
387 392
388 // These print preview tests do not work on Chrome OS yet. 393 // These print preview tests do not work on Chrome OS yet.
389 #if !defined(OS_CHROMEOS) 394 #if !defined(OS_CHROMEOS)
390 class PrintWebViewHelperPreviewTest : public PrintWebViewHelperTestBase { 395 class PrintWebViewHelperPreviewTest : public PrintWebViewHelperTestBase {
391 public: 396 public:
392 PrintWebViewHelperPreviewTest() {} 397 PrintWebViewHelperPreviewTest() {}
393 virtual ~PrintWebViewHelperPreviewTest() {} 398 virtual ~PrintWebViewHelperPreviewTest() {}
394 399
395 protected: 400 protected:
396 void VerifyPrintPreviewCancelled(bool did_cancel) { 401 void VerifyPrintPreviewCancelled(bool did_cancel) {
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after
907 CreatePrintSettingsDictionary(&dict); 912 CreatePrintSettingsDictionary(&dict);
908 OnPrintForPrintPreview(dict); 913 OnPrintForPrintPreview(dict);
909 914
910 VerifyPrintFailed(true); 915 VerifyPrintFailed(true);
911 VerifyPagesPrinted(false); 916 VerifyPagesPrinted(false);
912 } 917 }
913 918
914 #endif // !defined(OS_CHROMEOS) 919 #endif // !defined(OS_CHROMEOS)
915 920
916 } // namespace printing 921 } // namespace printing
OLDNEW
« no previous file with comments | « chrome/renderer/printing/print_web_view_helper.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698