1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Allow clear empty Specs detectors in UI to give user means for

restarting.
This commit is contained in:
Andrew Gvozdev 2012-04-08 06:44:03 -04:00
parent 58721c65b9
commit 36d837843b
2 changed files with 75 additions and 4 deletions

View file

@ -331,10 +331,13 @@ public class BuiltinSpecsDetectorTest extends BaseTestCase {
Document doc = XmlUtil.newDocument();
Element rootElement = XmlUtil.appendElement(doc, ELEM_TEST);
// load it to new provider
// initialize provider
MockBuiltinSpecsDetectorExecutedFlag provider = new MockBuiltinSpecsDetectorExecutedFlag();
assertEquals(false, provider.isExecuted());
// load the XML to new provider
provider.load(rootElement);
assertEquals(false, provider.isConsoleEnabled());
assertEquals(false, provider.isExecuted());
}
Element elementProvider;
@ -342,6 +345,7 @@ public class BuiltinSpecsDetectorTest extends BaseTestCase {
// define mock detector
MockBuiltinSpecsDetectorExecutedFlag provider = new MockBuiltinSpecsDetectorExecutedFlag();
assertEquals(false, provider.isConsoleEnabled());
assertEquals(false, provider.isExecuted());
// redefine the settings
provider.setConsoleEnabled(true);
@ -359,10 +363,69 @@ public class BuiltinSpecsDetectorTest extends BaseTestCase {
// create another instance of the provider
MockBuiltinSpecsDetectorExecutedFlag provider = new MockBuiltinSpecsDetectorExecutedFlag();
assertEquals(false, provider.isConsoleEnabled());
assertEquals(false, provider.isExecuted());
// load element
provider.load(elementProvider);
assertEquals(true, provider.isConsoleEnabled());
assertEquals(false, provider.isExecuted());
}
}
/**
* Test serialization of entries and "isExecuted" flag handling.
*/
public void testAbstractBuiltinSpecsDetector_SerializeEntriesDOM() throws Exception {
Element rootElement;
{
// create provider
MockBuiltinSpecsDetectorExecutedFlag provider = new MockBuiltinSpecsDetectorExecutedFlag();
List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
entries.add(new CIncludePathEntry("path0", 1));
provider.setSettingEntries(null, null, null, entries);
// serialize entries
Document doc = XmlUtil.newDocument();
rootElement = XmlUtil.appendElement(doc, ELEM_TEST);
provider.serializeEntries(rootElement);
// check XML
String xmlString = XmlUtil.toString(doc);
assertTrue(xmlString.contains("path0"));
}
{
// create new provider
MockBuiltinSpecsDetectorExecutedFlag provider = new MockBuiltinSpecsDetectorExecutedFlag();
assertEquals(true, provider.isEmpty());
assertEquals(false, provider.isExecuted());
// load the XML to the new provider
provider.load(rootElement);
List<ICLanguageSettingEntry> entries = provider.getSettingEntries(null, null, null);
assertNotNull(entries);
assertTrue(entries.size() > 0);
assertEquals(new CIncludePathEntry("path0", 1), entries.get(0));
assertEquals(false, provider.isEmpty());
assertEquals(true, provider.isExecuted());
// clear the new provider
provider.clear();
assertEquals(true, provider.isEmpty());
assertEquals(false, provider.isExecuted());
}
{
// create new provider
MockBuiltinSpecsDetectorExecutedFlag provider = new MockBuiltinSpecsDetectorExecutedFlag();
assertEquals(true, provider.isEmpty());
assertEquals(false, provider.isExecuted());
// execute provider
provider.execute();
List<ICLanguageSettingEntry> entries = provider.getSettingEntries(null, null, null);
assertEquals(null, entries);
// executed provider should NOT appear as empty even with no entries set
assertEquals(false, provider.isEmpty());
assertEquals(true, provider.isExecuted());
}
}

View file

@ -708,16 +708,24 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti
super.loadAttributes(providerNode);
String consoleValue = XmlUtil.determineAttributeValue(providerNode, ATTR_CONSOLE);
if (consoleValue!=null)
if (consoleValue != null) {
isConsoleEnabled = Boolean.parseBoolean(consoleValue);
}
}
@Override
public void loadEntries(Element providerNode) {
super.loadEntries(providerNode);
// TODO - test case for that or maybe introduce "isExecuted" attribute in XML?
if (!isEmpty())
if (!isEmpty()) {
isExecuted = true;
}
}
@Override
public boolean isEmpty() {
// treat provider that has been executed as not empty
// to let "Clear" button to restart the provider
return !isExecuted && super.isEmpty();
}
@Override