#This file was originally generated by NovalIDE's unitest wizard
import unittest
from noval.tool.syntax import lang,syndata,synglob,syntax
import noval.util.appdirs as appdirs
import os

class TestGlobalFunction(unittest.TestCase):
    def setUp(self):
        pass
    def tearDown(self):
        pass

    def testGetDescriptionFromId(self):
        print lang.GetDescriptionFromId(lang.ID_LANG_TXT)
        print lang.GetDescriptionFromId(lang.ID_LANG_C)
        print lang.GetDescriptionFromId(lang.ID_LANG_CPP)
        print lang.GetDescriptionFromId(lang.ID_LANG_PYTHON)
        
    def testLoadThemeSheet(self):
        style_sheet_path = os.path.join(appdirs.GetAppDataDirLocation(),"styles")
        theme_style_sheet = os.path.join(style_sheet_path,"BlackBoard.ess")
        syntax.LexerManager().LoadThemeSheet(theme_style_sheet)
        for name in  syntax.LexerManager.THEMES:
            themes = syntax.LexerManager.THEMES[name]
            for style in themes:
                print style,themes[style],"------------------"
        print syntax.LexerManager.GetStyleSheet("Default")

    def testGetIdFromDescription(self):
        synglob.LexerFactory().CreateLexers()
        print syntax.LexerManager().Lexers
        print syntax.LexerManager().GetLangIdFromExt(".py")
        print syntax.LexerManager().GetLangIdFromExt("py")
        print syntax.LexerManager().GetLangIdFromExt("PY")
        print syntax.LexerManager().GetLangIdFromExt("PYW")
        lang_id = syntax.LexerManager().GetLangIdFromExt("pyw")
        print lang_id,syntax.LexerManager().GetLexer(lang_id)
        print syntax.LexerManager().GetLangIdFromExt("ttt")
        print syntax.LexerManager().GetLangIdFromExt("js")
        print syntax.LexerManager().GetLangIdFromExt("cpp")
        print syntax.LexerManager().GetLangIdFromExt("c")
        print syntax.LexerManager().GetLangIdFromExt("css")
        print syntax.LexerManager().GetLangIdFromExt("")
        print syntax.LexerManager().GetLangIdFromExt("txt")


if __name__ == "__main__":
    unittest.main()
