~ubuntu-branches/ubuntu/trusty/monodevelop/trusty-proposed

« back to all changes in this revision

Viewing changes to tests/UnitTests/Mono.TextEditor.Tests/VirtualSpacesTests.cs

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2013-05-12 09:46:03 UTC
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20130512094603-mad323bzcxvmcam0
Tags: upstream-4.0.5+dfsg
Import upstream version 4.0.5+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// 
2
 
// VirtualSpacesTests.cs
3
 
//  
4
 
// Author:
5
 
//       Mike Krüger <mkrueger@novell.com>
6
 
// 
7
 
// Copyright (c) 2010 Novell, Inc (http://www.novell.com)
8
 
// 
9
 
// Permission is hereby granted, free of charge, to any person obtaining a copy
10
 
// of this software and associated documentation files (the "Software"), to deal
11
 
// in the Software without restriction, including without limitation the rights
12
 
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
 
// copies of the Software, and to permit persons to whom the Software is
14
 
// furnished to do so, subject to the following conditions:
15
 
// 
16
 
// The above copyright notice and this permission notice shall be included in
17
 
// all copies or substantial portions of the Software.
18
 
// 
19
 
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
 
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
 
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
 
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
 
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
 
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25
 
// THE SOFTWARE.
26
 
 
27
 
using System;
28
 
using NUnit.Framework;
29
 
using Gtk;
30
 
 
31
 
namespace Mono.TextEditor.Tests
32
 
{
33
 
        [TestFixture()]
34
 
        public class VirtualSpacesTests : TextEditorTestBase
35
 
        {
36
 
 
37
 
                /// <summary>
38
 
                /// Bug 615196 - Pasting a chunk of text into the virtual whitespace fracks everything up
39
 
                /// </summary>
40
 
                [Test()]
41
 
                public void TestBug615196 ()
42
 
                {
43
 
                        TextEditorData data = new Mono.TextEditor.TextEditorData ();
44
 
                        data.Options.IndentStyle = IndentStyle.Auto;
45
 
                        data.Document.Text = "\n\nHello World\n";
46
 
                        data.Caret.Offset = 1; // 2nd.Line
47
 
                        data.Caret.AllowCaretBehindLineEnd = true;
48
 
                        data.Caret.Column = DocumentLocation.MinColumn + 4;
49
 
                        Clipboard clipboard = Clipboard.Get (Mono.TextEditor.ClipboardActions.CopyOperation.CLIPBOARD_ATOM);
50
 
                        clipboard.Text = "Test";
51
 
                        
52
 
                        ClipboardActions.Paste (data);
53
 
                        
54
 
                        Assert.AreEqual ("\n    Test\nHello World\n", data.Document.Text);
55
 
                }
56
 
                
57
 
                /// <summary>
58
 
                /// Bug 613770 - Backspace inconsistently deletes entire lines when using "virtual spaces"
59
 
                /// </summary>
60
 
                [Test()]
61
 
                public void TestBug613770 ()
62
 
                {
63
 
                        TextEditorData data = new Mono.TextEditor.TextEditorData ();
64
 
                        data.Options.IndentStyle = IndentStyle.Auto;
65
 
                        data.Document.Text = "\n\n\n";
66
 
                        data.Caret.Offset = 1; // 2nd.Line
67
 
                        data.Caret.AllowCaretBehindLineEnd = true;
68
 
                        data.Caret.Column = DocumentLocation.MinColumn + 4;
69
 
                        DeleteActions.Backspace (data);
70
 
                        
71
 
                        Assert.AreEqual ("\n   \n\n", data.Document.Text);
72
 
                }
73
 
                
74
 
                [Test()]
75
 
                public void TestReturnKeyBehavior ()
76
 
                {
77
 
                        TextEditorData data = new Mono.TextEditor.TextEditorData ();
78
 
                        data.Options.IndentStyle = IndentStyle.Auto;
79
 
                        data.Document.Text = "\n\n\n";
80
 
                        data.Caret.Offset = 1; // 2nd.Line
81
 
                        data.Caret.AllowCaretBehindLineEnd = true;
82
 
                        data.Caret.Column = DocumentLocation.MinColumn + 4;
83
 
                        MiscActions.InsertNewLine (data);
84
 
                        
85
 
                        Assert.AreEqual ("\n    \n    \n\n", data.Document.Text);
86
 
                }
87
 
                
88
 
                /// <summary>
89
 
                /// Bug 615624 - Pressing DOWN after RETURN moves cursor to beginning of blank lines instead of to the indent
90
 
                /// </summary>
91
 
                [Test()]
92
 
                public void TestBug615624 ()
93
 
                {
94
 
                        TextEditorData data = new Mono.TextEditor.TextEditorData ();
95
 
                        data.Options.IndentStyle = IndentStyle.Auto;
96
 
                        data.Document.Text = "\n \n\n";
97
 
                        data.Caret.AllowCaretBehindLineEnd = true;
98
 
                        data.Caret.Offset = 2; // 2nd.Line
99
 
                        Assert.AreEqual (DocumentLocation.MinColumn + 1, data.Caret.Column);
100
 
                        TextDocument.RemoveTrailingWhitespaces (data, data.Document.GetLine (2));
101
 
                        Assert.AreEqual ("\n\n\n", data.Document.Text);
102
 
                        Assert.AreEqual (DocumentLocation.MinColumn + 1, data.Caret.Column);
103
 
                }
104
 
 
105
 
                [Test()]
106
 
                public void TestCaretRightBehavior ()
107
 
                {
108
 
                        TextEditorData data = new Mono.TextEditor.TextEditorData ();
109
 
                        data.Options.IndentStyle = IndentStyle.Auto;
110
 
                        data.Document.Text = "\n\n\n";
111
 
                        data.Caret.AllowCaretBehindLineEnd = true;
112
 
 
113
 
                        CaretMoveActions.Right (data);
114
 
                        Assert.AreEqual (2, data.Caret.Column);
115
 
                        CaretMoveActions.Right (data);
116
 
                        Assert.AreEqual (3, data.Caret.Column);
117
 
                        Assert.AreEqual ("\n\n\n", data.Document.Text);
118
 
                }
119
 
 
120
 
                [Test()]
121
 
                public void TestCaretLeftBehavior ()
122
 
                {
123
 
                        TextEditorData data = new Mono.TextEditor.TextEditorData ();
124
 
                        data.Options.IndentStyle = IndentStyle.Auto;
125
 
                        data.Document.Text = "\n\n\n";
126
 
                        data.Caret.AllowCaretBehindLineEnd = true;
127
 
                        data.Caret.Column = 4;
128
 
 
129
 
                        CaretMoveActions.Left (data);
130
 
                        Assert.AreEqual (3, data.Caret.Column);
131
 
                        CaretMoveActions.Left (data);
132
 
                        Assert.AreEqual (2, data.Caret.Column);
133
 
                        Assert.AreEqual ("\n\n\n", data.Document.Text);
134
 
                }
135
 
                
136
 
        }
137
 
}
138