// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License.txt in the project root for license information. /// /// module Helper.ToolBar { "use strict"; export var Constants = { typeSeparator: "separator", typeContent: "content", typeButton: "button", typeToggle: "toggle", typeFlyout: "flyout", controlCssClass: "win-toolbar", disposableCssClass: "win-disposable", overflowAreaCssClass: "win-toolbar-overflowarea", shownDisplayReducedCssClass: "win-toolbar-showndisplayreduced", shownDisplayFullCssClass: "win-toolbar-showndisplayfull", emptyToolBarCssClass: "win-toolbar-empty", commandType: "WinJS.UI.AppBarCommand", secondaryCommandSection: "secondary", commandSelector: ".win-command", inlineOverflowCommandHeight: 44, inlineOverflowSeparatorHeight: 12, controlWithFlyoutMenuMinWidth: 68, shownDisplayModes: { full: "full", reduced: "reduced", } } 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 verifyMainActionVisibleCommandsLabels(toolbar: WinJS.UI.ToolBar, labels: string[]) { var commands = getVisibleCommandsInElement((toolbar.element.winControl)._mainActionArea); LiveUnit.Assert.areEqual(labels.length, commands.length); labels.forEach((label, index) => { LiveUnit.Assert.areEqual(label, commands[index].winControl.label); }); } export function verifyOverflowAreaCommandsLabels(toolbar: WinJS.UI.ToolBar, labels: string[]) { var control = toolbar.element.winControl; var commands = getVisibleCommandsInElement(control.shownDisplayMode === Constants.shownDisplayModes.full ? control._inlineOverflowArea : control._menu.element); LiveUnit.Assert.areEqual(labels.length, commands.length); labels.forEach((label, index) => { LiveUnit.Assert.areEqual(label, commands[index].winControl.label); }); } }