Commit 35d0dccc authored by Brian Sheedy's avatar Brian Sheedy Committed by Commit Bot

Add configurable CRS to gtest Gold tests

Adds the ability to pass in --code-review-system to specify the code
review system being used for a Skia Gold-backed gtest pixel test. This
defaults to "gerrit" if not passed in, which is what it was hard-coded
to before, but can now be set to "gerrit-internal" for internal code
reviews.

Bug: skia:10532
Change-Id: I28848158efbf83f223f5d56acdf5bd62271ce95b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2476669Reviewed-by: default avatarSven Zheng <svenzheng@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Commit-Queue: Brian Sheedy <bsheedy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#818061}
parent 2f19541f
......@@ -48,6 +48,7 @@ const char* kBuildRevisionKey = "git-revision";
const char* kIssueKey = "gerrit-issue";
const char* kPatchSetKey = "gerrit-patchset";
const char* kJobIdKey = "buildbucket-id";
const char* kCodeReviewSystemKey = "code-review-system";
const char* kNoLuciAuth = "no-luci-auth";
const char* kBypassSkiaGoldFunctionality = "bypass-skia-gold-functionality";
......@@ -175,7 +176,7 @@ void SkiaGoldPixelDiff::InitSkiaGold() {
cmd.AppendSwitchASCII("issue", issue_);
cmd.AppendSwitchASCII("patchset", patchset_);
cmd.AppendSwitchASCII("jobid", job_id_);
cmd.AppendSwitchASCII("crs", "gerrit");
cmd.AppendSwitchASCII("crs", code_review_system_);
cmd.AppendSwitchASCII("cis", "buildbucket");
}
......@@ -205,6 +206,10 @@ void SkiaGoldPixelDiff::Init(const std::string& screenshot_prefix,
issue_ = cmd_line->GetSwitchValueASCII(kIssueKey);
patchset_ = cmd_line->GetSwitchValueASCII(kPatchSetKey);
job_id_ = cmd_line->GetSwitchValueASCII(kJobIdKey);
code_review_system_ = cmd_line->GetSwitchValueASCII(kCodeReviewSystemKey);
if (code_review_system_.empty()) {
code_review_system_ = "gerrit";
}
}
if (cmd_line->HasSwitch(kNoLuciAuth)) {
luci_auth_ = false;
......
......@@ -80,6 +80,9 @@ class SkiaGoldPixelDiff {
std::string patchset_;
// Buildbucket build id.
std::string job_id_;
// Which code review system is being used, typically "gerrit" for Chromium
// and "gerrit-internal" for Chrome.
std::string code_review_system_;
// The working dir for goldctl. It's the dir for storing temporary files.
base::FilePath working_dir_;
......
......@@ -201,5 +201,56 @@ TEST_F(SkiaGoldPixelDiffTest, ExplicitCorpus) {
EXPECT_TRUE(ret);
}
TEST_F(SkiaGoldPixelDiffTest, DefaultCodeReviewSystem) {
auto* cmd_line = base::CommandLine::ForCurrentProcess();
cmd_line->AppendSwitchASCII("gerrit-issue", "1");
cmd_line->AppendSwitchASCII("gerrit-patchset", "2");
cmd_line->AppendSwitchASCII("buildbucket-id", "3");
SkBitmap bitmap;
SkImageInfo info =
SkImageInfo::Make(10, 10, SkColorType::kBGRA_8888_SkColorType,
SkAlphaType::kPremul_SkAlphaType);
bitmap.allocPixels(info, 10 * 4);
MockSkiaGoldPixelDiff mock_pixel;
EXPECT_CALL(mock_pixel, LaunchProcess(_)).Times(AnyNumber());
EXPECT_CALL(
mock_pixel,
LaunchProcess(AllOf(Property(&base::CommandLine::GetCommandLineString,
HasSubstr(FILE_PATH_LITERAL("gerrit"))))))
.Times(1);
mock_pixel.Init("Prefix");
bool ret = mock_pixel.CompareScreenshot("test", bitmap);
EXPECT_TRUE(ret);
}
TEST_F(SkiaGoldPixelDiffTest, ExplicitCodeReviewSystem) {
auto* cmd_line = base::CommandLine::ForCurrentProcess();
cmd_line->AppendSwitchASCII("gerrit-issue", "1");
cmd_line->AppendSwitchASCII("gerrit-patchset", "2");
cmd_line->AppendSwitchASCII("buildbucket-id", "3");
cmd_line->AppendSwitchASCII("code-review-system", "new-crs");
SkBitmap bitmap;
SkImageInfo info =
SkImageInfo::Make(10, 10, SkColorType::kBGRA_8888_SkColorType,
SkAlphaType::kPremul_SkAlphaType);
bitmap.allocPixels(info, 10 * 4);
MockSkiaGoldPixelDiff mock_pixel;
EXPECT_CALL(mock_pixel, LaunchProcess(_)).Times(AnyNumber());
EXPECT_CALL(mock_pixel,
LaunchProcess(
AllOf(Property(&base::CommandLine::GetCommandLineString,
HasSubstr(FILE_PATH_LITERAL("new-crs"))),
Property(&base::CommandLine::GetCommandLineString,
Not(HasSubstr(FILE_PATH_LITERAL("gerrit")))))))
.Times(1);
mock_pixel.Init("Prefix");
bool ret = mock_pixel.CompareScreenshot("test", bitmap);
EXPECT_TRUE(ret);
}
} // namespace test
} // namespace ui
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment