]> git.saurik.com Git - wxWidgets.git/commitdiff
remove some tests from the console sample:
authorFrancesco Montorsi <f18m_cpp217828@yahoo.it>
Sun, 6 Jun 2010 14:21:27 +0000 (14:21 +0000)
committerFrancesco Montorsi <f18m_cpp217828@yahoo.it>
Sun, 6 Jun 2010 14:21:27 +0000 (14:21 +0000)
- wxLog already has a better cppunit test class
- wxLocale test in the console sample didn't work on Windows and wasn't very useful

move some tests from the console sample to CppUnit tests:
- wxPathList => PathListTestCase
- wxModule => ModuleTestCase

remove some tests about removed functions of wxMimeTypesManager

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64511 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

14 files changed:
samples/console/console.cpp
tests/Makefile.in
tests/makefile.bcc
tests/makefile.gcc
tests/makefile.vc
tests/makefile.wat
tests/misc/module.cpp [new file with mode: 0644]
tests/misc/pathlist.cpp [new file with mode: 0644]
tests/test.bkl
tests/test_test.dsp
tests/test_vc7_test.vcproj
tests/test_vc8_test.vcproj
tests/test_vc9_test.vcproj
tests/test_vc9_test_gui.vcproj

index 85ea17dc28d39fd4397923623fddce45d5ca3a35..91edcba41d6add24c28012c247709edf1616140b 100644 (file)
     #define TEST_FILE
     #define TEST_FILENAME
     #define TEST_FILETIME
-    #define TEST_INFO_FUNCTIONS
-    #define TEST_LOCALE
-    #define TEST_LOG
-    #define TEST_MIME
-    #define TEST_MODULE
-    #define TEST_PATHLIST
 #else // #if TEST_ALL
     #define TEST_DATETIME
     #define TEST_VOLUME
     #define TEST_FTP
     #define TEST_SNGLINST
     #define TEST_REGEX
+    #define TEST_INFO_FUNCTIONS
+    #define TEST_MIME
 #endif
 
 // some tests are interactive, define this to run them
@@ -766,306 +762,6 @@ static void TestFileSetTimes()
 
 #endif // TEST_FILETIME
 
