File: test_meta_info.h

package info (click to toggle)
chromium 140.0.7339.185-1
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 6,193,740 kB
  • sloc: cpp: 35,093,945; ansic: 7,161,670; javascript: 4,199,694; python: 1,441,797; asm: 949,904; xml: 747,515; pascal: 187,748; perl: 88,691; sh: 88,248; objc: 79,953; sql: 52,714; cs: 44,599; fortran: 24,137; makefile: 22,114; tcl: 15,277; php: 13,980; yacc: 9,000; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (49 lines) | stat: -rw-r--r-- 1,680 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Copyright 2025 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef COMPONENTS_HEADLESS_TEST_TEST_META_INFO_H_
#define COMPONENTS_HEADLESS_TEST_TEST_META_INFO_H_

#include <string>
#include <string_view>

#include "base/command_line.h"
#include "base/containers/flat_map.h"
#include "base/types/expected.h"

namespace headless {

// Holds headless JavaScript test meta info collected from '// META: ' comments
// found at the beginning of the .js test file. Meta info comment lines should
// contain one piece of info per line, with each line starting with '// META: '
// prefix. If the meta info line ends with '\', the next meta info line is
// considered to be a continuation of the previous meta info line.
struct TestMetaInfo {
  TestMetaInfo();
  TestMetaInfo(const TestMetaInfo& other);
  ~TestMetaInfo();

  bool operator==(const TestMetaInfo& other) const;

  // Command line switches, one switch per line.
  // META: --screen-info={1600x1200}
  base::flat_map<std::string, std::string> command_line_switches;

  // If true, Chrome Headless Mode and Headless Shell test expectations will be
  // maintained in '<script_name>-headless-mode-expected.txt' and
  // '<script_name>-headless-shell-expected.txt' respectively.
  bool fork_headless_mode_expectations = false;
  bool fork_headless_shell_expectations = false;

  static base::expected<TestMetaInfo, std::string> FromString(
      std::string_view test_body);

  bool IsEmpty() const;

  void AppendToCommandLine(base::CommandLine& command_line);
};

}  // namespace headless

#endif  // COMPONENTS_HEADLESS_TEST_TEST_META_INFO_H_