Commit 3373887f authored by ioedeveloper's avatar ioedeveloper Committed by yann300

Added line class to hightlighter

parent f465caf2
...@@ -60,7 +60,7 @@ class SourceHighlighter { ...@@ -60,7 +60,7 @@ class SourceHighlighter {
} }
` `
this.statementMarker = this._deps.editor.addMarker(lineColumnPos, this.source, css.highlightcode.className + ' ' + css.customBackgroundColor.className) this.statementMarker = this._deps.editor.addMarker(lineColumnPos, this.source, css.highlightcode.className + ' ' + css.customBackgroundColor.className + ' ' + `highlightLine${lineColumnPos.start.line}`)
this._deps.editor.scrollToLine(lineColumnPos.start.line, true, true, function () {}) this._deps.editor.scrollToLine(lineColumnPos.start.line, true, true, function () {})
this.position = lineColumnPos this.position = lineColumnPos
if (lineColumnPos.start.line === lineColumnPos.end.line) { if (lineColumnPos.start.line === lineColumnPos.end.line) {
......
const EventEmitter = require('events')
class ScrollUp extends EventEmitter {
command (target, height) {
this.api.perform((done) => {
_scrollUp(this.api, target, height, () => {
done()
this.emit('complete')
})
})
return this
}
}
function _scrollUp (browser, target, height, cb) {
browser.execute(function (target, height) {
const element = document.querySelector(target)
element.scrollTop = element.scrollHeight - height
}, [target, height], function () {
cb()
})
}
module.exports = ScrollUp
...@@ -73,9 +73,16 @@ module.exports = { ...@@ -73,9 +73,16 @@ module.exports = {
}, },
'Should highlight source code': function (browser) { 'Should highlight source code': function (browser) {
browser.addFile('browser/sourcehighlight.js', sourcehighlightScript) browser.addFile('sourcehighlight.js', sourcehighlightScript)
.switchFile('browser/sourcehighlight.js') .switchFile('browser/sourcehighlight.js')
.executeScript('remix.exeCurrent()') .executeScript('remix.exeCurrent()')
.scrollUp('*[data-id="editorInput"]', 100)
.pause(5000)
.scrollUp('.ace_scroller', 100)
.waitForElementPresent('.highlightLine32')
.checkElementStyle('.highlightLine32', 'background-color', 'rgb(8, 108, 181)')
.waitForElementPresent('.highlightLine40')
.checkElementStyle('.highlightLine40', 'background-color', 'rgb(8, 108, 181)')
.end() .end()
}, },
...@@ -97,8 +104,9 @@ var aceThemes = { ...@@ -97,8 +104,9 @@ var aceThemes = {
} }
} }
const sourcehighlightScript = ` const sourcehighlightScript = {
(async () => { content: `
(async () => {
try { try {
const pos = { const pos = {
start: { start: {
...@@ -138,5 +146,6 @@ const sourcehighlightScript = ` ...@@ -138,5 +146,6 @@ const sourcehighlightScript = `
} catch (e) { } catch (e) {
console.log(e.message) console.log(e.message)
} }
})() })()
` `
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment