-
-
Notifications
You must be signed in to change notification settings - Fork 14.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The test attempts to verify that JCEF works by building a simple browser application and checking that it can display the `chrome://system` page.
- Loading branch information
Showing
5 changed files
with
100 additions
and
0 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
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,34 @@ | ||
import com.jetbrains.cef.JCefAppConfig; | ||
import java.util.concurrent.CountDownLatch; | ||
import java.util.concurrent.TimeUnit; | ||
import javax.swing.JFrame; | ||
import org.cef.CefApp; | ||
import org.cef.CefSettings; | ||
import org.cef.browser.CefRendering; | ||
|
||
public class BrowserTest { | ||
private static void fail(String message) { | ||
throw new RuntimeException(message); | ||
} | ||
|
||
public static void main(String[] args) throws InterruptedException { | ||
var started = CefApp.startup(args); | ||
var config = JCefAppConfig.getInstance(); | ||
|
||
var settings = config.getCefSettings(); | ||
var app = CefApp.getInstance(settings); | ||
var latch = new CountDownLatch(1); | ||
app.onInitialization(s -> latch.countDown()); | ||
latch.await(30, TimeUnit.SECONDS); | ||
if (latch.getCount() > 0) { | ||
fail("CEF initialization timed out"); | ||
} | ||
|
||
var client = app.createClient(); | ||
var browser = client.createBrowser("chrome://system", CefRendering.DEFAULT, false); | ||
var frame = new JFrame("browser test"); | ||
frame.add(browser.getUIComponent()); | ||
frame.setSize(640, 480); | ||
frame.setVisible(true); | ||
} | ||
} |
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,25 @@ | ||
# Tests if opening a JCEF window with chrome://about by building | ||
# and running a simple Java application using JBR. | ||
{ lib, ... }: | ||
{ | ||
name = "jetbrains-jdk-jcef"; | ||
|
||
meta.maintainers = with lib.maintainers; [ liff ]; | ||
|
||
enableOCR = true; | ||
|
||
nodes.machine = | ||
{ lib, pkgs, ... }: | ||
let | ||
jbr-browser-test = pkgs.callPackage ./jbr-browser-test.nix { }; | ||
in | ||
{ | ||
services.cage.program = lib.getExe jbr-browser-test; | ||
imports = [ ../common/wayland-cage.nix ]; | ||
}; | ||
|
||
testScript = '' | ||
machine.wait_for_unit('graphical.target') | ||
machine.wait_for_text('CHROME VERSION', timeout=90) | ||
''; | ||
} |
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,30 @@ | ||
{ | ||
stdenv, | ||
lib, | ||
makeWrapper, | ||
jetbrains, | ||
}: | ||
|
||
stdenv.mkDerivation { | ||
name = "jbr-browser-test"; | ||
|
||
src = ./BrowserTest.java; | ||
dontUnpack = true; | ||
|
||
nativeBuildInputs = [ makeWrapper ]; | ||
buildInputs = [ jetbrains.jdk ]; | ||
|
||
buildPhase = '' | ||
cp $src BrowserTest.java | ||
javac BrowserTest.java | ||
''; | ||
|
||
installPhase = '' | ||
mkdir --parents $out/{lib,bin} | ||
cp *.class $out/lib/ | ||
makeWrapper ${lib.getBin jetbrains.jdk}/bin/java $out/bin/jbr-browser-test \ | ||
--append-flags "-cp $out/lib BrowserTest" | ||
''; | ||
|
||
meta.mainProgram = "jbr-browser-test"; | ||
} |
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