void runNoTagKeysTest()
 {
   const QString testName = "runNoTagKeysTest";
   Settings conf = _getDefaultConfig();
   conf.set("language.tag.keys", QStringList());
   QString exceptionMsg("");
   try
   {
     _runTranslationTest(
       conf,
       testOutputRoot + "/" + testName + ".osm",
       testInputRoot + "/" + testName + "-gold.osm");
   }
   catch (const HootException& e)
   {
     exceptionMsg = e.what();
   }
   CPPUNIT_ASSERT(exceptionMsg.startsWith("No tag keys specified"));
 }
 void runNoSourceLangsTest()
 {
   const QString testName = "runNoSourceLangsTest";
   Settings conf = _getDefaultConfig();
   conf.set("language.translation.source.languages", QStringList());
   QString exceptionMsg("");
   try
   {
     _runTranslationTest(
       conf,
       testOutputRoot + "/" + testName + ".osm",
       testInputRoot + "/" + testName + "-gold.osm");
   }
   catch (const HootException& e)
   {
     exceptionMsg = e.what();
   }
   CPPUNIT_ASSERT_EQUAL(
     QString("No source languages populated.").toStdString(), exceptionMsg.toStdString());
 }
Ejemplo n.º 3
0
// Unload (a package)
bool ecConfigItem::Unload()
{
    bool rc=FALSE;
    CdlPackage package=dynamic_cast<CdlPackage>(GetCdlItem());
    wxASSERT(package);
    ecConfigToolDoc* pDoc=wxGetApp().GetConfigToolDoc();

    // Remove its objects from the view to prevent any painting problems
    ecTreeItemData* data = (ecTreeItemData*) wxGetApp().GetTreeCtrl()->GetItemData(GetTreeItem());
    wxASSERT(data);

    // I _think_ we should do this to stop 'this' from being deleted when we delete the item.
    // But, in that case, where do we delete this item?
    // Perhaps should store them in an array in the document, as per the MFC tool.
    data->SetConfigItem(NULL);

    wxGetApp().GetTreeCtrl()->Delete(GetTreeItem());

#if wxCHECK_VERSION(2, 6, 0)
    wxNode* node = pDoc->GetItems().GetFirst();
    while (node)
    {
        ecConfigItem* item = wxDynamicCast(node->GetData(), ecConfigItem);
        if (package == item->GetOwnerPackage() && item != this)
        {
            item->SetTreeItem(wxTreeItemId()); // Make sure we can't attempt to paint it
            item->SetCdlItem(NULL); // Make sure we can't access stale data
            delete item; // Delete the item itself
        }
        node = node->GetNext();
    }
#else
    wxNode* node = pDoc->GetItems().First();
    while (node)
    {
        ecConfigItem* item = wxDynamicCast(node->Data(), ecConfigItem);
        if (package == item->GetOwnerPackage() && item != this)
        {
            item->SetTreeItem(wxTreeItemId()); // Make sure we can't attempt to paint it
            item->SetCdlItem(NULL); // Make sure we can't access stale data
            delete item; // Delete the item itself
        }
        node = node->Next();
    }
#endif

    const wxString strMacroName(GetMacro());
    //TRACE (wxT("Unloading package %s\n"), strMacroName);
    try {
        pDoc->GetCdlConfig()->unload_package (package);
        rc=TRUE;
    }
    catch (CdlStringException exception) {
        wxString msg;
        wxString exceptionMsg(exception.get_message ().c_str ());
        msg.Printf(wxT("Error unloading package %s:\n\n%s"), (const wxChar*) strMacroName, (const wxChar*) exceptionMsg );
        wxMessageBox(msg);
    }
    catch (...) {
        wxString msg;
        msg.Printf(wxT("Error unloading package %s"), (const wxChar*) strMacroName);
        wxMessageBox(msg);
    }
    m_treeItem=wxTreeItemId();   // Make sure we can't attempt to paint it
    m_CdlItem=NULL; // Make sure we can't access stale data
    return rc;
}