vminterview.java

来自「cqME :java framework for TCK test.」· Java 代码 · 共 393 行

JAVA
393
字号
/* * $Id$ * * Copyright 1996-2007 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License version * 2 only, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License version 2 for more details (a copy is * included at /legal/license.txt). * * You should have received a copy of the GNU General Public License * version 2 along with this work; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA * * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa * Clara, CA 95054 or visit www.sun.com if you need additional * information or have any questions. * */package com.sun.tck.j2me.interview;import java.util.Map;import com.sun.interview.ChoiceQuestion;import com.sun.interview.FinalQuestion;import com.sun.interview.NullQuestion;import com.sun.interview.Question;import com.sun.javatest.InterviewParameters;import com.sun.tck.j2me.interview.distributedtest.DTFInterview;import com.sun.tck.j2me.javatest.J2meBaseTestSuite;public class VmInterview extends com.sun.interview.Interview {    /**     * CLDC mode.     */    public static final String CLDC = "cldc";    /**     * MIDP mode.     */    public static final String MIDP = "midp";    /**     * CDC mode.     */    public static final String CDC = "cdc";    /**     * Creates high-level framework's interview.     * @param parent The parent interview. Usually TCK-specific interview.     * @param midpOnly Indicated support only MIDP without pure CLDC.     * @param cldc11Mode Indicates support only CLDC 1.1.     * @param defJarSizeLimit Default limit of jar file's size.     */    public VmInterview(MidpTckBaseInterview parent,             boolean midpOnly,             boolean cldc11Mode,            int defJarSizeLimit) throws InterviewParameters.Fault {        super(parent, "defRuntime");        setHelpSet("help/vm");        setResourceBundle("vm");        cldcParent = parent;        cdcCommInterview = new CdcBaseCommInterview(this, parent.isDistrMode());        CldcBaseCommInterview.defaultJarFileSizeLimit = defJarSizeLimit;        commInterview = new CldcBaseCommInterview(                this, cldc11Mode, parent.isDistrMode());        if (parent.isDistrMode()) {            dtfInterview = new DTFInterview(this);        }        this.midpOnly = midpOnly;        setFirstQuestion(qCldcDisp);        setImplemetationBaseChoices(new String[] {CLDC, MIDP, CDC});    }    /**     * Calling this constructor is equivalent to calling      * <blockquote>     * <code>VmInterview(parent, midpOnly, cldc11Mode, 60000)</code>     * </blockquote>     */     public VmInterview( MidpTckBaseInterview parent,                        boolean midpOnly,                        boolean cldc11Mode)                        throws InterviewParameters.Fault {        this(parent, midpOnly, cldc11Mode, 60000);    }    /**     * Calling this constructor is equivalent to calling      * <blockquote>     * <code>VmInterview(parent, false, false)</code>     * </blockquote>     */     public VmInterview(MidpTckBaseInterview parent) throws InterviewParameters.Fault {        this(parent, false, false);           }    /**     * Calling this constructor is equivalent to calling      * <blockquote>     * <code>VmInterview(parent, midpOnly, false)</code>     * </blockquote>     */     public VmInterview(MidpTckBaseInterview parent, boolean midpOnly) throws InterviewParameters.Fault {        this(parent, midpOnly, false);    }    public int getConcurrency() {        if (isCdcMode()) {            return cdcCommInterview.getConcurrency();        }        return commInterview.getConcurrency();    }    /**     * Sets a list of available choices for the implementation base. This list     * of choices will be presented to the user during interview configuration.     * <p>     * By default, all three available choices are present: CLDC, MIDP, CDC.     *     * @param impBaseChoices     *            The set of choices.     * @see #CLDC     * @see #MIDP     * @see #CDC     */    public void setImplemetationBaseChoices(String[] impBaseChoices) {        qImpBase.setChoices(impBaseChoices);    }    /**     * Returns <code>true</code> if CDC mode is selected, <code>false</code>     * otherwise.     *     * @return whether CDC mode is selected.     */    public boolean isCdcMode() {        try {            return !isMidpOnly() && CDC.equals(qImpBase.getValueOnPath());        } catch (NotOnPathFault e) {            return false;        }    }    public String getSignerJar() {        return commInterview.getSignerJar();    }    /**     * Returns <code>true</code> if MIDP mode is selected, <code>false</code>     * otherwise.     *     * @return whether MIDP mode is selected.     */    public boolean isMidpMode() {        try {            return isMidpOnly() || MIDP.equals(qImpBase.getValueOnPath());        } catch (NotOnPathFault e) {            return false;        }    }    /**     * Returns <code>true</code> if CLDC mode is selected, <code>false</code>     * otherwise.     *     * @return whether CLDC mode is selected.     */    public boolean isCldcMode() {        try {            return !isMidpOnly() && CLDC.equals(qImpBase.getValueOnPath());        } catch (NotOnPathFault e) {            return false;        }    }    // TODO: remove unused method    private boolean isCldcCustomMode() {        return !isMidpOnly()            && commInterview.isCldcCustomMode();    }    /**     * Returns <code>true</code> if CLDC or MIDP mode is selected and CLDC     * version is configured to be 1.1, <code>false</code> otherwise.     *     * @return whether CLDC-1.1 mode is selected.     */    public boolean isCldc11Mode() {        return (isCldcMode() || isMidpMode()) && commInterview.isCldc11Mode();    }    public String getLocalhost() {        return commInterview.getLocalhost();    }    public int getExecHttpServerPort() {        return commInterview.getExecHttpServerPort();    }    J2meBaseTestSuite getTestSuite() {        return (J2meBaseTestSuite) cldcParent.getTestSuite();    }    String getWorkDir() {        return cldcParent.getWorkDirectory().getPath();    }    private boolean isMidpOnly() {        return midpOnly;    }    /**     * Find out if the device supports trusted MIDlets and if the     * configuration currently indicates this. This method will return     * false if the user has not yet specified this setting.     *     * @return <code>true</code> if the user explicitly stated support     * for trusted MIDlets, <code>false</code> otherwise, including     * the case when trusted MIDlets question is not on interview path.     */    public boolean isTrustedMode() {        return commInterview.isTrustedMode();    }    /**     * Determines whether test export mode is configured in the interview.     *     * @return <code>true</code> if the user explicitly selected test export     *         mode in the interview, <code>false</code> otherwise.     */    public boolean isExport() {        return commInterview.isTestExportMode();    }    void setConcurrency(int num) {        cldcParent.setConcurrency(num);    }    /**     * Enables the preverifier sub-interview in CLDC mode. By default,     * the preverifier sub-interview is hidden.     */    public void setPreverifierAware() {        this.isPreverifierAware = true;    }    public boolean isPreverifierMode() {        if (pathContains(qProduct)) {            return PREVERIFIER.equals(qProduct.getValue());        } else {            return false;        }    }        public boolean isRemotePreverifier() {        return commInterview.isRemotePreverifier();    }        /**     * Allows to display interview about distributed framework's     * settings. By default this interview is hidden due to compatibility     * reasons.     *      * @param allow     *            true if the interview is allowed, otherwise false     */    public void setAllowDtfInterview(boolean allow) {        this.isAllowDtfInterview = allow;    }        // Please specify a product to be tested.    private static final String RUNTIME = "CLDC Runtime";    private static final String PREVERIFIER = "CLDC Preverifier";    private ChoiceQuestion qProduct = new ChoiceQuestion(this, "product") {        {            setChoices(new String[]{RUNTIME, PREVERIFIER});        }                public void clear() {            setValue(RUNTIME);        }                protected void export(Map data) {            data.put("product", value);            // NOTE: keywords are determined in getFilterKeywords()        }                protected Question getNext() {            if (value == null || value.trim().equals("")) {                return null;            } else if (midpOnly) {                return callInterview(commInterview, callDTFInterview(qEnd));            } else {                return qImpBase;            }        }    };    private class ImpBaseChoiceQuestion extends ChoiceQuestion {        /**         * Creates an "implementation base" choice question         * with tag "impBase".         */        protected ImpBaseChoiceQuestion() {            super(VmInterview.this, "impBase");            setDefaultValue(MIDP);        }        // makes setChoices public        public void setChoices(String[] choices) {            super.setChoices(choices, true);        }        protected Question getNext() {            if (CDC.equals(getValue())) {                return callInterview(cdcCommInterview, callDTFInterview(qEnd));            } else if (MIDP.equals(getValue())) {                // CLDC/MIDP                return callInterview(commInterview, callDTFInterview(qEnd));            } else {                return callInterview(commInterview, qEnd);            }        }        protected void export(Map data) {            String mode = getValue();            if (mode != null) {                data.put("baseConfiguration", mode.toUpperCase());                if (CDC.equals(mode)) {                    cdcCommInterview.exportCommonData(data);                }            }        }    }    private ImpBaseChoiceQuestion qImpBase = new ImpBaseChoiceQuestion();    private NullQuestion qCldcDisp = new NullQuestion(this, "cldcDisp") {        public boolean isEnabled() {            return false;        }        protected Question getNext() {            if (isPreverifierAware) {                return qProduct;            } else if (midpOnly) {                return callInterview(commInterview, callDTFInterview(qEnd));            } else {                return qImpBase;            }        }    };    private MidpTckBaseInterview cldcParent;    private CldcBaseCommInterview commInterview;    private CdcBaseCommInterview cdcCommInterview;    private DTFInterview dtfInterview;    private final boolean midpOnly;    private boolean isPreverifierAware = false;    private boolean isAllowDtfInterview = false;    //-------------------------------------------------------------------------    private Question callDTFInterview(Question qNext) {        if (dtfInterview != null && isAllowDtfInterview) {            return callInterview(dtfInterview, qNext);        } else {            return qNext;        }    }    private final Question qEnd = new FinalQuestion(this);}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?