-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#212: adds test to click on links in the about screen
- Loading branch information
1 parent
8a9c457
commit 876636f
Showing
16 changed files
with
160 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
app-tests/src/test/scala/app/logorrr/steps/VisibleItemActions.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package app.logorrr.steps | ||
|
||
import app.logorrr.usecases.TestFxBaseApplicationTest | ||
import app.logorrr.views.UiNode | ||
import org.testfx.api.FxRobotInterface | ||
|
||
trait VisibleItemActions { | ||
self: TestFxBaseApplicationTest => | ||
|
||
def waitAndClickVisibleItem(menu: UiNode): FxRobotInterface = { | ||
waitForVisibility(menu) | ||
clickOn(menu) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
app-tests/src/test/scala/app/logorrr/usecases/about/ShowAboutDialogTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package app.logorrr.usecases.about | ||
|
||
import app.logorrr.conf.Settings | ||
import app.logorrr.services.LogoRRRServices | ||
import app.logorrr.services.fileservices.EmptyFileService | ||
import app.logorrr.services.hostservices.MockHostServices | ||
import app.logorrr.steps.{CanStartApplication, VisibleItemActions} | ||
import app.logorrr.usecases.TestFxBaseApplicationTest | ||
import app.logorrr.views.UiNodes | ||
import app.logorrr.views.about.AboutScreen | ||
import org.junit.jupiter.api.Test | ||
|
||
|
||
class ShowAboutDialogTest extends TestFxBaseApplicationTest | ||
with CanStartApplication | ||
with VisibleItemActions { | ||
|
||
// to get a handle to clicked urls | ||
val mockHostServices = new MockHostServices | ||
|
||
final def services: LogoRRRServices = { | ||
LogoRRRServices(Settings.Default | ||
, mockHostServices | ||
, new EmptyFileService | ||
, isUnderTest = true) | ||
} | ||
|
||
|
||
@Test def showAboutDialog(): Unit = { | ||
waitAndClickVisibleItem(UiNodes.HelpMenu) | ||
waitAndClickVisibleItem(UiNodes.HelpMenuAbout) | ||
|
||
waitAndClickVisibleItem(UiNodes.AboutDialogOpenLogorrrMainSite) | ||
waitAndClickVisibleItem(UiNodes.AboutDialogOpenDevelopmentBlog) | ||
waitAndClickVisibleItem(UiNodes.AboutDialogOpenIssuePage) | ||
|
||
assert(AboutScreen.links.map(_.url.toString).forall(u => mockHostServices.visitedUrls.contains(u))) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
app/src/main/scala/app/logorrr/services/fileservices/EmptyFileService.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package app.logorrr.services.fileservices | ||
|
||
import java.nio.file.Path | ||
|
||
class EmptyFileService extends LogoRRRFileOpenService { | ||
override def openFile: Option[Path] = None | ||
} |
4 changes: 3 additions & 1 deletion
4
app/src/main/scala/app/logorrr/services/hostservices/LogoRRRHostServices.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
app/src/main/scala/app/logorrr/services/hostservices/MacNativeHostService.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package app.logorrr.services.hostservices | ||
|
||
import app.logorrr.OsxBridge | ||
import app.logorrr.views.UiNode | ||
|
||
/** | ||
* Delegate opening urls directly to native code on mac (because of apples entitlements / security system) | ||
*/ | ||
class MacNativeHostService extends LogoRRRHostServices { | ||
/** opens given document */ | ||
override def showDocument(uiNode: UiNode, url: String): Unit = { | ||
OsxBridge.openUrl(url) | ||
} | ||
} |
10 changes: 9 additions & 1 deletion
10
app/src/main/scala/app/logorrr/services/hostservices/MockHostServices.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,17 @@ | ||
package app.logorrr.services.hostservices | ||
|
||
import app.logorrr.util.CanLog | ||
import app.logorrr.views.UiNode | ||
import javafx.collections.{FXCollections, ObservableList} | ||
|
||
class MockHostServices extends LogoRRRHostServices with CanLog { | ||
|
||
override def showDocument(url: String): Unit = logTrace(s"showing '$url'.") | ||
/** used for tests */ | ||
val visitedUrls: ObservableList[String] = FXCollections.observableArrayList[String]() | ||
|
||
override def showDocument(uiNode: UiNode, url: String): Unit = { | ||
visitedUrls.add(url) | ||
logTrace(s"showing '$url'.") | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,29 @@ | ||
package app.logorrr.util | ||
|
||
import app.logorrr.conf.LogoRRRGlobals | ||
import app.logorrr.views.UiNode | ||
import javafx.scene.control.Hyperlink | ||
|
||
import java.net.{URI, URL} | ||
|
||
object HLink { | ||
|
||
def apply(url: String, description: String): HLink = { | ||
apply(URI.create(url).toURL, description) | ||
def apply(uiNode: UiNode | ||
, url: String | ||
, description: String): HLink = { | ||
apply(uiNode, URI.create(url).toURL, description) | ||
} | ||
|
||
} | ||
|
||
case class HLink(url: URL | ||
case class HLink(uiNode: UiNode | ||
, url: URL | ||
, description: String) { | ||
|
||
def mkHyperLink(): Hyperlink = { | ||
val hyperlink = new Hyperlink(description) | ||
hyperlink.setOnAction(_ => LogoRRRGlobals.getHostServices.showDocument(url.toString)) | ||
hyperlink.setId(uiNode.value) | ||
hyperlink.setOnAction(_ => LogoRRRGlobals.getHostServices.showDocument(uiNode, url.toString)) | ||
hyperlink | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters