Flutter Engine
The 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"
13#include "flutter/testing/assertions.h"
14#include "gtest/gtest.h"
16
17namespace flutter {
18namespace testing {
19
20const char* GetSourcePath();
21
22//------------------------------------------------------------------------------
23/// @brief Returns the directory containing the test fixture for the target
24/// if this target has fixtures configured. If there are no
25/// fixtures, this is a link error. If you see a linker error on
26/// this symbol, the unit-test target needs to depend on a
27/// `test_fixtures` target.
28///
29/// @return The fixtures path.
30///
31const char* GetFixturesPath();
32
33//------------------------------------------------------------------------------
34/// @brief Returns the directory containing assets shared across all tests.
35///
36/// @return The testing assets path.
37///
39
40//------------------------------------------------------------------------------
41/// @brief Returns the default path to kernel_blob.bin. This file is within
42/// the directory returned by `GetFixturesPath()`.
43///
44/// @return The kernel file path.
45///
46std::string GetDefaultKernelFilePath();
47
48//------------------------------------------------------------------------------
49/// @brief Opens the fixtures directory for the unit-test harness.
50///
51/// @return The file descriptor of the fixtures directory.
52///
54
55//------------------------------------------------------------------------------
56/// @brief Opens a fixture of the given file name.
57///
58/// @param[in] fixture_name The fixture name
59///
60/// @return The file descriptor of the given fixture. An invalid file
61/// descriptor is returned in case the fixture is not found.
62///
63fml::UniqueFD OpenFixture(const std::string& fixture_name);
64
65//------------------------------------------------------------------------------
66/// @brief Opens a fixture of the given file name and returns a mapping to
67/// its contents.
68///
69/// @param[in] fixture_name The fixture name
70///
71/// @return A mapping to the contents of fixture or null if the fixture does
72/// not exist or its contents cannot be mapped in.
73///
74std::unique_ptr<fml::Mapping> OpenFixtureAsMapping(
75 const std::string& fixture_name);
76
77//------------------------------------------------------------------------------
78/// @brief Opens a fixture of the given file name and returns a Skia SkData
79/// holding its contents.
80///
81/// @param[in] fixture_name The fixture name
82///
83/// @return An SkData, or null if the fixture does not exist or its contents
84/// cannot be mapped in.
85///
86sk_sp<SkData> OpenFixtureAsSkData(const std::string& fixture_name);
87
88//------------------------------------------------------------------------------
89/// @brief Gets the name of the currently running test. This is useful in
90/// generating logs or assets based on test name.
91///
92/// @return The current test name.
93///
94std::string GetCurrentTestName();
95
100
101//------------------------------------------------------------------------------
102/// @brief Depending on the operation, either scribbles a known pattern
103/// into the buffer or checks if that pattern is present in an
104/// existing buffer. This is a portable variant of the
105/// memset_pattern class of methods that also happen to do assert
106/// that the same pattern exists.
107///
108/// @param buffer The buffer
109/// @param[in] size The size
110/// @param[in] op The operation
111///
112/// @return If the result of the operation was a success.
113///
114bool MemsetPatternSetOrCheck(uint8_t* buffer, size_t size, MemsetPatternOp op);
115
116bool MemsetPatternSetOrCheck(std::vector<uint8_t>& buffer, MemsetPatternOp op);
117
118} // namespace testing
119} // namespace flutter
120
121#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:15
std::string GetDefaultKernelFilePath()
Returns the default path to kernel_blob.bin. This file is within the directory returned by GetFixture...
Definition testing.cc:19
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:79
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:64
fml::UniqueFD OpenFixture(const std::string &fixture_name)
Opens a fixture of the given file name.
Definition testing.cc:37
fml::UniqueFD OpenFixturesDirectory()
Opens the fixtures directory for the unit-test harness.
Definition testing.cc:23
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:59
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
Definition switches.h:126
it will be possible to load the file into Perfetto s trace viewer 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
Definition switches.h:259