#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "third_party/blink/renderer/modules/imagecapture/image_capture.h"
#include "base/time/time.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/web/web_heap.h"
#include "third_party/blink/renderer/bindings/core/v8/script_function.h"
#include "third_party/blink/renderer/bindings/core/v8/script_promise_resolver.h"
#include "third_party/blink/renderer/bindings/core/v8/script_promise_tester.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_binding_for_testing.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_union_string_stringsequence.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_constrain_boolean_parameters.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_constrain_dom_string_parameters.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_constrain_double_range.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_constrain_point_2d_parameters.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_media_settings_range.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_point_2d.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_union_boolean_constrainbooleanparameters.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_union_boolean_constraindoublerange_double.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_union_constraindomstringparameters_string_stringsequence.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_union_constraindoublerange_double.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_union_constrainpoint2dparameters_point2dsequence.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/page/page.h"
#include "third_party/blink/renderer/modules/imagecapture/image_capture.h"
#include "third_party/blink/renderer/modules/mediastream/media_stream_video_capturer_source.h"
#include "third_party/blink/renderer/modules/mediastream/media_stream_video_track.h"
#include "third_party/blink/renderer/modules/mediastream/mock_media_stream_track.h"
#include "third_party/blink/renderer/modules/mediastream/mock_video_capturer_source.h"
#include "third_party/blink/renderer/platform/bindings/script_state.h"
#include "third_party/blink/renderer/platform/testing/io_task_runner_testing_platform_support.h"
#include "third_party/blink/renderer/platform/testing/task_environment.h"
namespace blink {
namespace {
ExpectHasExposureModeAndFocusMode;
ExpectHasPanTiltZoom;
PopulatePanTiltZoom;
_;
Invoke;
NiceMock;
Return;
constexpr double kExposureCompensationDelta = …;
constexpr double kExposureTimeDelta = …;
constexpr double kColorTemperatureDelta = …;
constexpr double kIsoDelta = …;
constexpr double kBrightnessDelta = …;
constexpr double kContrastDelta = …;
constexpr double kSaturationDelta = …;
constexpr double kSharpnessDelta = …;
constexpr double kFocusDistanceDelta = …;
constexpr double kPanDelta = …;
constexpr double kTiltDelta = …;
constexpr double kZoomDelta = …;
class CaptureErrorFunction final : public ScriptFunction::Callable { … };
template <typename T>
struct ConstrainWithDictionaryTraits;
template <>
struct ConstrainWithDictionaryTraits<bool> { … };
template <>
struct ConstrainWithDictionaryTraits<double> { … };
template <>
struct ConstrainWithDictionaryTraits<HeapVector<Member<Point2D>>> { … };
template <>
struct ConstrainWithDictionaryTraits<String> { … };
template <>
struct ConstrainWithDictionaryTraits<Vector<String>> { … };
ConstrainWithDictionaryType;
V8UnionStringOrStringSequence* CreateDictionaryMemberValue(
const String& value) { … }
V8UnionStringOrStringSequence* CreateDictionaryMemberValue(
const Vector<String>& value) { … }
template <typename T>
const T& CreateDictionaryMemberValue(const T& value) { … }
struct ConstrainWithBareValueCreator { … };
struct ConstrainWithEmptyDictionaryCreator { … };
struct ConstrainWithExactDictionaryCreator { … };
struct ConstrainWithIdealDictionaryCreator { … };
struct ConstrainWithMaxDictionaryCreator { … };
struct ConstrainWithMaxOrEmptyDictionaryCreator { … };
struct ConstrainWithMinDictionaryCreator { … };
struct ConstrainWithMinOrEmptyDictionaryCreator { … };
MediaSettingsRange* CreateMediaSettingsRange(double min,
double max,
double step) { … }
MediaSettingsRange* CreateMediaSettingsRange(const char (&str)[3]) { … }
Point2D* CreatePoint2D(double x, double y) { … }
double RangeMean(const MediaSettingsRange* range) { … }
void CheckExactValues(
const media::mojom::blink::PhotoSettingsPtr& settings,
const MediaTrackCapabilities* all_capabilities,
ExpectHasPanTiltZoom expect_has_pan_tilt_zoom = ExpectHasPanTiltZoom(true),
ExpectHasExposureModeAndFocusMode expect_has_exposure_mode_and_focus_mode =
ExpectHasExposureModeAndFocusMode(true)) { … }
void CheckMaxValues(const media::mojom::blink::PhotoSettingsPtr& settings,
const MediaTrackCapabilities* all_capabilities,
const MediaTrackSettings* default_settings,
ExpectHasPanTiltZoom expect_has_pan_tilt_zoom =
ExpectHasPanTiltZoom(true)) { … }
void CheckMinValues(const media::mojom::blink::PhotoSettingsPtr& settings,
const MediaTrackCapabilities* all_capabilities,
const MediaTrackSettings* default_settings,
ExpectHasPanTiltZoom expect_has_pan_tilt_zoom =
ExpectHasPanTiltZoom(true)) { … }
void CheckNoValues(const media::mojom::blink::PhotoSettingsPtr& settings,
size_t expected_points_of_interest_size = 0u) { … }
template <typename ConstraintCreator>
void PopulateConstraintSet(
MediaTrackConstraintSet* constraint_set,
const MediaTrackCapabilities* all_capabilities,
PopulatePanTiltZoom populate_pan_tilt_zoom = PopulatePanTiltZoom(true)) { … }
class MockMediaStreamComponent
: public GarbageCollected<MockMediaStreamComponent>,
public MediaStreamComponent { … };
}
class ImageCaptureTest : public testing::Test { … };
class ImageCaptureConstraintTest : public ImageCaptureTest { … };
TEST_F(ImageCaptureConstraintTest, ApplyBasicBareValueConstraints) { … }
TEST_F(ImageCaptureConstraintTest, ApplyBasicExactConstraints) { … }
TEST_F(ImageCaptureConstraintTest, ApplyBasicIdealConstraints) { … }
TEST_F(ImageCaptureConstraintTest, ApplyBasicMaxConstraints) { … }
TEST_F(ImageCaptureConstraintTest, ApplyBasicMinConstraints) { … }
TEST_F(ImageCaptureConstraintTest, ApplyBasicNoConstraints) { … }
TEST_F(ImageCaptureConstraintTest, ApplyBasicOverconstrainedConstraints) { … }
TEST_F(ImageCaptureConstraintTest, ApplyFirstAdvancedBareValueConstraints) { … }
TEST_F(ImageCaptureConstraintTest, ApplyFirstAdvancedExactConstraints) { … }
TEST_F(ImageCaptureConstraintTest, ApplyFirstAdvancedIdealConstraints) { … }
TEST_F(ImageCaptureConstraintTest,
ApplyFirstAdvancedOverconstrainedConstraints) { … }
TEST_F(ImageCaptureConstraintTest, ApplyAdvancedBareValueConstraints) { … }
TEST_F(ImageCaptureConstraintTest, ApplyAdvancedExactConstraints) { … }
TEST_F(ImageCaptureConstraintTest, ApplyAdvancedIdealConstraints) { … }
TEST_F(ImageCaptureConstraintTest, ApplyAdvancedNoConstraints) { … }
TEST_F(ImageCaptureConstraintTest, ApplyAdvancedOverconstrainedConstraints) { … }
TEST_F(ImageCaptureConstraintTest, ApplySecurityErrorConstraints) { … }
TEST_F(ImageCaptureTest, GrabFrameOfLiveTrackIsFulfilled) { … }
TEST_F(ImageCaptureTest, GrabFrameOfMutedTrackIsFulfilled) { … }
TEST_F(ImageCaptureTest, GrabFrameOfMutedTrackWithoutFramesIsRejected) { … }
TEST_F(ImageCaptureTest, GrabFrameOfEndedTrackRejects) { … }
TEST_F(ImageCaptureTest, GrabFrameOfDisabledTrackRejects) { … }
}