chromium/chrome/browser/extensions/api/desktop_capture/desktop_capture_apitest.cc

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

#include <array>

#include "base/command_line.h"
#include "base/path_service.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/extensions/api/desktop_capture/desktop_capture_api.h"
#include "chrome/browser/extensions/extension_apitest.h"
#include "chrome/browser/media/webrtc/fake_desktop_media_picker_factory.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/test/base/ui_test_utils.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/browser_test_utils.h"
#include "extensions/common/switches.h"
#include "extensions/test/test_extension_dir.h"
#include "net/dns/mock_host_resolver.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
#include "third_party/webrtc/modules/desktop_capture/desktop_capture_types.h"
#include "ui/base/ozone_buildflags.h"

namespace extensions {

namespace {

DesktopMediaID;
WebContentsMediaCaptureId;
Combine;
Values;

class DesktopCaptureApiTest : public ExtensionApiTest {};

}  // namespace

// TODO(crbug.com/40805699): Crashes on Lacros.
// TODO(crbug.com/40805704): Fails on the linux-wayland-rel bot.
// TODO(crbug.com/40805725): Fails on Mac.
#if BUILDFLAG(IS_MAC) || BUILDFLAG(IS_OZONE_WAYLAND) || \
    BUILDFLAG(IS_CHROMEOS_LACROS)
#define MAYBE_ChooseDesktopMedia
#else
#define MAYBE_ChooseDesktopMedia
#endif
IN_PROC_BROWSER_TEST_F(DesktopCaptureApiTest, MAYBE_ChooseDesktopMedia) {}

// TODO(crbug.com/40805699): Crashes on Lacros.
// TODO(crbug.com/40805704): Fails on the linux-wayland-rel bot.
// TODO(crbug.com/40805725): Fails on Mac.
#if BUILDFLAG(IS_MAC) || BUILDFLAG(IS_OZONE_WAYLAND) || \
    BUILDFLAG(IS_CHROMEOS_LACROS)
#define MAYBE_Delegation
#else
#define MAYBE_Delegation
#endif
IN_PROC_BROWSER_TEST_F(DesktopCaptureApiTest, MAYBE_Delegation) {}

// Not specifying a tab defaults to the extension's background page.
// Service worker-based extensions don't have one, so they must specify
// a tab. This is a regression test for crbug.com/1271590.
IN_PROC_BROWSER_TEST_F(DesktopCaptureApiTest, ServiceWorkerMustSpecifyTab) {}

class DesktopCaptureApiMediaPickerOptionsBaseTest
    : public DesktopCaptureApiTest {};

void DesktopCaptureApiMediaPickerOptionsBaseTest::FromServiceWorker(
    const std::string& options) {}

class DesktopCaptureApiMediaPickerWithOptionsTest
    : public DesktopCaptureApiMediaPickerOptionsBaseTest,
      public testing::WithParamInterface<
          std::tuple<std::string, std::string, std::string>> {};

INSTANTIATE_TEST_SUITE_P();

IN_PROC_BROWSER_TEST_P(DesktopCaptureApiMediaPickerWithOptionsTest,
                       FromServiceWorker) {}

class DesktopCaptureApiMediaPickerWithoutOptionsTest
    : public DesktopCaptureApiMediaPickerOptionsBaseTest {};

IN_PROC_BROWSER_TEST_F(DesktopCaptureApiMediaPickerWithoutOptionsTest,
                       FromServiceWorker) {}

}  // namespace extensions