RFR: 8239880: CSS tests should cleanup any global state they modify

Ambarish Rapte arapte at openjdk.java.net
Wed Apr 21 09:26:15 UTC 2021


The tests that are modified in this PR set a stylesheet using API `StyleManager.getInstance().setDefaultUserAgentStylesheet()`.
This is a global state and should be reset after execution of each test.
It does not cause any test failures currently, but this has caused a test failure in past reported here [JDK-8239822](https://bugs.openjdk.java.net/browse/JDK-8239822) which was fixed with a similar change like in this PR.

A reset method like following seems sufficient to undo the changes made by `StyleManager.getInstance().setDefaultUserAgentStylesheet()`.
But this fix uses the same method definition of `resetStyleManager()` like in the [fix](https://git.openjdk.java.net/jfx/commit/c3ee1a30) for [JDK-8239822](https://bugs.openjdk.java.net/browse/JDK-8239822)


private static void resetStyleManager() {
    StyleManager sm = StyleManager.getInstance();
    sm.platformUserAgentStylesheetContainers.clear();
    sm.hasDefaultUserAgentStylesheet = false;
}


Fix also has 2 cleanup changes,
1. A minor typo correction in code, `StyleManager.getInstance().getInstance()` is replaced with `StyleManager.getInstance()`.
2. In test file _HonorDeveloperSettingsTest.java_: Unused class `TestWindow` is removed and few line of commented out code(which used the TestWindow class) is removed.

-------------

Commit messages:
 - reset StyleManager after test execution

Changes: https://git.openjdk.java.net/jfx/pull/470/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jfx&pr=470&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8239880
  Stats: 71 lines in 4 files changed: 48 ins; 10 del; 13 mod
  Patch: https://git.openjdk.java.net/jfx/pull/470.diff
  Fetch: git fetch https://git.openjdk.java.net/jfx pull/470/head:pull/470

PR: https://git.openjdk.java.net/jfx/pull/470


More information about the openjfx-dev mailing list