[meld] Add tests for syncpoint calculations
- From: Kai Willadsen <kaiw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [meld] Add tests for syncpoint calculations
- Date: Tue, 25 Apr 2017 01:57:49 +0000 (UTC)
commit 8e6d580221fccf65887fe517f785c43097b30cfd
Author: Kai Willadsen <kai willadsen gmail com>
Date: Tue Apr 25 11:45:47 2017 +1000
Add tests for syncpoint calculations
test/test_misc.py | 33 ++++++++++++++++++++++++++++++++-
1 files changed, 32 insertions(+), 1 deletions(-)
---
diff --git a/test/test_misc.py b/test/test_misc.py
index 01b5b43..661ee5c 100644
--- a/test/test_misc.py
+++ b/test/test_misc.py
@@ -1,6 +1,6 @@
import pytest
-from meld.misc import merge_intervals
+from meld.misc import calc_syncpoint, merge_intervals
@pytest.mark.parametrize("intervals, expected", [
@@ -20,3 +20,34 @@ from meld.misc import merge_intervals
def test_merge_intervals(intervals, expected):
merged = merge_intervals(intervals)
assert merged == expected
+
+
+@pytest.mark.parametrize("value, page_size, lower, upper, expected", [
+ # Boring top
+ (0, 100, 0, 1000, 0.0),
+ # Above the top!
+ (0, 100, 100, 1000, 0.0),
+ # Normal top scaling
+ (25, 100, 0, 1000, 0.25),
+ (50, 100, 0, 1000, 0.5),
+ # Scaling with a lower offset
+ (25, 100, 25, 1000, 0.0),
+ (50, 100, 25, 1000, 0.25),
+ # Somewhere in the middle
+ (500, 100, 0, 1000, 0.5),
+ # Normal bottom scaling
+ (850, 100, 0, 1000, 0.5),
+ (875, 100, 0, 1000, 0.75),
+ # Boring bottom
+ (900, 100, 0, 1000, 1.0),
+ # Below the bottom!
+ (1100, 100, 0, 1000, 1.0),
+])
+def test_calc_syncpoint(value, page_size, lower, upper, expected):
+ import gi
+ gi.require_version("Gtk", "3.0")
+ from gi.repository import Gtk
+ adjustment = Gtk.Adjustment()
+ adjustment.configure(value, lower, upper, 1, 1, page_size)
+ syncpoint = calc_syncpoint(adjustment)
+ assert syncpoint == expected
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]