Search in sources :

Example 1 with ClientProperties

use of com.faforever.client.config.ClientProperties in project downlords-faf-client by FAForever.

the class MainControllerTest method setUp.

@Before
public void setUp() throws Exception {
    ClientProperties clientProperties = new ClientProperties();
    clientProperties.getTrueSkill().setBeta(240).setInitialMean(1500).setInitialStandardDeviation(500);
    instance = new MainController(preferencesService, i18n, notificationService, playerService, gameService, clientUpdateService, uiService, eventBus, clientProperties, gamePathHandler, platformService);
    gameRunningProperty = new SimpleBooleanProperty();
    when(persistentNotificationsController.getRoot()).thenReturn(new Pane());
    when(transientNotificationsController.getRoot()).thenReturn(new Pane());
    when(preferencesService.getPreferences()).thenReturn(preferences);
    when(uiService.loadFxml("theme/window.fxml")).thenReturn(windowController);
    when(preferences.getMainWindow()).thenReturn(mainWindowPrefs);
    when(preferences.getNotification()).thenReturn(notificationPrefs);
    when(gameService.gameRunningProperty()).thenReturn(gameRunningProperty);
    when(uiService.loadFxml("theme/persistent_notifications.fxml")).thenReturn(persistentNotificationsController);
    when(uiService.loadFxml("theme/transient_notifications.fxml")).thenReturn(transientNotificationsController);
    when(uiService.loadFxml("theme/window.fxml")).thenReturn(windowController);
    when(uiService.loadFxml("theme/settings/settings.fxml")).thenReturn(settingsController);
    when(uiService.loadFxml("theme/login.fxml")).thenReturn(loginController);
    when(uiService.loadFxml("theme/chat/chat.fxml")).thenReturn(chatController);
    loadFxml("theme/main.fxml", clazz -> {
        if (clazz == instance.getClass()) {
            return instance;
        }
        return mock(clazz);
    });
    mainControllerInitializedLatch = new CountDownLatch(1);
    // As the login check is executed AFTER the main controller has been switched to logged in state, we hook to it
    doAnswer(invocation -> {
        mainControllerInitializedLatch.countDown();
        return null;
    }).when(clientUpdateService).checkForUpdateInBackground();
}
Also used : ClientProperties(com.faforever.client.config.ClientProperties) SimpleBooleanProperty(javafx.beans.property.SimpleBooleanProperty) CountDownLatch(java.util.concurrent.CountDownLatch) Pane(javafx.scene.layout.Pane) Before(org.junit.Before)

Example 2 with ClientProperties

use of com.faforever.client.config.ClientProperties in project downlords-faf-client by FAForever.

the class Ladder1V1ControllerTest method setUp.

@Before
public void setUp() throws Exception {
    instance = new Ladder1v1Controller(gameService, preferencesService, playerService, leaderboardService, i18n, new ClientProperties(), eventBus);
    Player player = new Player(USERNAME);
    player.setId(PLAYER_ID);
    currentPlayerProperty = new SimpleObjectProperty<>(player);
    factionList = FXCollections.observableArrayList();
    LeaderboardEntry leaderboardEntry = new LeaderboardEntry();
    leaderboardEntry.setRating(500);
    leaderboardEntry.setWinLossRatio(12.23f);
    leaderboardEntry.setRank(100);
    leaderboardEntry.setGamesPlayed(412);
    leaderboardEntry.setUsername(USERNAME);
    when(leaderboardService.getLadder1v1Stats()).thenReturn(CompletableFuture.completedFuture(new ArrayList<>()));
    when(leaderboardService.getEntryForPlayer(PLAYER_ID)).thenReturn(CompletableFuture.completedFuture(leaderboardEntry));
    when(gameService.searching1v1Property()).thenReturn(searching1v1Property);
    when(preferencesService.getPreferences()).thenReturn(preferences);
    when(preferences.getLadder1v1Prefs()).thenReturn(ladder1V1Prefs);
    when(ladder1V1Prefs.getFactions()).thenReturn(factionList);
    when(preferences.getForgedAlliance()).thenReturn(forgedAlliancePrefs);
    when(playerService.getCurrentPlayer()).thenReturn(Optional.ofNullable(currentPlayerProperty.get()));
    when(playerService.currentPlayerProperty()).thenReturn(currentPlayerProperty);
    loadFxml("theme/play/ranked_1v1.fxml", clazz -> instance);
}
Also used : ClientProperties(com.faforever.client.config.ClientProperties) Player(com.faforever.client.player.Player) ArrayList(java.util.ArrayList) LeaderboardEntry(com.faforever.client.leaderboard.LeaderboardEntry) Before(org.junit.Before)

