Ejemplo n.º 1
0
		public void TestCoordinatesAfterFolding ()
		{
			var editor = new TextEditorData ();
			for (int i = 0; i < 100; i++)
				editor.Insert (0, "line\n");
			
			HeightTree heightTree = new HeightTree (editor);
			heightTree.Rebuild ();
			
			heightTree.Fold (1, 2);
			
			heightTree.Fold (6, 4);
			heightTree.Fold (5, 10);
			
			var f = heightTree.Fold (20, 8);
			heightTree.Unfold (f, 20, 8);
			
			heightTree.Fold (20, 4);
			heightTree.Fold (25, 4);
			
			for (int i = 50; i <= editor.LineCount; i++) {
				var y = System.Math.Max (0, (i - 3 - 10 - 8) * editor.LineHeight);
				Assert.AreEqual (y, heightTree.LineNumberToY (i), "line:" + i + " --> y:" + y);
				Assert.AreEqual (i, heightTree.YToLineNumber (y), "y:" + y + " --> line:" + i);
			}
			for (int i = 50; i <= editor.LineCount; i++) {
				var y = System.Math.Max (0, (i - 3 - 10 - 8) * editor.LineHeight);
				Assert.AreEqual (y, heightTree.LineNumberToY (i), "line:" + i + " --> y:" + y);
				Assert.AreEqual (i, heightTree.YToLineNumber (y), "y:" + y + " --> line:" + i);
			}
		}
Ejemplo n.º 2
0
		public void TestUnfold ()
		{
			var editor = Create ("1\n2\n3\n4\n5\n6\n7");
			HeightTree heightTree = new HeightTree (editor);
			heightTree.Rebuild ();
			var f = heightTree.Fold (2, 2);
			heightTree.Unfold (f, 2, 2);
			for (int i = 1; i <= editor.LineCount; i++) {
				Assert.AreEqual ((i - 1) * editor.LineHeight, heightTree.LineNumberToY (i));
				Assert.AreEqual (i, heightTree.YToLineNumber ((i - 1) * editor.LineHeight));
			}
		}
Ejemplo n.º 3
0
		public void TestUnfold ()
		{
			var editor = new TextEditorData ();
			editor.Text = "1\n2\n3\n4\n5\n6\n7";
			HeightTree heightTree = new HeightTree (editor);
			heightTree.Rebuild ();
			heightTree.Fold (2, 2);
			heightTree.Unfold (2, 2);
			for (int i = 1; i <= editor.LineCount; i++) {
				Assert.AreEqual ((i - 1) * editor.LineHeight, heightTree.LineNumberToY (i));
				Assert.AreEqual (i, heightTree.YToLineNumber ((i - 1) * editor.LineHeight));
			}
		}
Ejemplo n.º 4
0
		public void TestCoordinatesAfterFolding ()
		{
			var editor = new TextEditorData ();
			for (int i = 0; i < 100; i++)
				editor.Insert (0, "line\n");
			
			HeightTree heightTree = new HeightTree (editor);
			heightTree.Rebuild ();
			
			heightTree.Fold (1, 2);
			
			heightTree.Fold (6, 4);
			heightTree.Fold (5, 10);
			
			var f = heightTree.Fold (20, 8);
			heightTree.Unfold (f, 20, 8);
			
			heightTree.Fold (20, 4);
			heightTree.Fold (25, 4);
			
			for (int i = 50; i <= editor.LineCount; i++) {
				var y = System.Math.Max (0, (i - 3 - 10 - 8) * editor.LineHeight);
				Assert.AreEqual (y, heightTree.LineNumberToY (i), "line:" + i + " --> y:" + y);
				Assert.AreEqual (i, heightTree.YToLineNumber (y), "y:" + y + " --> line:" + i);
			}
			for (int i = 50; i <= editor.LineCount; i++) {
				var y = System.Math.Max (0, (i - 3 - 10 - 8) * editor.LineHeight);
				Assert.AreEqual (y, heightTree.LineNumberToY (i), "line:" + i + " --> y:" + y);
				Assert.AreEqual (i, heightTree.YToLineNumber (y), "y:" + y + " --> line:" + i);
			}
		}