#include "content/browser/media/captured_surface_controller.h"
#include <limits>
#include <list>
#include <memory>
#include "base/functional/bind.h"
#include "base/notreached.h"
#include "base/run_loop.h"
#include "base/test/scoped_feature_list.h"
#include "content/browser/host_zoom_map_impl.h"
#include "content/browser/media/captured_surface_control_permission_manager.h"
#include "content/common/features.h"
#include "content/public/browser/global_routing_id.h"
#include "content/public/test/browser_task_environment.h"
#include "content/test/test_web_contents.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/common/page/page_zoom.h"
#include "third_party/blink/public/mojom/mediastream/media_stream.mojom.h"
#include "url/gurl.h"
namespace content {
namespace {
CapturedWheelAction;
CapturedWheelActionPtr;
CSCResult;
CSCPermissionResult;
const char* const kUrlString = …;
enum class Boundary { … };
CapturedWheelActionPtr MakeCapturedWheelActionPtr() { … }
class InputObserver : public RenderWidgetHost::InputEventObserver { … };
class TestView : public TestRenderWidgetHostView { … };
class TestTab { … };
class MockCapturedSurfaceControlPermissionManager
: public CapturedSurfaceControlPermissionManager { … };
MockPermissionManager;
class MockObserver : public content::WebContentsObserver { … };
base::OnceCallback<void(CSCResult)> MakeCallbackExpectingResult(
base::RunLoop* run_loop,
CSCResult expected_result) { … }
class CapturedSurfaceControllerTestBase : public RenderViewHostTestHarness { … };
class CapturedSurfaceControllerSendWheelTest
: public CapturedSurfaceControllerTestBase { … };
TEST_F(CapturedSurfaceControllerSendWheelTest, CorrectScaling) { … }
TEST_F(CapturedSurfaceControllerSendWheelTest,
GracefullyHandleZeroWidthCapturedSurface) { … }
TEST_F(CapturedSurfaceControllerSendWheelTest,
GracefullyHandleZeroHeightCapturedSurface) { … }
TEST_F(CapturedSurfaceControllerSendWheelTest,
GracefullyHandleExtremelyNarrowCapturedSurface) { … }
TEST_F(CapturedSurfaceControllerSendWheelTest,
GracefullyHandleExtremelyShortCapturedSurface) { … }
class CapturedSurfaceControllerZoomEventTest
: public CapturedSurfaceControllerTestBase { … };
TEST_F(CapturedSurfaceControllerZoomEventTest, ZoomEvent) { … }
TEST_F(CapturedSurfaceControllerZoomEventTest, ZoomEventUpdateTarget) { … }
class CapturedSurfaceControllerSetZoomLevelTest
: public CapturedSurfaceControllerTestBase,
public ::testing::WithParamInterface<int> { … };
INSTANTIATE_TEST_SUITE_P(…);
TEST_P(CapturedSurfaceControllerSetZoomLevelTest, SetZoomLevelSuccess) { … }
class CapturedSurfaceControllerSetZoomTemporarinessTest
: public CapturedSurfaceControllerTestBase,
public ::testing::WithParamInterface<bool> { … };
INSTANTIATE_TEST_SUITE_P(…);
TEST_P(CapturedSurfaceControllerSetZoomTemporarinessTest,
TemporarinessDependsOnConfiguration) { … }
enum class CapturedSurfaceControlAPI { … };
class CapturedSurfaceControllerInterfaceTestBase
: public CapturedSurfaceControllerTestBase { … };
class CapturedSurfaceControllerInterfaceTest
: public CapturedSurfaceControllerInterfaceTestBase,
public ::testing::WithParamInterface<CapturedSurfaceControlAPI> { … };
INSTANTIATE_TEST_SUITE_P(…);
TEST_P(CapturedSurfaceControllerInterfaceTest, SuccessReportedIfPermitted) { … }
TEST_P(CapturedSurfaceControllerInterfaceTest, NoPermissionReportedIfDenied) { … }
TEST_P(CapturedSurfaceControllerInterfaceTest,
UnknownErrorReportedIfPermissionError) { … }
TEST_P(CapturedSurfaceControllerInterfaceTest,
SurfaceNotFoundReportedIfTabClosedBeforePromptResponseHandled) { … }
TEST_P(CapturedSurfaceControllerInterfaceTest,
SurfaceNotFoundReportedIfCaptureTargetUpdatedToNonTabSurface) { … }
TEST_P(CapturedSurfaceControllerInterfaceTest,
CapturerNotFoundErrorReportedIfCapturerClosed) { … }
class CapturedSurfaceControllerWebContentsResolutionTest
: public CapturedSurfaceControllerInterfaceTestBase,
public ::testing::WithParamInterface<CapturedSurfaceControlAPI> { … };
INSTANTIATE_TEST_SUITE_P(…);
TEST_P(CapturedSurfaceControllerWebContentsResolutionTest,
ApiInvocationAfterWebContentsResolutionSucceeds) { … }
TEST_P(CapturedSurfaceControllerWebContentsResolutionTest,
ApiInvocationPriorToWebContentsResolutionFails) { … }
TEST_P(
CapturedSurfaceControllerWebContentsResolutionTest,
ApiInvocationPriorToWebContentsResolutionFailsButSubsequentCallsAreNotBlocked) { … }
TEST_P(CapturedSurfaceControllerWebContentsResolutionTest,
MultiplePendingResolutions) { … }
class CapturedSurfaceControllerWebContentsResolutionOfUpdatesTest
: public CapturedSurfaceControllerInterfaceTestBase,
public ::testing::WithParamInterface<CapturedSurfaceControlAPI> { … };
INSTANTIATE_TEST_SUITE_P(…);
TEST_P(
CapturedSurfaceControllerWebContentsResolutionOfUpdatesTest,
AfterUpdateCaptureTargetApiInvocationAfterToWebContentsResolutionSucceeds) { … }
TEST_P(CapturedSurfaceControllerWebContentsResolutionOfUpdatesTest,
AfterUpdateCaptureTargetApiInvocationPriorToWebContentsResolutionFails) { … }
class CapturedSurfaceControllerSelfCaptureTest
: public CapturedSurfaceControllerInterfaceTestBase,
public ::testing::WithParamInterface<CapturedSurfaceControlAPI> { … };
INSTANTIATE_TEST_SUITE_P(…);
TEST_P(CapturedSurfaceControllerSelfCaptureTest, SelfCaptureDisallowed) { … }
TEST_P(CapturedSurfaceControllerSelfCaptureTest,
UpdateCaptureTargetToOtherTabEnablesCapturedSurfaceControl) { … }
TEST_P(CapturedSurfaceControllerSelfCaptureTest,
UpdateCaptureTargetToCapturingTabDisablesCapturedSurfaceControl) { … }
class CapturedSurfaceControllerSendWheelClampTest
: public CapturedSurfaceControllerSendWheelTest,
public ::testing::WithParamInterface<Boundary> { … };
INSTANTIATE_TEST_SUITE_P(…);
TEST_P(CapturedSurfaceControllerSendWheelClampTest, ClampMinWheelDeltaX) { … }
TEST_P(CapturedSurfaceControllerSendWheelClampTest, ClampMaxWheelDeltaX) { … }
TEST_P(CapturedSurfaceControllerSendWheelClampTest, ClampMinWheelDeltaY) { … }
TEST_P(CapturedSurfaceControllerSendWheelClampTest, ClampMaxWheelDeltaY) { … }
class WebContentsObserverCscNotifiedTest
: public CapturedSurfaceControllerTestBase { … };
TEST_F(WebContentsObserverCscNotifiedTest, NotifiedBySendWheelIfSuccessful) { … }
TEST_F(WebContentsObserverCscNotifiedTest, NotifiedBySetZoomLevelIfSuccessful) { … }
TEST_F(WebContentsObserverCscNotifiedTest,
NotNotifiedBySendWheelIfUnsuccessful) { … }
TEST_F(WebContentsObserverCscNotifiedTest,
NotNotifiedBySetZoomLevelIfUnsuccessful) { … }
}
}