dotxyteam / SwingTestingToolkit

Java-Swing GUI testing framework
8 stars 0 forks source link

App window modified by recording #4

Open MarcMazas opened 4 days ago

MarcMazas commented 4 days ago

Hi When I want to record a test case with TestEditor on my application, the first time I click in the app window, this one changes : textFields see their withs reduced near zero, which prevents reading their texts. See attached captures: FlipperNormal FlipperAfterRecording I am missing something ? If not, is there a workaround, or could you tell me in which classes this behavior can be investigated? TIA

dotxyteam commented 1 day ago

There is a workaround: you can disable highlighting by using a custom Tester object :

        Tester tester = new Tester() {
            @Override
            protected void highlightCurrentComponent() {
                // do nothing
            }
            @Override
            protected void unhighlightCurrentComponent() {
                // do nothing
            }           
        };
        TestingUtils.assertSuccessfulReplay(tester, new File("test-specifications/testFlipper.stt"));
MarcMazas commented 1 day ago

OK. I see that changing the border (adding an outside border of 1 thickness in createCompoundBorder) causes the problem. I tried repacking the frame and it seems working.

        if (currentComponent instanceof JComponent) {
            currentComponentBorder = ((JComponent) currentComponent).getBorder();
            try {
                ((JComponent) currentComponent).setBorder( //
                        BorderFactory.createCompoundBorder( //
                                BorderFactory.createLineBorder(HIGHLIGHT_FOREGROUND, 1), //
                                currentComponentBorder) //
                );
            } catch (Throwable ignore) {
            }
            JFrame frame = (JFrame) SwingUtilities.getRoot(currentComponent);
            frame.pack();
        }