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

Side by Side Diff: chrome/browser/printing/print_preview_pdf_generated_browsertest.cc

Issue 414623005: PrintPreviewPdfGeneratedBrowserTest properly listens to messages and exits correctly. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added comment on exit condition for the test. Created 6 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
« no previous file with comments | « no previous file | 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <algorithm> 5 #include <algorithm>
6 #include <fstream> 6 #include <fstream>
7 #include <iostream> 7 #include <iostream>
8 #include <iterator> 8 #include <iterator>
9 #include <limits> 9 #include <limits>
10 #include <string> 10 #include <string>
(...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after
637 // 637 //
638 // Throughout this code, there will be |std::cout| statements. The layout test 638 // Throughout this code, there will be |std::cout| statements. The layout test
639 // framework uses stdout to get data from the browser test and uses stdin 639 // framework uses stdout to get data from the browser test and uses stdin
640 // to send data to the browser test. Writing "EOF\n" to |std::cout| indicates 640 // to send data to the browser test. Writing "EOF\n" to |std::cout| indicates
641 // that whatever block of data that the test was expecting has been completely 641 // that whatever block of data that the test was expecting has been completely
642 // sent. Sometimes EOF is printed to stderr because the test will expect it 642 // sent. Sometimes EOF is printed to stderr because the test will expect it
643 // from stderr in addition to stdout for certain blocks of data. 643 // from stderr in addition to stdout for certain blocks of data.
644 InitPdfFunctions(); 644 InitPdfFunctions();
645 SetupStdinAndSavePath(); 645 SetupStdinAndSavePath();
646 646
647 // There is no way to determine how many tests are to be run ahead of time
648 // without undesirable changes to the layout test framework. However, that is
649 // ok since whenever all the tests have been run, the layout test framework
650 // calls SIGKILL on this process, ending the test. This will end the while
651 // loop and cause the test to clean up after itself. For this to work, the
652 // browsertest must be run with '--single_process' not '--single-process.'
653 while (true) { 647 while (true) {
654 std::string input; 648 std::string input;
655 std::getline(std::cin, input); 649 while (input.empty()) {
656 if (input.empty()) { 650 std::getline(std::cin, input);
657 while (std::cin.eof()) { 651 if (std::cin.eof())
658 std::cin.clear(); 652 std::cin.clear();
659 std::getline(std::cin, input);
660 if (!input.empty()) {
661 break;
662 }
663 }
664 } 653 }
665 654
655 // If the layout test framework sends "QUIT" to this test, that means there
656 // are no more tests for this instance to run and it should quit.
657 if (input == "QUIT")
658 break;
659
666 base::FilePath::StringType file_extension = FILE_PATH_LITERAL(".pdf"); 660 base::FilePath::StringType file_extension = FILE_PATH_LITERAL(".pdf");
667 base::FilePath::StringType cmd; 661 base::FilePath::StringType cmd;
668 #if defined(OS_POSIX) 662 #if defined(OS_POSIX)
669 cmd = input; 663 cmd = input;
670 #elif defined(OS_WIN) 664 #elif defined(OS_WIN)
671 cmd = base::UTF8ToWide(input); 665 cmd = base::UTF8ToWide(input);
672 #endif 666 #endif
673 667
674 DuplicateTab(); 668 DuplicateTab();
675 PrintPreviewSettings settings( 669 PrintPreviewSettings settings(
(...skipping 22 matching lines...) Expand all
698 // waiting for this message and start waiting for the image data. 692 // waiting for this message and start waiting for the image data.
699 std::cout << "#EOF\n"; 693 std::cout << "#EOF\n";
700 std::cout.flush(); 694 std::cout.flush();
701 695
702 SendPng(); 696 SendPng();
703 Reset(); 697 Reset();
704 } 698 }
705 } 699 }
706 700
707 } // namespace printing 701 } // namespace printing
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698