Search in sources :

Example 1 with Vault

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

the class PrivateChatTabControllerTest method setUp.

@Before
public void setUp() throws IOException {
    Vault vault = new Vault();
    vault.setReplayDownloadUrlFormat("test.de");
    when(clientProperties.getVault()).thenReturn(vault);
    PreferencesService preferencesService = new PreferencesService();
    preferencesService.postConstruct();
    preferencesService.getPreferences().getMainWindow().setLastView(NavigationItem.CHAT.name());
    instance = new PrivateChatTabController(clanService, userService, platformService, preferencesService, playerService, timeService, i18n, imageUploadService, urlPreviewResolver, notificationService, reportingService, uiService, autoCompletionHelper, eventBus, audioService, chatService, mapService, webViewConfigurer, countryFlagService, replayService, clientProperties, externalReplayInfoGenerator);
    playerName = "testUser";
    Player player = new Player(playerName);
    when(playerService.getPlayerForUsername(playerName)).thenReturn(player);
    when(userService.getUsername()).thenReturn(playerName);
    when(uiService.getThemeFileUrl(CHAT_CONTAINER)).then(invocation -> getThemeFileUrl(invocation.getArgument(0)));
    TabPane tabPane = new TabPane();
    tabPane.setSkin(new TabPaneSkin(tabPane));
    loadFxml("theme/chat/private_chat_tab.fxml", clazz -> {
        if (clazz == PrivateUserInfoController.class) {
            return privateUserInfoController;
        }
        if (clazz == GameDetailController.class) {
            return gameDetailController;
        }
        if (clazz == WatchButtonController.class) {
            return watchButtonController;
        }
        return instance;
    });
    instance.setReceiver(playerName);
    WaitForAsyncUtils.asyncFx(() -> {
        getRoot().getChildren().setAll(tabPane);
        tabPane.getTabs().add(instance.getRoot());
    });
    WaitForAsyncUtils.waitForFxEvents();
    verify(webViewConfigurer).configureWebView(instance.messagesWebView);
}
Also used : TabPane(javafx.scene.control.TabPane) Player(com.faforever.client.player.Player) Vault(com.faforever.client.config.ClientProperties.Vault) TabPaneSkin(com.sun.javafx.scene.control.skin.TabPaneSkin) PreferencesService(com.faforever.client.preferences.PreferencesService) Before(org.junit.Before)

Example 2 with Vault

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

the class ChannelTabControllerTest method setUp.

@Before
public void setUp() throws Exception {
    Vault vault = new Vault();
    vault.setReplayDownloadUrlFormat("test.de");
    when(clientProperties.getVault()).thenReturn(vault);
    instance = new ChannelTabController(clanService, userService, chatService, platformService, preferencesService, playerService, audioService, timeService, i18n, imageUploadService, urlPreviewResolver, notificationService, reportingService, uiService, autoCompletionHelper, eventBus, webViewConfigurer, threadPoolExecutor, taskScheduler, countryFlagService, replayService, clientProperties, externalReplayInfoGenerator);
    when(preferencesService.getPreferences()).thenReturn(new Preferences());
    when(userService.getUsername()).thenReturn(USER_NAME);
    when(uiService.loadFxml("theme/chat/user_filter.fxml")).thenReturn(userFilterController);
    when(uiService.loadFxml("theme/chat/chat_user_item.fxml")).thenReturn(chatUserItemController);
    when(userFilterController.getRoot()).thenReturn(new Pane());
    when(chatUserItemController.getRoot()).thenReturn(new Pane());
    when(uiService.getThemeFileUrl(CHAT_CONTAINER)).thenReturn(getClass().getResource("/theme/chat/chat_container.html"));
    loadFxml("theme/chat/channel_tab.fxml", clazz -> instance);
    TabPane tabPane = new TabPane();
    tabPane.getTabs().add(instance.getRoot());
    WaitForAsyncUtils.waitForAsyncFx(5000, () -> getRoot().getChildren().add(tabPane));
}
Also used : TabPane(javafx.scene.control.TabPane) Vault(com.faforever.client.config.ClientProperties.Vault) Preferences(com.faforever.client.preferences.Preferences) TabPane(javafx.scene.control.TabPane) Pane(javafx.scene.layout.Pane) Before(org.junit.Before)

Example 3 with Vault

use of com.faforever.client.config.ClientProperties.Vault 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)

Aggregations

Vault (com.faforever.client.config.ClientProperties.Vault)3 TabPane (javafx.scene.control.TabPane)3 Preferences (com.faforever.client.preferences.Preferences)2 Before (org.junit.Before)2 Clan (com.faforever.client.clan.Clan)1 ClanTooltipController (com.faforever.client.clan.ClanTooltipController)1 Player (com.faforever.client.player.Player)1 PreferencesService (com.faforever.client.preferences.PreferencesService)1 Replay (com.faforever.client.replay.Replay)1 TabPaneSkin (com.sun.javafx.scene.control.skin.TabPaneSkin)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 Tab (javafx.scene.control.Tab)1 TextField (javafx.scene.control.TextField)1 TextInputControl (javafx.scene.control.TextInputControl)1 Pane (javafx.scene.layout.Pane)1 WebView (javafx.scene.web.WebView)1