-// ----------------------------------------------------------------------------
-// wxLocale
-// ----------------------------------------------------------------------------
-
-#ifdef TEST_LOCALE
-
-#include "wx/intl.h"
-#include "wx/utils.h"   // for wxSetEnv
-
-static wxLocale gs_localeDefault;
-    // NOTE: don't init it here as it needs a wxAppTraits object
-    //       and thus must be init-ed after creation of the wxInitializer
-    //       class in the main()
-
-// find the name of the language from its value
-static const wxChar *GetLangName(int lang)
-{
-    static const wxChar *languageNames[] =
-    {
-        wxT("DEFAULT"),
-        wxT("UNKNOWN"),
-        wxT("ABKHAZIAN"),
-        wxT("AFAR"),
-        wxT("AFRIKAANS"),
-        wxT("ALBANIAN"),
-        wxT("AMHARIC"),
-        wxT("ARABIC"),
-        wxT("ARABIC_ALGERIA"),
-        wxT("ARABIC_BAHRAIN"),
-        wxT("ARABIC_EGYPT"),
-        wxT("ARABIC_IRAQ"),
-        wxT("ARABIC_JORDAN"),
-        wxT("ARABIC_KUWAIT"),
-        wxT("ARABIC_LEBANON"),
-        wxT("ARABIC_LIBYA"),
-        wxT("ARABIC_MOROCCO"),
-        wxT("ARABIC_OMAN"),
-        wxT("ARABIC_QATAR"),
-        wxT("ARABIC_SAUDI_ARABIA"),
-        wxT("ARABIC_SUDAN"),
-        wxT("ARABIC_SYRIA"),
-        wxT("ARABIC_TUNISIA"),
-        wxT("ARABIC_UAE"),
-        wxT("ARABIC_YEMEN"),
-        wxT("ARMENIAN"),
-        wxT("ASSAMESE"),
-        wxT("AYMARA"),
-        wxT("AZERI"),
-        wxT("AZERI_CYRILLIC"),
-        wxT("AZERI_LATIN"),
-        wxT("BASHKIR"),
-        wxT("BASQUE"),
-        wxT("BELARUSIAN"),
-        wxT("BENGALI"),
-        wxT("BHUTANI"),
-        wxT("BIHARI"),
-        wxT("BISLAMA"),
-        wxT("BRETON"),
-        wxT("BULGARIAN"),
-        wxT("BURMESE"),
-        wxT("CAMBODIAN"),
-        wxT("CATALAN"),
-        wxT("CHINESE"),
-        wxT("CHINESE_SIMPLIFIED"),
-        wxT("CHINESE_TRADITIONAL"),
-        wxT("CHINESE_HONGKONG"),
-        wxT("CHINESE_MACAU"),
-        wxT("CHINESE_SINGAPORE"),
-        wxT("CHINESE_TAIWAN"),
-        wxT("CORSICAN"),
-        wxT("CROATIAN"),
-        wxT("CZECH"),
-        wxT("DANISH"),
-        wxT("DUTCH"),
-        wxT("DUTCH_BELGIAN"),
-        wxT("ENGLISH"),
-        wxT("ENGLISH_UK"),
-        wxT("ENGLISH_US"),
-        wxT("ENGLISH_AUSTRALIA"),
-        wxT("ENGLISH_BELIZE"),
-        wxT("ENGLISH_BOTSWANA"),
-        wxT("ENGLISH_CANADA"),
-        wxT("ENGLISH_CARIBBEAN"),
-        wxT("ENGLISH_DENMARK"),
-        wxT("ENGLISH_EIRE"),
-        wxT("ENGLISH_JAMAICA"),
-        wxT("ENGLISH_NEW_ZEALAND"),
-        wxT("ENGLISH_PHILIPPINES"),
-        wxT("ENGLISH_SOUTH_AFRICA"),
-        wxT("ENGLISH_TRINIDAD"),
-        wxT("ENGLISH_ZIMBABWE"),
-        wxT("ESPERANTO"),
-        wxT("ESTONIAN"),
-        wxT("FAEROESE"),
-        wxT("FARSI"),
-        wxT("FIJI"),
-        wxT("FINNISH"),
-        wxT("FRENCH"),
-        wxT("FRENCH_BELGIAN"),
-        wxT("FRENCH_CANADIAN"),
-        wxT("FRENCH_LUXEMBOURG"),
-        wxT("FRENCH_MONACO"),
-        wxT("FRENCH_SWISS"),
-        wxT("FRISIAN"),
-        wxT("GALICIAN"),
-        wxT("GEORGIAN"),
-        wxT("GERMAN"),
-        wxT("GERMAN_AUSTRIAN"),
-        wxT("GERMAN_BELGIUM"),
-        wxT("GERMAN_LIECHTENSTEIN"),
-        wxT("GERMAN_LUXEMBOURG"),
-        wxT("GERMAN_SWISS"),
-        wxT("GREEK"),
-        wxT("GREENLANDIC"),
-        wxT("GUARANI"),
-        wxT("GUJARATI"),
-        wxT("HAUSA"),
-        wxT("HEBREW"),
-        wxT("HINDI"),
-        wxT("HUNGARIAN"),
-        wxT("ICELANDIC"),
-        wxT("INDONESIAN"),
-        wxT("INTERLINGUA"),
-        wxT("INTERLINGUE"),
-        wxT("INUKTITUT"),
-        wxT("INUPIAK"),
-        wxT("IRISH"),
-        wxT("ITALIAN"),
-        wxT("ITALIAN_SWISS"),
-        wxT("JAPANESE"),
-        wxT("JAVANESE"),
-        wxT("KANNADA"),
-        wxT("KASHMIRI"),
-        wxT("KASHMIRI_INDIA"),
-        wxT("KAZAKH"),
-        wxT("KERNEWEK"),
-        wxT("KINYARWANDA"),
-        wxT("KIRGHIZ"),
-        wxT("KIRUNDI"),
-        wxT("KONKANI"),
-        wxT("KOREAN"),
-        wxT("KURDISH"),
-        wxT("LAOTHIAN"),
-        wxT("LATIN"),
-        wxT("LATVIAN"),
-        wxT("LINGALA"),
-        wxT("LITHUANIAN"),
-        wxT("MACEDONIAN"),
-        wxT("MALAGASY"),
-        wxT("MALAY"),
-        wxT("MALAYALAM"),
-        wxT("MALAY_BRUNEI_DARUSSALAM"),
-        wxT("MALAY_MALAYSIA"),
-        wxT("MALTESE"),
-        wxT("MANIPURI"),
-        wxT("MAORI"),
-        wxT("MARATHI"),
-        wxT("MOLDAVIAN"),
-        wxT("MONGOLIAN"),
-        wxT("NAURU"),
-        wxT("NEPALI"),
-        wxT("NEPALI_INDIA"),
-        wxT("NORWEGIAN_BOKMAL"),
-        wxT("NORWEGIAN_NYNORSK"),
-        wxT("OCCITAN"),
-        wxT("ORIYA"),
-        wxT("OROMO"),
-        wxT("PASHTO"),
-        wxT("POLISH"),
-        wxT("PORTUGUESE"),
-        wxT("PORTUGUESE_BRAZILIAN"),
-        wxT("PUNJABI"),
-        wxT("QUECHUA"),
-        wxT("RHAETO_ROMANCE"),
-        wxT("ROMANIAN"),
-        wxT("RUSSIAN"),
-        wxT("RUSSIAN_UKRAINE"),
-        wxT("SAMOAN"),
-        wxT("SANGHO"),
-        wxT("SANSKRIT"),
-        wxT("SCOTS_GAELIC"),
-        wxT("SERBIAN"),
-        wxT("SERBIAN_CYRILLIC"),
-        wxT("SERBIAN_LATIN"),
-        wxT("SERBO_CROATIAN"),
-        wxT("SESOTHO"),
-        wxT("SETSWANA"),
-        wxT("SHONA"),
-        wxT("SINDHI"),
-        wxT("SINHALESE"),
-        wxT("SISWATI"),
-        wxT("SLOVAK"),
-        wxT("SLOVENIAN"),
-        wxT("SOMALI"),
-        wxT("SPANISH"),
-        wxT("SPANISH_ARGENTINA"),
-        wxT("SPANISH_BOLIVIA"),
-        wxT("SPANISH_CHILE"),
-        wxT("SPANISH_COLOMBIA"),
-        wxT("SPANISH_COSTA_RICA"),
-        wxT("SPANISH_DOMINICAN_REPUBLIC"),
-        wxT("SPANISH_ECUADOR"),
-        wxT("SPANISH_EL_SALVADOR"),
-        wxT("SPANISH_GUATEMALA"),
-        wxT("SPANISH_HONDURAS"),
-        wxT("SPANISH_MEXICAN"),
-        wxT("SPANISH_MODERN"),
-        wxT("SPANISH_NICARAGUA"),
-        wxT("SPANISH_PANAMA"),
-        wxT("SPANISH_PARAGUAY"),
-        wxT("SPANISH_PERU"),
-        wxT("SPANISH_PUERTO_RICO"),
-        wxT("SPANISH_URUGUAY"),
-        wxT("SPANISH_US"),
-        wxT("SPANISH_VENEZUELA"),
-        wxT("SUNDANESE"),
-        wxT("SWAHILI"),
-        wxT("SWEDISH"),
-        wxT("SWEDISH_FINLAND"),
-        wxT("TAGALOG"),
-        wxT("TAJIK"),
-        wxT("TAMIL"),
-        wxT("TATAR"),
-        wxT("TELUGU"),
-        wxT("THAI"),
-        wxT("TIBETAN"),
-        wxT("TIGRINYA"),
-        wxT("TONGA"),
-        wxT("TSONGA"),
-        wxT("TURKISH"),
-        wxT("TURKMEN"),
-        wxT("TWI"),
-        wxT("UIGHUR"),
-        wxT("UKRAINIAN"),
-        wxT("URDU"),
-        wxT("URDU_INDIA"),
-        wxT("URDU_PAKISTAN"),
-        wxT("UZBEK"),
-        wxT("UZBEK_CYRILLIC"),
-        wxT("UZBEK_LATIN"),
-        wxT("VIETNAMESE"),
-        wxT("VOLAPUK"),
-        wxT("WELSH"),
-        wxT("WOLOF"),
-        wxT("XHOSA"),
-        wxT("YIDDISH"),
-        wxT("YORUBA"),
-        wxT("ZHUANG"),
-        wxT("ZULU"),
-    };
-
-    if ( (size_t)lang < WXSIZEOF(languageNames) )
-        return languageNames[lang];
-    else
-        return wxT("INVALID");
-}
-
-static void TestDefaultLang()
-{
-    wxPuts(wxT("*** Testing wxLocale::GetSystemLanguage ***"));
-
-    gs_localeDefault.Init(wxLANGUAGE_ENGLISH);
-
-    static const wxChar *langStrings[] =
-    {
-        NULL,               // system default
-        wxT("C"),
-        wxT("fr"),
-        wxT("fr_FR"),
-        wxT("en"),
-        wxT("en_GB"),
-        wxT("en_US"),
-        wxT("de_DE.iso88591"),
-        wxT("german"),
-        wxT("?"),            // invalid lang spec
-        wxT("klingonese"),   // I bet on some systems it does exist...
-    };
-
-    wxPrintf(wxT("The default system encoding is %s (%d)\n"),
-             wxLocale::GetSystemEncodingName().c_str(),
-             wxLocale::GetSystemEncoding());
-
-    for ( size_t n = 0; n < WXSIZEOF(langStrings); n++ )
-    {
-        const wxChar *langStr = langStrings[n];
-        if ( langStr )
-        {
-            // FIXME: this doesn't do anything at all under Windows, we need
-            //        to create a new wxLocale!
-            wxSetEnv(wxT("LC_ALL"), langStr);
-        }
-
-        int lang = gs_localeDefault.GetSystemLanguage();
-        wxPrintf(wxT("Locale for '%s' is %s.\n"),
-                 langStr ? langStr : wxT("system default"), GetLangName(lang));
-    }
-}
-
-#endif // TEST_LOCALE
-
 // ----------------------------------------------------------------------------
 // MIME types
 // ----------------------------------------------------------------------------
