mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-28 04:31:06 +00:00
Fix filtered range transformation (finally!)
This commit is contained in:
parent
dabf571006
commit
93a1da46c9
2 changed files with 72 additions and 6 deletions
|
@ -612,13 +612,14 @@ class FilteredLogModel (FilteredLogModelBase):
|
|||
if super_start_offset > 0:
|
||||
if not self.super_index:
|
||||
# Identity; there are no filters.
|
||||
start_offset = super_start_offset
|
||||
n_filtered = super_start_offset
|
||||
start_offset = n_filtered
|
||||
else:
|
||||
n_filtered = self.__filtered_indices_in_range (old_start, super_start - 1)
|
||||
assert n_filtered > 0
|
||||
n_filtered = self.__filtered_indices_in_range (0, super_start_offset - 1)
|
||||
start_offset = n_filtered
|
||||
|
||||
self.__remove_range (0, start_offset - 1)
|
||||
if n_filtered > 0:
|
||||
self.__remove_range (0, start_offset - 1)
|
||||
|
||||
from_super = self.from_super_index
|
||||
for i in self.super_index:
|
||||
|
|
|
@ -146,6 +146,71 @@ class TestDynamicFilter (TestCase):
|
|||
for i in range (11)],
|
||||
range (5, 16))
|
||||
|
||||
def test_filtered_range_refilter_skip (self):
|
||||
|
||||
full_model = Model ()
|
||||
ranged_model = GUI.RangeFilteredLogModel (full_model)
|
||||
# FIXME: Call to .reset should not be needed.
|
||||
ranged_model.reset ()
|
||||
filtered_model = GUI.FilteredLogModel (ranged_model)
|
||||
|
||||
row_list = self.__row_list
|
||||
|
||||
filtered_model.add_filter (GUI.CategoryFilter ("EVEN"),
|
||||
Common.Data.DefaultDispatcher ())
|
||||
self.__dump_model (filtered_model, "filtered")
|
||||
|
||||
self.assertEquals (row_list (filtered_model), range (1, 20, 2))
|
||||
self.assertEquals ([filtered_model.line_index_from_super (i)
|
||||
for i in range (1, 20, 2)],
|
||||
range (10))
|
||||
self.assertEquals ([filtered_model.line_index_to_super (i)
|
||||
for i in range (10)],
|
||||
range (1, 20, 2))
|
||||
self.assertEquals ([filtered_model.line_index_from_top (i)
|
||||
for i in range (1, 20, 2)],
|
||||
range (10))
|
||||
self.assertEquals ([filtered_model.line_index_to_top (i)
|
||||
for i in range (10)],
|
||||
range (1, 20, 2))
|
||||
|
||||
ranged_model.set_range (1, 19)
|
||||
self.__dump_model (ranged_model, "ranged (1, 19)")
|
||||
filtered_model.super_model_changed_range ()
|
||||
self.__dump_model (filtered_model, "filtered range")
|
||||
|
||||
self.assertEquals ([filtered_model.line_index_from_super (i)
|
||||
for i in range (0, 19, 2)],
|
||||
range (10))
|
||||
self.assertEquals ([filtered_model.line_index_to_super (i)
|
||||
for i in range (10)],
|
||||
range (0, 19, 2))
|
||||
self.assertEquals ([filtered_model.line_index_from_top (i)
|
||||
for i in range (1, 20, 2)],
|
||||
range (10))
|
||||
self.assertEquals ([filtered_model.line_index_to_top (i)
|
||||
for i in range (10)],
|
||||
range (1, 20, 2))
|
||||
|
||||
ranged_model.set_range (2, 19)
|
||||
self.__dump_model (ranged_model, "ranged (2, 19)")
|
||||
filtered_model.super_model_changed_range ()
|
||||
self.__dump_model (filtered_model, "filtered range")
|
||||
|
||||
self.assertEquals (row_list (filtered_model), range (3, 20, 2))
|
||||
self.assertEquals ([filtered_model.line_index_from_super (i)
|
||||
for i in range (1, 18, 2)],
|
||||
range (9))
|
||||
self.assertEquals ([filtered_model.line_index_to_super (i)
|
||||
for i in range (9)],
|
||||
range (1, 18, 2))
|
||||
self.assertEquals ([filtered_model.line_index_from_top (i)
|
||||
for i in range (3, 20, 2)],
|
||||
range (9))
|
||||
self.assertEquals ([filtered_model.line_index_to_top (i)
|
||||
for i in range (9)],
|
||||
range (3, 20, 2))
|
||||
|
||||
def test_filtered_range_refilter (self):
|
||||
|
||||
full_model = Model ()
|
||||
|
@ -335,7 +400,7 @@ class TestDynamicFilter (TestCase):
|
|||
|
||||
if not hasattr (model, "super_model"):
|
||||
# Top model.
|
||||
print "\t|%s|" % ("|".join ([str (i).rjust (2) for i in self.__row_list (model)]),),
|
||||
print "\t(%s)" % ("|".join ([str (i).rjust (2) for i in self.__row_list (model)]),),
|
||||
else:
|
||||
top_model = model.super_model
|
||||
if hasattr (top_model, "super_model"):
|
||||
|
@ -345,7 +410,7 @@ class TestDynamicFilter (TestCase):
|
|||
output = [" "] * len (top_indices)
|
||||
for i, position in enumerate (positions):
|
||||
output[position] = str (i).rjust (2)
|
||||
print "\t|%s|" % ("|".join (output),),
|
||||
print "\t(%s)" % ("|".join (output),),
|
||||
|
||||
if comment is None:
|
||||
print
|
||||
|
|
Loading…
Reference in a new issue