benjamin84 / fest

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

JSpinnerDriver.enterText press enter #161

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Testing a form with a lot of controls
2. JSpinnerDriver.enterText(...)

What is the expected output? What do you see instead?

See -
...
in JSpinnerDriver.enterText:
      textComponentDriver.replaceText(editor, text);
      robot.pressAndReleaseKeys(VK_ENTER);
...

on enter key - form unexpectedly submitted (VK_ENTER -> default form's
button pressed (e.g "OK")

Probably robot.pressAndReleaseKeys(VK_ENTER) should not be called in
enterText ?

Original issue reported on code.google.com by filim...@gmail.com on 19 Jun 2008 at 1:01

GoogleCodeExporter commented 9 years ago
Quick question, which operating system are you using?

Thanks!
-Alex

Original comment by Alex.Rui...@gmail.com on 19 Jun 2008 at 2:26

GoogleCodeExporter commented 9 years ago
Windows XP, but it does'not really depend on os. 

It is standart behavior for default button. You can set default button with:
getRootPane().setDefaultButton(...);

Find useful little sample (not sure if it will compile =)): 
enter in spin - > press default button

        JDialog f = new JDialog();
        f.addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
                System.exit(0);
            }
        });

        JButton btOK = new JButton(new AbstractAction("Ok and close") {

            @Override
            public void actionPerformed(ActionEvent e) {
                System.out.println("OK PRESSED");
            }
        });

        f.getRootPane().setDefaultButton(btOK);
        JSpinner spinner = new JSpinner();
        spinner.setName("spinner");

        JPanel p = new JPanel();
        p.add(spinner);
        p.add(btOK);
        f.getContentPane().add(p);

        f.pack();
        f.setSize(new Dimension(300, 200));

        f.setVisible(true);

Original comment by filim...@gmail.com on 19 Jun 2008 at 5:08

GoogleCodeExporter commented 9 years ago
We need to press 'ENTER' after entering text, otherwise the selection in the 
spinner
will not change. I suggest to use the 'increment', 'increment(int times)',
'decrement', 'decrement(int)' instead of 'enterText'. You are setting a default
button in your form, which is triggered by the 'ENTER' pressed by 'enterText'.

I'm marking this bug as 'Invalid' (IMHO, is not a bug.) Please feel to re-open 
it if
you think otherwise.

Cheers,
-Alex

Original comment by Alex.Rui...@gmail.com on 8 Jul 2008 at 12:52

GoogleCodeExporter commented 9 years ago
I think its a bug.
In my case it will be increment(Integer.MAX_VALUE) - life-long test.

btw: not understood about selection.

Original comment by filim...@gmail.com on 10 Jul 2008 at 5:50

GoogleCodeExporter commented 9 years ago
I see your point. Two things:

1. We need to press 'enter' after entering text, otherwise whatever text is 
entered
will not be applied to the spinner. For example, let's say the spinner has 
values
from 1 to 5. If we tell FEST to enter the text "4" without pressing 'enter', the
value of the spinner will not change to 4.

2. Instead of removing the 'press enter' behavior, I propose adding the method

select(String value)

which will increment/decrement the values in the spinner until the given value 
is
found. I think it will offer the functionality that you are looking for.

Please let me know what you think :)

Thanks!
-Alex

Original comment by Alex.Rui...@gmail.com on 14 Jul 2008 at 7:24

GoogleCodeExporter commented 9 years ago
Thanks for answer! =)
I thought JSpinner have to be updated from underlying textbox at least on focus 
lost.
I believe increment/decrement is not enough: e.g. if step is set to 1000, and 
you
have to enter 999 1001 for testing purposes, etc...

Original comment by filim...@gmail.com on 14 Jul 2008 at 7:41

GoogleCodeExporter commented 9 years ago
Besides if JSpinner itself not updated on enter text, why we have force it do 
it? It
is JSpinner behaivor. And if, e.g. we are testing form and when user entered 
text in
JSpinner - its model is not updated, but in our tests - it is updated at that 
moment.

Original comment by filim...@gmail.com on 14 Jul 2008 at 7:53

GoogleCodeExporter commented 9 years ago
A comment on comment 5.

A select(String value) method would definitely be useful.
I would rather call it spinToValue.

Regards,
Csabi

Original comment by csaba.ju...@gmail.com on 17 Jul 2008 at 7:54

GoogleCodeExporter commented 9 years ago
Removed pressing 'ENTER' in 'enterText' and added the method 
'enterTextAndCommit'. 
I'm not completely sure if adding 'select(String)' would be feasible to 
implement. 
JSpinners do not have a particular order and searching for a value will result 
in a 
sequential search, which could be slow, depending on the number of values.

Original comment by wanghy1...@gmail.com on 5 Aug 2008 at 1:57

GoogleCodeExporter commented 9 years ago
This was a bug, not an enhancement request :)

Original comment by wanghy1...@gmail.com on 5 Aug 2008 at 2:00

GoogleCodeExporter commented 9 years ago
Hi Yvonne,

I have a JSpinner using SpinnerNumberModel with a default value of 3 and a 
range from
2 to 50. The editor's text field is not editable.
In my test case I have to set the spinner to 5. Currently my only option is
increment(2). This is OK for now, but the default value of 3 might change.
I think that a select(String) method would be useful.
If a checkbox's text field isn't editable and the range of values is too wide, 
it is
a case of bad UI design, the textbox should be made editable.
In other cases I really think that a select(String) method would be OK.

Thank you,
Csabi

Original comment by csaba.ju...@gmail.com on 11 Aug 2008 at 11:04

GoogleCodeExporter commented 9 years ago
Hi Csabi,

I agree with you, we need this functionality. I filed issue 196 ( 
http://code.google.com/p/fest/issues/detail?id=196 ) to take care of this :)

Thanks!
-Yvonne

Original comment by wanghy1...@gmail.com on 11 Aug 2008 at 5:03

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:05