Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(309)

Unified Diff: dart/tests/try/cursor_position_test.dart

Issue 285043003: Two related changes that both affect how cursor positions might change on single line edits. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Merged with r36207. Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « dart/site/try/src/selection.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/tests/try/cursor_position_test.dart
diff --git a/dart/tests/try/cursor_position_test.dart b/dart/tests/try/cursor_position_test.dart
index aaef984eefe5cae8626d9da4a674e1e36011863f..f79179654f9e5436dcdc5a825f14656c1b825533 100644
--- a/dart/tests/try/cursor_position_test.dart
+++ b/dart/tests/try/cursor_position_test.dart
@@ -11,15 +11,36 @@ import 'test_try.dart';
void main() {
InteractionManager interaction = mockTryDartInteraction();
+ TestCase twoLines =
+ new TestCase('Test adding two lines programmatically.', () {
+ clearEditorPaneWithoutNotifications();
+ mainEditorPane.appendText('\n\n');
+ Text text = mainEditorPane.firstChild;
+ window.getSelection().collapse(text, 1);
+ checkSelectionIsCollapsed(text, 1);
+ }, checkAtBeginningOfSecondLine);
+
runTests(<TestCase>[
+ twoLines,
- new TestCase('Test adding two lines programmatically.', () {
- clearEditorPaneWithoutNotifications();
- mainEditorPane.appendText('\n\n');
- Text text = mainEditorPane.firstChild;
- window.getSelection().collapse(text, 1);
- checkSelectionIsCollapsed(text, 1);
- }, checkAtBeginningOfSecondLine),
+ new TestCase('Test adding a new text node.', () {
+ // This test relies on the previous test leaving two lines.
+ Text text = new Text('fisk');
+ window.getSelection().getRangeAt(0).insertNode(text);
+ window.getSelection().collapse(text, text.length);
+ checkSelectionIsCollapsed(text, text.length);
+ }, checkAtEndOfSecondLineWithFisk),
+
+ twoLines,
+
+ new TestCase('Test adding a new wrapped text node.', () {
+ // This test relies on the previous test leaving two lines.
+ Text text = new Text('fisk');
+ Node node = new SpanElement()..append(text);
+ window.getSelection().getRangeAt(0).insertNode(node);
+ window.getSelection().collapse(text, text.length);
+ checkSelectionIsCollapsed(text, text.length);
+ }, checkAtEndOfSecondLineWithFisk),
new TestCase('Test adding a new line with mock key event.', () {
clearEditorPaneWithoutNotifications();
@@ -53,6 +74,17 @@ void checkAtBeginningOfSecondLine() {
checkSelectionIsCollapsed(mainEditorPane.nodes[1].firstChild, 0);
}
+void checkAtEndOfSecondLineWithFisk() {
+ checkLineCount(2);
+ SpanElement secondLine = mainEditorPane.nodes[1];
+ Text text = secondLine.firstChild.firstChild;
+ Expect.stringEquals('fisk', text.text);
+ Expect.equals(4, text.length);
+ Text newline = secondLine.firstChild.nextNode;
+ Expect.equals(newline, secondLine.lastChild);
+ checkSelectionIsCollapsed(newline, 0);
+}
+
class MockKeyboardEvent extends KeyEvent {
final int keyCode;
« no previous file with comments | « dart/site/try/src/selection.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698