/*
 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
 */

package com.sun.glass.tests;

import com.sun.glass.ui.*;

import static org.junit.Assert.*;
import org.junit.Test;
import org.junit.Before;
import org.junit.After;
import org.junit.BeforeClass;
import org.junit.AfterClass;

import java.util.List;

public class WindowTest
{
    static int WINDOW_X = 101;
    static int WINDOW_Y = 102;
    static int WINDOW_W = 512;
    static int WINDOW_H = 256;
    
    @BeforeClass
    static public void prepare()
    {
        try
        {
            Application app = Application.GetApplication();
            Screen screen = Screen.getMainScreen();

            int windowMask = Window.TITLED|Window.CLOSABLE|Window.MINIMIZABLE;
            Window window = app.createWindow(screen, windowMask);
            window.setPosition(WINDOW_X, WINDOW_Y);
            window.setSize(WINDOW_W, WINDOW_H);
            window.setTitle(app.getName());
            window.setVisible(true);
        }
        catch (Throwable t)
        {
            t.printStackTrace();
            System.exit(0);
        }
    }
    
    @AfterClass
    static public void finish()
    {
        Window window = Window.getWindows().get(0);
        window.close();
    }
    
    @Test
    public void testWindowsList()
    {
        List<Window> list = Window.getWindows();
        assertTrue(list != null);
        assertTrue(list.size() == 1);
    }
    
    @Test
    public void testWindowX()
    {
        Window window = Window.getWindows().get(0);
        assertTrue(window != null);
        assertTrue(window.getX() == WINDOW_X);
    }
    
    @Test
    public void testWindowY()
    {
        Window window = Window.getWindows().get(0);
        assertTrue(window != null);
        assertTrue(window.getY() == WINDOW_Y);
    }

    @Test
    public void testWindowW()
    {
        Window window = Window.getWindows().get(0);
        assertTrue(window != null);
        assertTrue(window.getWidth() == WINDOW_W);
    }

    @Test
    public void testWindowH()
    {
        Window window = Window.getWindows().get(0);
        assertTrue(window != null);
        assertTrue(window.getHeight() == WINDOW_H);
    }
}
