Commit dbd15694 authored by Oleg Davydov's avatar Oleg Davydov Committed by Commit Bot

Extract extension-related stuff from policy_browsertest.cc

File policy_browsertest.cc contains integration tests for many unrelated
policies, that makes this test file extremely large. It's better to
split it into several parts according to testing section. This commit
starts with splitting work by moving extension-related policy tests into
separate file.

Possible follow-up improvement could be: extract other sections into
different files, leaving only generic policy tests in
policy_browsertest.cc. Another possible follow-up: refactor PolicyTest
base test class, eg., by moving its extension-related methods into new
subclass in extension_policy_browsertest.cc.

Bug: 1002483
Change-Id: I97f6286fd5ba0ba681fa95fc1f85107da4fe246c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1763667
Commit-Queue: Oleg Davydov <burunduk@chromium.org>
Reviewed-by: default avatarSergey Poromov <poromov@chromium.org>
Cr-Commit-Position: refs/heads/master@{#697157}
parent 128a107e
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_POLICY_POLICY_TEST_UTILS_H_
#define CHROME_BROWSER_POLICY_POLICY_TEST_UTILS_H_
#include "ash/public/cpp/keyboard/keyboard_types.h"
#include "base/files/file_path.h"
#include "chrome/browser/extensions/updater/extension_cache_fake.h"
#include "chrome/browser/extensions/updater/extension_updater.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "components/policy/core/common/mock_configuration_policy_provider.h"
#include "components/security_interstitials/core/controller_client.h"
#include "extensions/browser/scoped_ignore_content_verifier_for_test.h"
namespace extensions {
class Extension;
class ExtensionRegistry;
class ExtensionService;
} // namespace extensions
namespace policy {
extern const base::FilePath::CharType kTestExtensionsDir[];
class PolicyMap;
void GetTestDataDirectory(base::FilePath* test_data_directory);
class PolicyTest : public InProcessBrowserTest {
protected:
PolicyTest();
~PolicyTest() override;
void SetUp() override;
void SetUpInProcessBrowserTestFixture() override;
void SetUpOnMainThread() override;
void SetUpCommandLine(base::CommandLine* command_line) override;
void SetScreenshotPolicy(bool enabled);
void SetShouldRequireCTForTesting(bool* required);
extensions::ExtensionService* extension_service();
extensions::ExtensionRegistry* extension_registry();
const extensions::Extension* InstallExtension(
const base::FilePath::StringType& name);
const extensions::Extension* InstallBookmarkApp();
scoped_refptr<const extensions::Extension> LoadUnpackedExtension(
const base::FilePath::StringType& name);
void UninstallExtension(const std::string& id, bool expect_success);
void DisableExtension(const std::string& id);
void UpdateProviderPolicy(const PolicyMap& policy);
// Sends a mouse click at the given coordinates to the current renderer.
void PerformClick(int x, int y);
void SetPolicy(PolicyMap* policies,
const char* key,
std::unique_ptr<base::Value> value);
void ApplySafeSearchPolicy(std::unique_ptr<base::Value> legacy_safe_search,
std::unique_ptr<base::Value> google_safe_search,
std::unique_ptr<base::Value> legacy_youtube,
std::unique_ptr<base::Value> youtube_restrict);
#if defined(OS_CHROMEOS)
void TestScreenshotFile(bool enabled);
void SetEnableFlag(const keyboard::KeyboardEnableFlag& flag);
void ClearEnableFlag(const keyboard::KeyboardEnableFlag& flag);
#endif // defined(OS_CHROMEOS)
static GURL GetExpectedSearchURL(bool expect_safe_search);
static void CheckSafeSearch(Browser* browser,
bool expect_safe_search,
const std::string& url = "http://google.com/");
static void CheckYouTubeRestricted(
int youtube_restrict_mode,
const std::map<GURL, net::HttpRequestHeaders>& urls_requested,
const GURL& url);
static void CheckAllowedDomainsHeader(
const std::string& allowed_domain,
const std::map<GURL, net::HttpRequestHeaders>& urls_requested,
const GURL& url);
static bool FetchSubresource(content::WebContents* web_contents,
const GURL& url);
bool IsShowingInterstitial(content::WebContents* tab);
void WaitForInterstitial(content::WebContents* tab);
int IsExtendedReportingCheckboxVisibleOnInterstitial();
void SendInterstitialCommand(
content::WebContents* tab,
security_interstitials::SecurityInterstitialCommand command);
MockConfigurationPolicyProvider provider_;
std::unique_ptr<extensions::ExtensionCacheFake> test_extension_cache_;
extensions::ScopedIgnoreContentVerifierForTest ignore_content_verifier_;
extensions::ExtensionUpdater::ScopedSkipScheduledCheckForTest
skip_scheduled_extension_checks_;
};
} // namespace policy
#endif // CHROME_BROWSER_POLICY_POLICY_TEST_UTILS_H_
......@@ -1039,6 +1039,8 @@ if (!is_android) {
"../browser/policy/policy_network_browsertest.cc",
"../browser/policy/policy_prefs_browsertest.cc",
"../browser/policy/policy_startup_browsertest.cc",
"../browser/policy/policy_test_utils.cc",
"../browser/policy/policy_test_utils.h",
"../browser/policy/site_isolation_policy_browsertest.cc",
"../browser/predictors/loading_predictor_browsertest.cc",
"../browser/prefetch/prefetch_browsertest.cc",
......@@ -1751,6 +1753,7 @@ if (!is_android) {
"../browser/extensions/window_open_apitest.cc",
"../browser/extensions/worker_apitest.cc",
"../browser/notifications/notification_permission_context_apitest.cc",
"../browser/policy/extension_policy_browsertest.cc",
"../browser/safe_browsing/chrome_cleaner/chrome_cleaner_dialog_controller_impl_browsertest_win.cc",
"../browser/safe_browsing/chrome_cleaner/chrome_cleaner_reboot_dialog_controller_impl_browsertest_win.cc",
"../browser/safe_browsing/chrome_cleaner/mock_chrome_cleaner_controller_win.cc",
......
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