chromium/ui/base/test/skia_gold_pixel_diff.cc

// Copyright 2019 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#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  // defined(ARCH_CPU_ARM64)
#else
const char* kSkiaGoldCtl =;
#endif

const char* kBuildRevisionKey =;

// A dummy build revision used only under a dry run.
constexpr char kDummyBuildRevision[] =;

// The switch keys for tryjob.
const char* kIssueKey =;
const char* kPatchSetKey =;
const char* kJobIdKey =;
const char* kCodeReviewSystemKey =;

const char* kNoLuciAuth =;
const char* kBypassSkiaGoldFunctionality =;
const char* kDryRun =;

// The switch key for saving png file locally for debugging. This will allow
// the framework to save the screenshot png file to this path.
const char* kPngFilePathDebugging =;

const char* kGoldOutputTriageFormat =;
const char* kPublicTriageLink =;

// The separator used in the names of the screenshots taken on Ash platform.
constexpr char kAshSeparator[] =;

// The separator used by non-Ash platforms.
constexpr char kNonAshSeparator[] =;

namespace {

base::FilePath GetAbsoluteSrcRelativePath(base::FilePath::StringType path) {}

// Append args after program.
// The base::Commandline.AppendArg append the arg at
// the end which doesn't work for us.
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() {}

// Non-empty test corpus and environment map.
SessionCacheKey;
SessionCache;
SessionCache g_sessions(SessionCache::NO_AUTO_EVICT);

// If present, overrides |LaunchProcess|.
SkiaGoldPixelDiff::LaunchProcessCallback g_custom_launch_process;

int LaunchProcess(const base::CommandLine& cmdline) {}

}  // namespace

SkiaGoldPixelDiff::SkiaGoldPixelDiff() = default;

SkiaGoldPixelDiff::~SkiaGoldPixelDiff() = default;

SkiaGoldPixelDiff::ScopedSessionCacheForTesting::
    ScopedSessionCacheForTesting() {}

SkiaGoldPixelDiff::ScopedSessionCacheForTesting::
    ~ScopedSessionCacheForTesting() {}

// static
SkiaGoldPixelDiff* SkiaGoldPixelDiff::GetSession(
    const std::optional<std::string>& corpus,
    TestEnvironmentMap test_environment) {}

// static
base::AutoReset<SkiaGoldPixelDiff::LaunchProcessCallback>
SkiaGoldPixelDiff::OverrideLaunchProcessForTesting(
    SkiaGoldPixelDiff::LaunchProcessCallback custom_launch_process) {}

// static
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 {}

// static
std::string SkiaGoldPixelDiff::GetGoldenImageName(
    const std::string& test_suite_name,
    const std::string& test_name,
    const std::optional<std::string>& suffix) {}

// static
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 {}

}  // namespace test
}  // namespace ui