From a8b260832830e11ab32cd2d4044f507434aee0ad Mon Sep 17 00:00:00 2001 From: Stuart Morgan Date: Tue, 13 Sep 2022 10:42:02 -0400 Subject: [PATCH 1/3] Update mocks for wrapper changes --- .../windows/test/capture_controller_test.cpp | 4 ++-- .../camera_windows/windows/test/mocks.h | 22 +++++++++++++++++-- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/packages/camera/camera_windows/windows/test/capture_controller_test.cpp b/packages/camera/camera_windows/windows/test/capture_controller_test.cpp index 4662d3340456..8d6632cbc3f0 100644 --- a/packages/camera/camera_windows/windows/test/capture_controller_test.cpp +++ b/packages/camera/camera_windows/windows/test/capture_controller_test.cpp @@ -291,7 +291,7 @@ TEST(CaptureController, InitCaptureEngineReportsFailure) { EXPECT_CALL(*engine.Get(), Initialize).Times(1).WillOnce(Return(E_FAIL)); EXPECT_CALL(*texture_registrar, RegisterTexture).Times(0); - EXPECT_CALL(*texture_registrar, UnregisterTexture).Times(0); + EXPECT_CALL(*texture_registrar, UnregisterTexture(_)).Times(0); EXPECT_CALL(*camera, OnCreateCaptureEngineSucceeded).Times(0); EXPECT_CALL(*camera, OnCreateCaptureEngineFailed(Eq(CameraResult::kError), @@ -335,7 +335,7 @@ TEST(CaptureController, InitCaptureEngineReportsAccessDenied) { .WillOnce(Return(E_ACCESSDENIED)); EXPECT_CALL(*texture_registrar, RegisterTexture).Times(0); - EXPECT_CALL(*texture_registrar, UnregisterTexture).Times(0); + EXPECT_CALL(*texture_registrar, UnregisterTexture(_)).Times(0); EXPECT_CALL(*camera, OnCreateCaptureEngineSucceeded).Times(0); EXPECT_CALL(*camera, OnCreateCaptureEngineFailed(Eq(CameraResult::kAccessDenied), diff --git a/packages/camera/camera_windows/windows/test/mocks.h b/packages/camera/camera_windows/windows/test/mocks.h index 678b75899bc2..516a50bfd6eb 100644 --- a/packages/camera/camera_windows/windows/test/mocks.h +++ b/packages/camera/camera_windows/windows/test/mocks.h @@ -67,8 +67,9 @@ class MockTextureRegistrar : public flutter::TextureRegistrar { return this->texture_id_; }); - ON_CALL(*this, UnregisterTexture) - .WillByDefault([this](int64_t tid) -> bool { + // Deprecated pre-Flutter-3.4 version. + ON_CALL(*this, UnregisterTexture(_)) + .WillByDefault([this](int64_t tid)->bool { if (tid == this->texture_id_) { texture_ = nullptr; this->texture_id_ = -1; @@ -77,6 +78,17 @@ class MockTextureRegistrar : public flutter::TextureRegistrar { return false; }); + // Flutter 3.4+ version. + ON_CALL(*this, UnregisterTexture(_,_)) + .WillByDefault([this](int64_t tid, std::function callback) -> void { + // Forward to the pre-3.4 implementation so that expectations can + // be the same for all versions. + this->UnregisterTexture(tid); + if (callback) { + callback(); + } + }); + ON_CALL(*this, MarkTextureFrameAvailable) .WillByDefault([this](int64_t tid) -> bool { if (tid == this->texture_id_) { @@ -91,7 +103,13 @@ class MockTextureRegistrar : public flutter::TextureRegistrar { MOCK_METHOD(int64_t, RegisterTexture, (flutter::TextureVariant * texture), (override)); + // Pre-Flutter-3.4 version. MOCK_METHOD(bool, UnregisterTexture, (int64_t), (override)); + // Flutter 3.4+ version. + // TODO(cbracken): Add an override annotation to this once 3.4+ is the + // minimum version tested in CI. + MOCK_METHOD(void, UnregisterTexture, + (int64_t, std::function callback),()); MOCK_METHOD(bool, MarkTextureFrameAvailable, (int64_t), (override)); int64_t texture_id_ = -1; From e9a4b1a9e626c515ca9ee3f9028ea7c371eacafb Mon Sep 17 00:00:00 2001 From: Stuart Morgan Date: Tue, 13 Sep 2022 10:43:49 -0400 Subject: [PATCH 2/3] Include roll --- .ci/flutter_master.version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ci/flutter_master.version b/.ci/flutter_master.version index af8df44327ff..74c1c9a9cd2b 100644 --- a/.ci/flutter_master.version +++ b/.ci/flutter_master.version @@ -1 +1 @@ -4cd734ae3a1cc0c8f132ba07e6d2e0a3253c53e7 +4930444f4afe85272bbdc84b43196d59dad71166 From fc7b932943b7ceefa0db6e2de76f89376e4a84e8 Mon Sep 17 00:00:00 2001 From: Stuart Morgan Date: Tue, 13 Sep 2022 10:51:46 -0400 Subject: [PATCH 3/3] autoformat --- .../camera/camera_windows/windows/test/mocks.h | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/packages/camera/camera_windows/windows/test/mocks.h b/packages/camera/camera_windows/windows/test/mocks.h index 516a50bfd6eb..b6416eb7c710 100644 --- a/packages/camera/camera_windows/windows/test/mocks.h +++ b/packages/camera/camera_windows/windows/test/mocks.h @@ -69,7 +69,7 @@ class MockTextureRegistrar : public flutter::TextureRegistrar { // Deprecated pre-Flutter-3.4 version. ON_CALL(*this, UnregisterTexture(_)) - .WillByDefault([this](int64_t tid)->bool { + .WillByDefault([this](int64_t tid) -> bool { if (tid == this->texture_id_) { texture_ = nullptr; this->texture_id_ = -1; @@ -79,15 +79,16 @@ class MockTextureRegistrar : public flutter::TextureRegistrar { }); // Flutter 3.4+ version. - ON_CALL(*this, UnregisterTexture(_,_)) - .WillByDefault([this](int64_t tid, std::function callback) -> void { - // Forward to the pre-3.4 implementation so that expectations can - // be the same for all versions. - this->UnregisterTexture(tid); + ON_CALL(*this, UnregisterTexture(_, _)) + .WillByDefault( + [this](int64_t tid, std::function callback) -> void { + // Forward to the pre-3.4 implementation so that expectations can + // be the same for all versions. + this->UnregisterTexture(tid); if (callback) { callback(); } - }); + }); ON_CALL(*this, MarkTextureFrameAvailable) .WillByDefault([this](int64_t tid) -> bool { @@ -109,7 +110,7 @@ class MockTextureRegistrar : public flutter::TextureRegistrar { // TODO(cbracken): Add an override annotation to this once 3.4+ is the // minimum version tested in CI. MOCK_METHOD(void, UnregisterTexture, - (int64_t, std::function callback),()); + (int64_t, std::function callback), ()); MOCK_METHOD(bool, MarkTextureFrameAvailable, (int64_t), (override)); int64_t texture_id_ = -1;