#include "content/browser/media/capture/aura_window_video_capture_device.h"
#include <tuple>
#include "base/run_loop.h"
#include "base/test/scoped_feature_list.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "cc/test/pixel_test_utils.h"
#include "components/viz/common/features.h"
#include "content/browser/media/capture/content_capture_device_browsertest_base.h"
#include "content/browser/media/capture/fake_video_capture_stack.h"
#include "content/browser/media/capture/frame_test_util.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/desktop_media_id.h"
#include "content/public/browser/web_contents.h"
#include "content/public/test/browser_test.h"
#include "content/shell/browser/shell.h"
#include "media/base/video_util.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/aura/test/aura_test_utils.h"
#include "ui/aura/window.h"
#include "ui/aura/window_tree_host.h"
#include "ui/base/ui_base_features.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/rect_conversions.h"
#include "ui/gfx/geometry/rect_f.h"
namespace content {
namespace {
class AuraWindowVideoCaptureDeviceBrowserTest
: public ContentCaptureDeviceBrowserTestBase,
public FrameTestUtil { … };
IN_PROC_BROWSER_TEST_F(AuraWindowVideoCaptureDeviceBrowserTest,
ErrorsOutIfWindowHasGoneBeforeDeviceStart) { … }
IN_PROC_BROWSER_TEST_F(AuraWindowVideoCaptureDeviceBrowserTest,
DISABLED_ErrorsOutWhenWindowIsDestroyed) { … }
IN_PROC_BROWSER_TEST_F(AuraWindowVideoCaptureDeviceBrowserTest,
DISABLED_SuspendsAndResumes) { … }
IN_PROC_BROWSER_TEST_F(AuraWindowVideoCaptureDeviceBrowserTest,
DISABLED_DeliversRefreshFramesUponRequest) { … }
#if BUILDFLAG(IS_WIN)
class AuraWindowVideoCaptureDeviceBrowserTestWin
: public AuraWindowVideoCaptureDeviceBrowserTest {
public:
void SetUp() override {
scoped_feature_list_.InitAndEnableFeatureWithParameters(
features::kApplyNativeOcclusionToCompositor,
{{features::kApplyNativeOcclusionToCompositorType.name,
features::kApplyNativeOcclusionToCompositorTypeRelease}});
AuraWindowVideoCaptureDeviceBrowserTest::SetUp();
}
private:
base::test::ScopedFeatureList scoped_feature_list_;
};
IN_PROC_BROWSER_TEST_F(AuraWindowVideoCaptureDeviceBrowserTestWin,
DISABLED_CapturesOccludedWindow) {
aura::WindowTreeHost* window_tree_host = shell()->window()->GetHost();
aura::test::DisableNativeWindowOcclusionTracking(window_tree_host);
NavigateToInitialDocument();
AllocateAndStartAndWaitForFirstFrame();
window_tree_host->SetNativeWindowOcclusionState(
aura::Window::OcclusionState::OCCLUDED, {});
static constexpr SkColor kColorsToCycleThrough[] = {
SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE, SK_ColorYELLOW,
SK_ColorCYAN, SK_ColorMAGENTA, SK_ColorWHITE,
};
for (SkColor color : kColorsToCycleThrough) {
ChangePageContentColor(color);
WaitForFrameWithColor(color);
}
StopAndDeAllocate();
}
#endif
#if BUILDFLAG(IS_CHROMEOS_ASH)
IN_PROC_BROWSER_TEST_F(AuraWindowVideoCaptureDeviceBrowserTest,
DISABLED_CapturesOccludedWindows) {
NavigateToInitialDocument();
AllocateAndStartAndWaitForFirstFrame();
ASSERT_EQ(aura::Window::OcclusionState::VISIBLE,
shell()->web_contents()->GetNativeView()->GetOcclusionState());
auto window = std::make_unique<aura::Window>(nullptr);
window->Init(ui::LAYER_TEXTURED);
shell()->window()->GetRootWindow()->AddChild(window.get());
window->SetBounds(shell()->window()->bounds());
window->Show();
EXPECT_EQ(aura::Window::OcclusionState::VISIBLE,
shell()->web_contents()->GetNativeView()->GetOcclusionState());
window.reset();
StopAndDeAllocate();
}
#endif
class AuraWindowVideoCaptureDeviceBrowserTestP
: public AuraWindowVideoCaptureDeviceBrowserTest,
public testing::WithParamInterface<std::tuple<bool, bool>> { … };
#if BUILDFLAG(IS_CHROMEOS_ASH)
INSTANTIATE_TEST_SUITE_P(
All,
AuraWindowVideoCaptureDeviceBrowserTestP,
testing::Combine(
testing::Values(false ),
testing::Values(false ,
true )));
#else
INSTANTIATE_TEST_SUITE_P(…);
#endif
IN_PROC_BROWSER_TEST_P(AuraWindowVideoCaptureDeviceBrowserTestP,
DISABLED_CapturesContentChanges) { … }
}
}