private void verifySdkPanelStateForCurrentSettings(CloudSdkPanel sdkPanel) { CloudSdkServiceUserSettings userSettings = CloudSdkServiceUserSettings.getInstance(); switch (userSettings.getUserSelectedSdkServiceType()) { case CUSTOM_SDK: assertThat(sdkPanel.getCustomRadioButton().isSelected()).isTrue(); assertThat(sdkPanel.getManagedRadioButton().isSelected()).isFalse(); assertThat(sdkPanel.getEnableAutomaticUpdatesCheckbox().isEnabled()).isFalse(); break; case MANAGED_SDK: assertThat(sdkPanel.getManagedRadioButton().isSelected()).isTrue(); assertThat(sdkPanel.getEnableAutomaticUpdatesCheckbox().isEnabled()).isTrue(); assertThat(sdkPanel.getCustomRadioButton().isSelected()).isFalse(); assertThat(sdkPanel.getCloudSdkDirectoryField().isEnabled()).isFalse(); break; } assertThat(sdkPanel.getEnableAutomaticUpdatesCheckbox().isSelected()) .isEqualTo(userSettings.isAutomaticUpdateEnabled()); assertThat(sdkPanel.getCloudSdkDirectoryText()) .isEqualTo(Strings.nullToEmpty(userSettings.getCustomSdkPath())); } }
@Test public void changeSdkType_apply_callsChangedSdkTypeCallback() { ApplicationManager.getApplication() .invokeAndWait( () -> { // use non-spy panel as spy messes up with UI event thread field updates. CloudSdkPanel sdkPanel = new CloudSdkPanel(); CloudSdkServiceUserSettings.getInstance() .setUserSelectedSdkServiceType(CloudSdkServiceType.MANAGED_SDK); sdkPanel.reset(); sdkPanel.getCustomRadioButton().doClick(); String customSdkPath = "/home/gcloud"; sdkPanel.getCloudSdkDirectoryField().setText(customSdkPath); try { sdkPanel.apply(); } catch (ConfigurationException e) { throw new AssertionError(e); } verify(mockCloudSdkServiceManager) .onNewCloudSdkServiceTypeSelected(CloudSdkServiceType.CUSTOM_SDK); }); }
@Test public void customSdk_choice_apply_validSettings() { ApplicationManager.getApplication() .invokeAndWait( () -> { // use non-spy panel as spy messes up with UI event thread field updates. CloudSdkPanel sdkPanel = new CloudSdkPanel(); sdkPanel.reset(); sdkPanel.getCustomRadioButton().doClick(); String customSdkPath = "/home/gcloud"; sdkPanel.getCloudSdkDirectoryField().setText(customSdkPath); try { sdkPanel.apply(); } catch (ConfigurationException e) { throw new AssertionError(e); } verifyCloudSdkSettings( CloudSdkServiceType.CUSTOM_SDK, CloudSdkServiceUserSettings.DEFAULT_MANAGED_SDK_AUTOMATIC_UPDATES, customSdkPath); }); }