test_besttextview.py :  » IDE » PIDA » pida-0.6beta3 » tests » ui » Python Open Source

Home
Python Open Source
1.3.1.2 Python
2.Ajax
3.Aspect Oriented
4.Blog
5.Build
6.Business Application
7.Chart Report
8.Content Management Systems
9.Cryptographic
10.Database
11.Development
12.Editor
13.Email
14.ERP
15.Game 2D 3D
16.GIS
17.GUI
18.IDE
19.Installer
20.IRC
21.Issue Tracker
22.Language Interface
23.Log
24.Math
25.Media Sound Audio
26.Mobile
27.Network
28.Parser
29.PDF
30.Project Management
31.RSS
32.Search
33.Security
34.Template Engines
35.Test
36.UML
37.USB Serial
38.Web Frameworks
39.Web Server
40.Web Services
41.Web Unit
42.Wiki
43.Windows
44.XML
Python Open Source » IDE » PIDA 
PIDA » pida 0.6beta3 » tests » ui » test_besttextview.py

import gtk
import gtk.gdk

from pida.services.language import DOCTYPES
from pida.utils.testing import refresh_gui


class BaseTests(object):

    def setUp(self):
        self.textview = self.TextView()

    def setup_method(self, method):
        self.setUp()


    def test_setget_text(self):
        txt = 'some text to test with\nwith two lines'
        self.textview.get_buffer().set_text(txt)
        print txt
        assert txt==self.textview.get_buffer().props.text
        txt = u'some \u1234text to test \u4321 with\nwith two lines'
        self.textview.get_buffer().set_text(txt)
        print txt
        assert txt==self.textview.get_buffer().props.text

    def test_sethighligting(self):
        assert self.textview.get_doctype() is None

        self.textview.set_doctype(DOCTYPES['Python'])
        assert self.textview.get_doctype() == DOCTYPES['Python']
        #if self.textview.has_syntax_highlighting:
        #    self.assertNotEqual(self.textview.get_lang(), None)

    def test_readonly(self):
        txt = 'some text to test with\nwith two lines'
        win = gtk.Window()
        win.add(self.textview)
        win.show_all()
        for do in (True, False):
            self.textview.get_buffer().set_text(txt)
            self.textview.set_editable(do)

            event = gtk.gdk.Event(gtk.gdk.KEY_PRESS)
            event.keyval = gtk.keysyms.a
            #event.state = gtk.gdk.SHIFT_MASK
            event.window = self.textview.window#self.textview.get_to

            #widget.emit('key-press-event', event) 

            event = gtk.gdk.Event(gtk.gdk.KEY_PRESS)
            event.keyval = gtk.keysyms.a

            buffer_ = self.textview.get_buffer()
            buffer_.place_cursor(buffer_.get_iter_at_offset(0))
            #self.textview.do_event(self.textview, event)
            self.textview.emit('key-press-event', event) 
            refresh_gui()
            if do:
                assert self.textview.get_buffer().props.text == "a%s" %txt
            else:
                assert self.textview.get_buffer().props.text == txt
        win.destroy()
try:
    from pida.ui.besttextview.mooview import MooTextView
    
    class TestMoo(ViewTest):
        TextView = MooTextView
    
except ImportError:
    #FIXME: how to report skipped tests properly ???
    print "can't import moo, skipping MooTextView tests"

try:
    from pida.ui.besttextview.sourceview import SourceTextView
    
    class TestSourceView(BaseTests):
        TextView = SourceTextView
    
except ImportError:
    #FIXME: how to report skipped tests properly ???
    print "can't import gtksourceview, skipping SourceView tests"


from pida.ui.besttextview.textview import SimpleTextView

class TestSimpleText(BaseTests):
    TextView = SimpleTextView

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.