Search in sources :

Example 66 with IEclipsePreferences

use of org.eclipse.core.runtime.preferences.IEclipsePreferences in project linuxtools by eclipse.

the class CreaterepoDeltaPropertyPageTest method testCancel.

/**
 * Test if all preferences stay the same as it was after pressing cancel
 * instead of ok.
 */
@Test
public void testCancel() {
    bot.checkBox(Messages.CreaterepoDeltaPropertyPage_booleanEnableLabel).click();
    // $NON-NLS-1$
    bot.textWithLabel(Messages.CreaterepoDeltaPropertyPage_maxNumberOfDeltas).setText("9");
    // $NON-NLS-1$
    bot.textWithLabel(Messages.CreaterepoDeltaPropertyPage_maxDeltaSize).setText("13");
    bot.button(ICreaterepoTestConstants.APPLY_AND_CLOSE_BUTTON).click();
    openPropertyPage();
    bot.button(ICreaterepoTestConstants.DEFAULTS).click();
    bot.button(ICreaterepoTestConstants.CANCEL_BUTTON).click();
    openPropertyPage();
    IEclipsePreferences pref = project.getEclipsePreferences();
    IPreferenceStore prefStore = Activator.getDefault().getPreferenceStore();
    assertEquals(prefStore.getBoolean(CreaterepoPreferenceConstants.PREF_DELTA_ENABLE), bot.checkBox(Messages.CreaterepoDeltaPropertyPage_booleanEnableLabel).isChecked());
    assertEquals(pref.getInt(CreaterepoPreferenceConstants.PREF_NUM_DELTAS, prefStore.getInt(CreaterepoPreferenceConstants.PREF_NUM_DELTAS)), Integer.parseInt(bot.textWithLabel(Messages.CreaterepoDeltaPropertyPage_maxNumberOfDeltas).getText()));
    assertEquals(pref.getInt(CreaterepoPreferenceConstants.PREF_MAX_DELTA_SIZE, prefStore.getInt(CreaterepoPreferenceConstants.PREF_MAX_DELTA_SIZE)), Integer.parseInt(bot.textWithLabel(Messages.CreaterepoDeltaPropertyPage_maxDeltaSize).getText()));
}
Also used : IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) Test(org.junit.Test)

Example 67 with IEclipsePreferences

use of org.eclipse.core.runtime.preferences.IEclipsePreferences in project linuxtools by eclipse.

the class CreaterepoDeltaPropertyPageTest method testChangePreferences.

/**
 * Test if all preferences modified in the deltas createrepo property
 * page persist to project preferences.
 */
@Test
public void testChangePreferences() {
    bot.checkBox(Messages.CreaterepoDeltaPropertyPage_booleanEnableLabel).click();
    // $NON-NLS-1$
    bot.textWithLabel(Messages.CreaterepoDeltaPropertyPage_maxNumberOfDeltas).setText("9");
    // $NON-NLS-1$
    bot.textWithLabel(Messages.CreaterepoDeltaPropertyPage_maxDeltaSize).setText("13");
    bot.button(ICreaterepoTestConstants.APPLY_AND_CLOSE_BUTTON).click();
    openPropertyPage();
    IEclipsePreferences pref = project.getEclipsePreferences();
    IPreferenceStore prefStore = Activator.getDefault().getPreferenceStore();
    assertEquals(prefStore.getBoolean(CreaterepoPreferenceConstants.PREF_DELTA_ENABLE), bot.checkBox(Messages.CreaterepoDeltaPropertyPage_booleanEnableLabel).isChecked());
    assertEquals(pref.getInt(CreaterepoPreferenceConstants.PREF_NUM_DELTAS, prefStore.getInt(CreaterepoPreferenceConstants.PREF_NUM_DELTAS)), Integer.parseInt(bot.textWithLabel(Messages.CreaterepoDeltaPropertyPage_maxNumberOfDeltas).getText()));
    assertEquals(pref.getInt(CreaterepoPreferenceConstants.PREF_MAX_DELTA_SIZE, prefStore.getInt(CreaterepoPreferenceConstants.PREF_MAX_DELTA_SIZE)), Integer.parseInt(bot.textWithLabel(Messages.CreaterepoDeltaPropertyPage_maxDeltaSize).getText()));
}
Also used : IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) Test(org.junit.Test)

