| OLD | NEW |
| 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 <stdint.h> | 5 #include <stdint.h> |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <fstream> | 8 #include <fstream> |
| 9 #include <iostream> | 9 #include <iostream> |
| 10 #include <iterator> | 10 #include <iterator> |
| (...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 498 _setmode(_fileno(stderr), _O_BINARY); | 498 _setmode(_fileno(stderr), _O_BINARY); |
| 499 #endif | 499 #endif |
| 500 // Sends a message to the layout test framework indicating indicating | 500 // Sends a message to the layout test framework indicating indicating |
| 501 // that the browser test has completed setting itself up. The layout | 501 // that the browser test has completed setting itself up. The layout |
| 502 // test will then expect the file path for stdin. | 502 // test will then expect the file path for stdin. |
| 503 base::FilePath stdin_path; | 503 base::FilePath stdin_path; |
| 504 std::cout << "#READY\n"; | 504 std::cout << "#READY\n"; |
| 505 std::cout.flush(); | 505 std::cout.flush(); |
| 506 | 506 |
| 507 ASSERT_TRUE(tmp_dir_.CreateUniqueTempDir()); | 507 ASSERT_TRUE(tmp_dir_.CreateUniqueTempDir()); |
| 508 ASSERT_TRUE(base::CreateTemporaryFileInDir(tmp_dir_.path(), &stdin_path)); | 508 ASSERT_TRUE( |
| 509 base::CreateTemporaryFileInDir(tmp_dir_.GetPath(), &stdin_path)); |
| 509 | 510 |
| 510 // Redirects |std::cin| to the file |stdin_path|. |in| is not freed because | 511 // Redirects |std::cin| to the file |stdin_path|. |in| is not freed because |
| 511 // if it goes out of scope, |std::cin.rdbuf| will be freed, causing an | 512 // if it goes out of scope, |std::cin.rdbuf| will be freed, causing an |
| 512 // error. | 513 // error. |
| 513 std::ifstream* in = new std::ifstream(stdin_path.value().c_str()); | 514 std::ifstream* in = new std::ifstream(stdin_path.value().c_str()); |
| 514 ASSERT_TRUE(in->is_open()); | 515 ASSERT_TRUE(in->is_open()); |
| 515 std::cin.rdbuf(in->rdbuf()); | 516 std::cin.rdbuf(in->rdbuf()); |
| 516 | 517 |
| 517 pdf_file_save_path_ = | 518 pdf_file_save_path_ = |
| 518 tmp_dir_.path().Append(FILE_PATH_LITERAL("dummy.pdf")); | 519 tmp_dir_.GetPath().Append(FILE_PATH_LITERAL("dummy.pdf")); |
| 519 | 520 |
| 520 // Send the file path to the layout test framework so that it can | 521 // Send the file path to the layout test framework so that it can |
| 521 // communicate with this browser test. | 522 // communicate with this browser test. |
| 522 std::cout << "StdinPath: " << stdin_path.value() << "\n"; | 523 std::cout << "StdinPath: " << stdin_path.value() << "\n"; |
| 523 std::cout << "#EOF\n"; | 524 std::cout << "#EOF\n"; |
| 524 std::cout.flush(); | 525 std::cout.flush(); |
| 525 } | 526 } |
| 526 | 527 |
| 527 private: | 528 private: |
| 528 // Generates a png from bitmap data and stores it in |png_output_|. | 529 // Generates a png from bitmap data and stores it in |png_output_|. |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 639 // waiting for this message and start waiting for the image data. | 640 // waiting for this message and start waiting for the image data. |
| 640 std::cout << "#EOF\n"; | 641 std::cout << "#EOF\n"; |
| 641 std::cout.flush(); | 642 std::cout.flush(); |
| 642 | 643 |
| 643 SendPng(); | 644 SendPng(); |
| 644 Reset(); | 645 Reset(); |
| 645 } | 646 } |
| 646 } | 647 } |
| 647 | 648 |
| 648 } // namespace printing | 649 } // namespace printing |
| OLD | NEW |