/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 18:59:38 UTC
  • mto: This revision was merged to the branch mainline in revision 773.
  • Revision ID: sinzui.is@verizon.net-20120203185938-ra0jl3b1rn69gmmz
Verify the menu and its items are created.

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,
32
34
from bzrlib.plugins.gtk.diff import (
33
35
    DiffController,
34
36
    DiffView,
 
37
    DiffWidget,
35
38
    iter_changes_to_status,
36
39
    MergeDirectiveController,
37
40
    )
 
41
from bzrlib.plugins.gtk.tests import MockMethod
 
42
 
 
43
 
38
44
eg_diff = """\
39
45
=== modified file 'tests/test_diff.py'
40
46
--- tests/test_diff.py  2008-03-11 13:18:28 +0000
99
105
            )
100
106
 
101
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
 
102
134
class MockDiffWidget(object):
103
135
 
104
136
    def set_diff_text_sections(self, sections):