chromium/content/browser/sms/sms_browsertest.cc

// Copyright 2019 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include <memory>
#include <string>

#include "base/command_line.h"
#include "base/test/bind.h"
#include "base/test/metrics/histogram_tester.h"
#include "build/build_config.h"
#include "components/ukm/test_ukm_recorder.h"
#include "content/browser/browser_main_loop.h"
#include "content/browser/sms/sms_fetcher_impl.h"
#include "content/browser/sms/test/mock_sms_provider.h"
#include "content/browser/sms/test/mock_sms_web_contents_delegate.h"
#include "content/browser/sms/webotp_service.h"
#include "content/browser/web_contents/web_contents_impl.h"
#include "content/public/browser/sms_fetcher.h"
#include "content/public/common/content_switches.h"
#include "content/public/common/isolated_world_ids.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/content_browser_test.h"
#include "content/public/test/content_browser_test_utils.h"
#include "content/public/test/content_mock_cert_verifier.h"
#include "content/public/test/fenced_frame_test_util.h"
#include "content/public/test/prerender_test_util.h"
#include "content/shell/browser/shell.h"
#include "content/test/content_browser_test_utils_internal.h"
#include "net/cert/mock_cert_verifier.h"
#include "net/dns/mock_host_resolver.h"
#include "net/test/embedded_test_server/default_handlers.h"
#include "services/metrics/public/cpp/ukm_builders.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "third_party/blink/public/common/sms/webotp_service_outcome.h"

SmsStatus;
_;
Invoke;
NiceMock;
Return;

namespace content {

UserConsent;

namespace {

class SmsBrowserTest : public ContentBrowserTest {};

}  // namespace

// TODO(crbug.com/41486967): Flaky on Win Debug
#if BUILDFLAG(IS_WIN) && !defined(NDEBUG)
#define MAYBE_Receive
#else
#define MAYBE_Receive
#endif
IN_PROC_BROWSER_TEST_F(SmsBrowserTest, MAYBE_Receive) {}

IN_PROC_BROWSER_TEST_F(SmsBrowserTest, AtMostOneSmsRequestPerOrigin) {}

// Disabled test: https://crbug.com/1052385
IN_PROC_BROWSER_TEST_F(SmsBrowserTest,
                       DISABLED_AtMostOneSmsRequestPerOriginPerTab) {}

IN_PROC_BROWSER_TEST_F(SmsBrowserTest, Reload) {}

IN_PROC_BROWSER_TEST_F(SmsBrowserTest, Close) {}

// Disabled test: https://crbug.com/1052385
IN_PROC_BROWSER_TEST_F(SmsBrowserTest, DISABLED_TwoTabsSameOrigin) {}

// Disabled test: https://crbug.com/1052385
IN_PROC_BROWSER_TEST_F(SmsBrowserTest, DISABLED_TwoTabsDifferentOrigin) {}

// TODO(crbug.com/41486967): Flaky on Win Debug
#if BUILDFLAG(IS_WIN) && !defined(NDEBUG)
#define MAYBE_SmsReceivedAfterTabIsClosed
#else
#define MAYBE_SmsReceivedAfterTabIsClosed
#endif
IN_PROC_BROWSER_TEST_F(SmsBrowserTest, MAYBE_SmsReceivedAfterTabIsClosed) {}

IN_PROC_BROWSER_TEST_F(SmsBrowserTest, AbortAfterSmsRetrieval) {}

IN_PROC_BROWSER_TEST_F(SmsBrowserTest, SmsFetcherUAF) {}

IN_PROC_BROWSER_TEST_F(SmsBrowserTest, UpdateRenderFrameHostWithWebOTPUsage) {}

IN_PROC_BROWSER_TEST_F(SmsBrowserTest, RecordBackendNotAvailableAsOutcome) {}

IN_PROC_BROWSER_TEST_F(SmsBrowserTest,
                       NotRecordFailureForMultiplePendingOrigins) {}

// Verifies that the metrics are correctly recorded when an invalid SMS cannot
// be parsed.
IN_PROC_BROWSER_TEST_F(SmsBrowserTest, RecordSmsNotParsedMetrics) {}

// Verifies that a valid SMS can be parsed and no metrics regarding parsing
// failure should be recorded. Note that the metrics about successful parsing
// are tested separately below.
IN_PROC_BROWSER_TEST_F(SmsBrowserTest, SmsParsed) {}

// Verifies that after an SMS is parsed the metrics regarding successful parsing
// are recorded.
IN_PROC_BROWSER_TEST_F(SmsBrowserTest, RecordSmsParsedMetrics) {}

IN_PROC_BROWSER_TEST_F(SmsBrowserTest, TwoUniqueOrigins) {}

IN_PROC_BROWSER_TEST_F(SmsBrowserTest, ThreeUniqueOrigins) {}

IN_PROC_BROWSER_TEST_F(SmsBrowserTest, TwoUniqueOriginsConsecutive) {}

IN_PROC_BROWSER_TEST_F(SmsBrowserTest, TwoUniqueOriginsInconsecutive) {}

IN_PROC_BROWSER_TEST_F(SmsBrowserTest, RecordOutcomeWithCrossOriginFrame) {}

IN_PROC_BROWSER_TEST_F(SmsBrowserTest, RecordOutcomeWithSameOriginFrame) {}

class MockSmsPrerenderingWebContentsDelegate : public WebContentsDelegate {};

class SmsPrerenderingBrowserTest : public SmsBrowserTest {};

IN_PROC_BROWSER_TEST_F(SmsPrerenderingBrowserTest,
                       WebOTPWorksAfterPrerenderActivation) {}

class SmsFencedFrameBrowserTest : public SmsBrowserTest {};

// Tests that FencedFrame doesn't record any Sms metrics.
IN_PROC_BROWSER_TEST_F(SmsFencedFrameBrowserTest,
                       DoNotRecordSmsMetricsOnFencedFrame) {}

}  // namespace content