From 058be5c29730ef6276f3c00dbde75e2464c29f3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Calvi=C3=B1o=20S=C3=A1nchez?= Date: Sat, 11 Feb 2023 05:11:53 +0100 Subject: Add "starting" values for recording status MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As starting the recording can take some time "starting" values were added to signal that an audio or video recording is starting. The status will be changed from NONE to STARTING_VIDEO/AUDIO by the Nextcloud server when the request to start the recording succeeds, and then the recording status will be set to VIDEO or AUDIO by the recording server once the recording actually started. Stopping the recording, on the other hand, should be quite fast, so no STOPPING status were added. The system messages were also adjusted to be sent only once the recording really started or stopped. Signed-off-by: Daniel Calviño Sánchez --- .../integration/features/callapi/recording.feature | 12 +-- tests/php/Chat/SystemMessage/ListenerTest.php | 117 ++++++++++++++++++--- 2 files changed, 105 insertions(+), 24 deletions(-) (limited to 'tests') diff --git a/tests/integration/features/callapi/recording.feature b/tests/integration/features/callapi/recording.feature index eff03accd..0755a7129 100644 --- a/tests/integration/features/callapi/recording.feature +++ b/tests/integration/features/callapi/recording.feature @@ -18,7 +18,7 @@ Feature: callapi/recording | room1 | {"type":"start","start":{"status":1,"owner":"participant1","actor":{"type":"users","id":"participant1"}}} | And user "participant1" is participant of the following unordered rooms (v4) | type | name | callRecording | - | 2 | room1 | 0 | + | 2 | room1 | 3 | And recording server sent started request for "video" recording in room "room1" as "participant1" with 200 Then user "participant1" sees the following system messages in room "room1" with 200 (v1) | room | actorType | actorId | actorDisplayName | systemMessage | @@ -61,7 +61,7 @@ Feature: callapi/recording | room1 | {"type":"start","start":{"status":2,"owner":"participant1","actor":{"type":"users","id":"participant1"}}} | And user "participant1" is participant of the following unordered rooms (v4) | type | name | callRecording | - | 2 | room1 | 0 | + | 2 | room1 | 4 | And recording server sent started request for "audio" recording in room "room1" as "participant1" with 200 Then user "participant1" sees the following system messages in room "room1" with 200 (v1) | room | actorType | actorId | actorDisplayName | systemMessage | @@ -99,10 +99,6 @@ Feature: callapi/recording And user "participant1" joins room "room1" with 200 (v4) And user "participant1" joins call "room1" with 200 (v4) When user "participant1" starts "audio" recording in room "room1" with 200 (v1) - And recording server received the following requests - | token | data | - | room1 | {"type":"start","start":{"status":2,"owner":"participant1","actor":{"type":"users","id":"participant1"}}} | - And user "participant1" starts "audio" recording in room "room1" with 200 (v1) And recording server received the following requests | token | data | | room1 | {"type":"start","start":{"status":2,"owner":"participant1","actor":{"type":"users","id":"participant1"}}} | @@ -128,10 +124,6 @@ Feature: callapi/recording | type | name | callRecording | | 2 | room1 | 0 | When user "participant1" starts "video" recording in room "room1" with 200 (v1) - And recording server received the following requests - | token | data | - | room1 | {"type":"start","start":{"status":1,"owner":"participant1","actor":{"type":"users","id":"participant1"}}} | - And user "participant1" starts "video" recording in room "room1" with 200 (v1) And recording server received the following requests | token | data | | room1 | {"type":"start","start":{"status":1,"owner":"participant1","actor":{"type":"users","id":"participant1"}}} | diff --git a/tests/php/Chat/SystemMessage/ListenerTest.php b/tests/php/Chat/SystemMessage/ListenerTest.php index 3e073a244..91dd198ae 100644 --- a/tests/php/Chat/SystemMessage/ListenerTest.php +++ b/tests/php/Chat/SystemMessage/ListenerTest.php @@ -321,6 +321,34 @@ class ListenerTest extends TestCase { public function callRecordingChangeProvider() { return [ + [ + Room::RECORDING_VIDEO_STARTING, + Room::RECORDING_NONE, + null, + null, + null, + ], + [ + Room::RECORDING_VIDEO_STARTING, + Room::RECORDING_NONE, + Attendee::ACTOR_USERS, + 'alice', + null, + ], + [ + Room::RECORDING_VIDEO, + Room::RECORDING_VIDEO_STARTING, + null, + null, + ['message' => 'recording_started', 'parameters' => []], + ], + [ + Room::RECORDING_VIDEO, + Room::RECORDING_VIDEO_STARTING, + Attendee::ACTOR_USERS, + 'alice', + ['message' => 'recording_started', 'parameters' => []], + ], [ Room::RECORDING_VIDEO, Room::RECORDING_NONE, @@ -335,6 +363,34 @@ class ListenerTest extends TestCase { 'alice', ['message' => 'recording_started', 'parameters' => []], ], + [ + Room::RECORDING_AUDIO_STARTING, + Room::RECORDING_NONE, + null, + null, + null, + ], + [ + Room::RECORDING_AUDIO_STARTING, + Room::RECORDING_NONE, + Attendee::ACTOR_USERS, + 'alice', + null, + ], + [ + Room::RECORDING_AUDIO, + Room::RECORDING_AUDIO_STARTING, + null, + null, + ['message' => 'audio_recording_started', 'parameters' => []], + ], + [ + Room::RECORDING_AUDIO, + Room::RECORDING_AUDIO_STARTING, + Attendee::ACTOR_USERS, + 'alice', + ['message' => 'audio_recording_started', 'parameters' => []], + ], [ Room::RECORDING_AUDIO, Room::RECORDING_NONE, @@ -349,6 +405,20 @@ class ListenerTest extends TestCase { 'alice', ['message' => 'audio_recording_started', 'parameters' => []], ], + [ + Room::RECORDING_NONE, + Room::RECORDING_VIDEO_STARTING, + null, + null, + null, + ], + [ + Room::RECORDING_NONE, + Room::RECORDING_VIDEO_STARTING, + Attendee::ACTOR_USERS, + 'bob', + null, + ], [ Room::RECORDING_NONE, Room::RECORDING_VIDEO, @@ -363,6 +433,20 @@ class ListenerTest extends TestCase { 'bob', ['message' => 'recording_stopped', 'parameters' => []], ], + [ + Room::RECORDING_NONE, + Room::RECORDING_AUDIO_STARTING, + null, + null, + null, + ], + [ + Room::RECORDING_NONE, + Room::RECORDING_AUDIO_STARTING, + Attendee::ACTOR_USERS, + 'bob', + null, + ], [ Room::RECORDING_NONE, Room::RECORDING_AUDIO, @@ -389,7 +473,7 @@ class ListenerTest extends TestCase { * @param string|null $actorId * @param array $expectedMessage */ - public function testAfterCallRecordingSet(int $newStatus, int $oldStatus, ?string $actorType, ?string $actorId, array $expectedMessage): void { + public function testAfterCallRecordingSet(int $newStatus, int $oldStatus, ?string $actorType, ?string $actorId, ?array $expectedMessage): void { $this->mockLoggedInUser('logged_in_user'); $room = $this->createMock(Room::class); @@ -416,19 +500,24 @@ class ListenerTest extends TestCase { $event = new ModifyRoomEvent($room, 'callRecording', $newStatus, $oldStatus, $participant); - $this->chatManager->expects($this->once()) - ->method('addSystemMessage') - ->with( - $room, - $expectedActorType, - $expectedActorId, - json_encode($expectedMessage), - $this->dummyTime, - false, - SELF::DUMMY_REFERENCE_ID, - null, - false - ); + if ($expectedMessage !== null) { + $this->chatManager->expects($this->once()) + ->method('addSystemMessage') + ->with( + $room, + $expectedActorType, + $expectedActorId, + json_encode($expectedMessage), + $this->dummyTime, + false, + SELF::DUMMY_REFERENCE_ID, + null, + false + ); + } else { + $this->chatManager->expects($this->never()) + ->method('addSystemMessage'); + } $this->dispatch(Room::EVENT_AFTER_SET_CALL_RECORDING, $event); } -- cgit v1.2.3