forked from flutter/engine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlogger_listener.cc
58 lines (47 loc) · 1.69 KB
/
logger_listener.cc
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
50
51
52
53
54
55
56
57
58
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "flutter/testing/logger_listener.h"
namespace flutter::testing {
LoggerListener::LoggerListener() = default;
LoggerListener::~LoggerListener() = default;
void testing::LoggerListener::OnTestStart(
const ::testing::TestInfo& test_info) {
FML_LOG(IMPORTANT) << ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>";
FML_LOG(IMPORTANT) << "Starting Test: " << test_info.test_suite_name() << ":"
<< test_info.name();
}
std::string TestStatusAsString(const ::testing::TestResult* result) {
if (result == nullptr) {
return "UNKNOWN";
}
if (result->Passed()) {
return "PASSED";
}
if (result->Skipped()) {
return "SKIPPED";
}
if (result->Failed()) {
return "FAILED";
}
return "UNKNOWN";
}
std::string TestLabel(const ::testing::TestInfo& info) {
return std::string{info.test_suite_name()} + "." + info.name();
}
std::string TestTimeAsString(const ::testing::TestResult* result) {
if (result == nullptr) {
return "UNKNOWN";
}
return std::to_string(result->elapsed_time()) + " ms";
}
void testing::LoggerListener::OnTestEnd(const ::testing::TestInfo& info) {
FML_LOG(IMPORTANT) << "Test " << TestStatusAsString(info.result()) << " ("
<< TestTimeAsString(info.result())
<< "): " << TestLabel(info);
FML_LOG(IMPORTANT) << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<";
}
void testing::LoggerListener::OnTestDisabled(const ::testing::TestInfo& info) {
FML_LOG(IMPORTANT) << "Test Disabled: " << TestLabel(info);
}
} // namespace flutter::testing