Flutter Engine
The Flutter Engine
impeller
golden_tests
main.cc
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
#include <wordexp.h>
6
7
#include "flutter/fml/backtrace.h"
8
#include "flutter/fml/build_config.h"
9
#include "flutter/fml/command_line.h"
10
#include "flutter/fml/logging.h"
11
#include "flutter/impeller/base/validation.h"
12
#include "flutter/impeller/golden_tests/golden_digest.h"
13
#include "flutter/impeller/golden_tests/working_directory.h"
14
#include "gtest/gtest.h"
15
16
namespace
{
17
void
print_usage() {
18
std::cout <<
"usage: impeller_golden_tests --working_dir=<working_dir>"
19
<< std::endl
20
<< std::endl;
21
std::cout <<
"flags:"
<< std::endl;
22
std::cout <<
" working_dir: Where the golden images will be generated and "
23
"uploaded to Skia Gold from."
24
<< std::endl;
25
}
26
}
// namespace
27
28
namespace
impeller
{
29
TEST
(ValidationTest, IsFatal) {
30
EXPECT_TRUE
(
ImpellerValidationErrorsAreFatal
());
31
}
32
}
// namespace impeller
33
34
int
main
(
int
argc,
char
**
argv
) {
35
impeller::ImpellerValidationErrorsSetFatal
(
true
);
36
fml::InstallCrashHandler
();
37
testing::InitGoogleTest(&argc,
argv
);
38
fml::CommandLine
cmd
=
fml::CommandLineFromPlatformOrArgcArgv
(argc,
argv
);
39
40
std::optional<std::string> working_dir;
41
for
(
const
auto
& option :
cmd
.options()) {
42
if
(option.name ==
"working_dir"
) {
43
wordexp_t wordexp_result;
44
int
code
= wordexp(option.value.c_str(), &wordexp_result, 0);
45
FML_CHECK
(
code
== 0);
46
FML_CHECK
(wordexp_result.we_wordc != 0);
47
working_dir = wordexp_result.we_wordv[0];
48
wordfree(&wordexp_result);
49
}
50
}
51
if
(!working_dir) {
52
std::cout <<
"required argument \"working_dir\" is missing."
<< std::endl
53
<< std::endl;
54
print_usage();
55
return
1;
56
}
57
58
impeller::testing::WorkingDirectory::Instance
()->
SetPath
(working_dir.value());
59
std::cout <<
"working directory: "
60
<<
impeller::testing::WorkingDirectory::Instance
()->
GetPath
()
61
<< std::endl;
62
63
int
return_code = RUN_ALL_TESTS();
64
if
(0 == return_code) {
65
impeller::testing::GoldenDigest::Instance
()->
Write
(
66
impeller::testing::WorkingDirectory::Instance
());
67
}
68
return
return_code;
69
}
fml::CommandLine
Definition:
command_line.h:56
impeller::testing::GoldenDigest::Write
bool Write(WorkingDirectory *working_directory)
Definition:
golden_digest.cc:42
impeller::testing::GoldenDigest::Instance
static GoldenDigest * Instance()
Definition:
golden_digest.cc:18
impeller::testing::WorkingDirectory::SetPath
void SetPath(const std::string &path)
Definition:
working_directory.cc:28
impeller::testing::WorkingDirectory::GetPath
const std::string & GetPath() const
Definition:
working_directory.h:23
impeller::testing::WorkingDirectory::Instance
static WorkingDirectory * Instance()
Definition:
working_directory.cc:16
main
int main(int argc, char **argv)
Definition:
main.cc:407
FML_CHECK
#define FML_CHECK(condition)
Definition:
logging.h:85
argv
char ** argv
Definition:
library.h:9
fml::InstallCrashHandler
void InstallCrashHandler()
Definition:
backtrace.cc:126
fml::CommandLineFromPlatformOrArgcArgv
CommandLine CommandLineFromPlatformOrArgcArgv(int argc, const char *const *argv)
Definition:
command_line.h:242
impeller
Definition:
texture.h:18
impeller::ImpellerValidationErrorsAreFatal
bool ImpellerValidationErrorsAreFatal()
Definition:
validation.cc:63
impeller::ImpellerValidationErrorsSetFatal
void ImpellerValidationErrorsSetFatal(bool fatal)
Definition:
validation.cc:16
impeller::TEST
TEST(ValidationTest, IsFatal)
Definition:
main.cc:29
remove_file_on_device.cmd
list cmd
Definition:
remove_file_on_device.py:13
valgrind.code
code
Definition:
valgrind.py:29
EXPECT_TRUE
#define EXPECT_TRUE(handle)
Definition:
unit_test.h:678
Generated on Sun Jun 23 2024 21:54:56 for Flutter Engine by
1.9.4