| 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 ef7932f04d1a8fb3a8efb993a0b042f78003b0dd..aaef984eefe5cae8626d9da4a674e1e36011863f 100644
|
| --- a/dart/tests/try/cursor_position_test.dart
|
| +++ b/dart/tests/try/cursor_position_test.dart
|
| @@ -6,30 +6,12 @@
|
|
|
| // Test that cursor positions are correctly updated after adding new content.
|
|
|
| -library trydart.cursor_position_test;
|
| -
|
| -import 'dart:html';
|
| -import 'dart:async';
|
| -
|
| -import '../../site/try/src/interaction_manager.dart' show
|
| - InteractionManager;
|
| -
|
| -import '../../site/try/src/ui.dart' show
|
| - hackDiv,
|
| - mainEditorPane,
|
| - observer;
|
| -
|
| -import '../../site/try/src/user_option.dart' show
|
| - UserOption;
|
| -
|
| -import '../../pkg/expect/lib/expect.dart';
|
| -
|
| -import '../../pkg/async_helper/lib/async_helper.dart';
|
| +import 'test_try.dart';
|
|
|
| void main() {
|
| InteractionManager interaction = mockTryDartInteraction();
|
|
|
| - List<TestCase> tests = <TestCase>[
|
| + runTests(<TestCase>[
|
|
|
| new TestCase('Test adding two lines programmatically.', () {
|
| clearEditorPaneWithoutNotifications();
|
| @@ -45,9 +27,7 @@ void main() {
|
| simulateEnterKeyDown(interaction);
|
| }, checkAtBeginningOfSecondLine),
|
|
|
| - ];
|
| -
|
| - runTests(tests.iterator, completerForAsyncTest());
|
| + ]);
|
| }
|
|
|
| void simulateEnterKeyDown(InteractionManager interaction) {
|
| @@ -55,11 +35,6 @@ void simulateEnterKeyDown(InteractionManager interaction) {
|
| new MockKeyboardEvent('keydown', keyCode: KeyCode.ENTER));
|
| }
|
|
|
| -void clearEditorPaneWithoutNotifications() {
|
| - mainEditorPane.nodes.clear();
|
| - observer.takeRecords();
|
| -}
|
| -
|
| void checkSelectionIsCollapsed(Node node, int offset) {
|
| var selection = window.getSelection();
|
| Expect.isTrue(selection.isCollapsed, 'selection.isCollapsed');
|
| @@ -78,51 +53,6 @@ void checkAtBeginningOfSecondLine() {
|
| checkSelectionIsCollapsed(mainEditorPane.nodes[1].firstChild, 0);
|
| }
|
|
|
| -runTests(Iterator<TestCase> iterator, Completer completer) {
|
| - if (iterator.moveNext()) {
|
| - TestCase test = iterator.current;
|
| - new Future(() {
|
| - print('${test.description}\nSetup.');
|
| - test.setup();
|
| - new Future(() {
|
| - test.validate();
|
| - print('${test.description}\nDone.');
|
| - runTests(iterator, completer);
|
| - });
|
| - });
|
| - } else {
|
| - completer.complete(null);
|
| - }
|
| -}
|
| -
|
| -Completer completerForAsyncTest() {
|
| - Completer completer = new Completer();
|
| - asyncTest(() => completer.future.then((_) {
|
| - // Clear the DOM to work around a bug in test.dart.
|
| - document.body.nodes.clear();
|
| - }));
|
| - return completer;
|
| -}
|
| -
|
| -InteractionManager mockTryDartInteraction() {
|
| - UserOption.storage = {};
|
| -
|
| - InteractionManager interaction = new InteractionManager();
|
| -
|
| - hackDiv = new DivElement();
|
| - mainEditorPane = new DivElement()
|
| - ..style.whiteSpace = 'pre'
|
| - ..contentEditable = 'true';
|
| -
|
| - observer = new MutationObserver(interaction.onMutation);
|
| - observer.observe(
|
| - mainEditorPane, childList: true, characterData: true, subtree: true);
|
| -
|
| - document.body.nodes.addAll([mainEditorPane, hackDiv]);
|
| -
|
| - return interaction;
|
| -}
|
| -
|
| class MockKeyboardEvent extends KeyEvent {
|
| final int keyCode;
|
|
|
| @@ -132,13 +62,3 @@ class MockKeyboardEvent extends KeyEvent {
|
|
|
| bool getModifierState(String keyArgument) => false;
|
| }
|
| -
|
| -typedef void VoidFunction();
|
| -
|
| -class TestCase {
|
| - final String description;
|
| - final VoidFunction setup;
|
| - final VoidFunction validate;
|
| -
|
| - TestCase(this.description, this.setup, this.validate);
|
| -}
|
|
|