Skip to content

Commit

Permalink
#208: adds simple search test
Browse files Browse the repository at this point in the history
  • Loading branch information
rladstaetter committed Apr 3, 2024
1 parent f2bfa32 commit 15a71a5
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package app.logorrr.usecases.search

import app.logorrr.TestFiles
import app.logorrr.io.FileId
import app.logorrr.usecases.SingleFileApplicationTest
import app.logorrr.views.search.{SearchButton, SearchTextField}
import org.junit.jupiter.api.Test

class SimpleSearchTest extends SingleFileApplicationTest(TestFiles.simpleLog0) {

@Test def search(): Unit = {
openFile(path)

searchFor("1")
searchFor("2")
searchFor("3")
searchFor("4")
searchFor("0")

}

private def searchFor(needle: String) = {
clickOn(SearchTextField.id(FileId(path)).ref).write(needle)
clickOn(SearchButton.id(FileId(path)).ref)
}
}
1 change: 1 addition & 0 deletions app/src/main/scala/app/logorrr/views/LogoRRRNodes.scala
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,5 @@ object LogoRRRNodes {
val LogFileHeaderTabCloseButton = ".tab-container > .tab-close-button"



}
8 changes: 4 additions & 4 deletions app/src/main/scala/app/logorrr/views/search/OpsToolBar.scala
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,19 @@ class OpsToolBar(fileId: FileId
val regexToggleButton = new SearchActivateRegexToggleButton()

/** textfield to enter search queries */
val searchTextField = new SearchTextField(regexToggleButton)
val searchTextField = new SearchTextField(fileId, regexToggleButton)

private val searchButton = new SearchButton(searchTextField, regexToggleButton, colorPicker, addFilterFn)
private val searchButton = new SearchButton(fileId, searchTextField, regexToggleButton, colorPicker, addFilterFn)

val autoScrollCheckBox = new AutoScrollCheckBox(fileId)

val clearLogButton = new ClearLogButton(logEntries)

val copySelectionButton = new CopyLogButton(filteredList)

// val firstNEntries: ObservableList[LogEntry] = TimerSettingsLogView.mkEntriesToShow(logEntries)
// val firstNEntries: ObservableList[LogEntry] = TimerSettingsLogView.mkEntriesToShow(logEntries)

// val timerButton = new TimerButton(fileId, firstNEntries)
// val timerButton = new TimerButton(fileId, firstNEntries)

def execSearchOnHitEnter(event: KeyEvent): Unit = {
if (event.getCode == KeyCode.ENTER) {
Expand Down
15 changes: 13 additions & 2 deletions app/src/main/scala/app/logorrr/views/search/SearchButton.scala
Original file line number Diff line number Diff line change
@@ -1,15 +1,26 @@
package app.logorrr.views.search


import app.logorrr.util.ColorUtil
import app.logorrr.io.FileId
import app.logorrr.util.{ColorUtil, HashUtil}
import app.logorrr.views.LogoRRRNode
import javafx.scene.control.{Button, Tooltip}
import org.kordamp.ikonli.fontawesome5.FontAwesomeSolid
import org.kordamp.ikonli.javafx.FontIcon

class SearchButton(searchTextField: SearchTextField
object SearchButton {

def id(id: FileId): LogoRRRNode = LogoRRRNode("searchbutton-" + HashUtil.md5Sum(id))

}

class SearchButton(fileId: FileId
, searchTextField: SearchTextField
, regexToggleButton: SearchActivateRegexToggleButton
, colorPicker: SearchColorPicker
, addFilterFn: Filter => Unit) extends Button {

setId(SearchButton.id(fileId).value)
setGraphic(new FontIcon(FontAwesomeSolid.SEARCH))
setTooltip(new Tooltip("search"))
setMaxWidth(40)
Expand Down
15 changes: 13 additions & 2 deletions app/src/main/scala/app/logorrr/views/search/SearchTextField.scala
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
package app.logorrr.views.search

import app.logorrr.util.OsUtil
import app.logorrr.io.FileId
import app.logorrr.util.{HashUtil, OsUtil}
import app.logorrr.views.LogoRRRNode
import javafx.beans.binding.StringBinding
import javafx.scene.control.{TextField, Tooltip}

class SearchTextField(regexToggleButton: SearchActivateRegexToggleButton) extends TextField {
object SearchTextField {

def id(id: FileId): LogoRRRNode = LogoRRRNode("searchtextfield-" + HashUtil.md5Sum(id))
}

class SearchTextField(fileId: FileId
, regexToggleButton: SearchActivateRegexToggleButton)
extends TextField {

setId(SearchTextField.id(fileId).value)
setPrefWidth(200)
setMaxWidth(200)
setTooltip(new Tooltip(s"enter search pattern\n\nshortcut: ${OsUtil.osFun("CTRL-F", "COMMAND-F", "CTRL-F")}"))
Expand Down

0 comments on commit 15a71a5

Please sign in to comment.