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

Side by Side Diff: content/renderer/render_view_browsertest.cc

Issue 6750018: Cleanup: Stop creating RenderViewObservers from chrome/ in RenderViewer. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: printPage -> PrintPage Created 9 years, 8 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 | « content/renderer/render_view.cc ('k') | content/renderer/render_view_observer.h » ('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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/basictypes.h" 5 #include "base/basictypes.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/shared_memory.h" 8 #include "base/shared_memory.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 GetMainFrame()->contentAsText(kMaxOutputCharacters)); 393 GetMainFrame()->contentAsText(kMaxOutputCharacters));
394 EXPECT_EQ(output, kTextDirection[i].expected_result); 394 EXPECT_EQ(output, kTextDirection[i].expected_result);
395 } 395 }
396 } 396 }
397 397
398 // Tests that printing pages work and sending and receiving messages through 398 // Tests that printing pages work and sending and receiving messages through
399 // that channel all works. 399 // that channel all works.
400 TEST_F(RenderViewTest, OnPrintPages) { 400 TEST_F(RenderViewTest, OnPrintPages) {
401 // Lets simulate a print pages with Hello world. 401 // Lets simulate a print pages with Hello world.
402 LoadHTML("<body><p>Hello World!</p></body>"); 402 LoadHTML("<body><p>Hello World!</p></body>");
403 view_->print_helper_->OnPrintPages(); 403 PrintWebViewHelper::Get(view_)->OnPrintPages();
404 404
405 VerifyPageCount(1); 405 VerifyPageCount(1);
406 VerifyPagesPrinted(true); 406 VerifyPagesPrinted(true);
407 } 407 }
408 408
409 // Duplicate of OnPrintPagesTest only using javascript to print. 409 // Duplicate of OnPrintPagesTest only using javascript to print.
410 TEST_F(RenderViewTest, PrintWithJavascript) { 410 TEST_F(RenderViewTest, PrintWithJavascript) {
411 // HTML contains a call to window.print() 411 // HTML contains a call to window.print()
412 LoadHTML(kPrintWithJSHTML); 412 LoadHTML(kPrintWithJSHTML);
413 413
(...skipping 11 matching lines...) Expand all
425 LoadHTML(kPrintWithJSHTML); 425 LoadHTML(kPrintWithJSHTML);
426 LoadHTML(kPrintWithJSHTML); 426 LoadHTML(kPrintWithJSHTML);
427 VerifyPagesPrinted(false); 427 VerifyPagesPrinted(false);
428 428
429 // Pretend user will print. (but printing is blocked.) 429 // Pretend user will print. (but printing is blocked.)
430 render_thread_.set_print_dialog_user_response(true); 430 render_thread_.set_print_dialog_user_response(true);
431 LoadHTML(kPrintWithJSHTML); 431 LoadHTML(kPrintWithJSHTML);
432 VerifyPagesPrinted(false); 432 VerifyPagesPrinted(false);
433 433
434 // Unblock script initiated printing and verify printing works. 434 // Unblock script initiated printing and verify printing works.
435 view_->print_helper_->ResetScriptedPrintCount(); 435 PrintWebViewHelper::Get(view_)->ResetScriptedPrintCount();
436 render_thread_.printer()->ResetPrinter(); 436 render_thread_.printer()->ResetPrinter();
437 LoadHTML(kPrintWithJSHTML); 437 LoadHTML(kPrintWithJSHTML);
438 VerifyPageCount(1); 438 VerifyPageCount(1);
439 VerifyPagesPrinted(true); 439 VerifyPagesPrinted(true);
440 } 440 }
441 441
442 #if defined(OS_WIN) || defined(OS_MACOSX) 442 #if defined(OS_WIN) || defined(OS_MACOSX)
443 // TODO(estade): I don't think this test is worth porting to Linux. We will have 443 // TODO(estade): I don't think this test is worth porting to Linux. We will have
444 // to rip out and replace most of the IPC code if we ever plan to improve 444 // to rip out and replace most of the IPC code if we ever plan to improve
445 // printing, and the comment below by sverrir suggests that it doesn't do much 445 // printing, and the comment below by sverrir suggests that it doesn't do much
(...skipping 13 matching lines...) Expand all
459 // Find the frame and set it as the focused one. This should mean that that 459 // Find the frame and set it as the focused one. This should mean that that
460 // the printout should only contain the contents of that frame. 460 // the printout should only contain the contents of that frame.
461 WebFrame* sub1_frame = 461 WebFrame* sub1_frame =
462 view_->webview()->findFrameByName(WebString::fromUTF8("sub1")); 462 view_->webview()->findFrameByName(WebString::fromUTF8("sub1"));
463 ASSERT_TRUE(sub1_frame); 463 ASSERT_TRUE(sub1_frame);
464 view_->webview()->setFocusedFrame(sub1_frame); 464 view_->webview()->setFocusedFrame(sub1_frame);
465 ASSERT_NE(view_->webview()->focusedFrame(), 465 ASSERT_NE(view_->webview()->focusedFrame(),
466 view_->webview()->mainFrame()); 466 view_->webview()->mainFrame());
467 467
468 // Initiate printing. 468 // Initiate printing.
469 view_->print_helper_->OnPrintPages(); 469 PrintWebViewHelper::Get(view_)->OnPrintPages();
470 470
471 // Verify output through MockPrinter. 471 // Verify output through MockPrinter.
472 const MockPrinter* printer(render_thread_.printer()); 472 const MockPrinter* printer(render_thread_.printer());
473 ASSERT_EQ(1, printer->GetPrintedPages()); 473 ASSERT_EQ(1, printer->GetPrintedPages());
474 const printing::Image& image1(printer->GetPrintedPage(0)->image()); 474 const printing::Image& image1(printer->GetPrintedPage(0)->image());
475 475
476 // TODO(sverrir): Figure out a way to improve this test to actually print 476 // TODO(sverrir): Figure out a way to improve this test to actually print
477 // only the content of the iframe. Currently image1 will contain the full 477 // only the content of the iframe. Currently image1 will contain the full
478 // page. 478 // page.
479 EXPECT_NE(0, image1.size().width()); 479 EXPECT_NE(0, image1.size().width());
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 // hooking up Cairo to read a pdf stream, or accessing the cairo surface in the 523 // hooking up Cairo to read a pdf stream, or accessing the cairo surface in the
524 // metafile directly. 524 // metafile directly.
525 #if defined(OS_WIN) || defined(OS_MACOSX) 525 #if defined(OS_WIN) || defined(OS_MACOSX)
526 TEST_F(RenderViewTest, PrintLayoutTest) { 526 TEST_F(RenderViewTest, PrintLayoutTest) {
527 bool baseline = false; 527 bool baseline = false;
528 528
529 EXPECT_TRUE(render_thread_.printer() != NULL); 529 EXPECT_TRUE(render_thread_.printer() != NULL);
530 for (size_t i = 0; i < arraysize(kTestPages); ++i) { 530 for (size_t i = 0; i < arraysize(kTestPages); ++i) {
531 // Load an HTML page and print it. 531 // Load an HTML page and print it.
532 LoadHTML(kTestPages[i].page); 532 LoadHTML(kTestPages[i].page);
533 view_->print_helper_->OnPrintPages(); 533 PrintWebViewHelper::Get(view_)->OnPrintPages();
534 534
535 // MockRenderThread::Send() just calls MockRenderThread::OnMsgReceived(). 535 // MockRenderThread::Send() just calls MockRenderThread::OnMsgReceived().
536 // So, all IPC messages sent in the above RenderView::OnPrintPages() call 536 // So, all IPC messages sent in the above RenderView::OnPrintPages() call
537 // has been handled by the MockPrinter object, i.e. this printing job 537 // has been handled by the MockPrinter object, i.e. this printing job
538 // has been already finished. 538 // has been already finished.
539 // So, we can start checking the output pages of this printing job. 539 // So, we can start checking the output pages of this printing job.
540 // Retrieve the number of pages actually printed. 540 // Retrieve the number of pages actually printed.
541 size_t pages = render_thread_.printer()->GetPrintedPages(); 541 size_t pages = render_thread_.printer()->GetPrintedPages();
542 EXPECT_EQ(kTestPages[i].printed_pages, pages); 542 EXPECT_EQ(kTestPages[i].printed_pages, pages);
543 543
(...skipping 687 matching lines...) Expand 10 before | Expand all | Expand 10 after
1231 LoadHTML("<html><head><meta http-equiv=\"content-language\" " 1231 LoadHTML("<html><head><meta http-equiv=\"content-language\" "
1232 "content=\" fr , es,en \">" 1232 "content=\" fr , es,en \">"
1233 "</head><body>A random page with random content.</body></html>"); 1233 "</head><body>A random page with random content.</body></html>");
1234 ProcessPendingMessages(); 1234 ProcessPendingMessages();
1235 message = render_thread_.sink().GetUniqueMessageMatching( 1235 message = render_thread_.sink().GetUniqueMessageMatching(
1236 ViewHostMsg_PageContents::ID); 1236 ViewHostMsg_PageContents::ID);
1237 ASSERT_NE(static_cast<IPC::Message*>(NULL), message); 1237 ASSERT_NE(static_cast<IPC::Message*>(NULL), message);
1238 ViewHostMsg_PageContents::Read(message, &params); 1238 ViewHostMsg_PageContents::Read(message, &params);
1239 EXPECT_EQ("fr", params.d); 1239 EXPECT_EQ("fr", params.d);
1240 } 1240 }
OLDNEW
« no previous file with comments | « content/renderer/render_view.cc ('k') | content/renderer/render_view_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698