#include <stddef.h>
#include <memory>
#include <utility>
#include "base/command_line.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/json/json_writer.h"
#include "base/memory/raw_ptr.h"
#include "base/strings/string_split.h"
#include "base/strings/stringprintf.h"
#include "base/test/scoped_command_line.h"
#include "base/test/scoped_feature_list.h"
#include "build/build_config.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/extensions/api/webrtc_logging_private/webrtc_logging_private_api.h"
#include "chrome/browser/extensions/extension_apitest.h"
#include "chrome/browser/extensions/extension_tab_util.h"
#include "chrome/browser/media/webrtc/webrtc_event_log_manager.h"
#include "chrome/browser/media/webrtc/webrtc_event_log_manager_common.h"
#include "chrome/browser/media/webrtc/webrtc_log_uploader.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/common/chrome_features.h"
#include "chrome/common/chrome_switches.h"
#include "components/policy/core/browser/browser_policy_connector.h"
#include "components/policy/core/common/mock_configuration_policy_provider.h"
#include "components/policy/policy_constants.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/test_utils.h"
#include "extensions/browser/api_test_utils.h"
#include "extensions/common/extension_builder.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
#include "net/test/embedded_test_server/http_request.h"
#include "net/test/embedded_test_server/http_response.h"
#include "third_party/zlib/google/compression_utils.h"
GzipUncompress;
Extension;
WebrtcLoggingPrivateDiscardFunction;
WebrtcLoggingPrivateSetMetaDataFunction;
WebrtcLoggingPrivateStartAudioDebugRecordingsFunction;
WebrtcLoggingPrivateStartEventLoggingFunction;
WebrtcLoggingPrivateStartFunction;
WebrtcLoggingPrivateStartRtpDumpFunction;
WebrtcLoggingPrivateStopAudioDebugRecordingsFunction;
WebrtcLoggingPrivateStopFunction;
WebrtcLoggingPrivateStopRtpDumpFunction;
WebrtcLoggingPrivateStoreFunction;
WebrtcLoggingPrivateUploadFunction;
WebrtcLoggingPrivateUploadStoredFunction;
kMaxOutputPeriodMs;
kMaxRemoteLogFileSizeBytes;
kStartRemoteLoggingFailureAlreadyLogging;
kStartRemoteLoggingFailureFeatureDisabled;
kStartRemoteLoggingFailureMaxSizeTooLarge;
kStartRemoteLoggingFailureMaxSizeTooSmall;
kStartRemoteLoggingFailureOutputPeriodMsTooLarge;
kStartRemoteLoggingFailureUnknownOrInactivePeerConnection;
kStartRemoteLoggingFailureUnlimitedSizeDisallowed;
kWebRtcEventLogManagerUnlimitedFileSize;
WebRtcEventLogManager;
utils;
namespace {
static const char kTestLoggingSessionIdKey[] = …;
static const char kTestLoggingSessionIdValue[] = …;
static const char kTestLoggingUrl[] = …;
constexpr int kWebAppId = …;
constexpr char kTestUploadUrlPath[] = …;
constexpr char kTestReportId[] = …;
std::string ParamsToString(const base::Value::List& parameters) { … }
void InitializeTestMetaData(base::Value::List& parameters) { … }
class WebrtcLoggingPrivateApiTest : public extensions::ExtensionApiTest { … };
}
IN_PROC_BROWSER_TEST_F(WebrtcLoggingPrivateApiTest, TestStartStopDiscard) { … }
IN_PROC_BROWSER_TEST_F(WebrtcLoggingPrivateApiTest, TestStartStopUpload) { … }
IN_PROC_BROWSER_TEST_F(WebrtcLoggingPrivateApiTest, TestStartStopRtpDump) { … }
IN_PROC_BROWSER_TEST_F(WebrtcLoggingPrivateApiTest, TestStoreWithoutLog) { … }
IN_PROC_BROWSER_TEST_F(WebrtcLoggingPrivateApiTest, TestStartStopStore) { … }
IN_PROC_BROWSER_TEST_F(WebrtcLoggingPrivateApiTest,
TestStartStopStoreAndUpload) { … }
IN_PROC_BROWSER_TEST_F(WebrtcLoggingPrivateApiTest,
TestStartStopStoreAndUploadWithRtp) { … }
IN_PROC_BROWSER_TEST_F(WebrtcLoggingPrivateApiTest,
TestStartStopStoreAndUploadWithMetaData) { … }
IN_PROC_BROWSER_TEST_F(WebrtcLoggingPrivateApiTest,
TestStartStopAudioDebugRecordings) { … }
IN_PROC_BROWSER_TEST_F(WebrtcLoggingPrivateApiTest,
TestStartTimedAudioDebugRecordings) { … }
#if !BUILDFLAG(IS_ANDROID)
class WebrtcLoggingPrivateApiStartEventLoggingTestBase
: public WebrtcLoggingPrivateApiTest { … };
class WebrtcLoggingPrivateApiStartEventLoggingTestFeatureAndPolicyEnabled
: public WebrtcLoggingPrivateApiStartEventLoggingTestBase,
public testing::WithParamInterface<bool> { … };
IN_PROC_BROWSER_TEST_P(
WebrtcLoggingPrivateApiStartEventLoggingTestFeatureAndPolicyEnabled,
StartEventLoggingForKnownPeerConnectionSucceeds) { … }
IN_PROC_BROWSER_TEST_F(
WebrtcLoggingPrivateApiStartEventLoggingTestFeatureAndPolicyEnabled,
StartEventLoggingWithUnlimitedSizeFails) { … }
IN_PROC_BROWSER_TEST_F(
WebrtcLoggingPrivateApiStartEventLoggingTestFeatureAndPolicyEnabled,
StartEventLoggingWithTooSmallMaxSize) { … }
IN_PROC_BROWSER_TEST_F(
WebrtcLoggingPrivateApiStartEventLoggingTestFeatureAndPolicyEnabled,
StartEventLoggingWithExcessiveMaxSizeFails) { … }
IN_PROC_BROWSER_TEST_F(
WebrtcLoggingPrivateApiStartEventLoggingTestFeatureAndPolicyEnabled,
StartEventLoggingWithTooLargeOutputPeriodMsFails) { … }
IN_PROC_BROWSER_TEST_F(
WebrtcLoggingPrivateApiStartEventLoggingTestFeatureAndPolicyEnabled,
StartEventLoggingForNeverAddedPeerConnectionFails) { … }
IN_PROC_BROWSER_TEST_F(
WebrtcLoggingPrivateApiStartEventLoggingTestFeatureAndPolicyEnabled,
StartEventLoggingForWrongSessionIdFails) { … }
IN_PROC_BROWSER_TEST_F(
WebrtcLoggingPrivateApiStartEventLoggingTestFeatureAndPolicyEnabled,
StartEventLoggingIfSessionIdNeverSetFails) { … }
IN_PROC_BROWSER_TEST_F(
WebrtcLoggingPrivateApiStartEventLoggingTestFeatureAndPolicyEnabled,
StartEventLoggingIfSessionIdNeverSetFailsForEmptySessionId) { … }
IN_PROC_BROWSER_TEST_F(
WebrtcLoggingPrivateApiStartEventLoggingTestFeatureAndPolicyEnabled,
StartEventLogginWithEmptySessionIdFails) { … }
IN_PROC_BROWSER_TEST_F(
WebrtcLoggingPrivateApiStartEventLoggingTestFeatureAndPolicyEnabled,
StartEventLoggingForAlreadyLoggedPeerConnectionFails) { … }
IN_PROC_BROWSER_TEST_F(
WebrtcLoggingPrivateApiStartEventLoggingTestFeatureAndPolicyEnabled,
StartEventLoggingForTooLowWebAppIdFails) { … }
IN_PROC_BROWSER_TEST_F(
WebrtcLoggingPrivateApiStartEventLoggingTestFeatureAndPolicyEnabled,
StartEventLoggingForTooHighWebAppIdFails) { … }
INSTANTIATE_TEST_SUITE_P(…);
class WebrtcLoggingPrivateApiStartEventLoggingTestFeatureOrPolicyDisabled
: public WebrtcLoggingPrivateApiStartEventLoggingTestBase,
public ::testing::WithParamInterface<bool> { … };
IN_PROC_BROWSER_TEST_P(
WebrtcLoggingPrivateApiStartEventLoggingTestFeatureOrPolicyDisabled,
StartEventLoggingFails) { … }
INSTANTIATE_TEST_SUITE_P(…);
class WebrtcLoggingPrivateApiStartEventLoggingTestInIncognitoMode
: public WebrtcLoggingPrivateApiStartEventLoggingTestBase { … };
IN_PROC_BROWSER_TEST_F(
WebrtcLoggingPrivateApiStartEventLoggingTestInIncognitoMode,
StartEventLoggingFails) { … }
#endif