#include "chrome/browser/enterprise/connectors/analysis/content_analysis_dialog.h"
#include "base/memory/raw_ptr.h"
#include "base/run_loop.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/bind.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/test_future.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/enterprise/connectors/analysis/content_analysis_delegate.h"
#include "chrome/browser/enterprise/connectors/analysis/content_analysis_downloads_delegate.h"
#include "chrome/browser/enterprise/connectors/analysis/content_analysis_features.h"
#include "chrome/browser/enterprise/connectors/test/deep_scanning_browsertest_base.h"
#include "chrome/browser/enterprise/connectors/test/deep_scanning_test_utils.h"
#include "chrome/browser/enterprise/connectors/test/fake_content_analysis_delegate.h"
#include "chrome/browser/safe_browsing/cloud_content_scanning/deep_scanning_utils.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/test/test_browser_dialog.h"
#include "chrome/grit/generated_resources.h"
#include "chrome/grit/theme_resources.h"
#include "components/download/public/common/mock_download_item.h"
#include "components/enterprise/common/proto/connectors.pb.h"
#include "components/prefs/scoped_user_pref_update.h"
#include "content/public/browser/web_contents_observer.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/browser_test_utils.h"
#include "ui/accessibility/ax_node_data.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/mojom/dialog_button.mojom.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/views/accessibility/view_accessibility.h"
#include "ui/views/controls/image_view.h"
#include "ui/views/controls/textarea/textarea.h"
#include "ui/views/controls/throbber.h"
#include "ui/views/test/ax_event_counter.h"
#include "ui/views/test/views_test_utils.h"
namespace enterprise_connectors {
namespace {
constexpr base::TimeDelta kNoDelay = …;
constexpr base::TimeDelta kSmallDelay = …;
constexpr base::TimeDelta kNormalDelay = …;
constexpr char kBlockingScansForDlpAndMalware[] = …;
constexpr char kBlockingScansForDlp[] = …;
constexpr char kBlockingScansForDlpAndMalwareWithCustomMessage[] = …;
std::string text() { … }
class ContentAnalysisDialogBehaviorBrowserTest
: public test::DeepScanningBrowserTestBase,
public ContentAnalysisDialog::TestObserver,
public testing::WithParamInterface<
std::tuple<bool, bool, base::TimeDelta, bool>> { … };
class ContentAnalysisDialogCancelPendingScanBrowserTest
: public test::DeepScanningBrowserTestBase,
public ContentAnalysisDialog::TestObserver { … };
class ContentAnalysisDialogWarningBrowserTest
: public test::DeepScanningBrowserTestBase,
public ContentAnalysisDialog::TestObserver,
public testing::WithParamInterface<bool> { … };
class ContentAnalysisDialogAppearanceBrowserTest
: public test::DeepScanningBrowserTestBase,
public ContentAnalysisDialog::TestObserver,
public testing::WithParamInterface<
std::tuple<bool,
bool,
safe_browsing::DeepScanAccessPoint,
bool,
bool>> { … };
class ContentAnalysisDialogCustomMessageBrowserTest
: public ContentAnalysisDialogAppearanceBrowserTest { … };
constexpr char kTestUrl[] = …;
}
IN_PROC_BROWSER_TEST_P(ContentAnalysisDialogBehaviorBrowserTest, Test) { … }
INSTANTIATE_TEST_SUITE_P(…);
IN_PROC_BROWSER_TEST_F(ContentAnalysisDialogCancelPendingScanBrowserTest,
Test) { … }
IN_PROC_BROWSER_TEST_P(ContentAnalysisDialogWarningBrowserTest, Test) { … }
INSTANTIATE_TEST_SUITE_P(…);
IN_PROC_BROWSER_TEST_P(ContentAnalysisDialogAppearanceBrowserTest, Test) { … }
INSTANTIATE_TEST_SUITE_P(…);
IN_PROC_BROWSER_TEST_P(ContentAnalysisDialogCustomMessageBrowserTest, Test) { … }
INSTANTIATE_TEST_SUITE_P(…);
class ContentAnalysisDialogPlainTests : public InProcessBrowserTest { … };
IN_PROC_BROWSER_TEST_F(ContentAnalysisDialogPlainTests, TestCustomMessage) { … }
IN_PROC_BROWSER_TEST_F(ContentAnalysisDialogPlainTests, TestCustomRuleMessage) { … }
IN_PROC_BROWSER_TEST_F(ContentAnalysisDialogPlainTests,
TestBypassJustification) { … }
IN_PROC_BROWSER_TEST_F(ContentAnalysisDialogPlainTests,
TestBypassJustificationTooLongDisablesBypassButton) { … }
IN_PROC_BROWSER_TEST_F(ContentAnalysisDialogPlainTests,
TestOpenInDefaultPendingState) { … }
IN_PROC_BROWSER_TEST_F(ContentAnalysisDialogPlainTests,
TestOpenInWarningState) { … }
IN_PROC_BROWSER_TEST_F(ContentAnalysisDialogPlainTests, TestOpenInBlockState) { … }
IN_PROC_BROWSER_TEST_F(ContentAnalysisDialogPlainTests,
TestOpenInFailClosedState) { … }
IN_PROC_BROWSER_TEST_F(ContentAnalysisDialogPlainTests,
TestOpenInLargeFilesState) { … }
IN_PROC_BROWSER_TEST_F(ContentAnalysisDialogPlainTests,
TestOpenInEncryptedFilesState) { … }
IN_PROC_BROWSER_TEST_F(ContentAnalysisDialogPlainTests,
TestWithDownloadsDelegateBypassWarning) { … }
IN_PROC_BROWSER_TEST_F(ContentAnalysisDialogPlainTests,
TestWithDownloadsDelegateDiscardWarning) { … }
IN_PROC_BROWSER_TEST_F(ContentAnalysisDialogPlainTests,
TestWithDownloadsDelegateDiscardBlock) { … }
IN_PROC_BROWSER_TEST_F(ContentAnalysisDialogPlainTests,
BypassJustificationLabelAndTextareaAccessibility) { … }
class ContentAnalysisDialogUiTest
: public DialogBrowserTest,
public testing::WithParamInterface<std::tuple<bool, bool, bool>> { … };
IN_PROC_BROWSER_TEST_P(ContentAnalysisDialogUiTest, InvokeUi_default) { … }
INSTANTIATE_TEST_SUITE_P(…);
class ContentAnalysisDialogCustomRuleMessageUiTest
: public ContentAnalysisDialogUiTest { … };
IN_PROC_BROWSER_TEST_P(ContentAnalysisDialogCustomRuleMessageUiTest,
InvokeUi_default) { … }
INSTANTIATE_TEST_SUITE_P(…);
class ContentAnalysisDialogDownloadObserverTest
: public test::DeepScanningBrowserTestBase,
public ContentAnalysisDialog::TestObserver { … };
IN_PROC_BROWSER_TEST_F(ContentAnalysisDialogDownloadObserverTest,
DownloadOpened) { … }
IN_PROC_BROWSER_TEST_F(ContentAnalysisDialogDownloadObserverTest,
DownloadUpdated) { … }
IN_PROC_BROWSER_TEST_F(ContentAnalysisDialogDownloadObserverTest,
DownloadDestroyed) { … }
}