Skip to content

Commit

Permalink
- Using Audio file from existing issue.
Browse files Browse the repository at this point in the history
- Removed superfluous check
- Added audioService mock to the test, making them pass.
- Renamed the preference to be more in line with the existing values.
  • Loading branch information
Trenair committed Jun 27, 2024
1 parent b7a19bd commit 54e9141
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class NotificationPrefs {
private final IntegerProperty toastDisplayTime = new SimpleIntegerProperty(5000);
private final IntegerProperty silenceBetweenSounds = new SimpleIntegerProperty(30000);
private final BooleanProperty afterGameReviewEnabled = new SimpleBooleanProperty(true);
private final BooleanProperty isMatchFoundSoundEnabled = new SimpleBooleanProperty(true);
private final BooleanProperty matchFoundSoundEnabled = new SimpleBooleanProperty(true);

public boolean isSoundsEnabled() {
return soundsEnabled.get();
Expand Down Expand Up @@ -286,15 +286,15 @@ public BooleanProperty afterGameReviewEnabledProperty() {
return afterGameReviewEnabled;
}

public void setIsMatchFoundSoundEnabled(boolean isMatchFoundSoundEnabled) {
this.isMatchFoundSoundEnabled.set(isMatchFoundSoundEnabled);
public void setMatchFoundSoundEnabled(boolean matchFoundSoundEnabled) {
this.matchFoundSoundEnabled.set(matchFoundSoundEnabled);
}

public boolean isMatchFoundSoundEnabled() {
return isMatchFoundSoundEnabled.get();
return matchFoundSoundEnabled.get();
}
public BooleanProperty isMatchFoundSoundEnabledProperty() {
return isMatchFoundSoundEnabled;
public BooleanProperty matchFoundSoundEnabledProperty() {
return matchFoundSoundEnabled;
}

public int getSilenceBetweenSounds() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ private void bindNotificationPreferences() {
.bindBidirectional(notificationPrefs.privateMessageSoundEnabledProperty());
displayMatchFoundNotificationCheckBox.selectedProperty().setValue(true);
playMatchFoundSoundCheckBox.selectedProperty()
.bindBidirectional(notificationPrefs.isMatchFoundSoundEnabledProperty());
.bindBidirectional(notificationPrefs.matchFoundSoundEnabledProperty());
afterGameReviewCheckBox.selectedProperty().bindBidirectional(notificationPrefs.afterGameReviewEnabledProperty());
notifyOnAtMentionOnlyToggle.selectedProperty()
.bindBidirectional(notificationPrefs.notifyOnAtMentionOnlyEnabledProperty());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import com.faforever.client.player.PlayerService;
import com.faforever.client.player.ServerStatus;
import com.faforever.client.preferences.MatchmakerPrefs;
import com.faforever.client.preferences.NotificationPrefs;
import com.faforever.client.preferences.PreferencesService;
import com.faforever.client.remote.FafServerAccessor;
import com.faforever.client.user.LoginService;
Expand Down Expand Up @@ -113,7 +112,6 @@ public class TeamMatchmakingService implements InitializingBean {
private final MatchmakerPrefs matchmakerPrefs;
private final GamePathHandler gamePathHandler;
private final AudioService audioService;
private final NotificationPrefs notificationPrefs;

@Getter
private final PartyInfo party = new PartyInfo();
Expand Down Expand Up @@ -346,9 +344,7 @@ private void setTimedOutMatchingStatus(MatchmakerQueueInfo queue, MatchingStatus
}

private void notifyMatchFound() {
if (notificationPrefs.isMatchFoundSoundEnabled()) {
audioService.playMatchFoundSound();
}
audioService.playMatchFoundSound();

notificationService.addNotification(
new TransientNotification(i18n.get("teammatchmaking.notification.matchFound.title"),
Expand Down
Binary file modified src/main/resources/theme/sounds/matchFoundSound.mp3
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void setUp() throws Exception {
notificationPrefs.setFriendOnlineSoundEnabled(true);
notificationPrefs.setFriendPlaysGameSoundEnabled(true);
notificationPrefs.setFriendOfflineSoundEnabled(true);
notificationPrefs.setIsMatchFoundSoundEnabled(true);
notificationPrefs.setMatchFoundSoundEnabled(true);
notificationPrefs.setSilenceBetweenSounds(SILENCE_BETWEEN_SOUNDS);

instance.afterPropertiesSet();
Expand Down Expand Up @@ -84,7 +84,7 @@ public void testNoSoundsWhenIndividuallyOff() {
notificationPrefs.setFriendOnlineSoundEnabled(false);
notificationPrefs.setFriendPlaysGameSoundEnabled(false);
notificationPrefs.setPrivateMessageSoundEnabled(false);
notificationPrefs.setIsMatchFoundSoundEnabled(false);
notificationPrefs.setMatchFoundSoundEnabled(false);
instance.playChatMentionSound();
instance.playPrivateMessageSound();
instance.playInfoNotificationSound();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.faforever.client.teammatchmaking;

import com.faforever.client.api.FafApiAccessor;
import com.faforever.client.audio.AudioService;
import com.faforever.client.builders.GameInfoBuilder;
import com.faforever.client.builders.GameLaunchMessageBuilder;
import com.faforever.client.builders.PartyInfoBuilder.PartyMemberBuilder;
Expand Down Expand Up @@ -119,6 +120,8 @@ public class TeamMatchmakingServiceTest extends ServiceTest {
private GameRunner gameRunner;
@Mock
private NavigationHandler navigationHandler;
@Mock
private AudioService audioService;
@Spy
private MatchmakerPrefs matchmakerPrefs = new MatchmakerPrefs();

Expand All @@ -141,7 +144,6 @@ public class TeamMatchmakingServiceTest extends ServiceTest {
private final TestPublisher<GameLaunchResponse> gameLaunchResponseTestPublisher = TestPublisher.create();
private final SimpleObjectProperty<ConnectionState> connectionState = new SimpleObjectProperty<>(
ConnectionState.DISCONNECTED);
;

@BeforeEach
public void setUp() throws Exception {
Expand Down

0 comments on commit 54e9141

Please sign in to comment.