summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRené Stadler <mail@renestadler.de>2008-01-21 11:15:42 +0200
committerRené Stadler <mail@renestadler.de>2008-01-21 11:15:42 +0200
commitcdd7b10c9aa23bb7b1ffe6532205305828617f68 (patch)
treec9ed2964632b8d1cb3b9b479fb588e794642ae6c
parent1f2c6d0640a14adca86b71a2563f30da7239159b (diff)
Fix filtered range transformation (finally!)
-rw-r--r--GstDebugViewer/GUI.py9
-rwxr-xr-xtests/test_models.py69
2 files changed, 72 insertions, 6 deletions
diff --git a/GstDebugViewer/GUI.py b/GstDebugViewer/GUI.py
index 28309b4..90bc258 100644
--- a/GstDebugViewer/GUI.py
+++ b/GstDebugViewer/GUI.py
@@ -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:
diff --git a/tests/test_models.py b/tests/test_models.py
index b9e5bed..9a23f77 100755
--- a/tests/test_models.py
+++ b/tests/test_models.py
@@ -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