Example 3 with ClientProperties

use of com.faforever.client.config.ClientProperties in project downlords-faf-client by FAForever.

the class ServerAccessorImplTest method setUp.

@Before
public void setUp() throws Exception {
    serverToClientReadyLatch = new CountDownLatch(1);
    messagesReceivedByFafServer = new ArrayBlockingQueue<>(10);
    startFakeFafLobbyServer();
    ClientProperties clientProperties = new ClientProperties();
    clientProperties.getServer().setHost(LOOPBACK_ADDRESS.getHostAddress()).setPort(fafLobbyServerSocket.getLocalPort());
    instance = new FafServerAccessorImpl(preferencesService, uidService, notificationService, i18n, clientProperties, reportingService);
    LoginPrefs loginPrefs = new LoginPrefs();
    loginPrefs.setUsername("junit");
    loginPrefs.setPassword("password");
    when(preferencesService.getFafDataDirectory()).thenReturn(faDirectory.getRoot().toPath());
    when(uidService.generate(any(), any())).thenReturn("encrypteduidstring");
}
Also used : ClientProperties(com.faforever.client.config.ClientProperties) LoginPrefs(com.faforever.client.preferences.LoginPrefs) CountDownLatch(java.util.concurrent.CountDownLatch) Before(org.junit.Before)

Example 4 with ClientProperties

use of com.faforever.client.config.ClientProperties in project downlords-faf-client by FAForever.

the class LoginControllerTest method setUp.

@Before
public void setUp() throws Exception {
    ClientProperties clientProperties = new ClientProperties();
    instance = new LoginController(userService, preferencesService, platformService, clientProperties);
    loadFxml("theme/login.fxml", param -> instance);
    Website website = clientProperties.getWebsite();
    website.setCreateAccountUrl("create");
    website.setForgotPasswordUrl("forgot");
    when(preferencesService.getPreferences()).thenReturn(new Preferences());
}
Also used : ClientProperties(com.faforever.client.config.ClientProperties) Website(com.faforever.client.config.ClientProperties.Website) Preferences(com.faforever.client.preferences.Preferences) Before(org.junit.Before)

Example 5 with ClientProperties

use of com.faforever.client.config.ClientProperties in project downlords-faf-client by FAForever.

the class CheckForUpdateTaskTest method setUp.

@Before
public void setUp() throws Exception {
    instance = new CheckForUpdateTask();
    instance.i18n = i18n;
    instance.clientProperties = new ClientProperties();
    terminateLatch = new CountDownLatch(1);
}
Also used : ClientProperties(com.faforever.client.config.ClientProperties) CountDownLatch(java.util.concurrent.CountDownLatch) Before(org.junit.Before)

Aggregations

ClientProperties (com.faforever.client.config.ClientProperties)9 Before (org.junit.Before)9 CountDownLatch (java.util.concurrent.CountDownLatch)4 Preferences (com.faforever.client.preferences.Preferences)3 Website (com.faforever.client.config.ClientProperties.Website)1 LeaderboardEntry (com.faforever.client.leaderboard.LeaderboardEntry)1 Player (com.faforever.client.player.Player)1 LoginPrefs (com.faforever.client.preferences.LoginPrefs)1 GameInfoMessage (com.faforever.client.remote.domain.GameInfoMessage)1 SocialMessage (com.faforever.client.remote.domain.SocialMessage)1 Path (java.nio.file.Path)1 ArrayList (java.util.ArrayList)1 SimpleBooleanProperty (javafx.beans.property.SimpleBooleanProperty)1 Pane (javafx.scene.layout.Pane)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1