Commit 6da75f9e authored by Sven Zheng's avatar Sven Zheng Committed by Commit Bot

Pixel test do not use --luci for local development

Currently if a developer want to run a pixel test locally, they need to
append "--no-luci-auth" flag.
With this change, developer will not need to the flag when running test
locally. This makes the test easier to use as adding the flag is not
obvious.

Change-Id: I4cba13fba41a38099e714d0ab5e9e3ddc648d250
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2506139Reviewed-by: default avatarBrian Sheedy <bsheedy@chromium.org>
Reviewed-by: default avatarSadrul Chowdhury <sadrul@chromium.org>
Commit-Queue: Sven Zheng <svenzheng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#822251}
parent ccb63ad7
...@@ -246,7 +246,8 @@ void SkiaGoldPixelDiff::Init(const std::string& screenshot_prefix, ...@@ -246,7 +246,8 @@ void SkiaGoldPixelDiff::Init(const std::string& screenshot_prefix,
code_review_system_ = "gerrit"; code_review_system_ = "gerrit";
} }
} }
if (cmd_line->HasSwitch(kNoLuciAuth)) { if (cmd_line->HasSwitch(kNoLuciAuth) ||
!cmd_line->HasSwitch(switches::kTestLauncherBotMode)) {
luci_auth_ = false; luci_auth_ = false;
} }
initialized_ = true; initialized_ = true;
......
...@@ -73,6 +73,52 @@ TEST_F(SkiaGoldPixelDiffTest, BypassSkiaGoldFunctionality) { ...@@ -73,6 +73,52 @@ TEST_F(SkiaGoldPixelDiffTest, BypassSkiaGoldFunctionality) {
EXPECT_TRUE(ret); EXPECT_TRUE(ret);
} }
TEST_F(SkiaGoldPixelDiffTest, LuciAuthSwitch) {
MockSkiaGoldPixelDiff mock_pixel;
auto* cmd_line = base::CommandLine::ForCurrentProcess();
cmd_line->AppendSwitch(switches::kTestLauncherBotMode);
EXPECT_CALL(mock_pixel, LaunchProcess(_)).Times(AnyNumber());
EXPECT_CALL(
mock_pixel,
LaunchProcess(AllOf(Property(&base::CommandLine::GetCommandLineString,
HasSubstr(FILE_PATH_LITERAL("--luci"))))))
.Times(1);
mock_pixel.Init("Prefix");
bool ret = mock_pixel.CompareScreenshot("test", GetTestBitmap());
EXPECT_TRUE(ret);
}
TEST_F(SkiaGoldPixelDiffTest, NoLuciAuthSwitch) {
MockSkiaGoldPixelDiff mock_pixel;
auto* cmd_line = base::CommandLine::ForCurrentProcess();
cmd_line->AppendSwitch("no-luci-auth");
EXPECT_CALL(mock_pixel, LaunchProcess(_)).Times(AnyNumber());
EXPECT_CALL(mock_pixel, LaunchProcess(AllOf(Property(
&base::CommandLine::GetCommandLineString,
Not(HasSubstr(FILE_PATH_LITERAL("--luci")))))))
.Times(3);
mock_pixel.Init("Prefix");
bool ret = mock_pixel.CompareScreenshot("test", GetTestBitmap());
EXPECT_TRUE(ret);
}
TEST_F(SkiaGoldPixelDiffTest, LocalNoLuciAuth) {
MockSkiaGoldPixelDiff mock_pixel;
auto* cmd_line = base::CommandLine::ForCurrentProcess();
cmd_line->RemoveSwitch(switches::kTestLauncherBotMode);
EXPECT_CALL(mock_pixel, LaunchProcess(_)).Times(AnyNumber());
EXPECT_CALL(mock_pixel, LaunchProcess(AllOf(Property(
&base::CommandLine::GetCommandLineString,
Not(HasSubstr(FILE_PATH_LITERAL("--luci")))))))
.Times(3);
mock_pixel.Init("Prefix");
bool ret = mock_pixel.CompareScreenshot("test", GetTestBitmap());
EXPECT_TRUE(ret);
}
TEST_F(SkiaGoldPixelDiffTest, FuzzyMatching) { TEST_F(SkiaGoldPixelDiffTest, FuzzyMatching) {
MockSkiaGoldPixelDiff mock_pixel; MockSkiaGoldPixelDiff mock_pixel;
EXPECT_CALL(mock_pixel, LaunchProcess(_)).Times(AnyNumber()); EXPECT_CALL(mock_pixel, LaunchProcess(_)).Times(AnyNumber());
......
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