test_info_extractor.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. // Copyright 2015 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef CONTENT_WEB_TEST_BROWSER_TEST_INFO_EXTRACTOR_H_
  5. #define CONTENT_WEB_TEST_BROWSER_TEST_INFO_EXTRACTOR_H_
  6. #include <stddef.h>
  7. #include <memory>
  8. #include <string>
  9. #include "base/command_line.h"
  10. #include "base/files/file_path.h"
  11. #include "url/gurl.h"
  12. namespace content {
  13. struct TestInfo {
  14. TestInfo(const GURL& url,
  15. const std::string& expected_pixel_hash,
  16. const base::FilePath& current_working_directory,
  17. bool protocol_mode);
  18. ~TestInfo();
  19. GURL url;
  20. std::string expected_pixel_hash;
  21. base::FilePath current_working_directory;
  22. // If true, the input and output of content_shell are assumed to follow the
  23. // run_web_tests protocol through pipes that connect stdin and stdout of
  24. // run_web_tests.py and content_shell:
  25. //
  26. // run_web_tests.py content_shell
  27. // | <------ #READY\n ------- |
  28. // | |
  29. // | --- <test_name>['<pixelhash>]\n --> |
  30. // | |
  31. // | <------ [<text|audio dump>] ------- |
  32. // | <------ #EOF\n ------- |
  33. // | <------ [<pixel dump>] ------- |
  34. // | <------ #EOF\n ------- |
  35. // | |
  36. // | .... |
  37. // | .... |
  38. // | |
  39. // | ----------- QUIT\n -------------> |
  40. //
  41. // In this mode, each test creates 1 or 2 test output dumps. The first dump
  42. // is text or audio (can be empty), and the second dump is image (can be
  43. // empty, too). Each dump, if not empty, is in the following format:
  44. //
  45. // Content-Type: <mime-type>\n
  46. // [<other headers>]
  47. // [Content-Length: <content-length>\n] # Required for binary content data
  48. // <content data>
  49. //
  50. // Content_shell enters the protocol mode when it sees a "-" parameter in the
  51. // command line. For the tests listed in the content_shell command line, this
  52. // field is false, and the test runner will dump pure text only without binary
  53. // data and protocol tags.
  54. bool protocol_mode;
  55. };
  56. class TestInfoExtractor {
  57. public:
  58. explicit TestInfoExtractor(const base::CommandLine& cmd_line);
  59. TestInfoExtractor(const TestInfoExtractor&) = delete;
  60. TestInfoExtractor& operator=(const TestInfoExtractor&) = delete;
  61. ~TestInfoExtractor();
  62. std::unique_ptr<TestInfo> GetNextTest();
  63. private:
  64. base::CommandLine::StringVector cmdline_args_;
  65. size_t cmdline_position_;
  66. };
  67. } // namespace content
  68. #endif // CONTENT_WEB_TEST_BROWSER_TEST_INFO_EXTRACTOR_H_