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

Unified Diff: third_party/WebKit/LayoutTests/http/tests/inspector-unit/suggest-box.js

Issue 2513423003: DevTools: Convert inspector-unit tests to use reusable test harness (Closed)
Patch Set: Moved type definition out of externs Created 4 years 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
Index: third_party/WebKit/LayoutTests/http/tests/inspector-unit/suggest-box.js
diff --git a/third_party/WebKit/LayoutTests/http/tests/inspector-unit/suggest-box.js b/third_party/WebKit/LayoutTests/http/tests/inspector-unit/suggest-box.js
new file mode 100644
index 0000000000000000000000000000000000000000..0e784ca26897e9ac8d8ca97adf1a1978e8898774
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/http/tests/inspector-unit/suggest-box.js
@@ -0,0 +1,55 @@
+TestRunner.addResult("This tests if the SuggestBox works properly.");
+
+var delegate = {
+ applySuggestion: function(suggestion, isIntermediateSuggestion) {
+ TestRunner.addResult((isIntermediateSuggestion ? "Intermediate " : "") + "Suggestion Applied: " + suggestion);
+ },
+ acceptSuggestion: function() {
+ TestRunner.addResult("Suggestion accepted");
+ }
+};
+var div = document.createElement("div");
+UI.inspectorView.element.appendChild(div);
+var suggestBox = new UI.SuggestBox(delegate);
+
+TestRunner.addResult("");
+TestRunner.addResult("Testing that the first item is selected.");
+suggestBox.updateSuggestions(new AnchorBox(50, 50, 400, 400), [
+ {title: "First"},
+ {title: "Hello"},
+ {title: "The best suggestion"}], true, true, "e");
+
+TestRunner.addResult("");
+TestRunner.addResult("Testing that no item is selected.");
+suggestBox.updateSuggestions(new AnchorBox(50, 50, 400, 400), [
+ {title: "First"},
+ {title: "Hello", priority: 2},
+ {title: "The best suggestion", priority: 5}], false, true, "e");
+
+TestRunner.addResult("");
+TestRunner.addResult("Testing that highest priority item is selected.");
+suggestBox.updateSuggestions(new AnchorBox(50, 50, 400, 400), [
+ {title: "First"},
+ {title: "Hello", priority: 2},
+ {title: "The best suggestion", priority: 5}], true, true, "e");
+
+TestRunner.addResult("");
+TestRunner.addResult("Testing that arrow keys can be used for selection.");
+suggestBox.keyPressed(TestRunner.createKeyEvent("ArrowUp"));
+suggestBox.keyPressed(TestRunner.createKeyEvent("ArrowUp"));
+suggestBox.keyPressed(TestRunner.createKeyEvent("ArrowUp"));
+suggestBox.keyPressed(TestRunner.createKeyEvent("ArrowDown"));
+suggestBox.keyPressed(TestRunner.createKeyEvent("ArrowDown"));
+
+TestRunner.addResult("");
+TestRunner.addResult("Testing that enter can be used to accept a suggestion.");
+suggestBox.keyPressed(TestRunner.createKeyEvent("Enter"));
+
+TestRunner.addResult("");
+TestRunner.addResult("Testing that highest priority item is selected.");
+suggestBox.updateSuggestions(new AnchorBox(50, 50, 400, 400), [
+ {title: "First"},
+ {title: "Hello", priority: 2},
+ {title: "The best suggestion", priority: 5}], true, true, "e");
+
+TestRunner.completeTest();

Powered by Google App Engine
This is Rietveld 408576698