#include "ui/base/test/skia_gold_pixel_diff.h"
#include <memory>
#include <string_view>
#if BUILDFLAG(IS_WIN)
#include <windows.h>
#endif
#include "base/auto_reset.h"
#include "base/base_paths.h"
#include "base/command_line.h"
#include "base/containers/lru_cache.h"
#include "base/containers/span.h"
#include "base/environment.h"
#include "base/files/file.h"
#include "base/files/file_enumerator.h"
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/json/json_reader.h"
#include "base/json/json_writer.h"
#include "base/logging.h"
#include "base/notreached.h"
#include "base/path_service.h"
#include "base/process/launch.h"
#include "base/process/process.h"
#include "base/sequence_checker.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "base/test/test_switches.h"
#include "base/threading/thread_restrictions.h"
#include "base/values.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/base/test/skia_gold_matching_algorithm.h"
#include "ui/gfx/codec/png_codec.h"
#include "ui/gfx/image/image.h"
#include "ui/snapshot/snapshot.h"
namespace ui {
namespace test {
const char* kSkiaGoldInstance = …;
const char* kSkiaGoldPublicInstance = …;
#if BUILDFLAG(IS_WIN)
const wchar_t* kSkiaGoldCtl = L"tools/skia_goldctl/win/goldctl.exe";
#elif BUILDFLAG(IS_APPLE)
#if defined(ARCH_CPU_ARM64)
const char* kSkiaGoldCtl = "tools/skia_goldctl/mac_arm64/goldctl";
#else
const char* kSkiaGoldCtl = "tools/skia_goldctl/mac_amd64/goldctl";
#endif
#else
const char* kSkiaGoldCtl = …;
#endif
const char* kBuildRevisionKey = …;
constexpr char kDummyBuildRevision[] = …;
const char* kIssueKey = …;
const char* kPatchSetKey = …;
const char* kJobIdKey = …;
const char* kCodeReviewSystemKey = …;
const char* kNoLuciAuth = …;
const char* kBypassSkiaGoldFunctionality = …;
const char* kDryRun = …;
const char* kPngFilePathDebugging = …;
const char* kGoldOutputTriageFormat = …;
const char* kPublicTriageLink = …;
constexpr char kAshSeparator[] = …;
constexpr char kNonAshSeparator[] = …;
namespace {
base::FilePath GetAbsoluteSrcRelativePath(base::FilePath::StringType path) { … }
void AppendArgsJustAfterProgram(base::CommandLine& cmd,
base::CommandLine::StringVector args) { … }
const char* GetPlatformName() { … }
const char* GetArchName() { … }
void FillInSystemEnvironment(TestEnvironmentMap& test_environment) { … }
const char* TestEnvironmentKeyToString(TestEnvironmentKey key) { … }
bool WriteTestEnvironmentToFile(const TestEnvironmentMap& test_environment,
const base::FilePath& keys_file) { … }
bool BotModeEnabled(const base::CommandLine* command_line) { … }
const char* GetDiffGoldInstance() { … }
SessionCacheKey;
SessionCache;
SessionCache g_sessions(SessionCache::NO_AUTO_EVICT);
SkiaGoldPixelDiff::LaunchProcessCallback g_custom_launch_process;
int LaunchProcess(const base::CommandLine& cmdline) { … }
}
SkiaGoldPixelDiff::SkiaGoldPixelDiff() = default;
SkiaGoldPixelDiff::~SkiaGoldPixelDiff() = default;
SkiaGoldPixelDiff::ScopedSessionCacheForTesting::
ScopedSessionCacheForTesting() { … }
SkiaGoldPixelDiff::ScopedSessionCacheForTesting::
~ScopedSessionCacheForTesting() { … }
SkiaGoldPixelDiff* SkiaGoldPixelDiff::GetSession(
const std::optional<std::string>& corpus,
TestEnvironmentMap test_environment) { … }
base::AutoReset<SkiaGoldPixelDiff::LaunchProcessCallback>
SkiaGoldPixelDiff::OverrideLaunchProcessForTesting(
SkiaGoldPixelDiff::LaunchProcessCallback custom_launch_process) { … }
std::string SkiaGoldPixelDiff::GetPlatform() { … }
void SkiaGoldPixelDiff::InitSkiaGold() const { … }
void SkiaGoldPixelDiff::Init(const std::string& corpus,
TestEnvironmentMap test_environment) { … }
bool SkiaGoldPixelDiff::UploadToSkiaGoldServer(
const base::FilePath& local_file_path,
const std::string& remote_golden_image_name,
const SkiaGoldMatchingAlgorithm* algorithm) const { … }
std::string SkiaGoldPixelDiff::GetGoldenImageName(
const std::string& test_suite_name,
const std::string& test_name,
const std::optional<std::string>& suffix) { … }
std::string SkiaGoldPixelDiff::GetGoldenImageName(
const ::testing::TestInfo* test_info,
const std::optional<std::string>& suffix) { … }
bool SkiaGoldPixelDiff::CompareScreenshot(
const std::string& golden_image_name,
const SkBitmap& bitmap,
const SkiaGoldMatchingAlgorithm* algorithm) const { … }
void SkiaGoldPixelDiff::GenerateLocalDiff(
const std::string& remote_golden_image_name,
const base::FilePath& test_output_path) const { … }
}
}