diff options
author | Mike Krüger <mkrueger@xamarin.com> | 2012-05-30 12:15:34 +0400 |
---|---|---|
committer | Mike Krüger <mkrueger@xamarin.com> | 2012-05-30 12:15:34 +0400 |
commit | 95fd2fb0cc8f4621f70491f51efbc46e049b9b59 (patch) | |
tree | 5007dad11db0619304276a0334392daa897311bf /main | |
parent | e2ea070c27f5d029566e1b6578fb7fb0604240e3 (diff) |
[TextEditor] Fixed failing editor unit tests.
Diffstat (limited to 'main')
5 files changed, 39 insertions, 38 deletions
diff --git a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SourceEditorWidget.cs b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SourceEditorWidget.cs index 5f9f132292..8557a19fd9 100644 --- a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SourceEditorWidget.cs +++ b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SourceEditorWidget.cs @@ -502,7 +502,7 @@ namespace MonoDevelop.SourceEditor marker.IsFolded = false; } - doc.UpdateFoldSegments (foldSegments, false); + doc.UpdateFoldSegments (foldSegments, false, true); if (reloadSettings) { reloadSettings = false; diff --git a/main/src/core/Mono.Texteditor/Mono.TextEditor/Document/TextDocument.cs b/main/src/core/Mono.Texteditor/Mono.TextEditor/Document/TextDocument.cs index fd74afb2af..d846aeb414 100644 --- a/main/src/core/Mono.Texteditor/Mono.TextEditor/Document/TextDocument.cs +++ b/main/src/core/Mono.Texteditor/Mono.TextEditor/Document/TextDocument.cs @@ -974,29 +974,29 @@ namespace Mono.TextEditor readonly object syncObject = new object(); - public void UpdateFoldSegments (List<FoldSegment> newSegments) - { - UpdateFoldSegments (newSegments, true); - } - - CancellationTokenSource foldSegmentSrc; Task foldSegmentTask; - public void UpdateFoldSegments (List<FoldSegment> newSegments, bool runInThread) + public void UpdateFoldSegments (List<FoldSegment> newSegments, bool startTask = false, bool useApplicationInvoke = false) { if (newSegments == null) { return; } + Console.WriteLine ("startTask={0}, useApplicationInvoke={1}", startTask, useApplicationInvoke); InterruptFoldWorker (); bool update; - if (!runInThread) { + if (!startTask) { var newFoldedSegments = UpdateFoldSegmentWorker (newSegments, out update); - Gtk.Application.Invoke (delegate { + if (useApplicationInvoke) { + Gtk.Application.Invoke (delegate { + foldedSegments = newFoldedSegments; + InformFoldTreeUpdated (); + }); + } else { foldedSegments = newFoldedSegments; InformFoldTreeUpdated (); - }); + } return; } foldSegmentSrc = new CancellationTokenSource (); diff --git a/main/tests/UnitTests/Mono.TextEditor.Tests.DefaultEditActions/MiscActionsTest.cs b/main/tests/UnitTests/Mono.TextEditor.Tests.DefaultEditActions/MiscActionsTest.cs index 1d0ba35918..66a4eb4e53 100644 --- a/main/tests/UnitTests/Mono.TextEditor.Tests.DefaultEditActions/MiscActionsTest.cs +++ b/main/tests/UnitTests/Mono.TextEditor.Tests.DefaultEditActions/MiscActionsTest.cs @@ -39,7 +39,8 @@ namespace Mono.TextEditor.Tests.Actions [Test()] public void TestInsertTabBug615196_IndentCase () { - TextEditorData data = new Mono.TextEditor.TextEditorData (); + TextEditorData data = new Mono.TextEditor.TextEditorData (); + data.Options = new TextEditorOptions () { IndentStyle = IndentStyle.Smart }; data.Document.Text = "\n\n\n\n\n"; data.Caret.Offset = data.Document.GetLine (2).Offset; // 2nd.Line data.MainSelection = new Selection (2, 1, 4, 1); diff --git a/main/tests/UnitTests/Mono.TextEditor.Tests.DefaultEditActions/TextEditorTestBase.cs b/main/tests/UnitTests/Mono.TextEditor.Tests.DefaultEditActions/TextEditorTestBase.cs index e6b044e4f1..53e3e2a225 100644 --- a/main/tests/UnitTests/Mono.TextEditor.Tests.DefaultEditActions/TextEditorTestBase.cs +++ b/main/tests/UnitTests/Mono.TextEditor.Tests.DefaultEditActions/TextEditorTestBase.cs @@ -131,7 +131,7 @@ namespace Mono.TextEditor.Tests } } if (foldSegments.Count > 0) - data.Document.UpdateFoldSegments (foldSegments, false); + data.Document.UpdateFoldSegments (foldSegments); return data; } diff --git a/main/tests/UnitTests/Mono.TextEditor.Tests/FoldingTests.cs b/main/tests/UnitTests/Mono.TextEditor.Tests/FoldingTests.cs index 09f789f326..532d378d03 100644 --- a/main/tests/UnitTests/Mono.TextEditor.Tests/FoldingTests.cs +++ b/main/tests/UnitTests/Mono.TextEditor.Tests/FoldingTests.cs @@ -113,7 +113,7 @@ namespace Mono.TextEditor.Tests 16 ]17 18"); - data.Document.UpdateFoldSegments (GetFoldSegments (data.Document), false); + data.Document.UpdateFoldSegments (GetFoldSegments (data.Document)); Assert.AreEqual (5, data.LogicalToVisualLine (12)); Assert.AreEqual (8, data.LogicalToVisualLine (16)); Assert.AreEqual (8, data.LogicalToVisualLine (17)); @@ -141,7 +141,7 @@ namespace Mono.TextEditor.Tests 16 ]17 18"); - data.Document.UpdateFoldSegments (GetFoldSegments (data.Document), false); + data.Document.UpdateFoldSegments (GetFoldSegments (data.Document)); Assert.AreEqual (7, data.LogicalToVisualLine (7)); } @@ -167,7 +167,7 @@ namespace Mono.TextEditor.Tests 16 ]17 18"); - data.Document.UpdateFoldSegments (GetFoldSegments (data.Document), false); + data.Document.UpdateFoldSegments (GetFoldSegments (data.Document)); Assert.AreEqual (7, data.VisualToLogicalLine (7)); } @@ -193,7 +193,7 @@ namespace Mono.TextEditor.Tests 16 ]17 18"); - data.Document.UpdateFoldSegments (GetFoldSegments (data.Document), false); + data.Document.UpdateFoldSegments (GetFoldSegments (data.Document)); Assert.AreEqual (6, data.VisualToLogicalLine (4)); Assert.AreEqual (14, data.VisualToLogicalLine (6)); Assert.AreEqual (15, data.VisualToLogicalLine (7)); @@ -221,7 +221,7 @@ namespace Mono.TextEditor.Tests 16 ]17 18"); - data.Document.UpdateFoldSegments (GetFoldSegments (data.Document), false); + data.Document.UpdateFoldSegments (GetFoldSegments (data.Document)); Assert.AreEqual (2, data.VisualToLogicalLine (2)); Assert.AreEqual (2, data.LogicalToVisualLine (2)); } @@ -258,18 +258,18 @@ namespace Mono.TextEditor.Tests 25 26"); var segments = GetFoldSegments (data.Document); - data.Document.UpdateFoldSegments (segments, false); + data.Document.UpdateFoldSegments (segments); Assert.AreEqual (25, data.VisualToLogicalLine (9)); Assert.AreEqual (3, data.Document.FoldSegments.Count ()); segments.RemoveAt (1); - data.Document.UpdateFoldSegments (segments, false); + data.Document.UpdateFoldSegments (segments); Assert.AreEqual (2, data.Document.FoldSegments.Count ()); Assert.AreEqual (17, data.LogicalToVisualLine (25)); segments.RemoveAt (1); - data.Document.UpdateFoldSegments (segments, false); + data.Document.UpdateFoldSegments (segments); Assert.AreEqual (1, data.Document.FoldSegments.Count ()); Assert.AreEqual (25, data.LogicalToVisualLine (25)); } @@ -293,11 +293,11 @@ namespace Mono.TextEditor.Tests 9 10"); var segments = GetFoldSegments (data.Document); - data.Document.UpdateFoldSegments (segments, false); + data.Document.UpdateFoldSegments (segments); Assert.AreEqual (true, data.Document.FoldSegments.FirstOrDefault ().IsFolded); segments = GetFoldSegments (data.Document); segments[0].IsFolded = false; - data.Document.UpdateFoldSegments (segments, false); + data.Document.UpdateFoldSegments (segments); Assert.AreEqual (5, data.LogicalToVisualLine (8)); } @@ -323,7 +323,7 @@ namespace Mono.TextEditor.Tests 15 ]16 17"); - data.Document.UpdateFoldSegments (GetFoldSegments (data.Document), false); + data.Document.UpdateFoldSegments (GetFoldSegments (data.Document)); Assert.AreEqual (13, data.VisualToLogicalLine (5)); Assert.AreEqual (18, data.VisualToLogicalLine (8)); } @@ -339,7 +339,7 @@ namespace Mono.TextEditor.Tests 123$4+[567890 1234]567890 1234567890"); - data.Document.UpdateFoldSegments (GetFoldSegments (data.Document), false); + data.Document.UpdateFoldSegments (GetFoldSegments (data.Document)); CaretMoveActions.Right (data); Assert.AreEqual (new DocumentLocation (3, 5), data.Caret.Location); CaretMoveActions.Right (data); @@ -355,7 +355,7 @@ namespace Mono.TextEditor.Tests 1234+[567890 1234]5$67890 1234567890"); - data.Document.UpdateFoldSegments (GetFoldSegments (data.Document), false); + data.Document.UpdateFoldSegments (GetFoldSegments (data.Document)); CaretMoveActions.Left (data); Assert.AreEqual (new DocumentLocation (4, 6), data.Caret.Location); CaretMoveActions.Left (data); @@ -371,7 +371,7 @@ namespace Mono.TextEditor.Tests 1234+[567890 1234567890] $1234567890"); - data.Document.UpdateFoldSegments (GetFoldSegments (data.Document), false); + data.Document.UpdateFoldSegments (GetFoldSegments (data.Document)); CaretMoveActions.Left (data); Assert.AreEqual (new DocumentLocation (4, 12), data.Caret.Location); CaretMoveActions.Left (data); @@ -400,7 +400,7 @@ $1234567890"); 15 16"); var segments = GetFoldSegments (data.Document); - data.Document.UpdateFoldSegments (segments, false); + data.Document.UpdateFoldSegments (segments); Assert.AreEqual (10, data.VisualToLogicalLine (8)); Assert.AreEqual (3, data.Document.FoldSegments.Count ()); int start = data.GetLine (2).Offset; @@ -431,9 +431,9 @@ $1234567890"); 15 16"); var segments = GetFoldSegments (data.Document); - data.Document.UpdateFoldSegments (segments, false); - data.Document.UpdateFoldSegments (segments, false); - data.Document.UpdateFoldSegments (segments, false); + data.Document.UpdateFoldSegments (segments); + data.Document.UpdateFoldSegments (segments); + data.Document.UpdateFoldSegments (segments); Assert.AreEqual (1, data.Document.GetStartFoldings (1).Count ()); Assert.AreEqual (1, data.Document.GetStartFoldings (4).Count ()); @@ -463,7 +463,7 @@ $1234567890"); 15 16"); var segments = GetFoldSegments (data.Document); - data.Document.UpdateFoldSegments (segments, false); + data.Document.UpdateFoldSegments (segments); Assert.AreEqual (15, data.LogicalToVisualLine (15)); data.Document.GetStartFoldings (6).First ().IsFolded = true; data.Document.GetStartFoldings (4).First ().IsFolded = true; @@ -491,7 +491,7 @@ $1234567890"); 15 16"); var segments = GetFoldSegments (data.Document); - data.Document.UpdateFoldSegments (segments, false); + data.Document.UpdateFoldSegments (segments); Assert.AreEqual (11, data.LogicalToVisualLine (15)); data.Document.GetStartFoldings (6).First ().IsFolded = false; data.Document.GetStartFoldings (4).First ().IsFolded = false; @@ -511,7 +511,7 @@ AAAAAAAABBBBBBBBBB AAAAAAAABBBBBBBBBB] AAAAAAAA "); - data.Document.UpdateFoldSegments (GetFoldSegments (data.Document), false); + data.Document.UpdateFoldSegments (GetFoldSegments (data.Document)); Assert.AreEqual (new DocumentLocation (2, 9), data.Caret.Location); CaretMoveActions.Down (data); @@ -533,7 +533,7 @@ AAAAAAAABBBBBBBBBB AAAAAAAABBBBBBBBBB] AAAAAAAA$ "); - data.Document.UpdateFoldSegments (GetFoldSegments (data.Document), false); + data.Document.UpdateFoldSegments (GetFoldSegments (data.Document)); Assert.AreEqual (new DocumentLocation (8, 9), data.Caret.Location); CaretMoveActions.Up (data); @@ -554,7 +554,7 @@ AAAAAAAABBBBBBBBBB AAAAAAAABBBBBBBBBB] AAAAAAAA$ "); - data.Document.UpdateFoldSegments (GetFoldSegments (data.Document), false); + data.Document.UpdateFoldSegments (GetFoldSegments (data.Document)); Assert.AreEqual (new DocumentLocation (8, 9), data.Caret.Location); CaretMoveActions.Up (data); @@ -584,11 +584,11 @@ AAAAAAAA$ var segments = GetFoldSegments (data.Document); var seg = segments[0]; segments.RemoveAt (0); - data.Document.UpdateFoldSegments (segments, false); + data.Document.UpdateFoldSegments (segments); Assert.AreEqual (2, data.Document.FoldSegments.Count ()); segments.Insert (0, seg); - data.Document.UpdateFoldSegments (segments, false); + data.Document.UpdateFoldSegments (segments); Assert.AreEqual (3, data.Document.FoldSegments.Count ()); } |