Example 68 with IEclipsePreferences

use of org.eclipse.core.runtime.preferences.IEclipsePreferences in project linuxtools by eclipse.

the class CreaterepoDeltaPropertyPageTest method tearDown.

/**
 * Restore the defaults for the general preference page.
 *
 * @throws BackingStoreException
 */
@After
public void tearDown() throws BackingStoreException {
    try {
        if (bot.shell(String.format(ICreaterepoTestConstants.PROPERTIES_SHELL, ICreaterepoTestConstants.REPO_NAME)).isActive()) {
            bot.shell(String.format(ICreaterepoTestConstants.PROPERTIES_SHELL, ICreaterepoTestConstants.REPO_NAME)).close();
        }
    } catch (WidgetNotFoundException e) {
    // cannot close property shell
    }
    testProject.restoreDefaults();
    IEclipsePreferences pref = project.getEclipsePreferences();
    pref.clear();
    pref.flush();
    assertEquals(0, pref.keys().length);
}
Also used : WidgetNotFoundException(org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException) IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) After(org.junit.After)

Example 69 with IEclipsePreferences

use of org.eclipse.core.runtime.preferences.IEclipsePreferences in project linuxtools by eclipse.

the class CreaterepoGeneralPropertyPageTest method tearDown.

/**
 * Restore the defaults for the general preference page.
 *
 * @throws BackingStoreException
 */
@After
public void tearDown() throws BackingStoreException {
    try {
        if (bot.shell(String.format(ICreaterepoTestConstants.PROPERTIES_SHELL, ICreaterepoTestConstants.REPO_NAME)).isActive()) {
            bot.shell(String.format(ICreaterepoTestConstants.PROPERTIES_SHELL, ICreaterepoTestConstants.REPO_NAME)).close();
        }
    } catch (WidgetNotFoundException e) {
    // cannot close property shell
    }
    testProject.restoreDefaults();
    IEclipsePreferences pref = project.getEclipsePreferences();
    pref.clear();
    pref.flush();
    assertEquals(0, pref.keys().length);
}
Also used : WidgetNotFoundException(org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException) IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) After(org.junit.After)

Example 70 with IEclipsePreferences

use of org.eclipse.core.runtime.preferences.IEclipsePreferences in project linuxtools by eclipse.

the class CreaterepoGeneralPropertyPageTest method testChangePreferences.

/**
 * Test if all preferences modified in the general createrepo property
 * page persist to project preferences.
 */
