Skip to content

Commit

Permalink
DevTools: namespace integration tests - inspector/sources, inspector/…
Browse files Browse the repository at this point in the history
…tracing (part 4)

Bug: 667560
Change-Id: Ifc1eb15c8184626defc2f05276731a899550c7cd
Reviewed-on: https://chromium-review.googlesource.com/619498
Commit-Queue: Will Chen <chenwilliam@chromium.org>
Reviewed-by: Dmitry Gozman <dgozman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#495356}
  • Loading branch information
wwwillchen authored and Commit Bot committed Aug 17, 2017
1 parent 68ea894 commit 788a447
Show file tree
Hide file tree
Showing 286 changed files with 2,648 additions and 2,646 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
<script>
function test()
{
InspectorTest.showScriptSource("empty.css", onSourceFrame);
SourcesTestRunner.showScriptSource("empty.css", onSourceFrame);

var textEditor;
var dumpSuggestions;
function onSourceFrame(sourceFrame)
{
textEditor = sourceFrame.textEditor;
dumpSuggestions = InspectorTest.dumpSuggestions.bind(InspectorTest, textEditor);
InspectorTest.runTestSuite(testSuite);
dumpSuggestions = SourcesTestRunner.dumpSuggestions.bind(InspectorTest, textEditor);
TestRunner.runTestSuite(testSuite);
}

var testSuite = [
Expand Down Expand Up @@ -88,14 +88,14 @@
" display"
].join("\n"));
textEditor.setSelection(TextUtils.TextRange.createFromLocation(1, 10));
InspectorTest.dumpTextWithSelection(textEditor);
InspectorTest.addSniffer(TextEditor.TextEditorAutocompleteController.prototype, "_onSuggestionsShownForTest", suggestionsShown);
InspectorTest.typeIn(textEditor, ":");
SourcesTestRunner.dumpTextWithSelection(textEditor);
TestRunner.addSniffer(TextEditor.TextEditorAutocompleteController.prototype, "_onSuggestionsShownForTest", suggestionsShown);
SourcesTestRunner.typeIn(textEditor, ":");

