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