@@ -1093,7 +789,7 @@ static void TestMimeEnum()
             wxTheMimeTypesManager->GetFileTypeFromMimeType(mimetypes[n]);
         if ( !filetype )
         {
-            wxPrintf(wxT("nothing known about the filetype '%s'!\n"),
+            wxPrintf(wxT("   nothing known about the filetype '%s'!\n"),
                    mimetypes[n].c_str());
             continue;
         }
@@ -1111,7 +807,7 @@ static void TestMimeEnum()
             extsAll += exts[e];
         }
 
-        wxPrintf(wxT("\t%s: %s (%s)\n"),
+        wxPrintf(wxT("   %s: %s (%s)\n"),
                mimetypes[n].c_str(), desc.c_str(), extsAll.c_str());
     }
 
@@ -1152,7 +848,7 @@ static void TestMimeFilename()
             else
                 cmd = wxString(wxT('"')) + cmd + wxT('"');
 
-            wxPrintf(wxT("To open %s (%s) do %s.\n"),
+            wxPrintf(wxT("To open %s (%s) run:\n   %s\n"),
                      fname.c_str(), desc.c_str(), cmd.c_str());
 
             delete ft;
@@ -1162,35 +858,6 @@ static void TestMimeFilename()
     wxPuts(wxEmptyString);
 }
 
-// these tests were broken by wxMimeTypesManager changes, temporarily disabling
-#if 0
-
-static void TestMimeOverride()
-{
-    wxPuts(wxT("*** Testing wxMimeTypesManager additional files loading ***\n"));
-
-    static const wxChar *mailcap = wxT("/tmp/mailcap");
-    static const wxChar *mimetypes = wxT("/tmp/mime.types");
-
-    if ( wxFile::Exists(mailcap) )
-        wxPrintf(wxT("Loading mailcap from '%s': %s\n"),
-                 mailcap,
-                 wxTheMimeTypesManager->ReadMailcap(mailcap) ? wxT("ok") : wxT("ERROR"));
-    else
-        wxPrintf(wxT("WARN: mailcap file '%s' doesn't exist, not loaded.\n"),
-                 mailcap);
-
-    if ( wxFile::Exists(mimetypes) )
-        wxPrintf(wxT("Loading mime.types from '%s': %s\n"),
-                 mimetypes,
-                 wxTheMimeTypesManager->ReadMimeTypes(mimetypes) ? wxT("ok") : wxT("ERROR"));
-    else
-        wxPrintf(wxT("WARN: mime.types file '%s' doesn't exist, not loaded.\n"),
-                 mimetypes);
-
-    wxPuts(wxEmptyString);
-}
-
 static void TestMimeAssociate()
 {
     wxPuts(wxT("*** Testing creation of filetype association ***\n"));
@@ -1219,83 +886,8 @@ static void TestMimeAssociate()
     wxPuts(wxEmptyString);
 }
 
-#endif // 0
-
 #endif // TEST_MIME
 
