jdk/test/java/awt/Focus/FocusTraversalPolicy/LayoutFTPTest.java
author goetz
Tue, 14 Jun 2016 10:44:59 +0200
changeset 39056 d99e63b6d962
parent 5506 202f599c92aa
permissions -rw-r--r--
8159690: [TESTBUG] Mark headful tests with @key headful. Reviewed-by: simonis, alexsch
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
39056
d99e63b6d962 8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents: 5506
diff changeset
     2
 * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3082
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3082
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3082
diff changeset
    21
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
  @test
39056
d99e63b6d962 8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents: 5506
diff changeset
    26
  @key headful
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
  @bug       6463545
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
  @summary   Tests javax.swing.LayoutFocusTraversalPolicy functionality.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
  @author    anton.tarasov, oleg.sukhodolsky: area=awt.focus
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
  @library   ../../regtesthelpers
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
  @build     AbstractPolicyTest
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
  @run       main LayoutFTPTest
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import java.awt.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import javax.swing.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import java.awt.event.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
import java.util.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
import test.java.awt.regtesthelpers.AbstractPolicyTest;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
Below are some notes about changes in SortingFocusTraversalPolicy behaviour.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
container(root) [...]           - focus traversal cycle with the <container> as the root.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
container(provider) [...]       - focus traversal cycle with the <container> as the provider.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
container(..)(focusable) [...]  - <container> is implicitly set focusable.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
comp[unfocusable]               - <comp> is set unfocusable.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
1. frame [ container(root)(focusable) [...] ]
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
- getComponentAfter(<frame>, <container>) returns <container>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
  If <container> is the default component to focus in its own cycle.  * NO CHANGE *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
3. frame [ comp1 container(root)(focusable) [ comp2 ] comp3 ]
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
- getComponentBefore(<frame>, <comp3>) returns <comp2>.                                 ** BEHAVIOUR CHANGE **
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
  Previously <container> would be returned. This was a bug as it
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
  wasn't according to the spec.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
- getComponentBefore(<container>, <comp2>) returns <container>.     * NO CHANGE *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
- getComponentBefore(<frame>, <container>) returns <comp1>.         * NO CHANGE *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
- getComponentBefore(<container>, <container>) returns <comp2>.     * NO CHANGE *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
4. frame [ container(provider) [...] comp ]
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
- getComponentAfter(<frame>, <container>) returns <container>'s default.                ** BEHAVIOUR CHANGE. SPEC ADDITION **
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
  Previously <comp> would be returned. Not specified in the spec.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
- getComponentBefore(<frame>, <comp>) returns <container>'s last.                       ** SPEC CHANGE **
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
  The spec says (incorrectly) that default should be returned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
5. frame [ container(provider)(focusable) [...] comp2 ]
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
- getComponentBefore(<frame>, <comp2>) returns <container>'s last.                      ** BEHAVIOUR CHANGE. SPEC ADDITION **
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
  Previously <container> would be returned. Not specified in the spec.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
6. frame [ comp1 container(root) [...] comp2 ]
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
- getComponentAfter(<frame>, <comp1>) returns <container>'s default.                    ** BEHAVIOUR CHANGE. SPEC ADDITION **
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
  Previously <comp2> would be returned. It's just the fix for 6240842.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
  Not specified in the spec.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
7. frame [ comp1 container(root) [...] comp2(unfocusable) comp3 ]
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
- getComponentBefore(<frame>, <comp3>) returns <container>'s default.                   ** BEHAVIOUR CHANGE **
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
  Previously <comp1> would be returned. This was a bug, because
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
  in case if <comp2> is focusable getComponentBefore(<frame>, <comp2>) would
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
  return <container>'s default.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
