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

// Copyright 2024 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/run_loop.h"
#include "base/test/run_until.h"
#include "build/build_config.h"
#include "chrome/browser/content_settings/host_content_settings_map_factory.h"
#include "chrome/browser/media/webrtc/desktop_media_picker_manager.h"
#include "chrome/browser/media/webrtc/display_media_access_handler.h"
#include "chrome/browser/media/webrtc/webrtc_browsertest_base.h"
#include "chrome/browser/picture_in_picture/picture_in_picture_window_manager.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/browser/ui/views/frame/browser_frame.h"
#include "chrome/browser/ui/views/frame/browser_view.h"
#include "chrome/test/base/ui_test_utils.h"
#include "chrome/test/interaction/interactive_browser_test.h"
#include "components/content_settings/core/browser/host_content_settings_map.h"
#include "content/public/browser/render_widget_host.h"
#include "content/public/browser/render_widget_host_view.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/browser_test_utils.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace {

// Wait for a NativeWindow to receive window focus.
bool FocusWidgetAndWait(content::WebContents* contents) {}

}  // namespace

class DisplayMediaAccessHandlerInteractiveUITest
    : public WebRtcTestBase,
      public testing::WithParamInterface<
          std::tuple</*focus_opener=*/bool, /*request_from_opener=*/bool>>,
      public DesktopMediaPickerManager::DialogObserver {};

// Verify that the picker shows up in the correct window when document picture
// in picture is involved, based on whether `getDisplayMedia()` is called from
// the opener's navigator or pip's navigator, and which window has the focus.
IN_PROC_BROWSER_TEST_P(DisplayMediaAccessHandlerInteractiveUITest,
                       PickerUiSelectsCorrectWindow) {}

INSTANTIATE_TEST_SUITE_P();