chromium/chrome/browser/media/webrtc/webrtc_mediadevices_interactive_uitest.cc

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

#include "base/command_line.h"
#include "base/containers/contains.h"
#include "base/json/json_reader.h"
#include "base/strings/string_util.h"
#include "base/test/bind.h"
#include "base/test/gmock_expected_support.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/test_future.h"
#include "build/build_config.h"
#include "chrome/browser/content_settings/cookie_settings_factory.h"
#include "chrome/browser/media/webrtc/media_device_salt_service_factory.h"
#include "chrome/browser/media/webrtc/webrtc_browsertest_base.h"
#include "chrome/browser/media/webrtc/webrtc_browsertest_common.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_tabstrip.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
#include "components/content_settings/core/browser/cookie_settings.h"
#include "components/content_settings/core/common/content_settings.h"
#include "components/media_device_salt/media_device_salt_service.h"
#include "components/permissions/permission_request_manager.h"
#include "components/permissions/test/permission_request_observer.h"
#include "components/prefs/pref_service.h"
#include "components/privacy_sandbox/tracking_protection_prefs.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browsing_data_remover.h"
#include "content/public/common/content_features.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/browsing_data_remover_test_util.h"
#include "content/public/test/prerender_test_util.h"
#include "media/audio/audio_device_description.h"
#include "media/audio/audio_manager.h"
#include "media/base/media_switches.h"
#include "net/test/embedded_test_server/embedded_test_server.h"

#if BUILDFLAG(IS_MAC)
#include <CoreGraphics/CoreGraphics.h>
#endif

namespace {

const char kMainWebrtcTestHtmlPage[] =;
const char kClearCookiesPage[] =;

const char kDeviceKindAudioInput[] =;
const char kDeviceKindVideoInput[] =;
const char kDeviceKindAudioOutput[] =;

}  // namespace

// Integration test for WebRTC enumerateDevices. It always uses fake devices.
// It needs to be a browser test (and not content browser test) to be able to
// test that labels are cleared or not depending on if access to devices has
// been granted.
class WebRtcMediaDevicesInteractiveUITest
    : public WebRtcTestBase,
      public testing::WithParamInterface<bool> {};

IN_PROC_BROWSER_TEST_P(WebRtcMediaDevicesInteractiveUITest,
                       EnumerateDevicesWithoutAccess) {}

IN_PROC_BROWSER_TEST_P(WebRtcMediaDevicesInteractiveUITest,
                       EnumerateDevicesWithAccess) {}

IN_PROC_BROWSER_TEST_P(WebRtcMediaDevicesInteractiveUITest,
                       GetUserMediaOnUnFocusedTab) {}

// Flakes on Linux TSan Tests; crbug.com/1396123.
#if BUILDFLAG(IS_LINUX) && defined(THREAD_SANITIZER)
#define MAYBE_GetUserMediaTabRegainsFocus
#else
#define MAYBE_GetUserMediaTabRegainsFocus
#endif
IN_PROC_BROWSER_TEST_P(WebRtcMediaDevicesInteractiveUITest,
                       MAYBE_GetUserMediaTabRegainsFocus) {}

IN_PROC_BROWSER_TEST_P(WebRtcMediaDevicesInteractiveUITest,
                       DeviceIdSameGroupIdDiffersAcrossTabs) {}

IN_PROC_BROWSER_TEST_P(WebRtcMediaDevicesInteractiveUITest,
                       DeviceIdDiffersAfterClearingCookies) {}

IN_PROC_BROWSER_TEST_P(WebRtcMediaDevicesInteractiveUITest,
                       DeviceIdDiffersAcrossTabsWithCookiesDisabled) {}

IN_PROC_BROWSER_TEST_P(WebRtcMediaDevicesInteractiveUITest,
                       DeviceIdDiffersSameTabAfterReloadWithCookiesDisabled) {}

IN_PROC_BROWSER_TEST_P(WebRtcMediaDevicesInteractiveUITest,
                       DeviceIdDiffersAfterClearSiteDataHeader) {}

IN_PROC_BROWSER_TEST_P(WebRtcMediaDevicesInteractiveUITest,
                       PRE_SaltsDeletedForSessionOnlyCookies) {}

IN_PROC_BROWSER_TEST_P(WebRtcMediaDevicesInteractiveUITest,
                       SaltsDeletedForSessionOnlyCookies) {}

IN_PROC_BROWSER_TEST_P(WebRtcMediaDevicesInteractiveUITest,
                       NoPersistentSaltStoredWithCookiesDisabled) {}

INSTANTIATE_TEST_SUITE_P();

class WebRtcMediaDevicesPrerenderingBrowserTest
    : public WebRtcMediaDevicesInteractiveUITest {};

IN_PROC_BROWSER_TEST_P(WebRtcMediaDevicesPrerenderingBrowserTest,
                       EnumerateDevicesInPrerendering) {}

INSTANTIATE_TEST_SUITE_P();