/*
 * MIT License
 *
 * Copyright (c) 2020 Jannis Weis
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 *
 */
package test;

import java.awt.*;
import java.awt.image.BufferedImage;
import java.lang.reflect.InvocationTargetException;

import javax.swing.*;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledOnOs;
import org.junit.jupiter.api.condition.OS;

import com.github.weisj.darklaf.LafManager;
import com.github.weisj.darklaf.theme.IntelliJTheme;
import com.github.weisj.darklaf.ui.tooltip.ToolTipConstants;
import com.github.weisj.darklaf.util.DarkUIUtil;
import com.github.weisj.darklaf.util.SystemInfo;

public class TooltipTest extends AbstractImageTest {

    public TooltipTest() {
        super("tooltip");
    }

    @BeforeAll
    static void setup() {
        LafManager.install(new IntelliJTheme());
    }

    private JToolTip createTooltip() {
        JToolTip toolTip = new JToolTip();
        toolTip.setTipText("Test ToolTip");
        toolTip.putClientProperty(ToolTipConstants.KEY_STYLE, ToolTipConstants.VARIANT_BALLOON);
        toolTip.setSize(toolTip.getPreferredSize());
        toolTip.doLayout();
        return toolTip;
    }

    @Test
    @EnabledOnOs({OS.MAC, OS.WINDOWS})
    public void testTooltipTransparency() throws InvocationTargetException, InterruptedException {
        JToolTip toolTip = createTooltip();

        SwingUtilities.invokeAndWait(() -> {
            Popup popup = PopupFactory.getSharedInstance().getPopup(null, toolTip, 0, 0);
            popup.show();
        });

        Window window = DarkUIUtil.getWindow(toolTip);
        SwingUtilities.invokeAndWait(() -> window.setOpacity(1));

        SwingUtilities.invokeLater(() -> {

            JRootPane rootPane = SwingUtilities.getRootPane(window);
            Assertions.assertNotNull(rootPane, "RootPane is null");
            Assertions.assertFalse(rootPane.isOpaque(), "RootPane is opaque");

            Color backgroundColor = window.getBackground();
            Assertions.assertNotNull(backgroundColor, "Background is null");
            Assertions.assertEquals(0, backgroundColor.getAlpha(), "Background is opaque");

            BufferedImage img = saveScreenShot(getPath("tooltip_" + SystemInfo.getOsName()), window);
            Assertions.assertNotNull(img, "Tooltip Image is null");
            int alpha = getAlpha(img.getRGB(img.getMinX(), img.getMinY() + img.getHeight() - 1));
            Assertions.assertEquals(0, alpha, "Tooltip is opaque");
        });
    }

    private int getAlpha(final int rgb) {
        return new Color(rgb, true).getAlpha();
    }
}

@@ -1217,46 +1217,46 @@
 ava.
-lang.reflect.InvocationTargetException
+util.concurrent.atomic.AtomicReference
 ;%0A%0Ai
@@ -2394,46 +2394,8 @@
 ows 
-InvocationTargetException, Interrupted
 Exce
@@ -2739,24 +2739,97 @@
 acity(1));%0A%0A
+        AtomicReference%3CException%3E exception = new AtomicReference%3C%3E();%0A%0A
         Swin
@@ -2859,17 +2859,38 @@
 () -%3E %7B%0A
-%0A
+            try %7B%0A    
         
@@ -2954,32 +2954,36 @@
 w);%0A            
+ 
+   
 Assertions.asser
@@ -3014,32 +3014,36 @@
 Pane is null%22);%0A
+    
             Asse
@@ -3118,16 +3118,20 @@
         
+   
+ 
 Color ba
@@ -3166,24 +3166,28 @@
 ckground();%0A
+    
             
@@ -3243,32 +3243,36 @@
 ound is null%22);%0A
+    
             Asse
@@ -3360,16 +3360,20 @@
         
+    
 Buffered
@@ -3458,32 +3458,36 @@
 w);%0A            
+    
 Assertions.asser
@@ -3538,16 +3538,20 @@
         
+  
+  
 int alph
@@ -3632,32 +3632,36 @@
 ));%0A            
+    
 Assertions.asser
@@ -3708,17 +3708,189 @@
         
+   
-%7D
+ %7D catch (Exception e) %7B%0A                exception.set(e);%0A            %7D%0A        %7D);%0A%0A        Assertions.assertNotNull(exception.get(), () -%3E exception.get().getMessage()
 );%0A    %7D

Make sure test fails if assertion isn't met on EDT.