Flutter Engine
 
Loading...
Searching...
No Matches
testing.h
Go to the documentation of this file.
1// Copyright 2013 The Flutter 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
5#ifndef FLUTTER_TESTING_TESTING_H_
6#define FLUTTER_TESTING_TESTING_H_
7
8#include <string>
9#include <vector>
10
11#include "flutter/fml/file.h"
12#include "flutter/fml/mapping.h"
14#include "gtest/gtest.h"
15#include "third_party/skia/include/core/SkData.h"
16
17namespace flutter::testing {
18
19const char* GetSourcePath();
20
21//------------------------------------------------------------------------------
22/// @brief Returns the directory containing the test fixture for the target
23/// if this target has fixtures configured. If there are no
24/// fixtures, this is a link error. If you see a linker error on
25/// this symbol, the unit-test target needs to depend on a
26/// `test_fixtures` target.
27///
28/// @return The fixtures path.
29///
30const char* GetFixturesPath();
31
32//------------------------------------------------------------------------------
33/// @brief Returns the directory containing assets shared across all tests.
34///
35/// @return The testing assets path.
36///
38
39//------------------------------------------------------------------------------
40/// @brief Returns the default path to kernel_blob.bin. This file is within
41/// the directory returned by `GetFixturesPath()`.
42///
43/// @return The kernel file path.
44///
45std::string GetDefaultKernelFilePath();
46
47//------------------------------------------------------------------------------
48/// @brief Opens the fixtures directory for the unit-test harness.
49///
50/// @return The file descriptor of the fixtures directory.
51///
53
54//------------------------------------------------------------------------------
55/// @brief Opens a fixture of the given file name.
56///
57/// @param[in] fixture_name The fixture name
58///
59/// @return The file descriptor of the given fixture. An invalid file
60/// descriptor is returned in case the fixture is not found.
61///
62fml::UniqueFD OpenFixture(const std::string& fixture_name);
63
64//------------------------------------------------------------------------------
65/// @brief Opens a fixture of the given file name and returns a mapping to
66/// its contents.
67///
68/// @param[in] fixture_name The fixture name
69///
70/// @return A mapping to the contents of fixture or null if the fixture does
71/// not exist or its contents cannot be mapped in.
72///
73std::unique_ptr<fml::Mapping> OpenFixtureAsMapping(
74 const std::string& fixture_name);
75
76//------------------------------------------------------------------------------
77/// @brief Opens a fixture of the given file name and returns a Skia SkData
78/// holding its contents.
79///
80/// @param[in] fixture_name The fixture name
81///
82/// @return An SkData, or null if the fixture does not exist or its contents
83/// cannot be mapped in.
84///
85sk_sp<SkData> OpenFixtureAsSkData(const std::string& fixture_name);
86
87//------------------------------------------------------------------------------
88/// @brief Gets the name of the currently running test. This is useful in
89/// generating logs or assets based on test name.
90///
91/// @return The current test name.
92///
93std::string GetCurrentTestName();
94
99
100//------------------------------------------------------------------------------
101/// @brief Depending on the operation, either scribbles a known pattern
102/// into the buffer or checks if that pattern is present in an
103/// existing buffer. This is a portable variant of the
104/// memset_pattern class of methods that also happen to do assert
105/// that the same pattern exists.
106///
107/// @param buffer The buffer
108/// @param[in] size The size
109/// @param[in] op The operation
110///
111/// @return If the result of the operation was a success.
112///
113bool MemsetPatternSetOrCheck(uint8_t* buffer, size_t size, MemsetPatternOp op);
114
115bool MemsetPatternSetOrCheck(std::vector<uint8_t>& buffer, MemsetPatternOp op);
116
117} // namespace flutter::testing
118
119#endif // FLUTTER_TESTING_TESTING_H_
std::string GetCurrentTestName()
Gets the name of the currently running test. This is useful in generating logs or assets based on tes...
Definition testing.cc:14
std::string GetDefaultKernelFilePath()
Returns the default path to kernel_blob.bin. This file is within the directory returned by GetFixture...
Definition testing.cc:18
const char * GetFixturesPath()
Returns the directory containing the test fixture for the target if this target has fixtures configur...
bool MemsetPatternSetOrCheck(uint8_t *buffer, size_t size, MemsetPatternOp op)
Depending on the operation, either scribbles a known pattern into the buffer or checks if that patter...
Definition testing.cc:78
const char * GetSourcePath()
sk_sp< SkData > OpenFixtureAsSkData(const std::string &fixture_name)
Opens a fixture of the given file name and returns a Skia SkData holding its contents.
Definition testing.cc:63
fml::UniqueFD OpenFixture(const std::string &fixture_name)
Opens a fixture of the given file name.
Definition testing.cc:36
fml::UniqueFD OpenFixturesDirectory()
Opens the fixtures directory for the unit-test harness.
Definition testing.cc:22
const char * GetTestingAssetsPath()
Returns the directory containing assets shared across all tests.
std::unique_ptr< fml::Mapping > OpenFixtureAsMapping(const std::string &fixture_name)
Opens a fixture of the given file name and returns a mapping to its contents.
Definition testing.cc:58
it will be possible to load the file into Perfetto s trace viewer use test Running tests that layout and measure text will not yield consistent results across various platforms Enabling this option will make font resolution default to the Ahem test font on all disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size