2009-12-05 22:26:48 +01:00
|
|
|
'''
|
|
|
|
Some diverse tests covering functionality in the GUI Interface class.
|
|
|
|
'''
|
2009-11-03 22:14:19 +01:00
|
|
|
import unittest
|
|
|
|
|
2018-11-11 01:31:50 +01:00
|
|
|
from test import lib
|
2009-11-03 22:14:19 +01:00
|
|
|
lib.setup_env()
|
|
|
|
|
2017-08-12 02:39:55 +02:00
|
|
|
from gajim.common import logging_helpers
|
2009-11-03 22:14:19 +01:00
|
|
|
logging_helpers.set_quiet()
|
|
|
|
|
2017-08-13 13:18:56 +02:00
|
|
|
from gajim.common import app
|
2009-11-05 09:06:46 +01:00
|
|
|
|
2017-08-12 02:39:55 +02:00
|
|
|
from gajim.gui_interface import Interface
|
2009-11-03 22:14:19 +01:00
|
|
|
|
2017-09-15 15:11:55 +02:00
|
|
|
from gi.repository import GLib
|
|
|
|
|
2009-12-05 22:26:48 +01:00
|
|
|
class TestInterface(unittest.TestCase):
|
2009-11-03 22:14:19 +01:00
|
|
|
|
2010-02-08 15:08:40 +01:00
|
|
|
def test_instantiation(self):
|
|
|
|
''' Test that we can proper initialize and do not fail on globals '''
|
2017-09-15 15:11:55 +02:00
|
|
|
def close_app():
|
|
|
|
app.app.quit()
|
|
|
|
GLib.idle_add(close_app)
|
2017-08-13 13:18:56 +02:00
|
|
|
app.app.run()
|
2010-02-08 15:08:40 +01:00
|
|
|
|
|
|
|
def test_links_regexp_entire(self):
|
|
|
|
sut = Interface()
|
|
|
|
def assert_matches_all(str_):
|
|
|
|
m = sut.basic_pattern_re.match(str_)
|
|
|
|
|
|
|
|
# the match should equal the string
|
|
|
|
str_span = (0, len(str_))
|
|
|
|
self.assertEqual(m.span(), str_span)
|
|
|
|
|
|
|
|
# these entire strings should be parsed as links
|
|
|
|
assert_matches_all('http://google.com/')
|
|
|
|
assert_matches_all('http://google.com')
|
|
|
|
assert_matches_all('http://www.google.ca/search?q=xmpp')
|
|
|
|
|
|
|
|
assert_matches_all('http://tools.ietf.org/html/draft-saintandre-rfc3920bis-05#section-12.3')
|
|
|
|
|
|
|
|
assert_matches_all('http://en.wikipedia.org/wiki/Protocol_(computing)')
|
|
|
|
assert_matches_all(
|
|
|
|
'http://en.wikipedia.org/wiki/Protocol_%28computing%29')
|
|
|
|
|
|
|
|
assert_matches_all('mailto:test@example.org')
|
|
|
|
|
|
|
|
assert_matches_all('xmpp:example-node@example.com')
|
|
|
|
assert_matches_all('xmpp:example-node@example.com/some-resource')
|
|
|
|
assert_matches_all('xmpp:example-node@example.com?message')
|
|
|
|
assert_matches_all('xmpp://guest@example.com/support@example.com?message')
|
2009-11-03 22:14:19 +01:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2010-02-08 15:08:40 +01:00
|
|
|
unittest.main()
|