// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License.txt in the project root for license information.
///
///
module Helper._CommandingSurface {
"use strict";
export var Constants = {
typeSeparator: "separator",
typeContent: "content",
typeButton: "button",
typeToggle: "toggle",
typeFlyout: "flyout",
controlCssClass: "win-commandingsurface",
disposableCssClass: "win-disposable",
overflowAreaCssClass: "win-commandingsurface-overflowarea",
emptyCommandingSurfaceCssClass: "win-commandingsurface-empty",
commandType: "WinJS.UI.AppBarCommand",
secondaryCommandSection: "secondary",
commandSelector: ".win-command",
actionAreaCommandWidth: 68,
actionAreaSeparatorWidth: 34,
actionAreaOverflowButtonWidth: 32,
overflowCommandHeight: 44,
overflowSeparatorHeight: 12,
commandingSurfaceMinWidth: 68,
heightOfMinimal: 24,
heightOfCompact: 48,
}
export function getVisibleCommandsInElement(element: HTMLElement) {
var result = [];
var commands = element.querySelectorAll(Constants.commandSelector);
for (var i = 0, len = commands.length; i < len; i++) {
if (getComputedStyle(commands[i]).display !== "none") {
result.push(commands[i]);
}
}
return result;
}
export function verifyOverflowMenuContent(visibleElements: HTMLElement[], expectedLabels: string[]): void {
var labelIndex = 0;
for (var i = 0, len = visibleElements.length; i < len; i++) {
if (visibleElements[i]["winControl"].type === Constants.typeSeparator) {
LiveUnit.Assert.areEqual(expectedLabels[labelIndex], Constants.typeSeparator);
} else {
LiveUnit.Assert.areEqual(expectedLabels[labelIndex], visibleElements[i]["winControl"].label);
}
labelIndex++;
}
}
export function verifyActionAreaVisibleCommandsLabels(commandingSurface: WinJS.UI._CommandingSurface, labels: string[]) {
var commands = getVisibleCommandsInElement((commandingSurface.element.winControl)._dom.actionArea);
LiveUnit.Assert.areEqual(labels.length, commands.length);
labels.forEach((label, index) => {
LiveUnit.Assert.areEqual(label, commands[index].winControl.label);
});
}
export function verifyOverflowAreaCommandsLabels(commandingSurface: WinJS.UI._CommandingSurface, labels: string[]) {
var control = commandingSurface.element.winControl;
var commands = getVisibleCommandsInElement(control._dom.overflowArea);
LiveUnit.Assert.areEqual(labels.length, commands.length);
labels.forEach((label, index) => {
LiveUnit.Assert.areEqual(label, commands[index].winControl.label);
});
}
}