001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: /**
018: * @author Michael Danilov
019: * @version $Revision$
020: */package java.awt.event;
021:
022: import java.awt.Frame;
023: import java.awt.Window;
024:
025: import junit.framework.TestCase;
026:
027: public class WindowEventTest extends TestCase {
028:
029: public final void testWindowEventWindowint() {
030: Window window = new Window(new Frame());
031: WindowEvent event = new WindowEvent(window,
032: WindowEvent.WINDOW_ACTIVATED);
033:
034: assertEquals(event.getSource(), window);
035: assertEquals(event.getID(), WindowEvent.WINDOW_ACTIVATED);
036: assertEquals(event.getWindow(), window);
037: assertNull(event.getOppositeWindow());
038: assertEquals(event.getOldState(), Frame.NORMAL);
039: assertEquals(event.getNewState(), Frame.NORMAL);
040: }
041:
042: public final void testWindowEventWindowintWindow() {
043: Window window = new Window(new Frame());
044: Window opposite = new Window(new Frame());
045: WindowEvent event = new WindowEvent(window,
046: WindowEvent.WINDOW_ACTIVATED, opposite);
047:
048: assertEquals(event.getSource(), window);
049: assertEquals(event.getID(), WindowEvent.WINDOW_ACTIVATED);
050: assertEquals(event.getWindow(), window);
051: assertEquals(event.getOppositeWindow(), opposite);
052: assertEquals(event.getOldState(), Frame.NORMAL);
053: assertEquals(event.getNewState(), Frame.NORMAL);
054: }
055:
056: public final void testWindowEventWindowintintint() {
057: Window window = new Window(new Frame());
058: WindowEvent event = new WindowEvent(window,
059: WindowEvent.WINDOW_ACTIVATED, Frame.MAXIMIZED_BOTH,
060: Frame.MAXIMIZED_HORIZ);
061:
062: assertEquals(event.getSource(), window);
063: assertEquals(event.getID(), WindowEvent.WINDOW_ACTIVATED);
064: assertEquals(event.getWindow(), window);
065: assertNull(event.getOppositeWindow());
066: assertEquals(event.getOldState(), Frame.MAXIMIZED_BOTH);
067: assertEquals(event.getNewState(), Frame.MAXIMIZED_HORIZ);
068: }
069:
070: public final void testWindowEventWindowintWindowintint() {
071: Window window = new Window(new Frame());
072: Window opposite = new Window(new Frame());
073: WindowEvent event = new WindowEvent(window,
074: WindowEvent.WINDOW_ACTIVATED, opposite,
075: Frame.MAXIMIZED_BOTH, Frame.MAXIMIZED_HORIZ);
076:
077: assertEquals(event.getSource(), window);
078: assertEquals(event.getID(), WindowEvent.WINDOW_ACTIVATED);
079: assertEquals(event.getWindow(), window);
080: assertEquals(event.getOppositeWindow(), opposite);
081: assertEquals(event.getOldState(), Frame.MAXIMIZED_BOTH);
082: assertEquals(event.getNewState(), Frame.MAXIMIZED_HORIZ);
083: }
084:
085: public final void testParamString() {
086: Window window = new Window(new Frame());
087: Window opposite = new Window(new Frame());
088: WindowEvent event = new WindowEvent(window,
089: WindowEvent.WINDOW_ACTIVATED, opposite,
090: Frame.MAXIMIZED_BOTH, Frame.MAXIMIZED_HORIZ);
091:
092: assertTrue(event.paramString().startsWith(
093: "WINDOW_ACTIVATED,opposite=java.awt.Window["));
094: assertTrue(event.paramString().endsWith(
095: "],oldState=6,newState=2"));
096: event = new WindowEvent(window,
097: WindowEvent.WINDOW_ACTIVATED + 1024, opposite,
098: Frame.MAXIMIZED_BOTH, Frame.MAXIMIZED_HORIZ);
099: assertTrue(event.paramString().startsWith("unknown type"));
100: }
101:
102: }
|