Search in sources :

Example 16 with Preferences

use of com.faforever.client.preferences.Preferences in project downlords-faf-client by FAForever.

the class FaInitGeneratorTest method setUp.

@Before
public void setUp() throws Exception {
    MockitoAnnotations.initMocks(this);
    instance = new FaInitGenerator(preferencesService);
    Preferences preferences = new Preferences();
    preferences.getForgedAlliance().setPath(faDirectory.getRoot().toPath());
    when(preferencesService.getFafBinDirectory()).thenReturn(fafBinDirectory.getRoot().toPath());
    when(preferencesService.getPreferences()).thenReturn(preferences);
}
Also used : Preferences(com.faforever.client.preferences.Preferences) Before(org.junit.Before)

Example 17 with Preferences

use of com.faforever.client.preferences.Preferences in project downlords-faf-client by FAForever.

the class GameServiceImplTest method setUp.

@Before
public void setUp() throws Exception {
    junitPlayer = PlayerBuilder.create("JUnit").defaultValues().get();
    ClientProperties clientProperties = new ClientProperties();
    clientProperties.getReplay().setLocalServerPort(LOCAL_REPLAY_PORT);
    instance = new GameServiceImpl(clientProperties, fafService, forgedAllianceService, mapService, preferencesService, gameUpdater, notificationService, i18n, executor, playerService, reportingService, eventBus, iceAdapter, modService, platformService, externalReplayInfoGenerator);
    instance.replayService = replayService;
    Preferences preferences = new Preferences();
    preferences.getForgedAlliance().setPort(GAME_PORT);
    when(preferencesService.getPreferences()).thenReturn(preferences);
    when(fafService.connectionStateProperty()).thenReturn(new SimpleObjectProperty<>());
    when(replayService.startReplayServer(anyInt())).thenReturn(CompletableFuture.completedFuture(null));
    when(iceAdapter.start()).thenReturn(CompletableFuture.completedFuture(GPG_PORT));
    when(playerService.getCurrentPlayer()).thenReturn(Optional.of(junitPlayer));
    doAnswer(invocation -> {
        try {
            ((Runnable) invocation.getArgument(0)).run();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }).when(executor).execute(any());
    instance.postConstruct();
    verify(fafService).addOnMessageListener(eq(GameInfoMessage.class), gameInfoMessageListenerCaptor.capture());
}
Also used : ClientProperties(com.faforever.client.config.ClientProperties) GameInfoMessage(com.faforever.client.remote.domain.GameInfoMessage) Preferences(com.faforever.client.preferences.Preferences) Before(org.junit.Before)

Example 18 with Preferences

use of com.faforever.client.preferences.Preferences in project downlords-faf-client by FAForever.

the class AbstractChatTabControllerTest method start.

@Override
public void start(Stage stage) throws Exception {
    super.start(stage);
    preferences = new Preferences();
    Clan clan = new Clan();
    clan.setId("1234");
    Vault vault = new Vault();
    vault.setReplayDownloadUrlFormat(TEST_REPLAY_BASE_URL);
    when(replayService.findById(any(Integer.class))).thenReturn(completedFuture(Optional.of(new Replay())));
    when(clanService.getClanByTag(sampleClanTag)).thenReturn(completedFuture(Optional.of(clan)));
    when(uiService.loadFxml("theme/chat/clan_tooltip.fxml")).thenReturn(mock(ClanTooltipController.class));
    when(uiService.getThemeFileUrl(any())).thenReturn(getClass().getResource("/theme/chat/chat_section.html"));
    when(timeService.asShortTime(any())).thenReturn("123");
    when(userService.getUsername()).thenReturn("junit");
    when(preferencesService.getPreferences()).thenReturn(preferences);
    when(clientProperties.getVault()).thenReturn(vault);
    instance = new AbstractChatTabController(clanService, webViewConfigurer, userService, chatService, platformService, preferencesService, playerService, audioService, timeService, i18n, imageUploadService, urlPreviewResolver, notificationService, reportingService, uiService, autoCompletionHelper, eventBus, countryFlagService, replayService, clientProperties, externalReplayInfoGenerator) {

        private final Tab root = new Tab();

        private final WebView webView = new WebView();

        private final TextInputControl messageTextField = new TextField();

        @Override
        public Tab getRoot() {
            return root;
        }

        @Override
        protected TextInputControl messageTextField() {
            return messageTextField;
        }

        @Override
        protected WebView getMessagesWebView() {
            return webView;
        }
    };
    TabPane tabPane = new TabPane(instance.getRoot());
    getRoot().getChildren().setAll(tabPane);
    chatReadyLatch = new CountDownLatch(1);
    instance.getMessagesWebView().getEngine().getLoadWorker().stateProperty().addListener((observable, oldValue, newValue) -> {
        if (Worker.State.SUCCEEDED.equals(newValue)) {
            chatReadyLatch.countDown();
        }
    });
    instance.initialize();
}
Also used : TabPane(javafx.scene.control.TabPane) CountDownLatch(java.util.concurrent.CountDownLatch) TextInputControl(javafx.scene.control.TextInputControl) Tab(javafx.scene.control.Tab) Clan(com.faforever.client.clan.Clan) Replay(com.faforever.client.replay.Replay) TextField(javafx.scene.control.TextField) Vault(com.faforever.client.config.ClientProperties.Vault) Preferences(com.faforever.client.preferences.Preferences) WebView(javafx.scene.web.WebView) ClanTooltipController(com.faforever.client.clan.ClanTooltipController)

Example 19 with Preferences

use of com.faforever.client.preferences.Preferences in project downlords-faf-client by FAForever.

the class SettingsControllerTest method setUp.

@Before
public void setUp() throws Exception {
    preferences = new Preferences();
    when(preferenceService.getPreferences()).thenReturn(preferences);
    when(uiService.currentThemeProperty()).thenReturn(new SimpleObjectProperty<>());
    instance = new SettingsController(userService, preferenceService, uiService, i18n, eventBus, notificationService);
    loadFxml("theme/settings/settings.fxml", param -> instance);
}
Also used : Preferences(com.faforever.client.preferences.Preferences) Before(org.junit.Before)

Example 20 with Preferences

use of com.faforever.client.preferences.Preferences in project downlords-faf-client by FAForever.

the class GameBinariesUpdateTaskTest method setUp.

@Before
public void setUp() throws Exception {
    MockitoAnnotations.initMocks(this);
    instance = new GameBinariesUpdateTaskImpl(i18n, preferencesService, new ClientProperties());
    Path faPath = faDirectory.getRoot().toPath();
    java.nio.file.Files.createDirectories(faPath.resolve("bin"));
    Preferences preferences = new Preferences();
    preferences.getForgedAlliance().setPath(faPath);
    when(preferencesService.getFafBinDirectory()).thenReturn(fafBinDirectory.getRoot().toPath());
    when(preferencesService.getPreferences()).thenReturn(preferences);
}
Also used : Path(java.nio.file.Path) ClientProperties(com.faforever.client.config.ClientProperties) Preferences(com.faforever.client.preferences.Preferences) Before(org.junit.Before)

Aggregations

Preferences (com.faforever.client.preferences.Preferences)21 Before (org.junit.Before)16 Pane (javafx.scene.layout.Pane)6 ClientProperties (com.faforever.client.config.ClientProperties)3 Clan (com.faforever.client.clan.Clan)2 Vault (com.faforever.client.config.ClientProperties.Vault)2 NumberFormat (java.text.NumberFormat)2 TabPane (javafx.scene.control.TabPane)2 NumberStringConverter (javafx.util.converter.NumberStringConverter)2 ChatColorMode (com.faforever.client.chat.ChatColorMode)1 AvatarBean (com.faforever.client.chat.avatar.AvatarBean)1 ClanTooltipController (com.faforever.client.clan.ClanTooltipController)1 Website (com.faforever.client.config.ClientProperties.Website)1 Controller (com.faforever.client.fx.Controller)1 PATH_STRING_CONVERTER (com.faforever.client.fx.JavaFxUtil.PATH_STRING_CONVERTER)1 StringListCell (com.faforever.client.fx.StringListCell)1 Game (com.faforever.client.game.Game)1 I18n (com.faforever.client.i18n.I18n)1 Action (com.faforever.client.notification.Action)1 NotificationService (com.faforever.client.notification.NotificationService)1