benjamin84 / fest

Automatically exported from code.google.com/p/fest
0 stars 0 forks source link

Ability to set global component matcher #158

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I want to be able to get a fixture based on visible attribute of the underlying 
component ie, title 
for JFrame and JDialog, buttont text for JButton.    Current implementation of 
default matcher 
uses getName() for all componens.  I want to be able to supply a global matcher 
strategy class to 
be used through out my test.

my matcher:
 public boolean matches(Component c) {
      String s = "";
      if (c instanceof JDialog) 
      {
          s=((JDialog)c).getTitle();
      }
      else
      if (c instanceof JFrame)
      {
          s = ((JFrame)c).getTitle();
      }
      else
      if (c instanceof JButton)
      {
          s = ((JButton)c).getText();
      }
      else
      {
          s = c.getName();
      }

    return areEqual(name, s) && type.isAssignableFrom(c.getClass()) && (!requireShowing || 
c.isShowing());
  }

What version of the product are you using? On what operating system?
-1.0.a2

Original issue reported on code.google.com by vnguyen....@gmail.com on 15 Jun 2008 at 5:37

GoogleCodeExporter commented 9 years ago

Original comment by Alex.Rui...@gmail.com on 15 Jun 2008 at 5:52

GoogleCodeExporter commented 9 years ago

Original comment by Alex.Rui...@gmail.com on 15 Jun 2008 at 5:55

GoogleCodeExporter commented 9 years ago
It is a very useful feature to add. I'm thinking about adding a new constructor 
to
all fixtures that take a GenericTypeMatcher. Is that what you are looking for? 
Please
let us know.

Thanks!
-Alex

Original comment by Alex.Rui...@gmail.com on 15 Jun 2008 at 5:59

GoogleCodeExporter commented 9 years ago
yes. constructor or setter method would be great.  While at it can you make it 
having cascading effect?  By 
that I mean the child fixture will take its parent custom type matcher if there 
is one.

mainFrameFixture.setCustomMatcher ( myCustomerMatcher );

DialogFixture dialogFixture = mainframeFixture.getDialog("foo");  // 
dialogFixture now alo usese my 
customer matcher!

thanks

Original comment by vnguyen....@gmail.com on 15 Jun 2008 at 6:34

GoogleCodeExporter commented 9 years ago
I'm thinking about dividing this issue into two issues:

1. Adding a constructor that takes a GenericTypeMatcher to all the fixtures 

2. Creating common-use matchers, like the one you described in this issues.

Thoughts?

Thanks!
-Alex

Original comment by Alex.Rui...@gmail.com on 18 Jul 2008 at 5:57

GoogleCodeExporter commented 9 years ago
That sounds good.

Original comment by vnguyen....@gmail.com on 20 Jul 2008 at 9:13

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Set the module as a label, instead of being part of the title.

Original comment by Alex.Rui...@gmail.com on 1 Dec 2008 at 2:03

GoogleCodeExporter commented 9 years ago
After careful consideration, I decided not to implement this feature. I think 
it will
complicate both FEST's code and users' code too much by having a super-matcher 
that
performs all component matching in a test. This feature can potentially add too 
many
responsibilities to a single class, resulting in bad OO design.

Original comment by Alex.Rui...@gmail.com on 18 Jan 2009 at 7:20