-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
IDEA-283718 com.intellij.ui.jcef.JCEFHtmlPanel ctor causes disposal e…
…rror GitOrigin-RevId: 3fc4401d6fc5876f00654145db89f739d50fd1c9
- Loading branch information
1 parent
521658a
commit 66b51c1
Showing
2 changed files
with
55 additions
and
3 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
55 changes: 55 additions & 0 deletions
55
platform/platform-tests/testSrc/com/intellij/ui/jcef/IDEA283718Test.java
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,55 @@ | ||
// Copyright 2000-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. | ||
package com.intellij.ui.jcef; | ||
|
||
import com.intellij.openapi.util.Disposer; | ||
import com.intellij.testFramework.ApplicationRule; | ||
import com.intellij.testFramework.NonHeadlessRule; | ||
import com.intellij.ui.scale.TestScaleHelper; | ||
import junit.framework.TestCase; | ||
import org.jetbrains.annotations.Nullable; | ||
import org.junit.*; | ||
import org.junit.rules.TestRule; | ||
|
||
/** | ||
* Tests https://youtrack.jetbrains.com/issue/IDEA-283718 | ||
* 1) JCEFHtmlPanel should not additionally chain the new browser instance for disposal. | ||
* 2) JCEFHtmlPanel should be auto-disposed after its client. | ||
* | ||
* @author tav | ||
*/ | ||
public class IDEA283718Test { | ||
@Rule public TestRule nonHeadless = new NonHeadlessRule(); | ||
@ClassRule public static final ApplicationRule appRule = new ApplicationRule(); | ||
|
||
@Before | ||
public void before() { | ||
TestScaleHelper.assumeStandalone(); | ||
} | ||
|
||
@Test | ||
public void test() { | ||
// | ||
// Try external JBCefClient. | ||
// | ||
doTest(JBCefApp.getInstance().createClient()); | ||
|
||
// | ||
// Try default JBCefClient. | ||
// | ||
doTest(null); | ||
} | ||
|
||
private static void doTest(@Nullable JBCefClient client) { | ||
JBCefBrowserBase browser = null; | ||
try { | ||
browser = new JCEFHtmlPanel(client, "about:blank"); | ||
} catch (RuntimeException ex) { | ||
TestCase.fail("Exception occurred: " + ex.getMessage()); | ||
ex.printStackTrace(); | ||
} | ||
if (client == null) client = browser.getJBCefClient(); | ||
TestCase.assertFalse(browser.isDisposed()); | ||
Disposer.dispose(client); | ||
TestCase.assertTrue(browser.isDisposed()); | ||
} | ||
} |