8
0
Pārlūkot izejas kodu

Added FocusTracker manual test.

Oskar Wróbel 9 gadi atpakaļ
vecāks
revīzija
f6398e6f51

+ 42 - 0
packages/ckeditor5-utils/tests/manual/focustracker.html

@@ -0,0 +1,42 @@
+<head>
+	<meta charset="utf-8">
+
+	<style>
+		div[contenteditable],
+		div[tabindex] {
+			padding: 10px;
+			border: solid 1px #888;
+		}
+
+		span {
+			padding-left: 10px;
+		}
+
+		.status {
+			font-weight: normal;
+		}
+	</style>
+</head>
+
+
+<h2 class="status">Status <span>focus: <b>0</b></span> <span>blur: <b>0</b></span></h2>
+<hr>
+
+<h2>Tracked by Focus Tracker:</h2>
+
+<h3>Input:</h3>
+<input type="text" class="track">
+
+<h3>Content editable:</h3>
+<div contenteditable="true" class="track">Some editable content</div>
+
+<h3>HTML Wrapper (uses event capturing):</h3>
+<div tabindex="-1" class="track">
+	<input type="text">
+	<input type="text">
+</div>
+
+<h2>Not tracked by Focus Tracker:</h2>
+
+<h3>Input:</h3>
+<input type="text">

+ 18 - 0
packages/ckeditor5-utils/tests/manual/focustracker.js

@@ -0,0 +1,18 @@
+/**
+ * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md.
+ */
+
+/* global document */
+
+import FocusTracker from '/ckeditor5/utils/focustracker.js';
+
+const focusTracker = new FocusTracker();
+const counters = document.querySelectorAll( '.status b' );
+
+[].forEach.call( document.querySelectorAll( '.track' ), el => focusTracker.add( el ) );
+
+focusTracker.on( 'change:isFocused', ( evt, name, value ) => {
+	const el = counters[ value ? 0 : 1 ];
+	el.textContent = parseInt( el.textContent ) + 1;
+} );

+ 14 - 0
packages/ckeditor5-utils/tests/manual/focustracker.md

@@ -0,0 +1,14 @@
+
+@bender-ui: collapsed
+@bender-tags: focustracker
+
+## Focus Tracker
+
+1. Set focus to first tracked input,
+2. Check if status is equal to: focus: **1** blur: **0**,
+3. Move focus to tracked content editable element,
+4. Move focus to first input of tracked HTML Wrapper,
+5. Move focus to second input of tracked HTML Wrapper,
+6. Check if status is still equal to: focus: **1** blur: **0**,
+7. Move focus to not tracked input,
+8. Check if status is equal to: focus: **1** blur: **1**.