/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
@test
@bug 6463545
@summary Tests javax.swing.LayoutFocusTraversalPolicy functionality.
@author anton.tarasov, oleg.sukhodolsky: area=awt.focus
@library ../../regtesthelpers
@build AbstractPolicyTest
@run main LayoutFTPTest
*/
/*
Below are some notes about changes in SortingFocusTraversalPolicy behaviour.
container(root) [...] - focus traversal cycle with the <container> as the root.
container(provider) [...] - focus traversal cycle with the <container> as the provider.
container(..)(focusable) [...] - <container> is implicitly set focusable.
comp[unfocusable] - <comp> is set unfocusable.
1. frame [ container(root)(focusable) [...] ]
- getComponentAfter(<frame>, <container>) returns <container>.
If <container> is the default component to focus in its own cycle. * NO CHANGE *
3. frame [ comp1 container(root)(focusable) [ comp2 ] comp3 ]
- getComponentBefore(<frame>, <comp3>) returns <comp2>. ** BEHAVIOUR CHANGE **
Previously <container> would be returned. This was a bug as it
wasn't according to the spec.
- getComponentBefore(<container>, <comp2>) returns <container>. * NO CHANGE *
- getComponentBefore(<frame>, <container>) returns <comp1>. * NO CHANGE *
- getComponentBefore(<container>, <container>) returns <comp2>. * NO CHANGE *
4. frame [ container(provider) [...] comp ]
- getComponentAfter(<frame>, <container>) returns <container>'s default. ** BEHAVIOUR CHANGE. SPEC ADDITION **
Previously <comp> would be returned. Not specified in the spec.
- getComponentBefore(<frame>, <comp>) returns <container>'s last. ** SPEC CHANGE **
The spec says (incorrectly) that default should be returned.
5. frame [ container(provider)(focusable) [...] comp2 ]
- getComponentBefore(<frame>, <comp2>) returns <container>'s last. ** BEHAVIOUR CHANGE. SPEC ADDITION **
Previously <container> would be returned. Not specified in the spec.
6. frame [ comp1 container(root) [...] comp2 ]
- getComponentAfter(<frame>, <comp1>) returns <container>'s default. ** BEHAVIOUR CHANGE. SPEC ADDITION **
Previously <comp2> would be returned. It's just the fix for 6240842.
Not specified in the spec.
7. frame [ comp1 container(root) [...] comp2(unfocusable) comp3 ]
- getComponentBefore(<frame>, <comp3>) returns <container>'s default. ** BEHAVIOUR CHANGE **
Previously <comp1> would be returned. This was a bug, because
in case if <comp2> is focusable getComponentBefore(<frame>, <comp2>) would
return <container>'s default.
*/
public class LayoutFTPTest {
}
public void start() {
try {
for (int i = 1; i <= TESTS_NUMBER; i++) {
}
}
} catch (RuntimeException rte) {
throw rte;
} catch (Exception e) {
throw new RuntimeException("Error: unexpected exception cought!", e);
}
}
}
/*
* frame [ container1 [...] container2 [...] container3 [...] ]
* - verifies simple configuration.
*/
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
}
}
return jframe;
}
protected void customizeHierarchy() {
}
return order;
}
return order;
}
return new String[] {"jframe"};
}
return "btn 0";
}
return "btn 0";
}
return "btn 202";
}
}
/*
* frame [ comp container(provider) [...] comp ]
* - transfering focus through a provider.
*/
return jframe;
}
protected void customizeHierarchy() {
}
return order;
}
return order;
}
}
return "btn 1";
return "btn 2";
}
return null;
}
return getDefaultComp(focusCycleRoot_id);
}
return "btn 4";
return "btn 3";
}
return null;
}
}
/*
* frame [ comp container(root) [...] comp ]
* - transfering focus through a root (includes the case reported in the CR 6240842).
*/
return jframe;
}
protected void customizeHierarchy() {
}
return order;
}
return order;
}
}
return "btn 1";
return "btn 2";
}
return null;
}
return getDefaultComp(focusCycleRoot_id);
}
return "btn 4";
return "btn 3";
}
return null;
}
}
/*
* frame [ container(provider) [...] comp1(unfocusable) comp2 ]
* - getComponentBefore(<frame>, <comp2>) should return <container>'s last.
*/
return jframe;
}
protected void customizeHierarchy() {
}
return order;
}
// no testing
return null;
}
return null;
}
return null;
}
return null;
}
return null;
}
}
/*
* frame [ container(root) [...] comp1(unfocusable) comp2 ]
* - getComponentBefore(<frame>, <comp2>) should return <container>'s default.
*/
return jframe;
}
protected void customizeHierarchy() {
}
return order;
}
// no testing
return null;
}
return null;
}
return null;
}
return null;
}
return null;
}
}
/*
* frame [ comp container(provider)(focusable) [...] comp ]
* - transfering focus through a focusable provider.
*/
return jframe;
}
protected void customizeHierarchy() {
return getComponent("btn 2");
}
});
}
return order;
}
return order;
}
return new String[] {"jpanel"};
}
return "btn 2";
}
return "jpanel";
}
return "btn 3";
}
}
/*
* frame [ comp container(root)(focusable) [...] comp ]
* - transfering focus through a focusable root.
*/
return jframe;
}
protected void customizeHierarchy() {
return getComponent("btn 2");
}
});
}
return order;
}
return order;
}
return new String[] {"jpanel"};
}
return "btn 2";
}
return "jpanel";
}
return "btn 3";
}
}
/*
* frame [ comp1 comp2 container1(provider) [...] container2(root) [...] ]
* - verifies a case when a provider is followed by a root.
*/
return jframe;
}
protected void customizeHierarchy() {
return getComponent("btn-4");
}
});
return getComponent("btn-7");
}
});
}
return order;
}
return order;
}
}
return "btn-1";
return "btn-4";
return "btn-7";
}
return null;
}
return "btn-1";
return "btn-3";
return "btn-6";
}
return null;
}
return "btn-5";
return "btn-5";
return "btn-8";
}
return null;
}
}
/*
* frame [ comp1 comp2 container1(root) [...] container2(provider) [...] ]
* - verifies a case when a root is followed by a provider.
*/
return jframe;
}
protected void customizeHierarchy() {
return getComponent("btn-4");
}
});
return getComponent("btn-7");
}
});
}
return order;
}
return order;
}
}
return "btn-1";
return "btn-4";
return "btn-7";
}
return null;
}
return "btn-1";
return "btn-3";
return "btn-6";
}
return null;
}
return "btn-8";
return "btn-5";
return "btn-8";
}
return null;
}
}
/*
* frame [ container0 [...] container1(root) [ comp1 comp2 container2(provider) [...] ] ]
* - verifies a case when a provider is nested in a root.
*/
return jframe;
}
protected void customizeHierarchy() {
return getComponent("panel-2");
}
});
}
return order;
}
return order;
}
}
return "btn-1";
return "panel-2";
return "btn-5";
}
return null;
}
return "btn-1";
return "btn-3";
return "btn-5";
}
return null;
}
return "btn-2";
} else {
return "btn-6";
}
}
}
/*
* frame [ container(root) [...] comp ]
* - getDefaultComponent(<frame>) should implicitly down-cycle into the <container>.
* - getFirstComponent(<frame>) should implicitly down-cycle into the <container>.
*/
return jframe;
}
protected void customizeHierarchy() {
}
return order;
}
return order;
}
return new String[] {"jframe"};
}
return "btn-1";
}
return "btn-1";
}
return "btn-3";
}
}