-// ----------------------------------------------------------------------------
-// module dependencies feature
-// ----------------------------------------------------------------------------
-
-#ifdef TEST_MODULE
-
-#include "wx/module.h"
-
-class wxTestModule : public wxModule
-{
-protected:
-    virtual bool OnInit() { wxPrintf(wxT("Load module: %s\n"), GetClassInfo()->GetClassName()); return true; }
-    virtual void OnExit() { wxPrintf(wxT("Unload module: %s\n"), GetClassInfo()->GetClassName()); }
-};
-
-class wxTestModuleA : public wxTestModule
-{
-public:
-    wxTestModuleA();
-private:
-    DECLARE_DYNAMIC_CLASS(wxTestModuleA)
-};
-
-class wxTestModuleB : public wxTestModule
-{
-public:
-    wxTestModuleB();
-private:
-    DECLARE_DYNAMIC_CLASS(wxTestModuleB)
-};
-
-class wxTestModuleC : public wxTestModule
-{
-public:
-    wxTestModuleC();
-private:
-    DECLARE_DYNAMIC_CLASS(wxTestModuleC)
-};
-
-class wxTestModuleD : public wxTestModule
-{
-public:
-    wxTestModuleD();
-private:
-    DECLARE_DYNAMIC_CLASS(wxTestModuleD)
-};
-
-IMPLEMENT_DYNAMIC_CLASS(wxTestModuleC, wxModule)
-wxTestModuleC::wxTestModuleC()
-{
-    AddDependency(CLASSINFO(wxTestModuleD));
-}
-
-IMPLEMENT_DYNAMIC_CLASS(wxTestModuleA, wxModule)
-wxTestModuleA::wxTestModuleA()
-{
-    AddDependency(CLASSINFO(wxTestModuleB));
-    AddDependency(CLASSINFO(wxTestModuleD));
-}
-
-IMPLEMENT_DYNAMIC_CLASS(wxTestModuleD, wxModule)
-wxTestModuleD::wxTestModuleD()
-{
-}
-
-IMPLEMENT_DYNAMIC_CLASS(wxTestModuleB, wxModule)
-wxTestModuleB::wxTestModuleB()
-{
-    AddDependency(CLASSINFO(wxTestModuleD));
-    AddDependency(CLASSINFO(wxTestModuleC));
-}
-
-#endif // TEST_MODULE
 
 // ----------------------------------------------------------------------------
 // misc information functions
