/b-gtk/fix-viz

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/b-gtk/fix-viz

« back to all changes in this revision

Viewing changes to tests/test_diff.py

  • Committer: Curtis Hovey
  • Date: 2012-02-03 19:49:55 UTC
  • mto: This revision was merged to the branch mainline in revision 773.
  • Revision ID: sinzui.is@verizon.net-20120203194955-69jvr0mgu8igea0i
Updated bzr-notify to gtk3.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
from cStringIO import StringIO
19
19
import os
20
20
 
 
21
from gi.repository import Gtk
 
22
 
21
23
from bzrlib import (
22
24
    conflicts,
23
25
    errors,
24
26
    tests,
25
27
    )
 
28
try:
 
29
    from bzrlib.tests.features import UnicodeFilenameFeature
 
30
except ImportError: # bzr < 2.5
 
31
    from bzrlib.tests import UnicodeFilenameFeature
26
32
from bzrlib.merge_directive import MergeDirective2
27
33
 
28
34
from bzrlib.plugins.gtk.diff import (
29
35
    DiffController,
30
36
    DiffView,
 
37
    DiffWidget,
31
38
    iter_changes_to_status,
32
39
    MergeDirectiveController,
33
40
    )
 
41
from bzrlib.plugins.gtk.tests import MockMethod
 
42
 
 
43
 
34
44
eg_diff = """\
35
45
=== modified file 'tests/test_diff.py'
36
46
--- tests/test_diff.py  2008-03-11 13:18:28 +0000
73
83
class TestDiffView(tests.TestCaseWithTransport):
74
84
 
75
85
    def test_unicode(self):
76
 
        self.requireFeature(tests.UnicodeFilenameFeature)
 
86
        self.requireFeature(UnicodeFilenameFeature)
77
87
 
78
88
        tree = self.make_branch_and_tree('tree')
79
89
        self.build_tree([u'tree/\u03a9'])
84
94
        view.show_diff(None)
85
95
        buf = view.buffer
86
96
        start, end = buf.get_bounds()
87
 
        text = buf.get_text(start, end)
 
97
        text = buf.get_text(start, end, True)
88
98
        self.assertContainsRe(text,
89
99
            "=== added file '\xce\xa9'\n"
90
100
            '--- .*\t1970-01-01 00:00:00 \\+0000\n'
95
105
            )
96
106
 
97
107
 
 
108
 
 
109
class FakeDiffWidget(DiffWidget):
 
110
 
 
111
    SHOW_WIDGETS = False
 
112
 
 
113
 
 
114
class TestDiffWidget(tests.TestCaseWithTransport):
 
115
 
 
116
    def test_treeview_cursor_cb(self):
 
117
        widget = FakeDiffWidget()
 
118
        widget.set_diff_text_sections(
 
119
            [('', None, 'patch1'), ('a', 'a', 'patch2')])
 
120
        widget.treeview.set_cursor(Gtk.TreePath(path=1), None, False)
 
121
        widget._treeview_cursor_cb(None)
 
122
        self.assertTrue('patch2', widget.diff_view.buffer.props.text)
 
123
 
 
124
    def test_treeview_cursor_cb_with_destroyed_treeview(self):
 
125
        widget = FakeDiffWidget()
 
126
        widget.set_diff_text_sections(
 
127
            [('', None, 'patch1'), ('a', 'a', 'patch2')])
 
128
        MockMethod.bind(self, widget.diff_view, 'show_diff')
 
129
        widget.treeview.destroy()
 
130
        widget._treeview_cursor_cb(None)
 
131
        self.assertFalse(widget.diff_view.show_diff.called)
 
132
 
 
133
 
98
134
class MockDiffWidget(object):
99
135
 
100
136
    def set_diff_text_sections(self, sections):