mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-11-10 00:48:45 +00:00
Order minimized window off screen and keep it in Windows menu for restore. Enable minimize button for miniaturizable windows. * CPWindow.j: - Order window out with attached sheet and visible child windows on miniaturize:; keep first responder and child windows for restore; ignore miniaturize: on minimized window. - Restore window, first responder and child windows when window orders front; post CPWindowDidDeminiaturizeNotification after restore. - Restore minimized window through makeKeyAndOrderFront: in deminiaturize:. - Remove calls to platform window's miniaturize: and deminiaturize:. - Minimize through performMiniaturize: only when window can minimize; enable performMiniaturize: and miniaturize: menu items under same condition. * _CPStandardWindowView.j: Enable minimize button for miniaturizable windows and target window's miniaturize:. * CPWindowTest.j: Add tests for restore, notification order, first responder restore, performMiniaturize: on non-miniaturizable window, minimize button action and menu validation. * CPApplicationWindowsMenuTest.j: Add tests for minimized window listed in mixed state and restored from Windows menu. * DropInCompatibilityTest.j: Replace test for minimize button never enabled with test for minimize button enabled only for miniaturizable windows.
201 lines
5.6 KiB
Plaintext
201 lines
5.6 KiB
Plaintext
@import <AppKit/CPApplication.j>
|
|
@import <AppKit/CPMenu.j>
|
|
@import <AppKit/CPPanel.j>
|
|
@import <AppKit/CPWindow.j>
|
|
|
|
@implementation CPApplicationWindowsMenuTest : OJTestCase
|
|
{
|
|
CPApplication app;
|
|
CPMenu windowsMenu;
|
|
}
|
|
|
|
- (void)setUp
|
|
{
|
|
app = [[CPApplication alloc] init];
|
|
|
|
// A main menu whose Window submenu carries the name nib2cib gives the Windows menu.
|
|
var mainMenu = [[CPMenu alloc] initWithTitle:@"Main"],
|
|
windowsMenuItem = [[CPMenuItem alloc] initWithTitle:@"Window" action:nil keyEquivalent:@""];
|
|
|
|
windowsMenu = [[CPMenu alloc] initWithTitle:@"Window"];
|
|
[windowsMenu _setMenuName:@"_CPWindowsMenu"];
|
|
[windowsMenu addItemWithTitle:@"Minimize" action:@selector(performMiniaturize:) keyEquivalent:@"m"];
|
|
|
|
[windowsMenuItem setSubmenu:windowsMenu];
|
|
[mainMenu addItem:windowsMenuItem];
|
|
[app setMainMenu:mainMenu];
|
|
}
|
|
|
|
- (void)tearDown
|
|
{
|
|
CPApp = nil;
|
|
}
|
|
|
|
- (CPWindow)visibleWindowWithTitle:(CPString)aTitle
|
|
{
|
|
var aWindow = [[CPWindow alloc] initWithContentRect:CGRectMake(0.0, 0.0, 200.0, 100.0) styleMask:CPTitledWindowMask];
|
|
|
|
// There is no DOM in the test runner, so ordering a window in does not make it visible.
|
|
aWindow._isVisible = YES;
|
|
[aWindow setTitle:aTitle];
|
|
|
|
return aWindow;
|
|
}
|
|
|
|
- (void)testWindowsMenuIsFoundInMainMenu
|
|
{
|
|
[self assert:windowsMenu equals:[app windowsMenu]];
|
|
}
|
|
|
|
- (void)testVisibleTitledWindowIsListedBelowSeparator
|
|
{
|
|
var aWindow = [self visibleWindowWithTitle:@"Report"];
|
|
|
|
[self assert:3 equals:[windowsMenu numberOfItems]];
|
|
[self assertTrue:[[windowsMenu itemAtIndex:1] isSeparatorItem] message:@"a separator should precede the window list"];
|
|
|
|
var item = [windowsMenu itemAtIndex:2];
|
|
|
|
[self assert:@"Report" equals:[item title]];
|
|
[self assert:aWindow equals:[item target]];
|
|
[self assert:@selector(makeKeyAndOrderFront:) equals:[item action]];
|
|
}
|
|
|
|
- (void)testRetitlingWindowChangesItsItem
|
|
{
|
|
var aWindow = [self visibleWindowWithTitle:@"Report"];
|
|
|
|
[aWindow setTitle:@"Final Report"];
|
|
|
|
[self assert:3 equals:[windowsMenu numberOfItems]];
|
|
[self assert:@"Final Report" equals:[[windowsMenu itemAtIndex:2] title]];
|
|
}
|
|
|
|
- (void)testUntitledWindowIsNotListed
|
|
{
|
|
[self visibleWindowWithTitle:@""];
|
|
|
|
[self assert:1 equals:[windowsMenu numberOfItems]];
|
|
}
|
|
|
|
- (void)testExcludedWindowIsNotListed
|
|
{
|
|
var aWindow = [self visibleWindowWithTitle:@"Report"];
|
|
|
|
[aWindow setExcludedFromWindowsMenu:YES];
|
|
|
|
[self assert:1 equals:[windowsMenu numberOfItems]];
|
|
|
|
[aWindow setExcludedFromWindowsMenu:NO];
|
|
|
|
[self assert:3 equals:[windowsMenu numberOfItems]];
|
|
}
|
|
|
|
- (void)testPanelIsNotListed
|
|
{
|
|
var panel = [[CPPanel alloc] initWithContentRect:CGRectMake(0.0, 0.0, 200.0, 100.0) styleMask:CPTitledWindowMask];
|
|
|
|
panel._isVisible = YES;
|
|
[panel setTitle:@"Inspector"];
|
|
|
|
[self assert:1 equals:[windowsMenu numberOfItems]];
|
|
}
|
|
|
|
- (void)testMainWindowIsChecked
|
|
{
|
|
var firstWindow = [self visibleWindowWithTitle:@"First"],
|
|
secondWindow = [self visibleWindowWithTitle:@"Second"];
|
|
|
|
[firstWindow makeMainWindow];
|
|
|
|
[self assert:CPOnState equals:[[windowsMenu itemAtIndex:2] state]];
|
|
[self assert:CPOffState equals:[[windowsMenu itemAtIndex:3] state]];
|
|
|
|
[secondWindow makeMainWindow];
|
|
|
|
[self assert:CPOffState equals:[[windowsMenu itemAtIndex:2] state]];
|
|
[self assert:CPOnState equals:[[windowsMenu itemAtIndex:3] state]];
|
|
}
|
|
|
|
- (void)testClosingLastWindowRemovesItemAndSeparator
|
|
{
|
|
var aWindow = [self visibleWindowWithTitle:@"Report"];
|
|
|
|
[aWindow close];
|
|
|
|
[self assert:1 equals:[windowsMenu numberOfItems]];
|
|
[self assert:@"Minimize" equals:[[windowsMenu itemAtIndex:0] title]];
|
|
}
|
|
|
|
- (void)testClosingOneWindowKeepsSeparatorForOthers
|
|
{
|
|
var firstWindow = [self visibleWindowWithTitle:@"First"];
|
|
|
|
[self visibleWindowWithTitle:@"Second"];
|
|
[firstWindow close];
|
|
|
|
[self assert:3 equals:[windowsMenu numberOfItems]];
|
|
[self assert:@"Second" equals:[[windowsMenu itemAtIndex:2] title]];
|
|
}
|
|
|
|
- (void)testFilenameItemShowsNameThenDirectory
|
|
{
|
|
var aWindow = [[CPWindow alloc] initWithContentRect:CGRectMake(0.0, 0.0, 200.0, 100.0) styleMask:CPTitledWindowMask];
|
|
|
|
[app addWindowsItem:aWindow title:@"/Users/me/Report.txt" filename:YES];
|
|
|
|
[self assert:@"Report.txt — /Users/me" equals:[[windowsMenu itemAtIndex:2] title]];
|
|
}
|
|
|
|
- (void)testAddingListedWindowAgainDoesNothing
|
|
{
|
|
var aWindow = [self visibleWindowWithTitle:@"Report"];
|
|
|
|
[app addWindowsItem:aWindow title:@"Other" filename:NO];
|
|
|
|
[self assert:3 equals:[windowsMenu numberOfItems]];
|
|
[self assert:@"Report" equals:[[windowsMenu itemAtIndex:2] title]];
|
|
}
|
|
|
|
- (void)testMinimizedWindowStaysListedInTheMixedState
|
|
{
|
|
var aWindow = [self visibleWindowWithTitle:@"Report"];
|
|
|
|
[aWindow makeMainWindow];
|
|
[aWindow miniaturize:self];
|
|
|
|
var item = [windowsMenu itemAtIndex:2];
|
|
|
|
[self assert:aWindow equals:[item target]];
|
|
[self assert:CPMixedState equals:[item state]];
|
|
}
|
|
|
|
- (void)testChoosingAMinimizedWindowRestoresIt
|
|
{
|
|
var aWindow = [self visibleWindowWithTitle:@"Report"];
|
|
|
|
[aWindow makeMainWindow];
|
|
[aWindow miniaturize:self];
|
|
|
|
var item = [windowsMenu itemAtIndex:2];
|
|
|
|
[[item target] performSelector:[item action] withObject:item];
|
|
|
|
[self assertFalse:[aWindow isMiniaturized]];
|
|
[self assert:CPOnState equals:[item state]];
|
|
}
|
|
|
|
- (void)testSetWindowsMenuMovesWindowItems
|
|
{
|
|
var aWindow = [self visibleWindowWithTitle:@"Report"],
|
|
otherMenu = [[CPMenu alloc] initWithTitle:@"Windows"];
|
|
|
|
[app setWindowsMenu:otherMenu];
|
|
|
|
[self assert:1 equals:[windowsMenu numberOfItems]];
|
|
[self assert:1 equals:[otherMenu numberOfItems]];
|
|
[self assert:aWindow equals:[[otherMenu itemAtIndex:0] target]];
|
|
}
|
|
|
|
@end
|