public class LayoutFTPTest {
3082
24c8d93ac1e1 4788402: SortingFocusTraversalPolicy: prob with non-focusable focus Cycle Root as first
ant
parents: 2
diff changeset
   109
    final int TESTS_NUMBER = 11;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    public static void main(String[] args) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
        LayoutFTPTest app = new LayoutFTPTest();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
        app.start();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    public void start() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
            Class clazz = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
            AbstractPolicyTest test = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
            for (int i = 1; i <= TESTS_NUMBER; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
                clazz = Class.forName("PolicyTest" + i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
                if (clazz != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
                    test = (AbstractPolicyTest)clazz.newInstance();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
                    System.out.print("Test " + i + " is in progress...");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
                    test.testIt();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
                    System.out.println(" passed.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
        } catch (RuntimeException rte) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
            throw rte;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
        } catch (Exception e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
            throw new RuntimeException("Error: unexpected exception cought!", e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
 * frame [ container1 [...] container2 [...] container3 [...] ]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
 * - verifies simple configuration.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
class PolicyTest1 extends AbstractPolicyTest {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
    protected Frame createFrame() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        JFrame jframe = (JFrame) registerComponent("jframe", new JFrame("Test Frame"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
        jframe.setLayout(new GridLayout(3, 1));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
        for (int i = 0; i < 3; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
            Container cont = (Container) registerComponent("jpanel" + i, new JPanel());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
            for (int j = 0; j < 3; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
                cont.add(registerComponent("btn " + (j + i*100), new JButton("jbutton")));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
            jframe.add(cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
        return jframe;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
    protected void customizeHierarchy() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
        ((Container)getComponent("jframe")).setFocusTraversalPolicy(new LayoutFocusTraversalPolicy());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
    protected Map<String, String> getForwardOrder() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
        Map<String, String> order = new HashMap<String, String>();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
        order.put("btn 0", "btn 1");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
        order.put("btn 1", "btn 2");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
        order.put("btn 2", "btn 100");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
        order.put("btn 100", "btn 101");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
        order.put("btn 101", "btn 102");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
        order.put("btn 102", "btn 200");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
        order.put("btn 200", "btn 201");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
        order.put("btn 201", "btn 202");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
        order.put("btn 202", "btn 0");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
        order.put("jpanel0", "btn 0");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
        order.put("jpanel1", "btn 100");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
        order.put("jpanel2", "btn 200");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
        order.put("jframe", "btn 0");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
        return order;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
    protected Map<String, String> getBackwardOrder() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
        Map<String, String> order = new HashMap<String, String>();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
        order.put("btn 0", "btn 202");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
        order.put("btn 1", "btn 0");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
        order.put("btn 2", "btn 1");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
        order.put("btn 100", "btn 2");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
        order.put("btn 101", "btn 100");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
        order.put("btn 102", "btn 101");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
        order.put("btn 200", "btn 102");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
        order.put("btn 201", "btn 200");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
        order.put("btn 202", "btn 201");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
        order.put("jpanel0", "btn 202");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
        order.put("jpanel1", "btn 2");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
        order.put("jpanel2", "btn 102");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
        order.put("jframe", "btn 202");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
        return order;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
    protected String[] getContainersToTest() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
        return new String[] {"jframe"};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
    protected String getDefaultComp(String focusCycleRoot_id) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
        return "btn 0";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
    protected String getFirstComp(String focusCycleRoot_id) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
        return "btn 0";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
    protected String getLastComp(String focusCycleRoot_id) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
        return "btn 202";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
 * frame [ comp container(provider) [...] comp ]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
 * - transfering focus through a provider.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
class PolicyTest2 extends AbstractPolicyTest {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
    protected Frame createFrame() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
        JFrame jframe = (JFrame) registerComponent("jframe", new JFrame("Test Frame"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
        jframe.setLayout(new FlowLayout());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
        jframe.add(registerComponent("btn 1", new JButton("jbutton")));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
        Container cont = (Container)registerComponent("jpanel", new JPanel());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
        cont.add(registerComponent("btn 2", new JButton("jbutton")));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
        cont.add(registerComponent("btn 3", new JButton("jbutton")));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
        jframe.add(cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
        jframe.add(registerComponent("btn 4", new JButton("jbutton")));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
        return jframe;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
    protected void customizeHierarchy() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
        ((Container)getComponent("jframe")).setFocusTraversalPolicy(new LayoutFocusTraversalPolicy());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
        ((Container)getComponent("jpanel")).setFocusTraversalPolicyProvider(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
    protected Map<String, String> getForwardOrder() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
        Map<String, String> order = new HashMap<String, String>();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
        order.put("jframe", "btn 1");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
        order.put("btn 1", "btn 2");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
        order.put("btn 2", "btn 3");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
        order.put("btn 3", "btn 4");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
        order.put("btn 4", "btn 1");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
        order.put("jpanel", "btn 2");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
        return order;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
    protected Map<String, String> getBackwardOrder() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
        Map<String, String> order = new HashMap<String, String>();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
        order.put("btn 4", "btn 3");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
        order.put("btn 3", "btn 2");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
        order.put("btn 2", "btn 1");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
        order.put("btn 1", "btn 4");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
        return order;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
    protected String[] getContainersToTest() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
        return new String[] {"jframe", "jpanel"};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
    protected String getDefaultComp(String focusCycleRoot_id) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
        if ("jframe".equals(focusCycleRoot_id)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
            return "btn 1";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
        } else if ("jpanel".equals(focusCycleRoot_id)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
            return "btn 2";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
    protected String getFirstComp(String focusCycleRoot_id) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
        return getDefaultComp(focusCycleRoot_id);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
    protected String getLastComp(String focusCycleRoot_id) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
        if ("jframe".equals(focusCycleRoot_id)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
            return "btn 4";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
        } else if ("jpanel".equals(focusCycleRoot_id)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
            return "btn 3";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
 * frame [ comp container(root) [...] comp ]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
 * - transfering focus through a root (includes the case reported in the CR 6240842).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
class PolicyTest3 extends AbstractPolicyTest {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
    protected Frame createFrame() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
        JFrame jframe = (JFrame) registerComponent("jframe", new JFrame("Test Frame"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
        jframe.setLayout(new FlowLayout());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
        jframe.add(registerComponent("btn 1", new JButton("jbutton")));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
        Container cont = (Container)registerComponent("jpanel", new JPanel());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
        cont.add(registerComponent("btn 2", new JButton("jbutton")));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
        cont.add(registerComponent("btn 3", new JButton("jbutton")));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
        jframe.add(cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
        jframe.add(registerComponent("btn 4", new JButton("jbutton")));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
        return jframe;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
    protected void customizeHierarchy() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
        ((Container)getComponent("jframe")).setFocusTraversalPolicy(new LayoutFocusTraversalPolicy());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
        ((Container)getComponent("jpanel")).setFocusCycleRoot(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
    protected Map<String, String> getForwardOrder() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
        Map<String, String> order = new HashMap<String, String>();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
        order.put("jframe", "btn 1");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
        order.put("btn 1", "btn 2");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
        order.put("btn 2", "btn 3");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
        order.put("btn 3", "btn 2");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
        order.put("btn 4", "btn 1");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
        order.put("jpanel", "btn 2");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
        return order;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
    protected Map<String, String> getBackwardOrder() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
        Map<String, String> order = new HashMap<String, String>();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
        order.put("btn 4", "btn 2");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
        order.put("btn 3", "btn 2");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
        order.put("btn 2", "btn 3");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
        order.put("btn 1", "btn 4");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
        return order;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
    protected String[] getContainersToTest() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
        return new String[] {"jframe", "jpanel"};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
    protected String getDefaultComp(String focusCycleRoot_id) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
        if ("jframe".equals(focusCycleRoot_id)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
            return "btn 1";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
        } else if ("jpanel".equals(focusCycleRoot_id)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
            return "btn 2";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
    protected String getFirstComp(String focusCycleRoot_id) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
        return getDefaultComp(focusCycleRoot_id);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
    protected String getLastComp(String focusCycleRoot_id) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
        if ("jframe".equals(focusCycleRoot_id)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
            return "btn 4";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
        } else if ("jpanel".equals(focusCycleRoot_id)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
            return "btn 3";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
 * frame [ container(provider) [...] comp1(unfocusable) comp2 ]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
 * - getComponentBefore(<frame>, <comp2>) should return <container>'s last.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
class PolicyTest4 extends AbstractPolicyTest {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
    protected Frame createFrame() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
        JFrame jframe = (JFrame) registerComponent("jframe", new JFrame("Test Frame"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
        jframe.setLayout(new FlowLayout());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
        Container cont = (Container)registerComponent("jpanel", new JPanel());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
        cont.add(registerComponent("btn 1", new JButton("jbutton")));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
        cont.add(registerComponent("btn 2", new JButton("jbutton")));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
        jframe.add(cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
        jframe.add(registerComponent("btn 3", new JButton("jbutton")));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
        jframe.add(registerComponent("btn 4", new JButton("jbutton")));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
        return jframe;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
    protected void customizeHierarchy() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
        ((Container)getComponent("jframe")).setFocusTraversalPolicy(new LayoutFocusTraversalPolicy());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
        ((Container)getComponent("jpanel")).setFocusTraversalPolicyProvider(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
        ((JButton)getComponent("btn 3")).setFocusable(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
    protected Map<String, String> getBackwardOrder() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
        Map<String, String> order = new HashMap<String, String>();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
        order.put("btn 4", "btn 2");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
        order.put("btn 2", "btn 1");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
        order.put("btn 1", "btn 4");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
        return order;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
    // no testing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
    protected Map<String, String> getForwardOrder() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
    protected String[] getContainersToTest() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
    protected String getDefaultComp(String focusCycleRoot_id) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
    protected String getFirstComp(String focusCycleRoot_id) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
    protected String getLastComp(String focusCycleRoot_id) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
 * frame [ container(root) [...] comp1(unfocusable) comp2 ]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
 * - getComponentBefore(<frame>, <comp2>) should return <container>'s default.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
class PolicyTest5 extends AbstractPolicyTest {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
    protected Frame createFrame() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
        JFrame jframe = (JFrame) registerComponent("jframe", new JFrame("Test Frame"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
        jframe.setLayout(new FlowLayout());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
        Container cont = (Container)registerComponent("jpanel", new JPanel());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
        cont.add(registerComponent("btn 1", new JButton("jbutton")));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
        cont.add(registerComponent("btn 2", new JButton("jbutton")));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
        jframe.add(cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
        jframe.add(registerComponent("btn 3", new JButton("jbutton")));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
        jframe.add(registerComponent("btn 4", new JButton("jbutton")));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
        return jframe;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
    protected void customizeHierarchy() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
        ((Container)getComponent("jframe")).setFocusTraversalPolicy(new LayoutFocusTraversalPolicy());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
        ((Container)getComponent("jpanel")).setFocusCycleRoot(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
        ((JButton)getComponent("btn 3")).setFocusable(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
    protected Map<String, String> getBackwardOrder() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
        Map<String, String> order = new HashMap<String, String>();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
        order.put("btn 4", "btn 1");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
        order.put("btn 2", "btn 1");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
        order.put("btn 1", "btn 2");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
        return order;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
    // no testing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
    protected Map<String, String> getForwardOrder() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
    protected String[] getContainersToTest() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
    protected String getDefaultComp(String focusCycleRoot_id) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
    protected String getFirstComp(String focusCycleRoot_id) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
    protected String getLastComp(String focusCycleRoot_id) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
 * frame [ comp container(provider)(focusable) [...] comp ]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
 * - transfering focus through a focusable provider.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
class PolicyTest6 extends AbstractPolicyTest {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
    protected Frame createFrame() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
        JFrame jframe = (JFrame) registerComponent("jframe", new JFrame("Test Frame"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
        jframe.setLayout(new FlowLayout());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
        jframe.add(registerComponent("btn 1", new JButton("jbutton")));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
        Container cont = (Container)registerComponent("jpanel", new JPanel());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
        cont.add(registerComponent("btn 2", new JButton("jbutton")));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
        cont.add(registerComponent("btn 3", new JButton("jbutton")));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
        jframe.add(cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
        jframe.add(registerComponent("btn 4", new JButton("jbutton")));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
        return jframe;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
    protected void customizeHierarchy() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
        ((Container)getComponent("jframe")).setFocusTraversalPolicy(new LayoutFocusTraversalPolicy());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
        ((Container)getComponent("jpanel")).setFocusTraversalPolicy(new LayoutFocusTraversalPolicy() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
                public Component getDefaultComponent(Container aContainer) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
                    return getComponent("btn 2");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
            });
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
        ((Container)getComponent("jpanel")).setFocusTraversalPolicyProvider(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
        ((Container)getComponent("jpanel")).setFocusable(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
    protected Map<String, String> getForwardOrder() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
        Map<String, String> order = new HashMap<String, String>();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
        order.put("jframe", "btn 1");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
        order.put("btn 1", "jpanel");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
        order.put("btn 2", "btn 3");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
        order.put("btn 3", "btn 4");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
        order.put("btn 4", "btn 1");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
        order.put("jpanel", "btn 2");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
        return order;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
    protected Map<String, String> getBackwardOrder() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
        Map<String, String> order = new HashMap<String, String>();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
        order.put("btn 4", "btn 3");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
        order.put("btn 3", "btn 2");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
        order.put("btn 2", "jpanel");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
        order.put("btn 1", "btn 4");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
        order.put("jpanel", "btn 1");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
        return order;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
    protected String[] getContainersToTest() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
        return new String[] {"jpanel"};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
    protected String getDefaultComp(String focusCycleRoot_id) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
        return "btn 2";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
    protected String getFirstComp(String focusCycleRoot_id) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
        return "jpanel";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
    protected String getLastComp(String focusCycleRoot_id) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
        return "btn 3";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
 * frame [ comp container(root)(focusable) [...] comp ]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
 * - transfering focus through a focusable root.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
class PolicyTest7 extends AbstractPolicyTest {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
    protected Frame createFrame() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
        JFrame jframe = (JFrame) registerComponent("jframe", new JFrame("Test Frame"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
        jframe.setLayout(new FlowLayout());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
        jframe.add(registerComponent("btn 1", new JButton("jbutton")));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
        Container cont = (Container)registerComponent("jpanel", new JPanel());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
        cont.add(registerComponent("btn 2", new JButton("jbutton")));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
        cont.add(registerComponent("btn 3", new JButton("jbutton")));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
        jframe.add(cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
        jframe.add(registerComponent("btn 4", new JButton("jbutton")));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
        return jframe;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
    protected void customizeHierarchy() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
        ((Container)getComponent("jframe")).setFocusTraversalPolicy(new LayoutFocusTraversalPolicy());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
        ((Container)getComponent("jpanel")).setFocusTraversalPolicy(new LayoutFocusTraversalPolicy() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
                public Component getDefaultComponent(Container aContainer) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
                    return getComponent("btn 2");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
            });
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
        ((Container)getComponent("jpanel")).setFocusCycleRoot(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
        ((Container)getComponent("jpanel")).setFocusable(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
    protected Map<String, String> getForwardOrder() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
        Map<String, String> order = new HashMap<String, String>();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
        order.put("jframe", "btn 1");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
        order.put("btn 1", "jpanel");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
        order.put("btn 2", "btn 3");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
        order.put("btn 3", "jpanel");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
        order.put("btn 4", "btn 1");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
        order.put("jpanel", "btn 2");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
        return order;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
    protected Map<String, String> getBackwardOrder() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
        Map<String, String> order = new HashMap<String, String>();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
        order.put("btn 4", "btn 2");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
        order.put("btn 3", "btn 2");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
        order.put("btn 2", "jpanel");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
        order.put("btn 1", "btn 4");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
        order.put("jpanel", "btn 1");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
        return order;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
    protected String[] getContainersToTest() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
        return new String[] {"jpanel"};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
    protected String getDefaultComp(String focusCycleRoot_id) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
        return "btn 2";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
    protected String getFirstComp(String focusCycleRoot_id) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
        return "jpanel";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
    protected String getLastComp(String focusCycleRoot_id) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
        return "btn 3";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
 * frame [ comp1 comp2 container1(provider) [...] container2(root) [...] ]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
 * - verifies a case when a provider is followed by a root.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
class PolicyTest8 extends AbstractPolicyTest {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
    protected Frame createFrame() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
        JFrame jframe = (JFrame) registerComponent("frame", new JFrame("Test Frame"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
        jframe.setLayout(new FlowLayout());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
        jframe.add(registerComponent("btn-1", new JButton("jbutton")));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
        jframe.add(registerComponent("btn-2", new JButton("jbutton")));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
        Container cont1 = (Container)registerComponent("panel-1", new JPanel());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
        cont1.add(registerComponent("btn-3", new JButton("jbutton")));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
        cont1.add(registerComponent("btn-4", new JButton("jbutton")));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
        cont1.add(registerComponent("btn-5", new JButton("jbutton")));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
        Container cont2 = (Container)registerComponent("panel-2", new JPanel());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
        cont2.add(registerComponent("btn-6", new JButton("jbutton")));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
        cont2.add(registerComponent("btn-7", new JButton("jbutton")));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
        cont2.add(registerComponent("btn-8", new JButton("jbutton")));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
        jframe.add(cont1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
        jframe.add(cont2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
        return jframe;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
    protected void customizeHierarchy() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
        ((Container)getComponent("panel-1")).setFocusTraversalPolicyProvider(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
        ((Container)getComponent("panel-1")).setFocusTraversalPolicy(new LayoutFocusTraversalPolicy() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
                public Component getDefaultComponent(Container aContainer) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
                    return getComponent("btn-4");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
            });
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
        ((Container)getComponent("panel-2")).setFocusCycleRoot(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
        ((Container)getComponent("panel-2")).setFocusTraversalPolicy(new LayoutFocusTraversalPolicy() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
                public Component getDefaultComponent(Container aContainer) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
                    return getComponent("btn-7");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
            });
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
    protected Map<String, String> getForwardOrder() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
        Map<String, String> order = new HashMap<String, String>();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
        order.put("frame", "btn-1");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
        order.put("btn-1", "btn-2");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
        order.put("btn-2", "btn-4");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
        order.put("btn-3", "btn-4");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
        order.put("btn-4", "btn-5");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
        order.put("btn-5", "btn-7");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
        order.put("btn-6", "btn-7");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
        order.put("btn-7", "btn-8");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
        order.put("btn-8", "btn-6");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
        order.put("panel-1", "btn-4");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
        order.put("panel-2", "btn-7");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
        return order;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
    protected Map<String, String> getBackwardOrder() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
        Map<String, String> order = new HashMap<String, String>();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
        order.put("btn-1", "btn-5");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
        order.put("btn-2", "btn-1");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
        order.put("btn-3", "btn-2");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
        order.put("btn-4", "btn-3");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
        order.put("btn-5", "btn-4");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
        order.put("btn-6", "btn-8");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
        order.put("btn-7", "btn-6");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
        order.put("btn-8", "btn-7");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
        return order;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
    protected String[] getContainersToTest() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
        return new String[] {"frame", "panel-1", "panel-2"};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
    protected String getDefaultComp(String focusCycleRoot_id) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
        if ("frame".equals(focusCycleRoot_id)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
            return "btn-1";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
        } else if ("panel-1".equals(focusCycleRoot_id)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
            return "btn-4";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
        } else if ("panel-2".equals(focusCycleRoot_id)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
            return "btn-7";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
    protected String getFirstComp(String focusCycleRoot_id) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
        if ("frame".equals(focusCycleRoot_id)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
            return "btn-1";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
        } else if ("panel-1".equals(focusCycleRoot_id)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
            return "btn-3";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
        } else if ("panel-2".equals(focusCycleRoot_id)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
            return "btn-6";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
    protected String getLastComp(String focusCycleRoot_id) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
        if ("frame".equals(focusCycleRoot_id)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
            return "btn-5";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
        } else if ("panel-1".equals(focusCycleRoot_id)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
            return "btn-5";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
        } else if ("panel-2".equals(focusCycleRoot_id)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
            return "btn-8";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
 * frame [ comp1 comp2 container1(root) [...] container2(provider) [...] ]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
 * - verifies a case when a root is followed by a provider.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
class PolicyTest9 extends AbstractPolicyTest {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
    protected Frame createFrame() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
        JFrame jframe = (JFrame) registerComponent("frame", new JFrame("Test Frame"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
        jframe.setLayout(new FlowLayout());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
        jframe.add(registerComponent("btn-1", new JButton("jbutton")));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
        jframe.add(registerComponent("btn-2", new JButton("jbutton")));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
        Container cont1 = (Container)registerComponent("panel-1", new JPanel());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
        cont1.add(registerComponent("btn-3", new JButton("jbutton")));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
        cont1.add(registerComponent("btn-4", new JButton("jbutton")));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
        cont1.add(registerComponent("btn-5", new JButton("jbutton")));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
        Container cont2 = (Container)registerComponent("panel-2", new JPanel());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
        cont2.add(registerComponent("btn-6", new JButton("jbutton")));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
        cont2.add(registerComponent("btn-7", new JButton("jbutton")));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
        cont2.add(registerComponent("btn-8", new JButton("jbutton")));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
        jframe.add(cont1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
        jframe.add(cont2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
        return jframe;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
    protected void customizeHierarchy() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
        ((Container)getComponent("panel-1")).setFocusCycleRoot(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
        ((Container)getComponent("panel-1")).setFocusTraversalPolicy(new LayoutFocusTraversalPolicy() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
                public Component getDefaultComponent(Container aContainer) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
                    return getComponent("btn-4");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
            });
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
        ((Container)getComponent("panel-2")).setFocusTraversalPolicyProvider(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
        ((Container)getComponent("panel-2")).setFocusTraversalPolicy(new LayoutFocusTraversalPolicy() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
                public Component getDefaultComponent(Container aContainer) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
                    return getComponent("btn-7");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
            });
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
    protected Map<String, String> getForwardOrder() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
        Map<String, String> order = new HashMap<String, String>();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
        order.put("frame", "btn-1");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
        order.put("btn-1", "btn-2");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
        order.put("btn-2", "btn-4");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
        order.put("btn-3", "btn-4");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
        order.put("btn-4", "btn-5");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
        order.put("btn-5", "btn-3");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
        order.put("btn-6", "btn-7");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
        order.put("btn-7", "btn-8");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
        order.put("btn-8", "btn-1");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
        order.put("panel-1", "btn-4");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
        order.put("panel-2", "btn-7");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
        return order;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
    protected Map<String, String> getBackwardOrder() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
        Map<String, String> order = new HashMap<String, String>();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
        order.put("btn-1", "btn-8");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
        order.put("btn-2", "btn-1");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
        order.put("btn-3", "btn-5");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   788
        order.put("btn-4", "btn-3");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
        order.put("btn-5", "btn-4");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
        order.put("btn-6", "btn-4");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
        order.put("btn-7", "btn-6");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
        order.put("btn-8", "btn-7");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
        return order;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
    protected String[] getContainersToTest() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
        return new String[] {"frame", "panel-1", "panel-2"};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
    protected String getDefaultComp(String focusCycleRoot_id) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
        if ("frame".equals(focusCycleRoot_id)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
            return "btn-1";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
        } else if ("panel-1".equals(focusCycleRoot_id)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
            return "btn-4";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
        } else if ("panel-2".equals(focusCycleRoot_id)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
            return "btn-7";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   807
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
    protected String getFirstComp(String focusCycleRoot_id) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
        if ("frame".equals(focusCycleRoot_id)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
            return "btn-1";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
        } else if ("panel-1".equals(focusCycleRoot_id)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
            return "btn-3";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
        } else if ("panel-2".equals(focusCycleRoot_id)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   817
            return "btn-6";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   819
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   821
90ce3da70b43 Initial load
duke
parents:
diff changeset
   822
    protected String getLastComp(String focusCycleRoot_id) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   823
        if ("frame".equals(focusCycleRoot_id)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   824
            return "btn-8";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
        } else if ("panel-1".equals(focusCycleRoot_id)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   826
            return "btn-5";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   827
        } else if ("panel-2".equals(focusCycleRoot_id)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   828
            return "btn-8";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   833
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   835
 * frame [ container0 [...] container1(root) [ comp1 comp2 container2(provider) [...] ] ]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   836
 * - verifies a case when a provider is nested in a root.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   837
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   838
class PolicyTest10 extends AbstractPolicyTest {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   839
90ce3da70b43 Initial load
duke
parents:
diff changeset
   840
    protected Frame createFrame() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   841
        JFrame jframe = (JFrame) registerComponent("frame", new JFrame("Test Frame"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
        jframe.setLayout(new GridLayout(2, 1));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
90ce3da70b43 Initial load
duke
parents:
diff changeset
   844
        Container cont0 = new JPanel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   845
        cont0.add(registerComponent("btn-1", new JButton("jbutton")));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   846
        cont0.add(registerComponent("btn-2", new JButton("jbutton")));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   847
90ce3da70b43 Initial load
duke
parents:
diff changeset
   848
        Container cont1 = (Container)registerComponent("panel-1", new JPanel());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   849
        cont1.add(registerComponent("btn-3", new JButton("jbutton")));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   850
        cont1.add(registerComponent("btn-4", new JButton("jbutton")));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   851
90ce3da70b43 Initial load
duke
parents:
diff changeset
   852
        Container cont2 = (Container)registerComponent("panel-2", new JPanel());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   853
        cont2.add(registerComponent("btn-5", new JButton("jbutton")));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   854
        cont2.add(registerComponent("btn-6", new JButton("jbutton")));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   855
90ce3da70b43 Initial load
duke
parents:
diff changeset
   856
        cont1.add(cont2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   857
        jframe.add(cont0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   858
        jframe.add(cont1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   859
90ce3da70b43 Initial load
duke
parents:
diff changeset
   860
        return jframe;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   861
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   862
90ce3da70b43 Initial load
duke
parents:
diff changeset
   863
    protected void customizeHierarchy() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   864
        ((Container)getComponent("panel-1")).setFocusCycleRoot(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   865
        ((Container)getComponent("panel-1")).setFocusTraversalPolicy(new LayoutFocusTraversalPolicy() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   866
                public Component getDefaultComponent(Container aContainer) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   867
                    return getComponent("panel-2");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   868
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   869
            });
90ce3da70b43 Initial load
duke
parents:
diff changeset
   870
        ((Container)getComponent("panel-2")).setFocusTraversalPolicyProvider(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   871
        ((Container)getComponent("panel-2")).setFocusTraversalPolicy(new LayoutFocusTraversalPolicy());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   872
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   873
90ce3da70b43 Initial load
duke
parents:
diff changeset
   874
    protected Map<String, String> getForwardOrder() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   875
        Map<String, String> order = new HashMap<String, String>();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   876
        order.put("frame", "btn-1");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   877
        order.put("btn-1", "btn-2");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   878
        order.put("btn-2", "panel-2");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   879
        order.put("btn-3", "btn-4");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   880
        order.put("btn-4", "btn-5");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   881
        order.put("btn-5", "btn-6");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   882
        order.put("btn-6", "btn-3");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   883
        order.put("panel-1", "panel-2");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   884
        order.put("panel-2", "btn-5");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   885
        return order;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   886
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   887
90ce3da70b43 Initial load
duke
parents:
diff changeset
   888
    protected Map<String, String> getBackwardOrder() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   889
        Map<String, String> order = new HashMap<String, String>();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   890
        order.put("btn-1", "btn-2");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   891
        order.put("btn-2", "btn-1");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   892
        order.put("btn-3", "btn-6");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   893
        order.put("btn-4", "btn-3");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   894
        order.put("btn-5", "btn-4");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   895
        order.put("btn-6", "btn-5");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   896
        return order;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   897
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   898
90ce3da70b43 Initial load
duke
parents:
diff changeset
   899
    protected String[] getContainersToTest() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   900
        return new String[] {"frame", "panel-1", "panel-2"};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   901
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   902
90ce3da70b43 Initial load
duke
parents:
diff changeset
   903
    protected String getDefaultComp(String focusCycleRoot_id) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   904
        if ("frame".equals(focusCycleRoot_id)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   905
            return "btn-1";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   906
        } else if ("panel-1".equals(focusCycleRoot_id)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   907
            return "panel-2";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   908
        } else if ("panel-2".equals(focusCycleRoot_id)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   909
            return "btn-5";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   910
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   911
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   912
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   913
90ce3da70b43 Initial load
duke
parents:
diff changeset
   914
    protected String getFirstComp(String focusCycleRoot_id) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   915
        if ("frame".equals(focusCycleRoot_id)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   916
            return "btn-1";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   917
        } else if ("panel-1".equals(focusCycleRoot_id)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   918
            return "btn-3";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   919
        } else if ("panel-2".equals(focusCycleRoot_id)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   920
            return "btn-5";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   921
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   922
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   923
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   924
90ce3da70b43 Initial load
duke
parents:
diff changeset
   925
    protected String getLastComp(String focusCycleRoot_id) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   926
        if ("frame".equals(focusCycleRoot_id)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   927
            return "btn-2";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   928
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   929
            return "btn-6";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   930
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   931
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   932
}
3082
24c8d93ac1e1 4788402: SortingFocusTraversalPolicy: prob with non-focusable focus Cycle Root as first
ant
parents: 2
diff changeset
   933
24c8d93ac1e1 4788402: SortingFocusTraversalPolicy: prob with non-focusable focus Cycle Root as first
ant
parents: 2
diff changeset
   934
/*
24c8d93ac1e1 4788402: SortingFocusTraversalPolicy: prob with non-focusable focus Cycle Root as first
ant
parents: 2
diff changeset
   935
 * frame [ container(root) [...] comp ]
24c8d93ac1e1 4788402: SortingFocusTraversalPolicy: prob with non-focusable focus Cycle Root as first
ant
parents: 2
diff changeset
   936
 * - getDefaultComponent(<frame>) should implicitly down-cycle into the <container>.
24c8d93ac1e1 4788402: SortingFocusTraversalPolicy: prob with non-focusable focus Cycle Root as first
ant
parents: 2
diff changeset
   937
 * - getFirstComponent(<frame>) should implicitly down-cycle into the <container>.
24c8d93ac1e1 4788402: SortingFocusTraversalPolicy: prob with non-focusable focus Cycle Root as first
ant
parents: 2
diff changeset
   938
 */
24c8d93ac1e1 4788402: SortingFocusTraversalPolicy: prob with non-focusable focus Cycle Root as first
ant
parents: 2
diff changeset
   939
class PolicyTest11 extends AbstractPolicyTest {
24c8d93ac1e1 4788402: SortingFocusTraversalPolicy: prob with non-focusable focus Cycle Root as first
ant
parents: 2
diff changeset
   940
    protected Frame createFrame() {
24c8d93ac1e1 4788402: SortingFocusTraversalPolicy: prob with non-focusable focus Cycle Root as first
ant
parents: 2
diff changeset
   941
        JFrame jframe = (JFrame) registerComponent("jframe", new JFrame("Test Frame"));
24c8d93ac1e1 4788402: SortingFocusTraversalPolicy: prob with non-focusable focus Cycle Root as first
ant
parents: 2
diff changeset
   942
        jframe.setLayout(new FlowLayout());
24c8d93ac1e1 4788402: SortingFocusTraversalPolicy: prob with non-focusable focus Cycle Root as first
ant
parents: 2
diff changeset
   943
24c8d93ac1e1 4788402: SortingFocusTraversalPolicy: prob with non-focusable focus Cycle Root as first
ant
parents: 2
diff changeset
   944
        Container cont = (Container)registerComponent("jpanel", new JPanel());
24c8d93ac1e1 4788402: SortingFocusTraversalPolicy: prob with non-focusable focus Cycle Root as first
ant
parents: 2
diff changeset
   945
        cont.add(registerComponent("btn-1", new JButton("jbutton")));
24c8d93ac1e1 4788402: SortingFocusTraversalPolicy: prob with non-focusable focus Cycle Root as first
ant
parents: 2
diff changeset
   946
        cont.add(registerComponent("btn-2", new JButton("jbutton")));
24c8d93ac1e1 4788402: SortingFocusTraversalPolicy: prob with non-focusable focus Cycle Root as first
ant
parents: 2
diff changeset
   947
24c8d93ac1e1 4788402: SortingFocusTraversalPolicy: prob with non-focusable focus Cycle Root as first
ant
parents: 2
diff changeset
   948
        jframe.add(cont);
24c8d93ac1e1 4788402: SortingFocusTraversalPolicy: prob with non-focusable focus Cycle Root as first
ant
parents: 2
diff changeset
   949
        jframe.add(registerComponent("btn-3", new JButton("jbutton")));
24c8d93ac1e1 4788402: SortingFocusTraversalPolicy: prob with non-focusable focus Cycle Root as first
ant
parents: 2
diff changeset
   950
24c8d93ac1e1 4788402: SortingFocusTraversalPolicy: prob with non-focusable focus Cycle Root as first
ant
parents: 2
diff changeset
   951
        return jframe;
24c8d93ac1e1 4788402: SortingFocusTraversalPolicy: prob with non-focusable focus Cycle Root as first
ant
parents: 2
diff changeset
   952
    }
24c8d93ac1e1 4788402: SortingFocusTraversalPolicy: prob with non-focusable focus Cycle Root as first
ant
parents: 2
diff changeset
   953
24c8d93ac1e1 4788402: SortingFocusTraversalPolicy: prob with non-focusable focus Cycle Root as first
ant
parents: 2
diff changeset
   954
    protected void customizeHierarchy() {
24c8d93ac1e1 4788402: SortingFocusTraversalPolicy: prob with non-focusable focus Cycle Root as first
ant
parents: 2
diff changeset
   955
        ((Container)getComponent("jframe")).setFocusTraversalPolicy(new LayoutFocusTraversalPolicy());
24c8d93ac1e1 4788402: SortingFocusTraversalPolicy: prob with non-focusable focus Cycle Root as first
ant
parents: 2
diff changeset
   956
        ((Container)getComponent("jpanel")).setFocusCycleRoot(true);
24c8d93ac1e1 4788402: SortingFocusTraversalPolicy: prob with non-focusable focus Cycle Root as first
ant
parents: 2
diff changeset
   957
    }
24c8d93ac1e1 4788402: SortingFocusTraversalPolicy: prob with non-focusable focus Cycle Root as first
ant
parents: 2
diff changeset
   958
24c8d93ac1e1 4788402: SortingFocusTraversalPolicy: prob with non-focusable focus Cycle Root as first
ant
parents: 2
diff changeset
   959
    protected Map<String, String> getForwardOrder() {
24c8d93ac1e1 4788402: SortingFocusTraversalPolicy: prob with non-focusable focus Cycle Root as first
ant
parents: 2
diff changeset
   960
        Map<String, String> order = new HashMap<String, String>();
24c8d93ac1e1 4788402: SortingFocusTraversalPolicy: prob with non-focusable focus Cycle Root as first
ant
parents: 2
diff changeset
   961
        order.put("jframe", "btn-1");
24c8d93ac1e1 4788402: SortingFocusTraversalPolicy: prob with non-focusable focus Cycle Root as first
ant
parents: 2
diff changeset
   962
        order.put("btn-1", "btn-2");
24c8d93ac1e1 4788402: SortingFocusTraversalPolicy: prob with non-focusable focus Cycle Root as first
ant
parents: 2
diff changeset
   963
        order.put("btn-2", "btn-1");
24c8d93ac1e1 4788402: SortingFocusTraversalPolicy: prob with non-focusable focus Cycle Root as first
ant
parents: 2
diff changeset
   964
        order.put("btn-3", "btn-1");
24c8d93ac1e1 4788402: SortingFocusTraversalPolicy: prob with non-focusable focus Cycle Root as first
ant
parents: 2
diff changeset
   965
        return order;
24c8d93ac1e1 4788402: SortingFocusTraversalPolicy: prob with non-focusable focus Cycle Root as first
ant
parents: 2
diff changeset
   966
    }
24c8d93ac1e1 4788402: SortingFocusTraversalPolicy: prob with non-focusable focus Cycle Root as first
ant
parents: 2
diff changeset
   967
24c8d93ac1e1 4788402: SortingFocusTraversalPolicy: prob with non-focusable focus Cycle Root as first
ant
parents: 2
diff changeset
   968
    protected Map<String, String> getBackwardOrder() {
24c8d93ac1e1 4788402: SortingFocusTraversalPolicy: prob with non-focusable focus Cycle Root as first
ant
parents: 2
diff changeset
   969
        Map<String, String> order = new HashMap<String, String>();
24c8d93ac1e1 4788402: SortingFocusTraversalPolicy: prob with non-focusable focus Cycle Root as first
ant
parents: 2
diff changeset
   970
        order.put("btn-3", "btn-1");
24c8d93ac1e1 4788402: SortingFocusTraversalPolicy: prob with non-focusable focus Cycle Root as first
ant
parents: 2
diff changeset
   971
        order.put("btn-2", "btn-1");
24c8d93ac1e1 4788402: SortingFocusTraversalPolicy: prob with non-focusable focus Cycle Root as first
ant
parents: 2
diff changeset
   972
        order.put("btn-1", "btn-2");
24c8d93ac1e1 4788402: SortingFocusTraversalPolicy: prob with non-focusable focus Cycle Root as first
ant
parents: 2
diff changeset
   973
        order.put("jframe", "btn-3");
24c8d93ac1e1 4788402: SortingFocusTraversalPolicy: prob with non-focusable focus Cycle Root as first
ant
parents: 2
diff changeset
   974
        return order;
24c8d93ac1e1 4788402: SortingFocusTraversalPolicy: prob with non-focusable focus Cycle Root as first
ant
parents: 2
diff changeset
   975
    }
24c8d93ac1e1 4788402: SortingFocusTraversalPolicy: prob with non-focusable focus Cycle Root as first
ant
parents: 2
diff changeset
   976
24c8d93ac1e1 4788402: SortingFocusTraversalPolicy: prob with non-focusable focus Cycle Root as first
ant
parents: 2
diff changeset
   977
    protected String[] getContainersToTest() {
24c8d93ac1e1 4788402: SortingFocusTraversalPolicy: prob with non-focusable focus Cycle Root as first
ant
parents: 2
diff changeset
   978
        return new String[] {"jframe"};
24c8d93ac1e1 4788402: SortingFocusTraversalPolicy: prob with non-focusable focus Cycle Root as first
ant
parents: 2
diff changeset
   979
    }
24c8d93ac1e1 4788402: SortingFocusTraversalPolicy: prob with non-focusable focus Cycle Root as first
ant
parents: 2
diff changeset
   980
24c8d93ac1e1 4788402: SortingFocusTraversalPolicy: prob with non-focusable focus Cycle Root as first
ant
parents: 2
diff changeset
   981
    protected String getDefaultComp(String focusCycleRoot_id) {
24c8d93ac1e1 4788402: SortingFocusTraversalPolicy: prob with non-focusable focus Cycle Root as first
ant
parents: 2
diff changeset
   982
        return "btn-1";
24c8d93ac1e1 4788402: SortingFocusTraversalPolicy: prob with non-focusable focus Cycle Root as first
ant
parents: 2
diff changeset
   983
    }
24c8d93ac1e1 4788402: SortingFocusTraversalPolicy: prob with non-focusable focus Cycle Root as first
ant
parents: 2
diff changeset
   984
24c8d93ac1e1 4788402: SortingFocusTraversalPolicy: prob with non-focusable focus Cycle Root as first
ant
parents: 2
diff changeset
   985
    protected String getFirstComp(String focusCycleRoot_id) {
24c8d93ac1e1 4788402: SortingFocusTraversalPolicy: prob with non-focusable focus Cycle Root as first
ant
parents: 2
diff changeset
   986
        return "btn-1";
24c8d93ac1e1 4788402: SortingFocusTraversalPolicy: prob with non-focusable focus Cycle Root as first
ant
parents: 2
diff changeset
   987
    }
24c8d93ac1e1 4788402: SortingFocusTraversalPolicy: prob with non-focusable focus Cycle Root as first
ant
parents: 2
diff changeset
   988
24c8d93ac1e1 4788402: SortingFocusTraversalPolicy: prob with non-focusable focus Cycle Root as first
ant
parents: 2
diff changeset
   989
    protected String getLastComp(String focusCycleRoot_id) {
24c8d93ac1e1 4788402: SortingFocusTraversalPolicy: prob with non-focusable focus Cycle Root as first
ant
parents: 2
diff changeset
   990
        return "btn-3";
24c8d93ac1e1 4788402: SortingFocusTraversalPolicy: prob with non-focusable focus Cycle Root as first
ant
parents: 2
diff changeset
   991
    }
24c8d93ac1e1 4788402: SortingFocusTraversalPolicy: prob with non-focusable focus Cycle Root as first
ant
parents: 2
diff changeset
   992
}