xref: /aosp_15_r20/external/cronet/base/test/launcher/test_launcher_test_utils.h (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1 // Copyright 2019 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef BASE_TEST_LAUNCHER_TEST_LAUNCHER_TEST_UTILS_H_
6 #define BASE_TEST_LAUNCHER_TEST_LAUNCHER_TEST_UTILS_H_
7 
8 #include <stddef.h>
9 
10 #include <optional>
11 #include <string>
12 
13 #include "base/values.h"
14 #include "testing/gtest/include/gtest/gtest.h"
15 
16 namespace base {
17 
18 class FilePath;
19 
20 namespace test_launcher_utils {
21 
22 // Validate |dict_value| value in |key| is equal to |expected_value|
23 bool ValidateKeyValue(const Value::Dict& dict,
24                       const std::string& key,
25                       const std::string& expected_value);
26 
27 // Validate |dict_value| value in |key| is equal to |expected_value|
28 bool ValidateKeyValue(const Value::Dict& dict,
29                       const std::string& key,
30                       int64_t expected_value);
31 
32 // Validate |iteration_data| contains one test result under |test_name|
33 // with |status|, |result_part_count| number of result parts and additional
34 // fields that only generated after execution when |have_running_info|.
35 bool ValidateTestResult(const Value::Dict& iteration_data,
36                         const std::string& test_name,
37                         const std::string& status,
38                         size_t result_part_count,
39                         bool have_running_info = true);
40 
41 // Validate test_locations contains all tests in |test_case_name|.
42 bool ValidateTestLocations(const Value::Dict& test_locations,
43                            const std::string& test_case_name);
44 
45 // Validate test_locations contains the correct file name and line number.
46 bool ValidateTestLocation(const Value::Dict& test_locations,
47                           const std::string& test_name,
48                           const std::string& file,
49                           int line);
50 
51 // Read json output file of test launcher.
52 std::optional<Value::Dict> ReadSummary(const FilePath& path);
53 
54 }  // namespace test_launcher_utils
55 
56 }  // namespace base
57 
58 #endif  // BASE_TEST_LAUNCHER_TEST_LAUNCHER_TEST_UTILS_H_
59