@@ -0,0 +1,3161 @@
+/*%0A * Licensed to the Apache Software Foundation (ASF) under one or more%0A * contributor license agreements.  See the NOTICE file distributed with%0A * this work for additional information regarding copyright ownership.%0A * The ASF licenses this file to You under the Apache License, Version 2.0%0A * (the %22License%22); you may not use this file except in compliance with%0A * the License.  You may obtain a copy of the License at%0A * %0A * http://www.apache.org/licenses/LICENSE-2.0%0A * %0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS, WITHOUT%0A * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the%0A * License for the specific language governing permissions and limitations under%0A * the License.%0A */%0A%0Apackage org.apache.harmony.awt.tests.image;%0A%0Aimport java.awt.Image;%0Aimport java.awt.Toolkit;%0Aimport java.awt.image.ColorModel;%0Aimport java.awt.image.ImageConsumer;%0Aimport java.awt.image.ImageProducer;%0Aimport java.net.URL;%0Aimport java.util.Hashtable;%0A%0Aimport junit.framework.TestCase;%0A%0Apublic class GifDecoderTest extends TestCase implements ImageConsumer%7B%0A%0A    ImageProducer ip;%0A    Object lock = new Object();%0A    ColorModel cm = ColorModel.getRGBdefault();%0A    int state = 0;%0A    boolean started = false;%0A%0A    private final ClassLoader c = ClassLoader.getSystemClassLoader();%0A%0A    private Image createImage(String name) %7B%0A        final URL path = c.getResource(%22../resources/images/%22 + name);%0A        assertNotNull(%22Resource not found: %22 + name, path); //$NON-NLS-1$%0A        return Toolkit.getDefaultToolkit().createImage(path);%0A    %7D%0A%0A    public void setColorModel(ColorModel model)%7B%7D%0A    public void setHints(int hintflags)%7B%7D%0A    public void setDimensions(int width, int height)%7B%7D%0A    public void setProperties(Hashtable%3C?,?%3E props)%7B%7D%0A%0A    public void imageComplete(int status)%7B%0A%0A        state = status;%0A        if(state == STATICIMAGEDONE) stopProduction(); %0A        synchronized(lock)%7B%0A            lock.notify();%0A        %7D%0A%0A    %7D%0A%0A    public void setPixels(int x, int y, int w, int h, ColorModel model,%0A        byte%5B%5D pixels, int off, int scansize) %7B%0A%0A        cm = model;%0A        synchronized(lock)%7B%0A            lock.notify();%0A        %7D%0A%0A    %7D%0A%0A    public void setPixels(int x, int y, int w, int h, ColorModel model,%0A        int%5B%5D pixels, int off, int scansize) %7B%0A%0A        cm = model;%0A        synchronized(lock)%7B%0A            lock.notify();%0A        %7D%0A%0A    %7D%0A%0A    private void startProduction(ImageProducer ip)%7B%0A        if(!started)%7B%0A            this.ip = ip;%0A            started = true;%0A            ip.startProduction(this);%0A        %7D%0A%0A    %7D%0A%0A    private synchronized void stopProduction()%7B%0A        ip.removeConsumer(this);%0A    %7D%0A%0A    public void test_H5491() throws Exception%7B%0A%0A        Image img = createImage(%22test.gif%22);%0A        while(state != STATICIMAGEDONE)%7B%0A            startProduction(img.getSource());%0A            synchronized(lock)%7B%0A                try%7B%0A                    lock.wait(2000);%0A                %7D catch(InterruptedException e)%7B%7D%0A            %7D%0A%0A            if(cm == null)  fail(%22ColorModel in setPixels is null!%22);%0A        %7D%0A%0A    %7D%0A%7D%0A

Apply regression test for HARMONY-5491 ([classlib][awt] GifDecoder not always passes ColorModel through setPixels method)