150N/A/*
553N/A * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
150N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
150N/A *
150N/A * This code is free software; you can redistribute it and/or modify it
150N/A * under the terms of the GNU General Public License version 2 only, as
150N/A * published by the Free Software Foundation.
150N/A *
150N/A * This code is distributed in the hope that it will be useful, but WITHOUT
150N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
150N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
150N/A * version 2 for more details (a copy is included in the LICENSE file that
150N/A * accompanied this code).
150N/A *
150N/A * You should have received a copy of the GNU General Public License version
150N/A * 2 along with this work; if not, write to the Free Software Foundation,
150N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
150N/A *
553N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
553N/A * or visit www.oracle.com if you need additional information or have any
553N/A * questions.
150N/A */
150N/A
150N/A/*
150N/A * @test
150N/A * @bug 8007458
150N/A * @summary Tests CardLayout encoding
150N/A * @author Sergey Malenkov
150N/A */
150N/A
150N/Aimport java.awt.CardLayout;
150N/Aimport java.lang.reflect.Field;
150N/Aimport java.util.Vector;
150N/Aimport javax.swing.JLabel;
150N/A
150N/Apublic final class java_awt_CardLayout extends AbstractTest<CardLayout> {
150N/A private static final Field VECTOR = getField("java.awt.CardLayout.vector");
150N/A private static final Field NAME = getField("java.awt.CardLayout$Card.name");
150N/A private static final Field COMP = getField("java.awt.CardLayout$Card.comp");
150N/A
150N/A public static void main(String[] args) throws Exception {
150N/A new java_awt_CardLayout().test(true);
150N/A }
150N/A
150N/A @Override
150N/A protected CardLayout getObject() {
150N/A CardLayout layout = new CardLayout();
150N/A layout.addLayoutComponent(new JLabel("a"), "a");
150N/A layout.addLayoutComponent(new JLabel("b"), "b");
150N/A layout.addLayoutComponent(new JLabel("c"), "c");
150N/A return layout;
150N/A }
150N/A
150N/A @Override
150N/A protected CardLayout getAnotherObject() {
150N/A CardLayout layout = new CardLayout();
150N/A layout.addLayoutComponent(new JLabel("a"), "a");
150N/A layout.addLayoutComponent(new JLabel("b"), "b");
150N/A layout.addLayoutComponent(new JLabel("c"), "c");
150N/A layout.addLayoutComponent(new JLabel("d"), "d");
150N/A return layout;
150N/A }
150N/A
150N/A @Override
150N/A protected void validate(CardLayout before, CardLayout after) {
150N/A super.validate(before, after);
150N/A try {
150N/A Vector a = (Vector) VECTOR.get(after);
150N/A Vector b = (Vector) VECTOR.get(before);
150N/A int size = a.size();
150N/A if (size != b.size()) {
150N/A throw new Error("different content");
150N/A }
150N/A for (int i = 0; i < size; i++) {
150N/A super.validator.validate(NAME.get(a.get(i)), NAME.get(b.get(i)));
150N/A super.validator.validate(COMP.get(a.get(i)), COMP.get(b.get(i)));
150N/A }
150N/A }
150N/A catch (Exception exception) {
throw new Error(exception);
}
}
}