qspin / qtaste

[NEW RELEASE VERSION 3.0.0] The QTaste is an open-source functional and non-functional test environment offering services to developers and testers. It has been implemented following a data driven testing philosophy.
http://www.qtaste.org
GNU Lesser General Public License v3.0
6 stars 11 forks source link

No function to check if a component is showing at top level #230

Open smxu opened 6 years ago

smxu commented 6 years ago

isVisible() returns true even if the component is hidden. I can find suitable interface in the exisiting code. So I made asolution on my local computer, is it possible to be included in the next release? Thanks. My solution: define a new interface in com.qspin.qtaste.javagui.server.JavaGUI: @Override public boolean isShowing(String componentName) throws QTasteException { LOGGER.trace("isShowing(\"" + componentName + "\")"); return new ComponentShowingChecker().executeCommand(COMPONENT_ENABLED_TIMEOUT, componentName); } Create a new class ComponentShowingChecker in com.qspin.qtaste.javagui.server:

package com.qspin.qtaste.javagui.server;

import com.qspin.qtaste.testsuite.QTasteException; import java.awt.*; import java.util.stream.Stream;

public class ComponentShowingChecker extends ComponentCommander {

@Override Boolean executeCommand(int timeout, String componentName, Object... data) throws QTasteException { Component c = getComponentByName(componentName); Component currentComponent = c; if (c == null) { LOGGER.debug("ComponentShowingChecker on a null component"); return false; } while (currentComponent != null) { boolean lastRun = currentComponent instanceof Window; // Dialog can have another window as parent.

     if (!currentComponent.isVisible())
     {
        if (c == currentComponent)
        {
           LOGGER.debug("The component " + c.getName() + " is not visible.");
        }
        else
        {
           LOGGER.debug(
                 "The parent (" + currentComponent.getName() + ") of the component " + c.getName() + " is not visible.");
        }
        return false;
     }
     if (lastRun)
     {
        break;
     }
     else
     {
        currentComponent = currentComponent.getParent();
     }
  }
  if (!isAccessible(c))
  {
     LOGGER.debug("The component \"" + componentName + "\" is not reachable as a modal dialog is opened.");
     return false;
  }
  return ((Window) currentComponent).isFocusableWindow();

}

private boolean isAccessible(Component c) { Window[] windows = getDisplayableWindows(); if (windows != null) { for (Window w : windows) { if (w.isShowing() && w instanceof Dialog && ((Dialog) w).isModal() && !w.isAncestorOf(c)) { return false; } } } return true; } }

dergo commented 6 years ago

Possibly a duplicate of issue #227 which is already solved (but not yet in a released version).

Could you please try isVisible() with the latest QTaste version from master branch of the repository to verify that your issue is still present ?

smxu commented 6 years ago

Hello Dergo, It’s not same as the problem of #277, the component.isVisible() still returns true because the window is not disposed at all which contains the component. Thanks for your quick response. Shiming

From: dergo [mailto:notifications@github.com] Sent: Thursday, December 07, 2017 3:58 PM To: qspin/qtaste Cc: Shiming Xu; Author Subject: Re: [qspin/qtaste] No function to check if a component is showing at top level (#230)

Possibly a duplicate of issue #227https://github.com/qspin/qtaste/issues/227 which is already solved (but not yet in a released version).

Could you please try isVisible() with the latest QTaste version from master branch of the repository to verify that your issue is still present ?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/qspin/qtaste/issues/230#issuecomment-349991636, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AgwNowIDQGgDa863dHECniWpN3XSkV9uks5s9_z3gaJpZM4Q5pxj.