@@ -1313,12 +905,15 @@ static void TestDiskInfo()
     for ( ;; )
     {
         wxChar pathname[128];
-        wxPrintf(wxT("\nEnter a directory name: "));
+        wxPrintf(wxT("\nEnter a directory name (or 'quit' to escape): "));
         if ( !wxFgets(pathname, WXSIZEOF(pathname), stdin) )
             break;
 
         // kill the last '\n'
         pathname[wxStrlen(pathname) - 1] = 0;
+        
+        if (wxStrcmp(pathname, "quit") == 0)
+            break;
 
         wxLongLong total, free;
         if ( !wxGetDiskSpace(pathname, &total, &free) )
@@ -1384,37 +979,6 @@ static void TestUserInfo()
 
 #endif // TEST_INFO_FUNCTIONS
 
-// ----------------------------------------------------------------------------
-// path list
-// ----------------------------------------------------------------------------
-
-#ifdef TEST_PATHLIST
-
-#ifdef __UNIX__
-    #define CMD_IN_PATH wxT("ls")
-#else
-    #define CMD_IN_PATH wxT("command.com")
-#endif
-
-static void TestPathList()
-{
-    wxPuts(wxT("*** Testing wxPathList ***\n"));
-
-    wxPathList pathlist;
-    pathlist.AddEnvList(wxT("PATH"));
-    wxString path = pathlist.FindValidPath(CMD_IN_PATH);
-    if ( path.empty() )
-    {
-        wxPrintf(wxT("ERROR: command not found in the path.\n"));
-    }
-    else
-    {
-        wxPrintf(wxT("Command found in the path as '%s'.\n"), path.c_str());
-    }
-}
-
-#endif // TEST_PATHLIST
-
 // ----------------------------------------------------------------------------
 // regular expressions
 // ----------------------------------------------------------------------------
@@ -1430,13 +994,16 @@ static void TestRegExInteractive()
     for ( ;; )
     {
         wxChar pattern[128];
-        wxPrintf(wxT("\nEnter a pattern: "));
+        wxPrintf(wxT("\nEnter a pattern (or 'quit' to escape): "));
         if ( !wxFgets(pattern, WXSIZEOF(pattern), stdin) )
             break;
 
         // kill the last '\n'
         pattern[wxStrlen(pattern) - 1] = 0;
 
+        if (wxStrcmp(pattern, "quit") == 0)
+            break;
+            
         wxRegEx re;
         if ( !re.Compile(pattern) )
         {
@@ -1928,34 +1495,6 @@ int main(int argc, char **argv)
     TestEnvironment();
 #endif // TEST_ENVIRON
 
-#ifdef TEST_LOCALE
-    TestDefaultLang();
-#endif // TEST_LOCALE
-
-#ifdef TEST_LOG
-    wxPuts(wxT("*** Testing wxLog ***"));
-
-    wxString s;
-    for ( size_t n = 0; n < 8000; n++ )
-    {
-        s << (wxChar)(wxT('A') + (n % 26));
-    }
-
-    wxLogWarning(wxT("The length of the string is %lu"),
-                 (unsigned long)s.length());
-
-    wxString msg;
-    msg.Printf(wxT("A very very long message: '%s', the end!\n"), s.c_str());
-
-    // this one shouldn't be truncated
-    wxPrintf(msg);
-
-    // but this one will because log functions use fixed size buffer
-    // (note that it doesn't need '\n' at the end neither - will be added
-    //  by wxLog anyhow)
-    wxLogMessage(wxT("A very very long message 2: '%s', the end!"), s.c_str());
-#endif // TEST_LOG
-
 #ifdef TEST_FILE
     TestFileRead();
     TestTextFileRead();
@@ -1995,10 +1534,7 @@ int main(int argc, char **argv)
 #ifdef TEST_MIME
     //wxLog::AddTraceMask(wxT("mime"));
     TestMimeEnum();
-#if 0
-    TestMimeOverride();
     TestMimeAssociate();
-#endif
     TestMimeFilename();
 #endif // TEST_MIME
 
@@ -2012,10 +1548,6 @@ int main(int argc, char **argv)
     #endif
 #endif // TEST_INFO_FUNCTIONS
 
-#ifdef TEST_PATHLIST
-    TestPathList();
-#endif // TEST_PATHLIST
-
 #ifdef TEST_PRINTF
     TestPrintf();
 #endif // TEST_PRINTF
index 04af2f1b253df3ec5401bfca1c344b58ceae4b69..91ecf7e7d9a8093786f7ff437d006417c3629a98 100644 (file)
@@ -84,6 +84,8 @@ TEST_OBJECTS =  \
        test_convautotest.o \
        test_mbconvtest.o \
        test_misctests.o \
+       test_module.o \
+       test_pathlist.o \
        test_typeinfotest.o \
        test_ipc.o \
        test_socket.o \
@@ -449,6 +451,12 @@ test_mbconvtest.o: $(srcdir)/mbconv/mbconvtest.cpp $(TEST_ODEP)
 test_misctests.o: $(srcdir)/misc/misctests.cpp $(TEST_ODEP)
        $(CXXC) -c -o $@ $(TEST_CXXFLAGS) $(srcdir)/misc/misctests.cpp
 
+test_module.o: $(srcdir)/misc/module.cpp $(TEST_ODEP)
+       $(CXXC) -c -o $@ $(TEST_CXXFLAGS) $(srcdir)/misc/module.cpp
+
+test_pathlist.o: $(srcdir)/misc/pathlist.cpp $(TEST_ODEP)
+       $(CXXC) -c -o $@ $(TEST_CXXFLAGS) $(srcdir)/misc/pathlist.cpp
+
 test_typeinfotest.o: $(srcdir)/misc/typeinfotest.cpp $(TEST_ODEP)
        $(CXXC) -c -o $@ $(TEST_CXXFLAGS) $(srcdir)/misc/typeinfotest.cpp
 
index bfc3d4729f48bf9a0fb543acb9ad3bdcf6156819..67337b20150f70c0615a2864fca61ab9905845ae 100644 (file)
@@ -68,6 +68,8 @@ TEST_OBJECTS =  \
        $(OBJS)\test_convautotest.obj \\r
        $(OBJS)\test_mbconvtest.obj \\r
        $(OBJS)\test_misctests.obj \\r
+       $(OBJS)\test_module.obj \\r
+       $(OBJS)\test_pathlist.obj \\r
        $(OBJS)\test_typeinfotest.obj \\r
        $(OBJS)\test_ipc.obj \\r
        $(OBJS)\test_socket.obj \\r
@@ -491,6 +493,12 @@ $(OBJS)\test_mbconvtest.obj: .\mbconv\mbconvtest.cpp
 $(OBJS)\test_misctests.obj: .\misc\misctests.cpp\r
        $(CXX) -q -c -P -o$@ $(TEST_CXXFLAGS) .\misc\misctests.cpp\r
 \r
+$(OBJS)\test_module.obj: .\misc\module.cpp\r
+       $(CXX) -q -c -P -o$@ $(TEST_CXXFLAGS) .\misc\module.cpp\r
+\r
+$(OBJS)\test_pathlist.obj: .\misc\pathlist.cpp\r
+       $(CXX) -q -c -P -o$@ $(TEST_CXXFLAGS) .\misc\pathlist.cpp\r
+\r
 $(OBJS)\test_typeinfotest.obj: .\misc\typeinfotest.cpp\r
        $(CXX) -q -c -P -o$@ $(TEST_CXXFLAGS) .\misc\typeinfotest.cpp\r
 \r
index a6bff86db078e084faf373aa3511f775a87aba13..9edc69b7f34a5082bd10b173db78a9c7d3500c7d 100644 (file)
@@ -60,6 +60,8 @@ TEST_OBJECTS =  \
        $(OBJS)\test_convautotest.o \\r
        $(OBJS)\test_mbconvtest.o \\r
        $(OBJS)\test_misctests.o \\r
+       $(OBJS)\test_module.o \\r
+       $(OBJS)\test_pathlist.o \\r
        $(OBJS)\test_typeinfotest.o \\r
        $(OBJS)\test_ipc.o \\r
        $(OBJS)\test_socket.o \\r
@@ -472,6 +474,12 @@ $(OBJS)\test_mbconvtest.o: ./mbconv/mbconvtest.cpp
 $(OBJS)\test_misctests.o: ./misc/misctests.cpp\r
        $(CXX) -c -o $@ $(TEST_CXXFLAGS) $(CPPDEPS) $<\r
 \r
+$(OBJS)\test_module.o: ./misc/module.cpp\r
+       $(CXX) -c -o $@ $(TEST_CXXFLAGS) $(CPPDEPS) $<\r
+\r
+$(OBJS)\test_pathlist.o: ./misc/pathlist.cpp\r
+       $(CXX) -c -o $@ $(TEST_CXXFLAGS) $(CPPDEPS) $<\r
+\r
 $(OBJS)\test_typeinfotest.o: ./misc/typeinfotest.cpp\r
        $(CXX) -c -o $@ $(TEST_CXXFLAGS) $(CPPDEPS) $<\r
 \r
index ec487a111af6024470b81f1bf4ea0b5fcd2c6bc9..b485b46766d7f9165282d36950bc87ed493d230a 100644 (file)
@@ -62,6 +62,8 @@ TEST_OBJECTS =  \
        $(OBJS)\test_convautotest.obj \\r
        $(OBJS)\test_mbconvtest.obj \\r
        $(OBJS)\test_misctests.obj \\r
+       $(OBJS)\test_module.obj \\r
+       $(OBJS)\test_pathlist.obj \\r
        $(OBJS)\test_typeinfotest.obj \\r
        $(OBJS)\test_ipc.obj \\r
        $(OBJS)\test_socket.obj \\r
@@ -617,6 +619,12 @@ $(OBJS)\test_mbconvtest.obj: .\mbconv\mbconvtest.cpp
 $(OBJS)\test_misctests.obj: .\misc\misctests.cpp\r
        $(CXX) /c /nologo /TP /Fo$@ $(TEST_CXXFLAGS) .\misc\misctests.cpp\r
 \r
+$(OBJS)\test_module.obj: .\misc\module.cpp\r
+       $(CXX) /c /nologo /TP /Fo$@ $(TEST_CXXFLAGS) .\misc\module.cpp\r
+\r
+$(OBJS)\test_pathlist.obj: .\misc\pathlist.cpp\r
+       $(CXX) /c /nologo /TP /Fo$@ $(TEST_CXXFLAGS) .\misc\pathlist.cpp\r
+\r
 $(OBJS)\test_typeinfotest.obj: .\misc\typeinfotest.cpp\r
        $(CXX) /c /nologo /TP /Fo$@ $(TEST_CXXFLAGS) .\misc\typeinfotest.cpp\r
 \r
index c530ed3563899c8b3f03240ffad036a5427c849e..a6a6e50b25574eb789a2e180f10d2bca7e37fe73 100644 (file)
@@ -298,6 +298,8 @@ TEST_OBJECTS =  &
        $(OBJS)\test_convautotest.obj &\r
        $(OBJS)\test_mbconvtest.obj &\r
        $(OBJS)\test_misctests.obj &\r
+       $(OBJS)\test_module.obj &\r
+       $(OBJS)\test_pathlist.obj &\r
        $(OBJS)\test_typeinfotest.obj &\r
        $(OBJS)\test_ipc.obj &\r
        $(OBJS)\test_socket.obj &\r
@@ -529,6 +531,12 @@ $(OBJS)\test_mbconvtest.obj :  .AUTODEPEND .\mbconv\mbconvtest.cpp
 $(OBJS)\test_misctests.obj :  .AUTODEPEND .\misc\misctests.cpp\r
        $(CXX) -bt=nt -zq -fo=$^@ $(TEST_CXXFLAGS) $<\r
 \r
+$(OBJS)\test_module.obj :  .AUTODEPEND .\misc\module.cpp\r
+       $(CXX) -bt=nt -zq -fo=$^@ $(TEST_CXXFLAGS) $<\r
+\r
+$(OBJS)\test_pathlist.obj :  .AUTODEPEND .\misc\pathlist.cpp\r
+       $(CXX) -bt=nt -zq -fo=$^@ $(TEST_CXXFLAGS) $<\r
+\r
 $(OBJS)\test_typeinfotest.obj :  .AUTODEPEND .\misc\typeinfotest.cpp\r
        $(CXX) -bt=nt -zq -fo=$^@ $(TEST_CXXFLAGS) $<\r
 \r
diff --git a/tests/misc/module.cpp b/tests/misc/module.cpp
new file mode 100644 (file)
index 0000000..e41c713
--- /dev/null
@@ -0,0 +1,120 @@
+///////////////////////////////////////////////////////////////////////////////
+// Name:        tests/misc/module.cpp
+// Purpose:     Test wxModule
+// Author:      Francesco Montorsi (extracted from console sample)
+// Created:     2010-06-02
+// RCS-ID:      $Id$
+// Copyright:   (c) 2010 wxWidgets team
+///////////////////////////////////////////////////////////////////////////////
+
+// ----------------------------------------------------------------------------
+// headers
+// ----------------------------------------------------------------------------
+
+#include "testprec.h"
+
+#ifdef __BORLANDC__
+#   pragma hdrstop
+#endif
+
+#include "wx/module.h"
+
+// ----------------------------------------------------------------------------
+// test classes derived from wxModule
+// ----------------------------------------------------------------------------
+
+char g_strLoadOrder[256] = "\0";
+
+class Module : public wxModule
+{
+protected:
+    virtual bool OnInit() { wxStrcat(g_strLoadOrder, GetClassInfo()->GetClassName()); return true; }
+    virtual void OnExit() { }
+};
+
+class ModuleA : public Module
+{
+public:
+    ModuleA();
+private:
+    DECLARE_DYNAMIC_CLASS(ModuleA)
+};
+
+class ModuleB : public Module
+{
+public:
+    ModuleB();
+private:
+    DECLARE_DYNAMIC_CLASS(ModuleB)
+};
+
+class ModuleC : public Module
+{
+public:
+    ModuleC();
+private:
+    DECLARE_DYNAMIC_CLASS(ModuleC)
+};
+
+class ModuleD : public Module
+{
+public:
+    ModuleD();
+private:
+    DECLARE_DYNAMIC_CLASS(ModuleD)
+};
+
+IMPLEMENT_DYNAMIC_CLASS(ModuleA, wxModule)
+ModuleA::ModuleA()
+{
+    AddDependency(CLASSINFO(ModuleB));
+    AddDependency(CLASSINFO(ModuleD));
+}
+
+IMPLEMENT_DYNAMIC_CLASS(ModuleB, wxModule)
+ModuleB::ModuleB()
+{
+    AddDependency(CLASSINFO(ModuleC));
+    AddDependency(CLASSINFO(ModuleD));
+}
+
+IMPLEMENT_DYNAMIC_CLASS(ModuleC, wxModule)
+ModuleC::ModuleC()
+{
+    AddDependency(CLASSINFO(ModuleD));
+}
+
+IMPLEMENT_DYNAMIC_CLASS(ModuleD, wxModule)
+ModuleD::ModuleD()
+{
+}
+
+// ----------------------------------------------------------------------------
+// test class
+// ----------------------------------------------------------------------------
+
+class ModuleTestCase : public CppUnit::TestCase
+{
+public:
+    ModuleTestCase() { }
+
+private:
+    CPPUNIT_TEST_SUITE( ModuleTestCase );
+        CPPUNIT_TEST( LoadOrder );
+    CPPUNIT_TEST_SUITE_END();
+
+    void LoadOrder();
+    DECLARE_NO_COPY_CLASS(ModuleTestCase)
+};
+
+// register in the unnamed registry so that these tests are run by default
+CPPUNIT_TEST_SUITE_REGISTRATION( ModuleTestCase );
+
+// also include in it's own registry so that these tests can be run alone
+CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( ModuleTestCase, "ModuleTestCase" );
+
+void ModuleTestCase::LoadOrder()
+{
+    // module D is the only one with no dependencies and so should load as first (and so on):
+    CPPUNIT_ASSERT_EQUAL( "ModuleDModuleCModuleBModuleA", g_strLoadOrder );
+}
diff --git a/tests/misc/pathlist.cpp b/tests/misc/pathlist.cpp
new file mode 100644 (file)
index 0000000..cf54608
--- /dev/null
@@ -0,0 +1,62 @@
+///////////////////////////////////////////////////////////////////////////////
+// Name:        tests/misc/pathlist.cpp
+// Purpose:     Test wxPathList
+// Author:      Francesco Montorsi (extracted from console sample)
+// Created:     2010-06-02
+// RCS-ID:      $Id$
+// Copyright:   (c) 2010 wxWidgets team
+///////////////////////////////////////////////////////////////////////////////
+
+// ----------------------------------------------------------------------------
+// headers
+// ----------------------------------------------------------------------------
+
+#include "testprec.h"
+
+#ifdef __BORLANDC__
+#   pragma hdrstop
+#endif
+
+#include "wx/filefn.h"
+
+// ----------------------------------------------------------------------------
+// test class
+// ----------------------------------------------------------------------------
+
+class PathListTestCase : public CppUnit::TestCase
+{
+public:
+    PathListTestCase() { }
+
+private:
+    CPPUNIT_TEST_SUITE( PathListTestCase );
+        CPPUNIT_TEST( FindValidPath );
+    CPPUNIT_TEST_SUITE_END();
+
+    void FindValidPath();
+
+    DECLARE_NO_COPY_CLASS(PathListTestCase)
+};
+
+// register in the unnamed registry so that these tests are run by default
+CPPUNIT_TEST_SUITE_REGISTRATION( PathListTestCase );
+
+// also include in it's own registry so that these tests can be run alone
+CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( PathListTestCase, "PathListTestCase" );
+
+void PathListTestCase::FindValidPath()
+{
+#ifdef __UNIX__
+    #define CMD_IN_PATH wxT("ls")
+#else
+    #define CMD_IN_PATH wxT("cmd.exe")
+#endif
+
+    wxPathList pathlist;
+    pathlist.AddEnvList(wxT("PATH"));
+    
+    wxString path = pathlist.FindValidPath(CMD_IN_PATH);
+    CPPUNIT_ASSERT( !path.empty() );
+}
+
+
index d2b98b8df864ed12feb74e89d748d6205ed167a1..398d90a1e2d646390eb4585bc1eac7ada4f245ea 100644 (file)
@@ -59,6 +59,8 @@
             mbconv/convautotest.cpp
             mbconv/mbconvtest.cpp
             misc/misctests.cpp
+            misc/module.cpp
+            misc/pathlist.cpp
             misc/typeinfotest.cpp
             net/ipc.cpp
             net/socket.cpp
index 7810710c57bb6eb3473adbea3c0154da968fd8f1..919aa02151b3298c3d6de31cd46aaef57014adb5 100644 (file)
@@ -401,6 +401,14 @@ SOURCE=.\misc\misctests.cpp
 # End Source File\r
 # Begin Source File\r
 \r
+SOURCE=.\misc\module.cpp\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=.\misc\pathlist.cpp\r
+# End Source File\r
+# Begin Source File\r
+\r
 SOURCE=.\thread\queue.cpp\r
 # End Source File\r
 # Begin Source File\r
index 55ebe2fdf2eda25ae4bc3fe017852fe02d0bcaf7..22709850d694a40f3b9f26a2e8ff18062c62931d 100644 (file)
                        <File\r
                                RelativePath=".\misc\misctests.cpp">\r
                        </File>\r
+                       <File\r
+                               RelativePath=".\misc\module.cpp">\r
+                       </File>\r
+                       <File\r
+                               RelativePath=".\misc\pathlist.cpp">\r
+                       </File>\r
                        <File\r
                                RelativePath=".\thread\queue.cpp">\r
                        </File>\r
index 81a40fe0d7f55a992902d1d1c81684397fa032f9..b93b72186b4240eb2c1c86890da151bd516cf482 100644 (file)
                                RelativePath=".\misc\misctests.cpp"\r
                                >\r
                        </File>\r
+                       <File\r
+                               RelativePath=".\misc\module.cpp"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath=".\misc\pathlist.cpp"\r
+                               >\r
+                       </File>\r
                        <File\r
                                RelativePath=".\thread\queue.cpp"\r
                                >\r
index 910861d3fbfea9a28564414416b3cd8bda24b80c..81d73b4506033d6a4ca8b074b168d0318a6b1bd3 100644 (file)
                                RelativePath=".\misc\misctests.cpp"\r
                                >\r
                        </File>\r
+                       <File\r
+                               RelativePath=".\misc\module.cpp"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath=".\misc\pathlist.cpp"\r
+                               >\r
+                       </File>\r
                        <File\r
                                RelativePath=".\thread\queue.cpp"\r
                                >\r
index 875693c515dc749ecd61fee09b253f1ef4a2e0e7..207f762fa992463e9c9672e0b27c065e23d8c3f8 100644 (file)
@@ -1,10 +1,16 @@
 <?xml version="1.0" encoding="Windows-1252"?>\r
+<!--\r
+\r
+  This project was generated by\r
+  Bakefile 0.2.8 (http://www.bakefile.org)\r
+  Do not modify, all changes will be overwritten!\r
+\r
+-->\r
 <VisualStudioProject\r
        ProjectType="Visual C++"\r
-       Version="9,00"\r
+       Version="9.00"\r
        Name="test_gui"\r
        ProjectGUID="{9BB295D9-A6AA-510D-AA0D-9375B5D91025}"\r
-       TargetFrameworkVersion="0"\r
        >\r
        <Platforms>\r
                <Platform\r
@@ -12,6 +18,7 @@
                />\r
        </Platforms>\r
        <ToolFiles>\r
+               \r
        </ToolFiles>\r
        <Configurations>\r
                <Configuration\r
@@ -44,7 +51,7 @@
                                Name="VCCLCompilerTool"\r
                                AdditionalOptions="/MP"\r
                                Optimization="0"\r
-                               AdditionalIncludeDirectories=".\..\lib\vc_lib\mswud;.\..\include;.;.\..\samples;f:\cppunit\include"\r
+                               AdditionalIncludeDirectories=".\..\lib\vc_lib\mswud;.\..\include;.;.\..\samples"\r
                                PreprocessorDefinitions="WIN32;_DEBUG;__WXMSW__;_UNICODE;NOPCH;_CONSOLE"\r
                                ExceptionHandling="1"\r
                                BasicRuntimeChecks="3"\r
@@ -79,7 +86,7 @@
                                OutputFile="vc_mswud\test_gui.exe"\r
                                LinkIncremental="2"\r
                                SuppressStartupBanner="true"\r
-                               AdditionalLibraryDirectories=".\..\lib\vc_lib;f:\cppunit\lib"\r
+                               AdditionalLibraryDirectories=".\..\lib\vc_lib"\r
                                GenerateManifest="true"\r
                                GenerateDebugInformation="true"\r
                                ProgramDatabaseFile="vc_mswud\test_gui.pdb"\r
                        />\r
                        <Tool\r
                                Name="VCBscMakeTool"\r
-                               SuppressStartupBanner="true"\r
                                OutputFile="vc_mswud\test_vc9_test_gui.bsc"\r
+                               SuppressStartupBanner="true"\r
                        />\r
                        <Tool\r
                                Name="VCFxCopTool"\r
                                GenerateDebugInformation="true"\r
                                ProgramDatabaseFile="vc_mswu\test_gui.pdb"\r
                                SubSystem="1"\r
+                               TargetMachine="1"\r
                                OptimizeReferences="2"\r
                                EnableCOMDATFolding="2"\r
-                               TargetMachine="1"\r
                        />\r
                        <Tool\r
                                Name="VCALinkTool"\r
                        />\r
                        <Tool\r
                                Name="VCBscMakeTool"\r
-                               SuppressStartupBanner="true"\r
                                OutputFile="vc_mswu\test_vc9_test_gui.bsc"\r
+                               SuppressStartupBanner="true"\r
                        />\r
                        <Tool\r
                                Name="VCFxCopTool"\r
                        />\r
                        <Tool\r
                                Name="VCBscMakeTool"\r
-                               SuppressStartupBanner="true"\r
                                OutputFile="vc_mswunivud\test_vc9_test_gui.bsc"\r
+                               SuppressStartupBanner="true"\r
                        />\r
                        <Tool\r
                                Name="VCFxCopTool"\r
                                GenerateDebugInformation="true"\r
                                ProgramDatabaseFile="vc_mswunivu\test_gui.pdb"\r
                                SubSystem="1"\r
+                               TargetMachine="1"\r
                                OptimizeReferences="2"\r
                                EnableCOMDATFolding="2"\r
-                               TargetMachine="1"\r
                        />\r
                        <Tool\r
                                Name="VCALinkTool"\r
                        />\r
                        <Tool\r
                                Name="VCBscMakeTool"\r
-                               SuppressStartupBanner="true"\r
                                OutputFile="vc_mswunivu\test_vc9_test_gui.bsc"\r
+                               SuppressStartupBanner="true"\r
                        />\r
                        <Tool\r
                                Name="VCFxCopTool"\r
                        />\r
                        <Tool\r
                                Name="VCBscMakeTool"\r
-                               SuppressStartupBanner="true"\r
                                OutputFile="vc_mswuddll\test_vc9_test_gui.bsc"\r
+                               SuppressStartupBanner="true"\r
                        />\r
                        <Tool\r
                                Name="VCFxCopTool"\r
                                GenerateDebugInformation="true"\r
                                ProgramDatabaseFile="vc_mswudll\test_gui.pdb"\r
                                SubSystem="1"\r
+                               TargetMachine="1"\r
                                OptimizeReferences="2"\r
                                EnableCOMDATFolding="2"\r
-                               TargetMachine="1"\r
                        />\r
                        <Tool\r
                                Name="VCALinkTool"\r
                        />\r
                        <Tool\r
                                Name="VCBscMakeTool"\r
-                               SuppressStartupBanner="true"\r
                                OutputFile="vc_mswudll\test_vc9_test_gui.bsc"\r
+                               SuppressStartupBanner="true"\r
                        />\r
                        <Tool\r
                                Name="VCFxCopTool"\r
                        />\r
                        <Tool\r
                                Name="VCBscMakeTool"\r
-                               SuppressStartupBanner="true"\r
                                OutputFile="vc_mswunivuddll\test_vc9_test_gui.bsc"\r
+                               SuppressStartupBanner="true"\r
                        />\r
                        <Tool\r
                                Name="VCFxCopTool"\r
                                GenerateDebugInformation="true"\r
                                ProgramDatabaseFile="vc_mswunivudll\test_gui.pdb"\r
                                SubSystem="1"\r
+                               TargetMachine="1"\r
                                OptimizeReferences="2"\r
                                EnableCOMDATFolding="2"\r
-                               TargetMachine="1"\r
                        />\r
                        <Tool\r
                                Name="VCALinkTool"\r
                        />\r
                        <Tool\r
                                Name="VCBscMakeTool"\r
-                               SuppressStartupBanner="true"\r
                                OutputFile="vc_mswunivudll\test_vc9_test_gui.bsc"\r
+                               SuppressStartupBanner="true"\r
                        />\r
                        <Tool\r
                                Name="VCFxCopTool"\r
                </Configuration>\r
        </Configurations>\r
        <References>\r
+               \r
        </References>\r
        <Files>\r
                <Filter\r
                </Filter>\r
        </Files>\r
        <Globals>\r
+               \r
        </Globals>\r
 </VisualStudioProject>\r
+\r