function suggestionsShown(words)
{
InspectorTest.addResult("Suggestions displayed on ':' symbol typed in:");
InspectorTest.addResult("[" + words.map(item => item.text).join(", ") + "]");
TestRunner.addResult("Suggestions displayed on ':' symbol typed in:");
TestRunner.addResult("[" + words.map(item => item.text).join(", ") + "]");
next();
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
<script>
function test()
{
InspectorTest.showScriptSource("edit-me.js", onSourceFrame);
SourcesTestRunner.showScriptSource("edit-me.js", onSourceFrame);

var textEditor;
function onSourceFrame(sourceFrame)
{
textEditor = sourceFrame.textEditor;
textEditor.element.focus();
InspectorTest.runTestSuite(testSuite);
TestRunner.runTestSuite(testSuite);
}

var testSuite = [
Expand All @@ -24,11 +24,11 @@
{
textEditor.setText("name1 name2 name3 name4\nna");
textEditor.setSelection(TextUtils.TextRange.createFromLocation(1, 2));
InspectorTest.addSniffer(TextEditor.TextEditorAutocompleteController.prototype, "_onSuggestionsShownForTest", onAutocompletionSuggestBox);
InspectorTest.typeIn(textEditor, "m");
TestRunner.addSniffer(TextEditor.TextEditorAutocompleteController.prototype, "_onSuggestionsShownForTest", onAutocompletionSuggestBox);
SourcesTestRunner.typeIn(textEditor, "m");
function onAutocompletionSuggestBox()
{
document.activeElement.dispatchEvent(InspectorTest.createKeyEvent("Enter"));
document.activeElement.dispatchEvent(TestRunner.createKeyEvent("Enter"));
dumpDictionary(next);
}
},
Expand All @@ -49,7 +49,7 @@
{
textEditor.setText("one\none");
textEditor.setSelection(new TextUtils.TextRange(0, 0, 0, 3));
InspectorTest.typeIn(textEditor, "\b", dumpDictionary.bind(null, next));
SourcesTestRunner.typeIn(textEditor, "\b", dumpDictionary.bind(null, next));
},

function testSetText(next)
Expand All @@ -61,23 +61,23 @@
function testSimpleEdit(next)
{
textEditor.setSelection(TextUtils.TextRange.createFromLocation(0, 3));
InspectorTest.typeIn(textEditor, "\b", dumpDictionary.bind(null, next));
SourcesTestRunner.typeIn(textEditor, "\b", dumpDictionary.bind(null, next));
},

function testDeleteOneDogAndOneCat(next)
{
textEditor.setSelection(TextUtils.TextRange.createFromLocation(0, 6));
InspectorTest.typeIn(textEditor, "\b\b\b\b\b\b", dumpDictionary.bind(null, next));
SourcesTestRunner.typeIn(textEditor, "\b\b\b\b\b\b", dumpDictionary.bind(null, next));
}
];

function dumpDictionary(next) {
var wordsInDictionary = textEditor._autocompleteController._dictionary.wordsWithPrefix("");
InspectorTest.addResult("========= Text in editor =========");
InspectorTest.dumpTextWithSelection(textEditor);
InspectorTest.addResult("======= Words in dictionary =======");
InspectorTest.addResult("[" + wordsInDictionary.sort().join(", ") + "]");
InspectorTest.addResult("=============");
TestRunner.addResult("========= Text in editor =========");
SourcesTestRunner.dumpTextWithSelection(textEditor);
TestRunner.addResult("======= Words in dictionary =======");
TestRunner.addResult("[" + wordsInDictionary.sort().join(", ") + "]");
TestRunner.addResult("=============");
next();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,40 +8,40 @@

function test()
{
InspectorTest.showScriptSource("edit-me.js", onSourceFrame);
SourcesTestRunner.showScriptSource("edit-me.js", onSourceFrame);

var textEditor;
function onSourceFrame(sourceFrame)
{
textEditor = sourceFrame.textEditor;
textEditor.element.focus();
InspectorTest.runTestSuite(testSuite);
TestRunner.runTestSuite(testSuite);
}

var testSuite = [
function testSummonSuggestBox(next)
{
InspectorTest.addSniffer(TextEditor.TextEditorAutocompleteController.prototype, "_onSuggestionsShownForTest", onSuggestionsShown);
TestRunner.addSniffer(TextEditor.TextEditorAutocompleteController.prototype, "_onSuggestionsShownForTest", onSuggestionsShown);

textEditor.setText("one\n()");
textEditor.setSelection(TextUtils.TextRange.createFromLocation(1,1));
InspectorTest.typeIn(textEditor, "o", function() { });
SourcesTestRunner.typeIn(textEditor, "o", function() { });

function onSuggestionsShown()
{
InspectorTest.addResult("Suggestions shown.");
TestRunner.addResult("Suggestions shown.");
next();
}
},

function testTypeSmartBrace(next)
{
InspectorTest.addSniffer(TextEditor.TextEditorAutocompleteController.prototype, "_onSuggestionsHiddenForTest", onSuggestionsHidden);
InspectorTest.typeIn(textEditor, ")", function() { });
TestRunner.addSniffer(TextEditor.TextEditorAutocompleteController.prototype, "_onSuggestionsHiddenForTest", onSuggestionsHidden);
SourcesTestRunner.typeIn(textEditor, ")", function() { });

function onSuggestionsHidden()
{
InspectorTest.addResult("Suggestions hidden.");
TestRunner.addResult("Suggestions hidden.");
next();
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
<script>
function test()
{
InspectorTest.showScriptSource("empty.scss", onSourceFrame);
SourcesTestRunner.showScriptSource("empty.scss", onSourceFrame);

var dumpSuggestions;
function onSourceFrame(sourceFrame)
{
dumpSuggestions = InspectorTest.dumpSuggestions.bind(InspectorTest, sourceFrame.textEditor);
InspectorTest.runTestSuite(testSuite);
dumpSuggestions = SourcesTestRunner.dumpSuggestions.bind(InspectorTest, sourceFrame.textEditor);
TestRunner.runTestSuite(testSuite);
}

var testSuite = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,38 +9,38 @@
<script>
function test()
{
InspectorTest.showScriptSource("bezier.css", onSourceFrame);
SourcesTestRunner.showScriptSource("bezier.css", onSourceFrame);

function onSourceFrame(sourceFrame)
{
InspectorTest.addResult("Initial swatch positions:");
InspectorTest.dumpSwatchPositions(sourceFrame, Sources.CSSSourceFrame.SwatchBookmark);
TestRunner.addResult("Initial swatch positions:");
SourcesTestRunner.dumpSwatchPositions(sourceFrame, Sources.CSSSourceFrame.SwatchBookmark);

InspectorTest.runTestSuite([
TestRunner.runTestSuite([
function testEditBezier(next)
{
var swatch = sourceFrame.textEditor._codeMirrorElement.querySelector("span[is=bezier-swatch]");
swatch.shadowRoot.querySelector(".bezier-swatch-icon").click();
sourceFrame._bezierEditor.setBezier(UI.Geometry.CubicBezier.parse("linear"));
sourceFrame._bezierEditor._onchange();
sourceFrame._swatchPopoverHelper.hide(true)
InspectorTest.dumpSwatchPositions(sourceFrame, Sources.CSSSourceFrame.SwatchBookmark);
SourcesTestRunner.dumpSwatchPositions(sourceFrame, Sources.CSSSourceFrame.SwatchBookmark);
next();
},

function testAddBezier(next)
{
var bodyLineEnd = new TextUtils.TextRange(1, 37, 1, 37);
sourceFrame.textEditor.editRange(bodyLineEnd, " transition: height 1s cubic-bezier(0, 0.5, 1, 1);");
InspectorTest.dumpSwatchPositions(sourceFrame, Sources.CSSSourceFrame.SwatchBookmark);
SourcesTestRunner.dumpSwatchPositions(sourceFrame, Sources.CSSSourceFrame.SwatchBookmark);
next();
},

function testInvalidateBezier(next)
{
var startParenthesis = new TextUtils.TextRange(1, 67, 1, 68);
sourceFrame.textEditor.editRange(startParenthesis, "[");
InspectorTest.dumpSwatchPositions(sourceFrame, Sources.CSSSourceFrame.SwatchBookmark);
SourcesTestRunner.dumpSwatchPositions(sourceFrame, Sources.CSSSourceFrame.SwatchBookmark);
next();
}
]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,61 +9,61 @@
<script>
function test()
{
InspectorTest.showScriptSource("color.css", onSourceFrame);
SourcesTestRunner.showScriptSource("color.css", onSourceFrame);

function onSourceFrame(sourceFrame)
{
InspectorTest.addResult("Initial swatch positions:");
InspectorTest.dumpSwatchPositions(sourceFrame, Sources.CSSSourceFrame.SwatchBookmark);
TestRunner.addResult("Initial swatch positions:");
SourcesTestRunner.dumpSwatchPositions(sourceFrame, Sources.CSSSourceFrame.SwatchBookmark);

InspectorTest.runTestSuite([
TestRunner.runTestSuite([
function testEditSpectrum(next)
{
var swatch = sourceFrame.textEditor._codeMirrorElement.querySelector("span[is=color-swatch]");
swatch.shadowRoot.querySelector(".color-swatch-inner").click();
sourceFrame._spectrum._innerSetColor(Common.Color.parse("#008000").hsva(), "", Common.Color.Format.HEX, ColorPicker.Spectrum._ChangeSource.Other);
sourceFrame._swatchPopoverHelper.hide(true)
InspectorTest.dumpSwatchPositions(sourceFrame, Sources.CSSSourceFrame.SwatchBookmark);
SourcesTestRunner.dumpSwatchPositions(sourceFrame, Sources.CSSSourceFrame.SwatchBookmark);
next();
},

function testAddLine(next)
{
var start = TextUtils.TextRange.createFromLocation(0, 0);
sourceFrame.textEditor.editRange(start, "/* New line */\n");
InspectorTest.dumpSwatchPositions(sourceFrame, Sources.CSSSourceFrame.SwatchBookmark);
SourcesTestRunner.dumpSwatchPositions(sourceFrame, Sources.CSSSourceFrame.SwatchBookmark);
next();
},

function testDeleteLine(next)
{
var bodyLine = new TextUtils.TextRange(2, 0, 3, 0);
sourceFrame.textEditor.editRange(bodyLine, "");
InspectorTest.dumpSwatchPositions(sourceFrame, Sources.CSSSourceFrame.SwatchBookmark);
SourcesTestRunner.dumpSwatchPositions(sourceFrame, Sources.CSSSourceFrame.SwatchBookmark);
next();
},

function testAddColor(next)
{
var emptyBodyLine = new TextUtils.TextRange(2, 0, 2, 0);
sourceFrame.textEditor.editRange(emptyBodyLine, "color: hsl(300, 100%, 35%);");
InspectorTest.dumpSwatchPositions(sourceFrame, Sources.CSSSourceFrame.SwatchBookmark);
SourcesTestRunner.dumpSwatchPositions(sourceFrame, Sources.CSSSourceFrame.SwatchBookmark);
next();
},

function testInvalidateColor(next)
{
var endParenthesis = new TextUtils.TextRange(2, 25, 2, 26);
sourceFrame.textEditor.editRange(endParenthesis, "]");
InspectorTest.dumpSwatchPositions(sourceFrame, Sources.CSSSourceFrame.SwatchBookmark);
SourcesTestRunner.dumpSwatchPositions(sourceFrame, Sources.CSSSourceFrame.SwatchBookmark);
next();
},

function testBookmarksAtLineStart(next)
{
var lineStart = new TextUtils.TextRange(5, 0, 5, 0);
sourceFrame.textEditor.editRange(lineStart, "background color:\n#ff0;\n");
InspectorTest.dumpSwatchPositions(sourceFrame, Sources.CSSSourceFrame.SwatchBookmark);
SourcesTestRunner.dumpSwatchPositions(sourceFrame, Sources.CSSSourceFrame.SwatchBookmark);
next();
}
]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@

function test()
{
InspectorTest.showScriptSource("edit-me.js", onSourceFrame);
SourcesTestRunner.showScriptSource("edit-me.js", onSourceFrame);

function onSourceFrame(sourceFrame)
{
InspectorTest.addSniffer(Sources.JavaScriptCompiler.prototype, "_compilationFinishedForTest", onCompilationFinished.bind(null, sourceFrame));
TestRunner.addSniffer(Sources.JavaScriptCompiler.prototype, "_compilationFinishedForTest", onCompilationFinished.bind(null, sourceFrame));
sourceFrame.textEditor.setSelection(TextUtils.TextRange.createFromLocation(0, 0));
InspectorTest.typeIn(sourceFrame.textEditor, "test!");
SourcesTestRunner.typeIn(sourceFrame.textEditor, "test!");
}

function onCompilationFinished(sourceFrame)
{
InspectorTest.dumpSourceFrameMessages(sourceFrame);
InspectorTest.completeTest();
SourcesTestRunner.dumpSourceFrameMessages(sourceFrame);
TestRunner.completeTest();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
<script>
function test()
{
InspectorTest.showScriptSource("empty.scss", onSourceFrame);
SourcesTestRunner.showScriptSource("empty.scss", onSourceFrame);

function onSourceFrame(sourceFrame)
{
InspectorTest.addResult("Source mapping loaded.");
InspectorTest.completeTest();
dumpSuggestions = InspectorTest.dumpSuggestions.bind(InspectorTest, sourceFrame.textEditor);
InspectorTest.runTestSuite(testSuite);
TestRunner.addResult("Source mapping loaded.");
TestRunner.completeTest();
dumpSuggestions = SourcesTestRunner.dumpSuggestions.bind(InspectorTest, sourceFrame.textEditor);
TestRunner.runTestSuite(testSuite);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,30 @@

function test()
{
InspectorTest.showScriptSource("css-outline-column.css", onSourceShown);
SourcesTestRunner.showScriptSource("css-outline-column.css", onSourceShown);
var textEditor;
function onSourceShown(sourceFrame)
{
textEditor = sourceFrame.textEditor;
InspectorTest.addSniffer(Sources.OutlineQuickOpen.prototype, "refresh", onQuickOpenFulfilled);
TestRunner.addSniffer(Sources.OutlineQuickOpen.prototype, "refresh", onQuickOpenFulfilled);
UI.panels.sources._sourcesView._showOutlineQuickOpen();
}

function onQuickOpenFulfilled()
{
InspectorTest.addSniffer(Common.Revealer, "revealPromise", (revealable, omitFocus, promise) => promise.then(revealed));
TestRunner.addSniffer(Common.Revealer, "revealPromise", (revealable, omitFocus, promise) => promise.then(revealed));
this.selectItem(1, "");
}

function revealed() {
var selection = textEditor.selection();
if (!selection.isEmpty()) {
InspectorTest.addResult("ERROR: selection is not empty.");
InspectorTest.completeTest();
TestRunner.addResult("ERROR: selection is not empty.");
TestRunner.completeTest();
return;
}
InspectorTest.addResult(String.sprintf("Cursor position: line %d, column %d", selection.startLine, selection.startColumn));
InspectorTest.completeTest();
TestRunner.addResult(String.sprintf("Cursor position: line %d, column %d", selection.startLine, selection.startColumn));
TestRunner.completeTest();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
var test = function()
{
var totalDebuggerStatements = 4;
InspectorTest.runAsyncCallStacksTest(totalDebuggerStatements);
SourcesTestRunner.runAsyncCallStacksTest(totalDebuggerStatements);
}

</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
function test()
{
var totalDebuggerStatements = 2;
InspectorTest.runAsyncCallStacksTest(totalDebuggerStatements);
SourcesTestRunner.runAsyncCallStacksTest(totalDebuggerStatements);
}

</script>
Expand Down
Loading

0 comments on commit 788a447

Please sign in to comment.