Package org.jemmy

Examples of org.jemmy.JemmyException


        int attempts = 0;
        if (!selectable.getState().equals(state)) {
            do {
                final STATE currentState = selectable.getState();
                if (attempts >= selectable.getStates().size()) {
                    throw new JemmyException("State is not reached in " + attempts + " attempts", state);
                }
                target.mouse().click(clickCount(state));
                target.getEnvironment().getWaiter(Wrap.WAIT_STATE_TIMEOUT.getName()).ensureState(new State() {

                    public Object reached() {
View Full Code Here


            long before = System.currentTimeMillis();
            while (System.currentTimeMillis() < startTime + before) {
                try {
                    Thread.sleep(tic);
                } catch (InterruptedException ex) {
                    throw new JemmyException("Sleep interrupted.", ex);
                }
            }
        }
        long start = System.currentTimeMillis();
        while (hasMore()) {
            long now = System.currentTimeMillis() - start;
            TimedAction next = next(now);
            if (next != null) {
                env.getExecutor().execute(env,
                        true, next, Long.valueOf(now));
                if (!next.getResult()) {
                    throw new JemmyException("Check failed on " + now + ":", next.criteria);
                }
            }
            try {
                Thread.sleep(tic);
            } catch (InterruptedException ex) {
                throw new JemmyException("Sleep interrupted.", ex);
            }
        }
    }
View Full Code Here

                return res;
            }
            try {
                Thread.sleep(delta);
            } catch (InterruptedException ex) {
                throw new JemmyException("Wait interrupted for: ", state);
            }
        }
        return null;
    }
View Full Code Here

        return(result);
    }

    void checkEquality(byte[] b1, byte[] b2) {
        if(!Arrays.equals(b1, b2)) {
            throw(new JemmyException("Format error"));
        }
    }
View Full Code Here

        } else if(Arrays.equals(head, new byte[]{8, 0, 0, 0, 0})) {
            mode = PNGSaver.GREYSCALE_MODE;
        } else if(Arrays.equals(head, new byte[]{8, 2, 0, 0, 0})) {
            mode = PNGSaver.COLOR_MODE;
        } else {
            throw(new JemmyException("Format error"));
        }

        readInt();//!!crc

        int size = readInt();

        byte[] idat = read(4);
        checkEquality(idat, "IDAT".getBytes());

        byte[] data = read(size);


        Inflater inflater = new Inflater();
        inflater.setInput(data, 0, size);

        int[] colors = new int[3];
        int[] black = new int[] {0, 0, 0};
        int[] white = new int[] {1, 1, 1};

        try {
            switch (mode) {
            case PNGSaver.BW_MODE:
                {
                    int bytes = (int)(width / 8);
                    if((width % 8) != 0) {
                        bytes++;
                    }
                    byte colorset;
                    byte[] row = new byte[bytes];
                    for (int y = 0; y < height; y++) {
                        inflater.inflate(new byte[1]);
                        inflater.inflate(row);
                        for (int x = 0; x < bytes; x++) {
                            colorset = row[x];
                            for (int sh = 0; sh < 8; sh++) {
                                if(x * 8 + sh >= width) {
                                    break;
                                }
                                if((colorset & 0x80) == 0x80) {
                                    setColors(result, x * 8 + sh, y, white);
                                } else {
                                    setColors(result, x * 8 + sh, y, black);
                                }
                                colorset <<= 1;
                            }
                        }
                    }
                }
                break;
            case PNGSaver.GREYSCALE_MODE:
                {
                    byte[] row = new byte[width];
                    for (int y = 0; y < height; y++) {
                        inflater.inflate(new byte[1]);
                        inflater.inflate(row);
                        for (int x = 0; x < width; x++) {
                            colors[0] = row[x];
                            colors[1] = colors[0];
                            colors[2] = colors[0];
                            setColors(result, x, y, colors);
                        }
                    }
                }
                break;
            case PNGSaver.COLOR_MODE:
                {
                    byte[] row = new byte[width * 3];
                    for (int y = 0; y < height; y++) {
                        inflater.inflate(new byte[1]);
                        inflater.inflate(row);
                        for (int x = 0; x < width; x++) {
                            colors[0] = (row[x * 3 + 0]&0xff);
                            colors[1] = (row[x * 3 + 1]&0xff);
                            colors[2] = (row[x * 3 + 2]&0xff);
                            setColors(result, x, y, colors);
                        }
                    }
                }
            }
        } catch(DataFormatException e) {
            throw(new JemmyException("ZIP error", e));
        }

        readInt();//!!crc
        readInt();//0

View Full Code Here

        this.regex = regex;
        this.flags = flags;
        this.front = front;
        this.index = index;
        if (index < 0) {
            throw new JemmyException("Index must be >=0 but is " + index, regex);
        }
    }
View Full Code Here

     */
    public static int position(Text text, String regex, int flags, boolean front, int index) {
        Matcher matcher = Pattern.compile(regex, flags).matcher(text.text());
        for (int i = 0; i <= index; i++) {
            if (!matcher.find()) {
                throw new JemmyException(index + "'s occurance of \"" + regex + "\" not found.", text);
            }
        }
        return front ? matcher.start() : matcher.end();
    }
View Full Code Here

        if (propFile.exists()) {
            Properties props = new Properties();
            try {
                props.load(new FileInputStream(propFile));
            } catch (IOException ex) {
                throw new JemmyException("Unable to load properties", ex, propFileName);
            }
            for (Object k : props.keySet()) {
                setProperty(k.toString(), props.getProperty(k.toString()));
            }
        } else {
View Full Code Here

            String executorClassName = (String) getProperty(ActionExecutor.ACTION_EXECUTOR_PROPERTY);
            try {
                res = ActionExecutor.class.cast(Class.forName(executorClassName).newInstance());
                setExecutor(res);
            } catch (InstantiationException ex) {
                throw new JemmyException("Unable to instantiate executor ", ex, executorClassName);
            } catch (IllegalAccessException ex) {
                throw new JemmyException("Unable to instantiate executor ", ex, executorClassName);
            } catch (ClassNotFoundException ex) {
                throw new JemmyException("No executorclass ", ex, executorClassName);
            }
        }
        return res;
    }
View Full Code Here

            }
            try {
                res = ImageFactory.class.cast(Class.forName(String.class.cast(factoryClass)).newInstance());
                setImageFactory(res);
            } catch (InstantiationException ex) {
                throw new JemmyException("Unable to instantiate image factory ", ex, factoryClass);
            } catch (IllegalAccessException ex) {
                throw new JemmyException("Unable to instantiate image factory ", ex, factoryClass);
            } catch (ClassNotFoundException ex) {
                throw new JemmyException("No image factory class ", ex, factoryClass);
            }
        }
        return res;
    }
View Full Code Here

TOP

Related Classes of org.jemmy.JemmyException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.