This repository was archived by the owner on Sep 11, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 815
Advanced audio processing settings #8759
Merged
SimonBrandner
merged 13 commits into
matrix-org:develop
from
MrAnno:audio-processing-settings
Nov 9, 2022
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
6def45b
settings: reorganize VoiseUserSettingsTab
MrAnno 538ad86
Add advanced audio settings
MrAnno 080b91d
settings: use composition for VoiceUserSettingsTab's state
MrAnno aee4449
settings: add secondary line descriptions for p2p calls and fallbackICE
MrAnno 328c2f3
settings: UX refactor of advanced audio processing options
MrAnno c453176
Merge branch 'develop' into audio-processing-settings
MrAnno bc4f2b9
Merge branch 'develop' into audio-processing-settings
MrAnno d2bb279
Merge branch 'develop' into audio-processing-settings
MrAnno f6fb733
Merge branch 'develop' into audio-processing-settings
SimonBrandner 4187efd
test: add test for MediaDeviceHandler
MrAnno bf024e2
settings: allow null values
MrAnno 69b1eec
test: add test for VoiceUserSettingsTab
MrAnno 500c42c
Merge branch 'develop' into audio-processing-settings
MrAnno File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| /* | ||
| Copyright 2022 The Matrix.org Foundation C.I.C. | ||
|
|
||
| Licensed under the Apache License, Version 2.0 (the "License"); | ||
| you may not use this file except in compliance with the License. | ||
| You may obtain a copy of the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, software | ||
| distributed under the License is distributed on an "AS IS" BASIS, | ||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| See the License for the specific language governing permissions and | ||
| limitations under the License. | ||
| */ | ||
|
|
||
| import { mocked } from 'jest-mock'; | ||
|
|
||
| import { SettingLevel } from "../src/settings/SettingLevel"; | ||
| import { MatrixClientPeg } from '../src/MatrixClientPeg'; | ||
| import { stubClient } from "./test-utils"; | ||
| import MediaDeviceHandler from "../src/MediaDeviceHandler"; | ||
| import SettingsStore from '../src/settings/SettingsStore'; | ||
|
|
||
| jest.mock("../src/settings/SettingsStore"); | ||
|
|
||
| const SettingsStoreMock = mocked(SettingsStore); | ||
|
|
||
| describe("MediaDeviceHandler", () => { | ||
| beforeEach(() => { | ||
| stubClient(); | ||
| }); | ||
|
|
||
| afterEach(() => { | ||
| jest.clearAllMocks(); | ||
| }); | ||
|
|
||
| it("sets audio settings", async () => { | ||
| const expectedAudioSettings = new Map<string, boolean>([ | ||
| ["webrtc_audio_autoGainControl", false], | ||
| ["webrtc_audio_echoCancellation", true], | ||
| ["webrtc_audio_noiseSuppression", false], | ||
| ]); | ||
|
|
||
| SettingsStoreMock.getValue.mockImplementation((settingName): any => { | ||
| return expectedAudioSettings.get(settingName); | ||
| }); | ||
|
|
||
| await MediaDeviceHandler.setAudioAutoGainControl(false); | ||
| await MediaDeviceHandler.setAudioEchoCancellation(true); | ||
| await MediaDeviceHandler.setAudioNoiseSuppression(false); | ||
|
|
||
| expectedAudioSettings.forEach((value, key) => { | ||
| expect(SettingsStoreMock.setValue).toHaveBeenCalledWith( | ||
| key, null, SettingLevel.DEVICE, value, | ||
| ); | ||
| }); | ||
|
|
||
| expect(MatrixClientPeg.get().getMediaHandler().setAudioSettings).toHaveBeenCalledWith({ | ||
| autoGainControl: false, | ||
| echoCancellation: true, | ||
| noiseSuppression: false, | ||
| }); | ||
| }); | ||
| }); |
56 changes: 56 additions & 0 deletions
56
test/components/views/settings/tabs/user/VoiceUserSettingsTab-test.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| /* | ||
| Copyright 2022 The Matrix.org Foundation C.I.C. | ||
|
|
||
| Licensed under the Apache License, Version 2.0 (the "License"); | ||
| you may not use this file except in compliance with the License. | ||
| You may obtain a copy of the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, software | ||
| distributed under the License is distributed on an "AS IS" BASIS, | ||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| See the License for the specific language governing permissions and | ||
| limitations under the License. | ||
| */ | ||
|
|
||
| import React from 'react'; | ||
| import { mocked } from 'jest-mock'; | ||
| import { render } from '@testing-library/react'; | ||
|
|
||
| import VoiceUserSettingsTab from '../../../../../../src/components/views/settings/tabs/user/VoiceUserSettingsTab'; | ||
| import MediaDeviceHandler from "../../../../../../src/MediaDeviceHandler"; | ||
|
|
||
| jest.mock("../../../../../../src/MediaDeviceHandler"); | ||
| const MediaDeviceHandlerMock = mocked(MediaDeviceHandler); | ||
|
|
||
| describe('<VoiceUserSettingsTab />', () => { | ||
| const getComponent = (): React.ReactElement => (<VoiceUserSettingsTab />); | ||
|
|
||
| beforeEach(() => { | ||
| jest.clearAllMocks(); | ||
| }); | ||
|
|
||
| it('renders audio processing settings', () => { | ||
| const { getByTestId } = render(getComponent()); | ||
| expect(getByTestId('voice-auto-gain')).toBeTruthy(); | ||
| expect(getByTestId('voice-noise-suppression')).toBeTruthy(); | ||
| expect(getByTestId('voice-echo-cancellation')).toBeTruthy(); | ||
| }); | ||
|
|
||
| it('sets and displays audio processing settings', () => { | ||
| MediaDeviceHandlerMock.getAudioAutoGainControl.mockReturnValue(false); | ||
| MediaDeviceHandlerMock.getAudioEchoCancellation.mockReturnValue(true); | ||
| MediaDeviceHandlerMock.getAudioNoiseSuppression.mockReturnValue(false); | ||
|
|
||
| const { getByRole } = render(getComponent()); | ||
|
|
||
| getByRole("switch", { name: "Automatically adjust the microphone volume" }).click(); | ||
| getByRole("switch", { name: "Noise suppression" }).click(); | ||
| getByRole("switch", { name: "Echo cancellation" }).click(); | ||
|
|
||
| expect(MediaDeviceHandler.setAudioAutoGainControl).toHaveBeenCalledWith(true); | ||
| expect(MediaDeviceHandler.setAudioEchoCancellation).toHaveBeenCalledWith(false); | ||
| expect(MediaDeviceHandler.setAudioNoiseSuppression).toHaveBeenCalledWith(true); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.