@Test
public void testChangePreferences() {
    bot.checkBox(Messages.CreaterepoGeneralPropertyPage_projectSettings).click();
    bot.checkBox(Messages.CreaterepoPreferencePage_booleanChecksumName).click();
    bot.checkBox(Messages.CreaterepoPreferencePage_booleanGenerateSQLDB).click();
    bot.checkBox(Messages.CreaterepoPreferencePage_booleanIgnoreSymlinks).click();
    bot.checkBox(Messages.CreaterepoPreferencePage_booleanPrettyXML).click();
    // $NON-NLS-1$
    bot.textWithLabel(Messages.CreaterepoPreferencePage_numWorkers).setText("9");
    // $NON-NLS-1$
    bot.textWithLabel(Messages.CreaterepoPreferencePage_numChangelogLimit).setText("13");
    bot.checkBox(Messages.CreaterepoPreferencePage_booleanCheckTS).click();
    bot.radio(ICreaterepoChecksums.SHA512).click();
    bot.radio(ICreaterepoCompressionTypes.XZ).click();
    bot.button(ICreaterepoTestConstants.APPLY_AND_CLOSE_BUTTON).click();
    openPropertyPage();
    IEclipsePreferences pref = project.getEclipsePreferences();
    IPreferenceStore prefStore = Activator.getDefault().getPreferenceStore();
    assertEquals(prefStore.getBoolean(CreaterepoPreferenceConstants.PREF_GENERAL_ENABLED), bot.checkBox(Messages.CreaterepoGeneralPropertyPage_projectSettings).isChecked());
    assertEquals(pref.getBoolean(CreaterepoPreferenceConstants.PREF_UNIQUE_MD_NAME, prefStore.getDefaultBoolean(CreaterepoPreferenceConstants.PREF_UNIQUE_MD_NAME)), bot.checkBox(Messages.CreaterepoPreferencePage_booleanChecksumName).isChecked());
    assertEquals(pref.getBoolean(CreaterepoPreferenceConstants.PREF_GENERATE_DB, prefStore.getDefaultBoolean(CreaterepoPreferenceConstants.PREF_GENERATE_DB)), bot.checkBox(Messages.CreaterepoPreferencePage_booleanGenerateSQLDB).isChecked());
    assertEquals(pref.getBoolean(CreaterepoPreferenceConstants.PREF_IGNORE_SYMLINKS, prefStore.getDefaultBoolean(CreaterepoPreferenceConstants.PREF_IGNORE_SYMLINKS)), bot.checkBox(Messages.CreaterepoPreferencePage_booleanIgnoreSymlinks).isChecked());
    assertEquals(pref.getBoolean(CreaterepoPreferenceConstants.PREF_PRETTY_XML, prefStore.getDefaultBoolean(CreaterepoPreferenceConstants.PREF_PRETTY_XML)), bot.checkBox(Messages.CreaterepoPreferencePage_booleanPrettyXML).isChecked());
    assertEquals(pref.getInt(CreaterepoPreferenceConstants.PREF_WORKERS, prefStore.getInt(CreaterepoPreferenceConstants.PREF_WORKERS)), Integer.parseInt(bot.textWithLabel(Messages.CreaterepoPreferencePage_numWorkers).getText()));
    assertEquals(pref.getInt(CreaterepoPreferenceConstants.PREF_CHANGELOG_LIMIT, prefStore.getInt(CreaterepoPreferenceConstants.PREF_CHANGELOG_LIMIT)), Integer.parseInt(bot.textWithLabel(Messages.CreaterepoPreferencePage_numChangelogLimit).getText()));
    assertEquals(pref.getBoolean(CreaterepoPreferenceConstants.PREF_CHECK_TS, prefStore.getDefaultBoolean(CreaterepoPreferenceConstants.PREF_CHECK_TS)), bot.checkBox(Messages.CreaterepoPreferencePage_booleanCheckTS).isChecked());
    assertTrue(bot.radio(pref.get(CreaterepoPreferenceConstants.PREF_CHECKSUM, prefStore.getDefaultString(CreaterepoPreferenceConstants.PREF_CHECKSUM))).isSelected());
    assertTrue(bot.radio(pref.get(CreaterepoPreferenceConstants.PREF_COMPRESSION_TYPE, prefStore.getDefaultString(CreaterepoPreferenceConstants.PREF_COMPRESSION_TYPE))).isSelected());
}
Also used : IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) Test(org.junit.Test)

Aggregations

IEclipsePreferences (org.eclipse.core.runtime.preferences.IEclipsePreferences)79 BackingStoreException (org.osgi.service.prefs.BackingStoreException)15 Test (org.junit.Test)11 InstanceScope (org.eclipse.core.runtime.preferences.InstanceScope)9 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)9 IXMLMemento (com.cubrid.cubridmanager.core.common.xml.IXMLMemento)6 ProjectScope (org.eclipse.core.resources.ProjectScope)6 IScopeContext (org.eclipse.core.runtime.preferences.IScopeContext)6 After (org.junit.After)6 ByteArrayInputStream (java.io.ByteArrayInputStream)5 IOException (java.io.IOException)5 ArrayList (java.util.ArrayList)5 UnsupportedEncodingException (java.io.UnsupportedEncodingException)4 HashMap (java.util.HashMap)4 HashSet (java.util.HashSet)4 Iterator (java.util.Iterator)4 Map (java.util.Map)4 XMLMemento (com.cubrid.cubridmanager.core.common.xml.XMLMemento)3 ISourceViewer (org.eclipse.jface.text.source.ISourceViewer)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2