OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 // Test that cursor positions are correctly updated after adding new content. | 5 // Test that cursor positions are correctly updated after adding new content. |
6 | 6 |
7 import 'test_try.dart'; | 7 import 'test_try.dart'; |
8 | 8 |
9 void main() { | 9 void main() { |
10 InteractionManager interaction = mockTryDartInteraction(); | 10 InteractionManager interaction = mockTryDartInteraction(); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 | 42 |
43 new TestCase('Test adding a new line with mock key event.', () { | 43 new TestCase('Test adding a new line with mock key event.', () { |
44 clearEditorPaneWithoutNotifications(); | 44 clearEditorPaneWithoutNotifications(); |
45 checkSelectionIsCollapsed(mainEditorPane, 0); | 45 checkSelectionIsCollapsed(mainEditorPane, 0); |
46 simulateEnterKeyDown(interaction); | 46 simulateEnterKeyDown(interaction); |
47 }, checkAtBeginningOfSecondLine), | 47 }, checkAtBeginningOfSecondLine), |
48 | 48 |
49 new TestCase('Clear and presetup the test', () { | 49 new TestCase('Clear and presetup the test', () { |
50 clearEditorPaneWithoutNotifications(); | 50 clearEditorPaneWithoutNotifications(); |
51 mainEditorPane.text = 'var greeting = "Hello, World!\n";'; | 51 mainEditorPane.text = 'var greeting = "Hello, World!\n";'; |
52 }, () { | 52 }, () { |
53 checkLineCount(2); | 53 checkLineCount(2); |
54 }), | 54 }), |
55 | 55 |
56 new TestCase('Test removing a split line', () { | 56 new TestCase('Test removing a split line', () { |
57 mainEditorPane.nodes.first.nodes.last.remove(); | 57 mainEditorPane.nodes.first.nodes.last.remove(); |
58 }, () { | 58 }, () { |
59 checkLineCount(1); | 59 checkLineCount(1); |
60 }), | 60 }), |
61 ]); | 61 ]); |
62 } | 62 } |
63 | 63 |
64 void simulateEnterKeyDown(InteractionManager interaction) { | 64 void simulateEnterKeyDown(InteractionManager interaction) { |
65 interaction.onKeyUp( | 65 interaction.onKeyUp( |
66 new MockKeyboardEvent('keydown', keyCode: KeyCode.ENTER)); | 66 new MockKeyboardEvent('keydown', keyCode: KeyCode.ENTER)); |
67 } | 67 } |
68 | 68 |
69 void checkSelectionIsCollapsed(Node node, int offset) { | 69 void checkSelectionIsCollapsed(Node node, int offset) { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 | 105 |
106 class MockKeyboardEvent extends KeyEvent { | 106 class MockKeyboardEvent extends KeyEvent { |
107 final int keyCode; | 107 final int keyCode; |
108 | 108 |
109 MockKeyboardEvent(String type, {int keyCode}) | 109 MockKeyboardEvent(String type, {int keyCode}) |
110 : this.keyCode = keyCode, | 110 : this.keyCode = keyCode, |
111 super.wrap(new KeyEvent(type, keyCode: keyCode)); | 111 super.wrap(new KeyEvent(type, keyCode: keyCode)); |
112 | 112 |
113 bool getModifierState(String keyArgument) => false; | 113 bool getModifierState(String keyArgument) => false; |
114 } | 114 } |
OLD | NEW |