You are here

protected function TestBase::editorSetSelection in The CodeMirror Editor 8

Sets CodeMirror document selection.

2 calls to TestBase::editorSetSelection()
EditorTest::testEditor in tests/src/FunctionalJavascript/EditorTest.php
Test callback.
TextEditorTest::testTextEditor in tests/src/FunctionalJavascript/TextEditorTest.php
Test callback.

File

tests/src/FunctionalJavascript/TestBase.php, line 43

Class

TestBase
Base class for CodeMirror editor tests.

Namespace

Drupal\Tests\codemirror_editor\FunctionalJavascript

Code

protected function editorSetSelection($anchor, $head) {
  $script = 'document.querySelector("%s .CodeMirror").CodeMirror.setSelection({line: %d, ch: %d}, {line: %d, ch: %d});';
  $script = sprintf($script, $this
    ->getWrapperSelector(), $anchor[0], $anchor[1], $head[0], $head[1]);
  $this
    ->getSession()
    ->getDriver()
    ->executeScript($script);
}