Commit 7a9374ff authored by rbpotter's avatar rbpotter Committed by Commit Bot

PDF Viewer Tests: Add hooks for feature flags

From https://chromium-review.googlesouce.com/c/chromium/src/+/2368821
by dpapad@

Adding these hooks will be used to run tests with the PDFViewerUpdate
flag on or off in future CLs.

Bug: 1120279
Change-Id: I2e85e156e71f4e95db8754e13ca9c0bb944a81e5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2380260
Commit-Queue: Rebekah Potter <rbpotter@chromium.org>
Reviewed-by: default avatarLei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/master@{#802331}
parent f96444d1
...@@ -164,6 +164,8 @@ class PDFExtensionTest : public extensions::ExtensionApiTest { ...@@ -164,6 +164,8 @@ class PDFExtensionTest : public extensions::ExtensionApiTest {
void SetUpCommandLine(base::CommandLine* command_line) override { void SetUpCommandLine(base::CommandLine* command_line) override {
content::IsolateAllSitesForTesting(command_line); content::IsolateAllSitesForTesting(command_line);
feature_list_.InitWithFeatures(GetEnabledFeatures(), GetDisabledFeatures());
} }
void SetUpOnMainThread() override { void SetUpOnMainThread() override {
...@@ -359,6 +361,16 @@ class PDFExtensionTest : public extensions::ExtensionApiTest { ...@@ -359,6 +361,16 @@ class PDFExtensionTest : public extensions::ExtensionApiTest {
browser()->profile()->GetPath()); browser()->profile()->GetPath());
} }
protected:
// Hooks to set up feature flags.
virtual const std::vector<base::Feature> GetEnabledFeatures() const {
return {};
}
virtual const std::vector<base::Feature> GetDisabledFeatures() const {
return {};
}
private: private:
WebContents* LoadPdfGetGuestContentsHelper(const GURL& url, bool new_tab) { WebContents* LoadPdfGetGuestContentsHelper(const GURL& url, bool new_tab) {
if (new_tab) { if (new_tab) {
...@@ -374,6 +386,8 @@ class PDFExtensionTest : public extensions::ExtensionApiTest { ...@@ -374,6 +386,8 @@ class PDFExtensionTest : public extensions::ExtensionApiTest {
WebContents* guest_contents = guest_manager->GetFullPageGuest(contents); WebContents* guest_contents = guest_manager->GetFullPageGuest(contents);
return guest_contents; return guest_contents;
} }
base::test::ScopedFeatureList feature_list_;
}; };
class PDFExtensionTestWithTestGuestViewManager : public PDFExtensionTest { class PDFExtensionTestWithTestGuestViewManager : public PDFExtensionTest {
...@@ -930,11 +944,18 @@ class PDFExtensionContentSettingJSTest ...@@ -930,11 +944,18 @@ class PDFExtensionContentSettingJSTest
~PDFExtensionContentSettingJSTest() override = default; ~PDFExtensionContentSettingJSTest() override = default;
protected: protected:
void SetUpCommandLine(base::CommandLine* command_line) override { const std::vector<base::Feature> GetEnabledFeatures() const override {
PDFExtensionJSTest::SetUpCommandLine(command_line); if (ShouldHonorJsContentSettings()) {
feature_list_.InitWithFeatureState( return {chrome_pdf::features::kPdfHonorJsContentSettings};
chrome_pdf::features::kPdfHonorJsContentSettings, }
ShouldHonorJsContentSettings()); return {};
}
const std::vector<base::Feature> GetDisabledFeatures() const override {
if (ShouldHonorJsContentSettings()) {
return {};
}
return {chrome_pdf::features::kPdfHonorJsContentSettings};
} }
bool ShouldHonorJsContentSettings() const { return GetParam(); } bool ShouldHonorJsContentSettings() const { return GetParam(); }
...@@ -956,9 +977,6 @@ class PDFExtensionContentSettingJSTest ...@@ -956,9 +977,6 @@ class PDFExtensionContentSettingJSTest
std::string GetDisabledJsTestFile() const { std::string GetDisabledJsTestFile() const {
return ShouldHonorJsContentSettings() ? "nobeep_test.js" : "beep_test.js"; return ShouldHonorJsContentSettings() ? "nobeep_test.js" : "beep_test.js";
} }
private:
base::test::ScopedFeatureList feature_list_;
}; };
IN_PROC_BROWSER_TEST_P(PDFExtensionContentSettingJSTest, Beep) { IN_PROC_BROWSER_TEST_P(PDFExtensionContentSettingJSTest, Beep) {
...@@ -2739,13 +2757,6 @@ class PDFExtensionAccessibilityTextExtractionTest : public PDFExtensionTest { ...@@ -2739,13 +2757,6 @@ class PDFExtensionAccessibilityTextExtractionTest : public PDFExtensionTest {
PDFExtensionAccessibilityTextExtractionTest() = default; PDFExtensionAccessibilityTextExtractionTest() = default;
~PDFExtensionAccessibilityTextExtractionTest() override = default; ~PDFExtensionAccessibilityTextExtractionTest() override = default;
void SetUpCommandLine(base::CommandLine* command_line) override {
PDFExtensionTest::SetUpCommandLine(command_line);
std::vector<base::Feature> enabled_features = {
chrome_pdf::features::kAccessiblePDFForm};
feature_list_.InitWithFeatures(enabled_features, /*disabled_features=*/{});
}
void RunTextExtractionTest(const base::FilePath::CharType* pdf_file) { void RunTextExtractionTest(const base::FilePath::CharType* pdf_file) {
base::FilePath test_path = ui_test_utils::GetTestFilePath( base::FilePath test_path = ui_test_utils::GetTestFilePath(
base::FilePath(FILE_PATH_LITERAL("pdf")), base::FilePath(FILE_PATH_LITERAL("pdf")),
...@@ -2759,6 +2770,11 @@ class PDFExtensionAccessibilityTextExtractionTest : public PDFExtensionTest { ...@@ -2759,6 +2770,11 @@ class PDFExtensionAccessibilityTextExtractionTest : public PDFExtensionTest {
RunTest(pdf_path, "pdf/accessibility"); RunTest(pdf_path, "pdf/accessibility");
} }
protected:
const std::vector<base::Feature> GetEnabledFeatures() const override {
return {chrome_pdf::features::kAccessiblePDFForm};
}
private: private:
class TestExpectationsLocator class TestExpectationsLocator
: public content::AccessibilityTestExpectationsLocator { : public content::AccessibilityTestExpectationsLocator {
...@@ -2860,8 +2876,6 @@ class PDFExtensionAccessibilityTextExtractionTest : public PDFExtensionTest { ...@@ -2860,8 +2876,6 @@ class PDFExtensionAccessibilityTextExtractionTest : public PDFExtensionTest {
lines.push_back(line); lines.push_back(line);
return lines; return lines;
} }
base::test::ScopedFeatureList feature_list_;
}; };
// Test that Previous/NextOnLineId attributes are present and properly linked on // Test that Previous/NextOnLineId attributes are present and properly linked on
...@@ -2945,9 +2959,6 @@ class PDFExtensionAccessibilityTreeDumpTest ...@@ -2945,9 +2959,6 @@ class PDFExtensionAccessibilityTreeDumpTest
void SetUpCommandLine(base::CommandLine* command_line) override { void SetUpCommandLine(base::CommandLine* command_line) override {
PDFExtensionTest::SetUpCommandLine(command_line); PDFExtensionTest::SetUpCommandLine(command_line);
std::vector<base::Feature> enabled_features = {
chrome_pdf::features::kAccessiblePDFForm};
feature_list_.InitWithFeatures(enabled_features, /*disabled_features=*/{});
// Each test pass might require custom command-line setup // Each test pass might require custom command-line setup
if (test_pass_.set_up_command_line) if (test_pass_.set_up_command_line)
...@@ -2955,6 +2966,10 @@ class PDFExtensionAccessibilityTreeDumpTest ...@@ -2955,6 +2966,10 @@ class PDFExtensionAccessibilityTreeDumpTest
} }
protected: protected:
const std::vector<base::Feature> GetEnabledFeatures() const override {
return {chrome_pdf::features::kAccessiblePDFForm};
}
void RunPDFTest(const base::FilePath::CharType* pdf_file) { void RunPDFTest(const base::FilePath::CharType* pdf_file) {
base::FilePath test_path = ui_test_utils::GetTestFilePath( base::FilePath test_path = ui_test_utils::GetTestFilePath(
base::FilePath(FILE_PATH_LITERAL("pdf")), base::FilePath(FILE_PATH_LITERAL("pdf")),
...@@ -2968,8 +2983,6 @@ class PDFExtensionAccessibilityTreeDumpTest ...@@ -2968,8 +2983,6 @@ class PDFExtensionAccessibilityTreeDumpTest
RunTest(pdf_path, "pdf/accessibility"); RunTest(pdf_path, "pdf/accessibility");
} }
base::test::ScopedFeatureList feature_list_;
private: private:
using PropertyFilter = content::AccessibilityTreeFormatter::PropertyFilter; using PropertyFilter = content::AccessibilityTreeFormatter::PropertyFilter;
......
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