Hello GitHub
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using Microsoft.OneCoreUap.Test.AppModel;
|
||||
using MS.Internal.Mita.Foundation;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Calculator.UIAutomationLibrary.Components
|
||||
{
|
||||
public class CalculatorAppLfm
|
||||
{
|
||||
private readonly IViewDescriptor viewDescriptor;
|
||||
|
||||
public CalculatorAppLfm(CalculatorAppPom objectModel, IViewDescriptor viewDescriptor)
|
||||
{
|
||||
this.ObjectModel = objectModel;
|
||||
this.viewDescriptor = viewDescriptor;
|
||||
}
|
||||
|
||||
public CalculatorAppPom ObjectModel { get; }
|
||||
|
||||
public MainPageLfm MainPageLfm
|
||||
{
|
||||
get
|
||||
{
|
||||
return new MainPageLfm(this.ObjectModel.MainPagePom);
|
||||
}
|
||||
}
|
||||
|
||||
public void Close()
|
||||
{
|
||||
// ObjectModel is essentially the window ui object.
|
||||
if (this.viewDescriptor != null)
|
||||
{
|
||||
NavigationHelper.CloseApplication(this.viewDescriptor.AUMID);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,31 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using MS.Internal.Mita.Foundation;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Calculator.UIAutomationLibrary.Components
|
||||
{
|
||||
public class CalculatorAppPom : UIObject
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new instance of the <see cref="CalculatorAppPom"/> class.
|
||||
/// </summary>
|
||||
/// <param name="uiObject">UIObject for the calculator app window.</param>
|
||||
public CalculatorAppPom(UIObject uiObject)
|
||||
: base(uiObject)
|
||||
{
|
||||
}
|
||||
public MainPagePom MainPagePom
|
||||
{
|
||||
get
|
||||
{
|
||||
return new MainPagePom(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,35 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Calculator.UIAutomationLibrary.Components
|
||||
{
|
||||
public class ContentDialogLfm
|
||||
{
|
||||
public ContentDialogLfm(ContentDialogPom objectModel)
|
||||
{
|
||||
this.ObjectModel = objectModel;
|
||||
}
|
||||
|
||||
public ContentDialogPom ObjectModel { get; }
|
||||
|
||||
public void InvokePrimary()
|
||||
{
|
||||
this.ObjectModel.PrimaryButton.Invoke();
|
||||
}
|
||||
public void InvokeSecondary()
|
||||
{
|
||||
this.ObjectModel.SecondaryButton.Invoke();
|
||||
}
|
||||
|
||||
public void InvokeClose()
|
||||
{
|
||||
this.ObjectModel.CloseButton.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,62 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using MS.Internal.Mita.Foundation;
|
||||
using MS.Internal.Mita.Foundation.Controls;
|
||||
|
||||
namespace Calculator.UIAutomationLibrary.Components
|
||||
{
|
||||
public class ContentDialogPom : UIObject
|
||||
{
|
||||
private static readonly UICondition textScrollViewerCondition = UICondition.CreateFromId("ContentScrollViewer");
|
||||
private static readonly UICondition titleTextBlockCondition = UICondition.CreateFromClassName("TextBlock");
|
||||
|
||||
private static readonly UICondition primaryButtonCondition =
|
||||
UICondition.CreateFromClassName("Button")
|
||||
.AndWith(UICondition.CreateFromId("PrimaryButton"));
|
||||
private static readonly UICondition secondaryButtonCondition =
|
||||
UICondition.CreateFromClassName("Button")
|
||||
.AndWith(UICondition.CreateFromId("SecondaryButton"));
|
||||
private static readonly UICondition closeButtonCondition =
|
||||
UICondition.CreateFromClassName("Button")
|
||||
.AndWith(UICondition.CreateFromId("CloseButton"));
|
||||
|
||||
public ContentDialogPom(UIObject uiObject) : base(uiObject)
|
||||
{
|
||||
}
|
||||
|
||||
public Button PrimaryButton
|
||||
{
|
||||
get
|
||||
{
|
||||
return new Button(this.Children.Find(primaryButtonCondition));
|
||||
}
|
||||
}
|
||||
|
||||
public Button SecondaryButton
|
||||
{
|
||||
get
|
||||
{
|
||||
return new Button(this.Children.Find(secondaryButtonCondition));
|
||||
}
|
||||
}
|
||||
|
||||
public Button CloseButton
|
||||
{
|
||||
get
|
||||
{
|
||||
return new Button(this.Children.Find(closeButtonCondition));
|
||||
}
|
||||
}
|
||||
|
||||
public string Title
|
||||
{
|
||||
get
|
||||
{
|
||||
var scrollViewer = this.Children.Find(textScrollViewerCondition);
|
||||
var textBlock = scrollViewer.Children.Find(titleTextBlockCondition);
|
||||
return textBlock.Name;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,31 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
namespace Calculator.UIAutomationLibrary.Components
|
||||
{
|
||||
public class AboutFlyoutLfm : ICanFocusWithClicks
|
||||
{
|
||||
private const string FlyoutId = "FlyoutNav";
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="AboutFlyoutLfm" /> class.
|
||||
/// </summary>
|
||||
/// <param name="objectModel">The AboutFlyoutPom that represents the About flyout panel.</param>
|
||||
public AboutFlyoutLfm(AboutFlyoutPom objectModel)
|
||||
{
|
||||
this.ObjectModel = objectModel;
|
||||
}
|
||||
|
||||
public AboutFlyoutPom ObjectModel { get; }
|
||||
|
||||
public void FocusWithClicks()
|
||||
{
|
||||
this.ObjectModel.Title.DoubleClick();
|
||||
}
|
||||
|
||||
public void Close()
|
||||
{
|
||||
this.ObjectModel.SendKeys("{ESC}");
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,29 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using MS.Internal.Mita.Foundation;
|
||||
using MS.Internal.Mita.Foundation.Controls;
|
||||
|
||||
namespace Calculator.UIAutomationLibrary.Components
|
||||
{
|
||||
public class AboutFlyoutPom : UIObject
|
||||
{
|
||||
private const string TitleId = "Header";
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="AboutFlyoutPom" /> class.
|
||||
/// </summary>
|
||||
/// <param name="uiObject">The UIObject that is the root of the navigation menu.</param>
|
||||
public AboutFlyoutPom(UIObject uiObject) : base(uiObject)
|
||||
{
|
||||
}
|
||||
|
||||
public UIObject Title
|
||||
{
|
||||
get
|
||||
{
|
||||
return new UIObject(this.Descendants.Find(TitleId));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,57 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using MS.Internal.Mita.Foundation;
|
||||
using MS.Internal.Mita.Foundation.Controls;
|
||||
using MS.Internal.Mita.Foundation.Waiters;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Calculator.UIAutomationLibrary.Components
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the Display section of the calculator modes.
|
||||
/// </summary>
|
||||
public class CalculatorBasePom : UIObject
|
||||
{
|
||||
private const string ExpressionContainerId = "CalculatorExpression";
|
||||
private const string NormalOutputId = "normalOutput";
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="StandardCalculatorPom" /> class.
|
||||
/// </summary>
|
||||
/// <param name="uiObject">The UIObject that is the root of the standard calculator.</param>
|
||||
public CalculatorBasePom(UIObject uiObject) : base(uiObject)
|
||||
{
|
||||
}
|
||||
|
||||
public TextBlock Expression
|
||||
{
|
||||
get
|
||||
{
|
||||
return new TextBlock(this.Descendants.Find(ExpressionContainerId));
|
||||
}
|
||||
}
|
||||
|
||||
public UIEventWaiter GetExpressionChangedWaiter()
|
||||
{
|
||||
return new PropertyChangedEventWaiter(this.Expression, UIProperty.Get("Name"));
|
||||
}
|
||||
|
||||
public TextBlock Display
|
||||
{
|
||||
get
|
||||
{
|
||||
return new TextBlock(this.Descendants.Find(NormalOutputId));
|
||||
}
|
||||
}
|
||||
|
||||
public UIEventWaiter GetDisplayChangedWaiter()
|
||||
{
|
||||
return new PropertyChangedEventWaiter(this.Display, UIProperty.Get("Name"));
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,36 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
namespace Calculator.UIAutomationLibrary.Components
|
||||
{
|
||||
public class DateCalculatorLfm
|
||||
{
|
||||
public DateCalculatorLfm(DateCalculatorPom dateCalculatorPom)
|
||||
{
|
||||
this.ObjectModel = dateCalculatorPom;
|
||||
}
|
||||
|
||||
public DateCalculatorPom ObjectModel { get; }
|
||||
|
||||
public void EnsureDateDifferenceMode()
|
||||
{
|
||||
this.OpenModeSelector();
|
||||
this.ObjectModel.ModeSelector.AllItems[0].Select();
|
||||
}
|
||||
|
||||
public void EnsureAddSubtractMode()
|
||||
{
|
||||
this.OpenModeSelector();
|
||||
this.ObjectModel.ModeSelector.AllItems[1].Select();
|
||||
}
|
||||
|
||||
private void OpenModeSelector()
|
||||
{
|
||||
using (var waiter = this.ObjectModel.ModeSelector.GetExpandedWaiter())
|
||||
{
|
||||
this.ObjectModel.ModeSelector.Expand();
|
||||
waiter.TryWait();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,25 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using MS.Internal.Mita.Foundation;
|
||||
using MS.Internal.Mita.Foundation.Controls;
|
||||
|
||||
namespace Calculator.UIAutomationLibrary.Components
|
||||
{
|
||||
public class DateCalculatorPom : UIObject
|
||||
{
|
||||
private const string ModeSelectorId = "DateCalculationOption";
|
||||
|
||||
public DateCalculatorPom(UIObject uiObject) : base(uiObject)
|
||||
{
|
||||
}
|
||||
|
||||
public ComboBox ModeSelector
|
||||
{
|
||||
get
|
||||
{
|
||||
return new ComboBox(this.Descendants.Find(ModeSelectorId));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,255 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using Etw.Managed;
|
||||
using MS.Internal.Mita.Foundation.Waiters;
|
||||
|
||||
namespace Calculator.UIAutomationLibrary.Components
|
||||
{
|
||||
public class MainPageLfm : ICanFocusWithClicks
|
||||
{
|
||||
public MainPageLfm(MainPagePom objectModel)
|
||||
{
|
||||
this.ObjectModel = objectModel;
|
||||
}
|
||||
|
||||
public MainPagePom ObjectModel { get; }
|
||||
|
||||
public NavBarLfm OpenNavBar()
|
||||
{
|
||||
using (EtwWaiter waiter = this.ObjectModel.GetNavBarOpenedWaiter())
|
||||
{
|
||||
this.ObjectModel.NavButton.Invoke();
|
||||
waiter.Wait();
|
||||
}
|
||||
|
||||
return new NavBarLfm(this.ObjectModel.NavBarPom);
|
||||
}
|
||||
|
||||
public void CloseNavBar()
|
||||
{
|
||||
this.ObjectModel.NavBarPom.CloseButton.Invoke();
|
||||
}
|
||||
|
||||
public void FocusWithClicks()
|
||||
{
|
||||
this.ObjectModel.Header.DoubleClick();
|
||||
}
|
||||
|
||||
public StandardCalculatorLfm NavigateToStandardCalculator()
|
||||
{
|
||||
var navBar = this.OpenNavBar();
|
||||
using (var waiter = this.ObjectModel.GetModeChangedWaiter())
|
||||
{
|
||||
navBar.SelectStandard();
|
||||
waiter.TryWait();
|
||||
}
|
||||
|
||||
return new StandardCalculatorLfm(this.ObjectModel.StandardCalculatorPom);
|
||||
}
|
||||
|
||||
public ScientificCalculatorLfm NavigateToScientificCalculator()
|
||||
{
|
||||
var navBar = this.OpenNavBar();
|
||||
using (var waiter = this.ObjectModel.GetModeChangedWaiter())
|
||||
{
|
||||
navBar.SelectScientific();
|
||||
waiter.TryWait();
|
||||
}
|
||||
|
||||
return new ScientificCalculatorLfm(this.ObjectModel.ScientificCalculatorPom);
|
||||
}
|
||||
|
||||
public ProgrammerCalculatorLfm NavigateToProgrammerCalculator()
|
||||
{
|
||||
var navBar = this.OpenNavBar();
|
||||
using (var waiter = this.ObjectModel.GetModeChangedWaiter())
|
||||
{
|
||||
navBar.SelectProgrammer();
|
||||
waiter.TryWait();
|
||||
}
|
||||
|
||||
return new ProgrammerCalculatorLfm(this.ObjectModel.ProgrammerCalculatorPom);
|
||||
}
|
||||
|
||||
public DateCalculatorLfm NavigateToDateCalculator()
|
||||
{
|
||||
var navBar = this.OpenNavBar();
|
||||
using (var waiter = this.ObjectModel.GetModeChangedWaiter())
|
||||
{
|
||||
navBar.SelectDate();
|
||||
waiter.TryWait();
|
||||
}
|
||||
|
||||
return new DateCalculatorLfm(this.ObjectModel.DateCalculatorPom);
|
||||
}
|
||||
|
||||
public UnitConverterLfm NavigateToCurrencyConverter()
|
||||
{
|
||||
var navBar = this.OpenNavBar();
|
||||
using (var waiter = this.ObjectModel.GetModeChangedWaiter())
|
||||
{
|
||||
navBar.SelectCurrency();
|
||||
waiter.TryWait();
|
||||
}
|
||||
|
||||
return new UnitConverterLfm(this.ObjectModel.UnitConverterPom);
|
||||
}
|
||||
|
||||
public UnitConverterLfm NavigateToVolumeConverter()
|
||||
{
|
||||
var navBar = this.OpenNavBar();
|
||||
using (var waiter = this.ObjectModel.GetModeChangedWaiter())
|
||||
{
|
||||
navBar.SelectVolume();
|
||||
waiter.TryWait();
|
||||
}
|
||||
|
||||
return new UnitConverterLfm(this.ObjectModel.UnitConverterPom);
|
||||
}
|
||||
|
||||
public UnitConverterLfm NavigateToLengthConverter()
|
||||
{
|
||||
var navBar = this.OpenNavBar();
|
||||
using (var waiter = this.ObjectModel.GetModeChangedWaiter())
|
||||
{
|
||||
navBar.SelectLength();
|
||||
waiter.TryWait();
|
||||
}
|
||||
|
||||
return new UnitConverterLfm(this.ObjectModel.UnitConverterPom);
|
||||
}
|
||||
|
||||
public UnitConverterLfm NavigateToWeightConverter()
|
||||
{
|
||||
var navBar = this.OpenNavBar();
|
||||
using (var waiter = this.ObjectModel.GetModeChangedWaiter())
|
||||
{
|
||||
navBar.SelectWeight();
|
||||
waiter.TryWait();
|
||||
}
|
||||
|
||||
return new UnitConverterLfm(this.ObjectModel.UnitConverterPom);
|
||||
}
|
||||
|
||||
public UnitConverterLfm NavigateToTemperatureConverter()
|
||||
{
|
||||
var navBar = this.OpenNavBar();
|
||||
using (var waiter = this.ObjectModel.GetModeChangedWaiter())
|
||||
{
|
||||
navBar.SelectTemperature();
|
||||
waiter.TryWait();
|
||||
}
|
||||
|
||||
return new UnitConverterLfm(this.ObjectModel.UnitConverterPom);
|
||||
}
|
||||
|
||||
public UnitConverterLfm NavigateToEnergyConverter()
|
||||
{
|
||||
var navBar = this.OpenNavBar();
|
||||
using (var waiter = this.ObjectModel.GetModeChangedWaiter())
|
||||
{
|
||||
navBar.SelectEnergy();
|
||||
waiter.TryWait();
|
||||
}
|
||||
|
||||
return new UnitConverterLfm(this.ObjectModel.UnitConverterPom);
|
||||
}
|
||||
|
||||
public UnitConverterLfm NavigateToAreaConverter()
|
||||
{
|
||||
var navBar = this.OpenNavBar();
|
||||
using (var waiter = this.ObjectModel.GetModeChangedWaiter())
|
||||
{
|
||||
navBar.SelectArea();
|
||||
waiter.TryWait();
|
||||
}
|
||||
|
||||
return new UnitConverterLfm(this.ObjectModel.UnitConverterPom);
|
||||
}
|
||||
|
||||
public UnitConverterLfm NavigateToSpeedConverter()
|
||||
{
|
||||
var navBar = this.OpenNavBar();
|
||||
using (var waiter = this.ObjectModel.GetModeChangedWaiter())
|
||||
{
|
||||
navBar.SelectSpeed();
|
||||
waiter.TryWait();
|
||||
}
|
||||
|
||||
return new UnitConverterLfm(this.ObjectModel.UnitConverterPom);
|
||||
}
|
||||
|
||||
public UnitConverterLfm NavigateToTimeConverter()
|
||||
{
|
||||
var navBar = this.OpenNavBar();
|
||||
using (var waiter = this.ObjectModel.GetModeChangedWaiter())
|
||||
{
|
||||
navBar.SelectTime();
|
||||
waiter.TryWait();
|
||||
}
|
||||
|
||||
return new UnitConverterLfm(this.ObjectModel.UnitConverterPom);
|
||||
}
|
||||
|
||||
public UnitConverterLfm NavigateToPowerConverter()
|
||||
{
|
||||
var navBar = this.OpenNavBar();
|
||||
using (var waiter = this.ObjectModel.GetModeChangedWaiter())
|
||||
{
|
||||
navBar.SelectPower();
|
||||
waiter.TryWait();
|
||||
}
|
||||
|
||||
return new UnitConverterLfm(this.ObjectModel.UnitConverterPom);
|
||||
}
|
||||
|
||||
public UnitConverterLfm NavigateToDataConverter()
|
||||
{
|
||||
var navBar = this.OpenNavBar();
|
||||
using (var waiter = this.ObjectModel.GetModeChangedWaiter())
|
||||
{
|
||||
navBar.SelectData();
|
||||
waiter.TryWait();
|
||||
}
|
||||
|
||||
return new UnitConverterLfm(this.ObjectModel.UnitConverterPom);
|
||||
}
|
||||
|
||||
public UnitConverterLfm NavigateToPressureConverter()
|
||||
{
|
||||
var navBar = this.OpenNavBar();
|
||||
using (var waiter = this.ObjectModel.GetModeChangedWaiter())
|
||||
{
|
||||
navBar.SelectPressure();
|
||||
waiter.TryWait();
|
||||
}
|
||||
|
||||
return new UnitConverterLfm(this.ObjectModel.UnitConverterPom);
|
||||
}
|
||||
|
||||
public UnitConverterLfm NavigateToAngleConverter()
|
||||
{
|
||||
var navBar = this.OpenNavBar();
|
||||
using (var waiter = this.ObjectModel.GetModeChangedWaiter())
|
||||
{
|
||||
navBar.SelectAngle();
|
||||
waiter.TryWait();
|
||||
}
|
||||
|
||||
return new UnitConverterLfm(this.ObjectModel.UnitConverterPom);
|
||||
}
|
||||
|
||||
public AboutFlyoutLfm OpenAboutFlyout()
|
||||
{
|
||||
var navBar = this.OpenNavBar();
|
||||
using (EtwWaiter waiter = new EtwWaiter(Constants.CalculatorETWProviderGUID, Constants.AboutFlyoutOpenedETWEventName))
|
||||
{
|
||||
navBar.SelectAbout();
|
||||
waiter.Wait();
|
||||
}
|
||||
|
||||
return new AboutFlyoutLfm(this.ObjectModel.AboutFlyoutPom);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,54 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using Etw.Managed;
|
||||
using MS.Internal.Mita.Foundation;
|
||||
using MS.Internal.Mita.Foundation.Controls;
|
||||
using MS.Internal.Mita.Foundation.Waiters;
|
||||
|
||||
namespace Calculator.UIAutomationLibrary.Components
|
||||
{
|
||||
/// <summary>
|
||||
/// Physical Object Model for the app window.
|
||||
/// POM is the implementation model of the app.
|
||||
/// See following references to POM:
|
||||
/// * https://blogs.msdn.microsoft.com/wltester/2011/11/14/object-model-design/
|
||||
/// * https://blogs.msdn.microsoft.com/micahel/2005/06/03/how-do-i-invoke-thee-let-me-count-the-ways-the-physical-object-model/
|
||||
/// See https://en.wikipedia.org/wiki/Model-based_testing for model-based testing.
|
||||
/// </summary>
|
||||
public class MainPagePom : UIObject
|
||||
{
|
||||
private const string NavButtonId = "TogglePaneButton";
|
||||
private const string SplitViewPaneRootId = "PaneRoot";
|
||||
private const string NavBarFlyoutId = "FlyoutNav";
|
||||
private const string HeaderId = "Header";
|
||||
private const string AboutPageFlyoutId = "AboutPageFlyout";
|
||||
|
||||
public MainPagePom(UIObject uiObject)
|
||||
: base(uiObject)
|
||||
{
|
||||
}
|
||||
|
||||
public Button NavButton => new Button(this.Descendants.Find(UICondition.CreateFromId(NavButtonId)));
|
||||
|
||||
public UIObject Header => new UIObject(this.Descendants.Find(HeaderId));
|
||||
|
||||
public NavBarPom NavBarPom => new NavBarPom(this.Children.Find(SplitViewPaneRootId));
|
||||
|
||||
public EtwWaiter GetNavBarOpenedWaiter() => new EtwWaiter(Constants.CalculatorETWProviderGUID, Constants.NavBarOpenedETWEventName);
|
||||
|
||||
public StandardCalculatorPom StandardCalculatorPom => new StandardCalculatorPom(this);
|
||||
|
||||
public ScientificCalculatorPom ScientificCalculatorPom => new ScientificCalculatorPom(this);
|
||||
|
||||
public ProgrammerCalculatorPom ProgrammerCalculatorPom => new ProgrammerCalculatorPom(this);
|
||||
|
||||
public DateCalculatorPom DateCalculatorPom => new DateCalculatorPom(this);
|
||||
|
||||
public UnitConverterPom UnitConverterPom => new UnitConverterPom(this);
|
||||
|
||||
public AboutFlyoutPom AboutFlyoutPom => new AboutFlyoutPom(this.Descendants.Find(AboutPageFlyoutId));
|
||||
|
||||
public EtwWaiter GetModeChangedWaiter() => new EtwWaiter(Constants.CalculatorETWProviderGUID, Constants.AppModeChangeEndETWEventName);
|
||||
}
|
||||
}
|
@@ -0,0 +1,144 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using System;
|
||||
using System.Windows.Automation;
|
||||
using MS.Internal.Mita.Foundation;
|
||||
using MS.Internal.Mita.Foundation.Controls;
|
||||
using MS.Internal.Mita.Foundation.Patterns;
|
||||
|
||||
namespace Calculator.UIAutomationLibrary.Components
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the NavBar of the Calculator app.
|
||||
/// </summary>
|
||||
public class NavBarLfm : ICanFocusWithClicks
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="NavBarLfm" /> class.
|
||||
/// </summary>
|
||||
/// <param name="objectModel">The NavBarPom that represents the NavBar.</param>
|
||||
public NavBarLfm(NavBarPom objectModel)
|
||||
{
|
||||
this.ObjectModel = objectModel;
|
||||
}
|
||||
|
||||
public NavBarPom ObjectModel { get; }
|
||||
|
||||
public void SelectStandard()
|
||||
{
|
||||
SelectItem(this.ObjectModel.StandardMenuItem);
|
||||
}
|
||||
|
||||
public void SelectScientific()
|
||||
{
|
||||
SelectItem(this.ObjectModel.ScientificMenuItem);
|
||||
}
|
||||
|
||||
public void SelectProgrammer()
|
||||
{
|
||||
SelectItem(this.ObjectModel.ProgrammerMenuItem);
|
||||
}
|
||||
|
||||
public void SelectDate()
|
||||
{
|
||||
SelectItem(this.ObjectModel.DateMenuItem);
|
||||
}
|
||||
|
||||
public void SelectCurrency()
|
||||
{
|
||||
SelectItem(this.ObjectModel.CurrencyMenuItem);
|
||||
}
|
||||
|
||||
public void SelectVolume()
|
||||
{
|
||||
SelectItem(this.ObjectModel.VolumeMenuItem);
|
||||
}
|
||||
|
||||
public void SelectLength()
|
||||
{
|
||||
SelectItem(this.ObjectModel.LengthMenuItem);
|
||||
}
|
||||
|
||||
public void SelectWeight()
|
||||
{
|
||||
SelectItem(this.ObjectModel.WeightMenuItem);
|
||||
}
|
||||
|
||||
public void SelectTemperature()
|
||||
{
|
||||
SelectItem(this.ObjectModel.TemperatureMenuItem);
|
||||
}
|
||||
|
||||
public void SelectEnergy()
|
||||
{
|
||||
SelectItem(this.ObjectModel.EnergyMenuItem);
|
||||
}
|
||||
|
||||
public void SelectArea()
|
||||
{
|
||||
SelectItem(this.ObjectModel.AreaMenuItem);
|
||||
}
|
||||
|
||||
public void SelectSpeed()
|
||||
{
|
||||
SelectItem(this.ObjectModel.SpeedMenuItem);
|
||||
}
|
||||
|
||||
public void SelectTime()
|
||||
{
|
||||
SelectItem(this.ObjectModel.TimeMenuItem);
|
||||
}
|
||||
|
||||
public void SelectPower()
|
||||
{
|
||||
SelectItem(this.ObjectModel.PowerMenuItem);
|
||||
}
|
||||
|
||||
public void SelectData()
|
||||
{
|
||||
SelectItem(this.ObjectModel.DataMenuItem);
|
||||
}
|
||||
|
||||
public void SelectPressure()
|
||||
{
|
||||
SelectItem(this.ObjectModel.PressureMenuItem);
|
||||
}
|
||||
|
||||
public void SelectAngle()
|
||||
{
|
||||
SelectItem(this.ObjectModel.AngleMenuItem);
|
||||
}
|
||||
|
||||
public void SelectAbout()
|
||||
{
|
||||
this.ObjectModel.AboutButton.Invoke();
|
||||
}
|
||||
|
||||
public void Close()
|
||||
{
|
||||
this.ObjectModel.CloseButton.Invoke();
|
||||
}
|
||||
|
||||
public void FocusWithClicks()
|
||||
{
|
||||
// To focus (for AccSpot) without changing anything, click to the right of the close button.
|
||||
Button button = this.ObjectModel.CloseButton;
|
||||
int xPos = button.BoundingRectangle.Width + Constants.ClickMargin;
|
||||
int yPos = button.BoundingRectangle.Height / 2;
|
||||
button.DoubleClick(PointerButtons.Primary, xPos, yPos);
|
||||
}
|
||||
|
||||
private void SelectItem(ListViewItem item)
|
||||
{
|
||||
if (item.IsSelected)
|
||||
{
|
||||
this.Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
item.Select();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,96 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using System.Linq;
|
||||
using MS.Internal.Mita.Foundation;
|
||||
using MS.Internal.Mita.Foundation.Controls;
|
||||
|
||||
namespace Calculator.UIAutomationLibrary.Components
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the navigation menu.
|
||||
/// </summary>
|
||||
public class NavBarPom : UIObject
|
||||
{
|
||||
private const string StandardId = "Standard";
|
||||
private const string ScientificId = "Scientific";
|
||||
private const string ProgrammerId = "Programmer";
|
||||
private const string DateId = "Date";
|
||||
private const string CurrencyId = "Currency";
|
||||
private const string VolumeId = "Volume";
|
||||
private const string LengthId = "Length";
|
||||
private const string WeightId = "Weight";
|
||||
private const string TemperatureId = "Temperature";
|
||||
private const string EnergyId = "Energy";
|
||||
private const string AreaId = "Area";
|
||||
private const string SpeedId = "Speed";
|
||||
private const string TimeId = "Time";
|
||||
private const string PowerId = "Power";
|
||||
private const string DataId = "Data";
|
||||
private const string PressureId = "Pressure";
|
||||
private const string AngleId = "Angle";
|
||||
private const string AboutId = "AboutButton";
|
||||
private const string CloseId = "TogglePaneButton";
|
||||
private const string FlyoutListViewId = "MenuItemsHost";
|
||||
private const string ConverterSectionId = "Converter";
|
||||
private const string ConverterTextKey = "ConverterModeText";
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="NavBarPom" /> class.
|
||||
/// </summary>
|
||||
/// <param name="uiObject">The UIObject that is the root of the navigation menu.</param>
|
||||
public NavBarPom(UIObject uiObject) : base(uiObject)
|
||||
{
|
||||
}
|
||||
|
||||
public ListViewItem StandardMenuItem => ScrollAndGetItem(StandardId);
|
||||
|
||||
public ListViewItem ScientificMenuItem => ScrollAndGetItem(ScientificId);
|
||||
|
||||
public ListViewItem ProgrammerMenuItem => ScrollAndGetItem(ProgrammerId);
|
||||
|
||||
public ListViewItem DateMenuItem => ScrollAndGetItem(DateId);
|
||||
|
||||
public ListViewItem CurrencyMenuItem => ScrollAndGetItem(CurrencyId);
|
||||
|
||||
public ListViewItem VolumeMenuItem => ScrollAndGetItem(VolumeId);
|
||||
|
||||
public ListViewItem LengthMenuItem => ScrollAndGetItem(LengthId);
|
||||
|
||||
public ListViewItem WeightMenuItem => ScrollAndGetItem(WeightId);
|
||||
|
||||
public ListViewItem TemperatureMenuItem => ScrollAndGetItem(TemperatureId);
|
||||
|
||||
public ListViewItem EnergyMenuItem => ScrollAndGetItem(EnergyId);
|
||||
|
||||
public ListViewItem AreaMenuItem => ScrollAndGetItem(AreaId);
|
||||
|
||||
public ListViewItem SpeedMenuItem => ScrollAndGetItem(SpeedId);
|
||||
|
||||
public ListViewItem TimeMenuItem => ScrollAndGetItem(TimeId);
|
||||
|
||||
public ListViewItem PowerMenuItem => ScrollAndGetItem(PowerId);
|
||||
|
||||
public ListViewItem DataMenuItem => ScrollAndGetItem(DataId);
|
||||
|
||||
public ListViewItem PressureMenuItem => ScrollAndGetItem(PressureId);
|
||||
|
||||
public ListViewItem AngleMenuItem => ScrollAndGetItem(AngleId);
|
||||
|
||||
public Button AboutButton => new Button(this.Descendants.Find(AboutId));
|
||||
|
||||
public Button CloseButton => new Button(this.Parent.Children.Find(CloseId));
|
||||
|
||||
public ListView ModeListView => new ListView(this.Descendants.Find(FlyoutListViewId));
|
||||
|
||||
private ListViewItem ScrollAndGetItem(string id)
|
||||
{
|
||||
ListViewItem item;
|
||||
var res = this.ModeListView.AllItems.TryFind(id, out item);
|
||||
|
||||
item.ScrollIntoView();
|
||||
|
||||
return item;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,56 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using MS.Internal.Mita.Foundation.Waiters;
|
||||
|
||||
namespace Calculator.UIAutomationLibrary.Components
|
||||
{
|
||||
public class ProgrammerCalculatorLfm
|
||||
{
|
||||
public ProgrammerCalculatorLfm(ProgrammerCalculatorPom programmerCalculatorPom)
|
||||
{
|
||||
this.ObjectModel = programmerCalculatorPom;
|
||||
}
|
||||
|
||||
public ProgrammerCalculatorPom ObjectModel { get; }
|
||||
|
||||
public void EnsureFullKeypad()
|
||||
{
|
||||
if (!this.ObjectModel.FullKeypadButton.IsSelected)
|
||||
{
|
||||
this.ObjectModel.FullKeypadButton.Select();
|
||||
}
|
||||
}
|
||||
|
||||
public void EnsureBitTogglingKeypad()
|
||||
{
|
||||
if (!this.ObjectModel.BitFlipKeypadButton.IsSelected)
|
||||
{
|
||||
this.ObjectModel.BitFlipKeypadButton.Select();
|
||||
}
|
||||
}
|
||||
|
||||
public void ChangeBitLength()
|
||||
{
|
||||
this.ObjectModel.GetCurrentBitLengthButton().Invoke();
|
||||
}
|
||||
|
||||
public MemoryLfm OpenMemory()
|
||||
{
|
||||
MemoryLfm lfm = new MemoryLfm(this.ObjectModel.MemoryControls);
|
||||
lfm.OpenBody();
|
||||
return lfm;
|
||||
}
|
||||
|
||||
public void FiveMemorySet()
|
||||
{
|
||||
using (UIEventWaiter waiter = this.ObjectModel.GetDisplayChangedWaiter())
|
||||
{
|
||||
this.ObjectModel.NumberPad.FiveButton.Invoke();
|
||||
waiter.TryWait();
|
||||
}
|
||||
|
||||
this.ObjectModel.MemoryControls.SetButton.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,56 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using MS.Internal.Mita.Foundation;
|
||||
using MS.Internal.Mita.Foundation.Controls;
|
||||
using MS.Internal.Mita.Foundation.Waiters;
|
||||
|
||||
namespace Calculator.UIAutomationLibrary.Components
|
||||
{
|
||||
public class ProgrammerCalculatorPom : UIObject
|
||||
{
|
||||
private const string FullKeypadButtonId = "fullKeypad";
|
||||
private const string BitFlipKeypadButtonId = "bitFlip";
|
||||
private const string CalculatorResultsId = "CalculatorResults";
|
||||
private const string NumberPadId = "NumberPad";
|
||||
|
||||
private readonly string[] BitLengthButtonIds =
|
||||
{
|
||||
"qwordButton",
|
||||
"dwordButton",
|
||||
"wordButton",
|
||||
"byteButton"
|
||||
};
|
||||
|
||||
public ProgrammerCalculatorPom(UIObject uiObject) : base(uiObject)
|
||||
{
|
||||
}
|
||||
|
||||
public NumberPadPom NumberPad => new NumberPadPom(this.Descendants.Find(NumberPadId));
|
||||
|
||||
public MemoryPom MemoryControls => new MemoryPom(this);
|
||||
|
||||
public RadioButton FullKeypadButton => new RadioButton(this.Descendants.Find(FullKeypadButtonId));
|
||||
|
||||
public RadioButton BitFlipKeypadButton => new RadioButton(this.Descendants.Find(BitFlipKeypadButtonId));
|
||||
|
||||
public TextBlock Display => new TextBlock(this.Descendants.Find(CalculatorResultsId));
|
||||
|
||||
public UIEventWaiter GetDisplayChangedWaiter() => this.Display.GetNameChangedWaiter();
|
||||
|
||||
public Button GetCurrentBitLengthButton()
|
||||
{
|
||||
// There are four bit length buttons, with only one visible at a time.
|
||||
UIObject button = null;
|
||||
foreach (var buttonId in this.BitLengthButtonIds)
|
||||
{
|
||||
if (this.Descendants.TryFind(buttonId, out button))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return new Button(button);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,138 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using MS.Internal.Mita.Foundation.Waiters;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WEX.Logging.Interop;
|
||||
|
||||
namespace Calculator.UIAutomationLibrary.Components
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the Standard calculator view.
|
||||
/// </summary>
|
||||
public class ScientificCalculatorLfm
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ScientificCalculatorLfm" /> class.
|
||||
/// </summary>
|
||||
/// <param name="uiObject">The UIObject that is the root of the scientific Calculator.</param>
|
||||
public ScientificCalculatorLfm(ScientificCalculatorPom objectModel)
|
||||
{
|
||||
this.ObjectModel = objectModel;
|
||||
}
|
||||
|
||||
public ScientificCalculatorPom ObjectModel { get; }
|
||||
|
||||
public void Press1()
|
||||
{
|
||||
using (UIEventWaiter waiter = this.ObjectModel.GetDisplayChangedWaiter())
|
||||
{
|
||||
Log.Comment("Invoking 1");
|
||||
this.ObjectModel.OneButton.Invoke();
|
||||
waiter.TryWait();
|
||||
}
|
||||
}
|
||||
|
||||
public void Press2()
|
||||
{
|
||||
using (UIEventWaiter waiter = this.ObjectModel.GetDisplayChangedWaiter())
|
||||
{
|
||||
Log.Comment("Invoking 2");
|
||||
this.ObjectModel.NumberPad.TwoButton.Invoke();
|
||||
waiter.TryWait();
|
||||
}
|
||||
}
|
||||
|
||||
public void Press3()
|
||||
{
|
||||
using (UIEventWaiter waiter = this.ObjectModel.GetDisplayChangedWaiter())
|
||||
{
|
||||
Log.Comment("Invoking 3");
|
||||
this.ObjectModel.ThreeButton.Invoke();
|
||||
waiter.TryWait();
|
||||
}
|
||||
}
|
||||
|
||||
public void Press4()
|
||||
{
|
||||
using (UIEventWaiter waiter = this.ObjectModel.GetDisplayChangedWaiter())
|
||||
{
|
||||
Log.Comment("Invoking 4");
|
||||
this.ObjectModel.FourButton.Invoke();
|
||||
waiter.TryWait();
|
||||
}
|
||||
}
|
||||
|
||||
public void PressSqrt()
|
||||
{
|
||||
// When invoking sqrt, both the expression changes.
|
||||
using (UIEventWaiter waiter = this.ObjectModel.GetExpressionChangedWaiter())
|
||||
{
|
||||
Log.Comment("Invoking sqrt");
|
||||
this.ObjectModel.SqrtButton.Invoke();
|
||||
waiter.TryWait();
|
||||
}
|
||||
}
|
||||
|
||||
public void PressMinus()
|
||||
{
|
||||
using (UIEventWaiter waiter = this.ObjectModel.GetExpressionChangedWaiter())
|
||||
{
|
||||
Log.Comment("Invoking minus");
|
||||
this.ObjectModel.MinusButton.Invoke();
|
||||
waiter.TryWait();
|
||||
}
|
||||
}
|
||||
|
||||
public void PressPlus()
|
||||
{
|
||||
using (UIEventWaiter waiter = this.ObjectModel.GetExpressionChangedWaiter())
|
||||
{
|
||||
Log.Comment("Invoking plus");
|
||||
this.ObjectModel.PlusButton.Invoke();
|
||||
waiter.TryWait();
|
||||
}
|
||||
}
|
||||
|
||||
public void PressEquals()
|
||||
{
|
||||
// When invoking equals, both the display and the expression change.
|
||||
using (UIEventWaiter expressionWaiter = this.ObjectModel.GetExpressionChangedWaiter())
|
||||
using (UIEventWaiter displayWaiter = this.ObjectModel.GetDisplayChangedWaiter())
|
||||
{
|
||||
Log.Comment("Invoking equals");
|
||||
this.ObjectModel.EqualButton.Invoke();
|
||||
expressionWaiter.TryWait();
|
||||
displayWaiter.TryWait();
|
||||
}
|
||||
}
|
||||
|
||||
public void OnePlusTwoEnter()
|
||||
{
|
||||
Press1();
|
||||
PressPlus();
|
||||
Press2();
|
||||
PressEquals();
|
||||
}
|
||||
|
||||
public void MemorySet() => this.ObjectModel.MemoryControls.SetButton.Invoke();
|
||||
|
||||
public MemoryLfm OpenMemory()
|
||||
{
|
||||
MemoryLfm lfm = new MemoryLfm(this.ObjectModel.MemoryControls);
|
||||
lfm.OpenBody();
|
||||
return lfm;
|
||||
}
|
||||
|
||||
public HistoryLfm OpenHistory()
|
||||
{
|
||||
HistoryLfm lfm = new HistoryLfm(this.ObjectModel.HistoryControls);
|
||||
lfm.OpenBody();
|
||||
return lfm;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,63 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using MS.Internal.Mita.Foundation;
|
||||
using MS.Internal.Mita.Foundation.Controls;
|
||||
|
||||
namespace Calculator.UIAutomationLibrary.Components
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the Scientific Calculator
|
||||
/// </summary>
|
||||
public class ScientificCalculatorPom : CalculatorBasePom
|
||||
{
|
||||
private const string NumberPadId = "NumberPad";
|
||||
private const string StandardOperatorsId = "StandardOperators";
|
||||
private const string DisplayControlsId = "DisplayControls";
|
||||
private const string ScientificFunctionsId = "ScientificFunctions";
|
||||
private const string OneButtonId = "num1Button";
|
||||
private const string ThreeButtonId = "num3Button";
|
||||
private const string FourButtonId = "num4Button";
|
||||
private const string SqrtButtonId = "squareRootButton";
|
||||
private const string MinusButtonId = "minusButton";
|
||||
private const string PlusButtonId = "plusButton";
|
||||
private const string EqualButtonId = "equalButton";
|
||||
private const string ClearButtonId = "clearButton";
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ScientificCalculatorPom" /> class.
|
||||
/// </summary>
|
||||
/// <param name="uiObject">The UIObject that is the root of the scientific calculator.</param>
|
||||
public ScientificCalculatorPom(UIObject uiObject) : base(uiObject)
|
||||
{
|
||||
}
|
||||
|
||||
public UIObject StandardOperatorsGroup => this.Descendants.Find(StandardOperatorsId);
|
||||
|
||||
public UIObject DisplayControlsGroup => this.Descendants.Find(DisplayControlsId);
|
||||
|
||||
public UIObject ScientificFunctionsGroup => this.Descendants.Find(ScientificFunctionsId);
|
||||
|
||||
public Button OneButton => this.NumberPad.OneButton;
|
||||
|
||||
public Button ThreeButton => this.NumberPad.ThreeButton;
|
||||
|
||||
public Button FourButton => this.NumberPad.FourButton;
|
||||
|
||||
public Button SqrtButton => new Button(this.ScientificFunctionsGroup.Children.Find(SqrtButtonId));
|
||||
|
||||
public Button MinusButton => new Button(this.StandardOperatorsGroup.Children.Find(MinusButtonId));
|
||||
|
||||
public Button PlusButton => new Button(this.StandardOperatorsGroup.Children.Find(PlusButtonId));
|
||||
|
||||
public Button EqualButton => new Button(this.StandardOperatorsGroup.Children.Find(EqualButtonId));
|
||||
|
||||
public Button ClearButton => new Button(this.DisplayControlsGroup.Children.Find(ClearButtonId));
|
||||
|
||||
public NumberPadPom NumberPad => new NumberPadPom(this.Descendants.Find(NumberPadId));
|
||||
|
||||
public HistoryPom HistoryControls => new HistoryPom(this);
|
||||
|
||||
public MemoryPom MemoryControls => new MemoryPom(this);
|
||||
}
|
||||
}
|
@@ -0,0 +1,94 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using MS.Internal.Mita.Foundation.Waiters;
|
||||
using WEX.Logging.Interop;
|
||||
|
||||
namespace Calculator.UIAutomationLibrary.Components
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the Standard calculator view.
|
||||
/// </summary>
|
||||
public class StandardCalculatorLfm
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="StandardCalculatorLfm" /> class.
|
||||
/// </summary>
|
||||
/// <param name="uiObject">The UIObject that is the root of the Standard Calculator.</param>
|
||||
public StandardCalculatorLfm(StandardCalculatorPom objectModel)
|
||||
{
|
||||
this.ObjectModel = objectModel;
|
||||
}
|
||||
|
||||
public StandardCalculatorPom ObjectModel { get; }
|
||||
|
||||
public void OnePlusTwoEnter()
|
||||
{
|
||||
using (UIEventWaiter waiter = this.ObjectModel.GetDisplayChangedWaiter())
|
||||
{
|
||||
Log.Comment("Invoking 1");
|
||||
this.ObjectModel.NumPad.OneButton.Invoke();
|
||||
waiter.TryWait();
|
||||
}
|
||||
using (UIEventWaiter waiter = this.ObjectModel.GetExpressionChangedWaiter())
|
||||
{
|
||||
Log.Comment("Pressing +");
|
||||
this.ObjectModel.SendKeys("{ADD}");
|
||||
// PropertyChangeWaiter is unreliable for the first name changed notification
|
||||
// Bug 17624996: PropertyChanged event not fired when Name is updated for the first time for a control with custom automation peer.
|
||||
waiter.TryWait();
|
||||
}
|
||||
using (UIEventWaiter waiter = this.ObjectModel.GetDisplayChangedWaiter())
|
||||
{
|
||||
Log.Comment("Pressing 2");
|
||||
this.ObjectModel.SendKeys("2");
|
||||
waiter.TryWait();
|
||||
}
|
||||
// When pressing enter, both the display and the expression change.
|
||||
using (UIEventWaiter expressionWaiter = this.ObjectModel.GetExpressionChangedWaiter())
|
||||
using (UIEventWaiter displayWaiter = this.ObjectModel.GetDisplayChangedWaiter())
|
||||
{
|
||||
Log.Comment("Invoking equals");
|
||||
this.ObjectModel.EqualButton.Invoke();
|
||||
expressionWaiter.TryWait();
|
||||
displayWaiter.TryWait();
|
||||
}
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
using (UIEventWaiter waiter = this.ObjectModel.GetDisplayChangedWaiter())
|
||||
{
|
||||
Log.Comment("Pressing escape");
|
||||
this.ObjectModel.ClearButton.Invoke();
|
||||
waiter.TryWait();
|
||||
}
|
||||
}
|
||||
|
||||
public void ClearFiveMemorySet()
|
||||
{
|
||||
this.Clear();
|
||||
using (UIEventWaiter waiter = this.ObjectModel.GetDisplayChangedWaiter())
|
||||
{
|
||||
this.ObjectModel.NumPad.FiveButton.Invoke();
|
||||
waiter.TryWait();
|
||||
}
|
||||
|
||||
this.ObjectModel.MemoryControls.SetButton.Invoke();
|
||||
}
|
||||
|
||||
public MemoryLfm OpenMemory()
|
||||
{
|
||||
MemoryLfm lfm = new MemoryLfm(this.ObjectModel.MemoryControls);
|
||||
lfm.OpenBody();
|
||||
return lfm;
|
||||
}
|
||||
|
||||
public HistoryLfm OpenHistory()
|
||||
{
|
||||
HistoryLfm lfm = new HistoryLfm(this.ObjectModel.HistoryControls);
|
||||
lfm.OpenBody();
|
||||
return lfm;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,45 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using MS.Internal.Mita.Foundation;
|
||||
using MS.Internal.Mita.Foundation.Controls;
|
||||
using MS.Internal.Mita.Foundation.Waiters;
|
||||
|
||||
namespace Calculator.UIAutomationLibrary.Components
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the Standard Calculator
|
||||
/// </summary>
|
||||
public class StandardCalculatorPom : CalculatorBasePom
|
||||
{
|
||||
private const string CalculatorResultsId = "CalculatorResults";
|
||||
private const string ExpressionContainerId = "CalculatorExpression";
|
||||
private const string NumberPadId = "NumberPad";
|
||||
private const string StandardOperatorsId = "StandardOperators";
|
||||
private const string DisplayControlsId = "DisplayControls";
|
||||
private const string EqualButtonId = "equalButton";
|
||||
private const string ClearButtonId = "clearButton";
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="StandardCalculatorPom" /> class.
|
||||
/// </summary>
|
||||
/// <param name="uiObject">The UIObject that is the root of the standard calculator.</param>
|
||||
public StandardCalculatorPom(UIObject uiObject) : base(uiObject)
|
||||
{
|
||||
}
|
||||
|
||||
public NumberPadPom NumPad => new NumberPadPom(this.Descendants.Find(NumberPadId));
|
||||
|
||||
public MemoryPom MemoryControls => new MemoryPom(this);
|
||||
|
||||
public HistoryPom HistoryControls => new HistoryPom(this);
|
||||
|
||||
public UIObject StandardOperatorsGroup => this.Descendants.Find(StandardOperatorsId);
|
||||
|
||||
public UIObject DisplayControlsGroup => this.Descendants.Find(DisplayControlsId);
|
||||
|
||||
public Button EqualButton => new Button(this.StandardOperatorsGroup.Children.Find(EqualButtonId));
|
||||
|
||||
public Button ClearButton => new Button(this.DisplayControlsGroup.Children.Find(ClearButtonId));
|
||||
}
|
||||
}
|
@@ -0,0 +1,24 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
namespace Calculator.UIAutomationLibrary.Components
|
||||
{
|
||||
public class UnitConverterLfm
|
||||
{
|
||||
public UnitConverterLfm(UnitConverterPom unitConverterPom)
|
||||
{
|
||||
this.ObjectModel = unitConverterPom;
|
||||
}
|
||||
|
||||
public UnitConverterPom ObjectModel { get; }
|
||||
|
||||
public void Eight()
|
||||
{
|
||||
using (var waiter = this.ObjectModel.GetDisplayChangedWaiter())
|
||||
{
|
||||
this.ObjectModel.NumberPad.EightButton.Invoke();
|
||||
waiter.TryWait();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,27 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using MS.Internal.Mita.Foundation;
|
||||
using MS.Internal.Mita.Foundation.Controls;
|
||||
using MS.Internal.Mita.Foundation.Waiters;
|
||||
|
||||
namespace Calculator.UIAutomationLibrary.Components
|
||||
{
|
||||
public class UnitConverterPom : UIObject
|
||||
{
|
||||
private const string DisplayId = "Value1";
|
||||
private const string NumberPadId = "numberPad";
|
||||
|
||||
public UnitConverterPom(UIObject uiObject) : base(uiObject)
|
||||
{
|
||||
}
|
||||
|
||||
public NumberPadPom NumberPad => new NumberPadPom(this.Descendants.Find(NumberPadId));
|
||||
|
||||
public TextBlock Display => new TextBlock(this.Descendants.Find(DisplayId));
|
||||
|
||||
public PropertyChangedEventWaiter GetDisplayChangedWaiter() => this.Display.GetNameChangedWaiter();
|
||||
|
||||
public ElementAddedWaiter GetDisplayElementAddedWaiter() => new ElementAddedWaiter(this, Scope.Descendants, DisplayId);
|
||||
}
|
||||
}
|
@@ -0,0 +1,48 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using Etw.Managed;
|
||||
using MS.Internal.Mita.Foundation;
|
||||
|
||||
namespace Calculator.UIAutomationLibrary.Components
|
||||
{
|
||||
public class HistoryLfm : ICanFocusWithClicks
|
||||
{
|
||||
public HistoryLfm(HistoryPom historyPom)
|
||||
{
|
||||
this.ObjectModel = historyPom;
|
||||
}
|
||||
|
||||
public HistoryPom ObjectModel { get; }
|
||||
|
||||
public void FocusWithClicks()
|
||||
{
|
||||
// On the Programming calc, the default click location can land on the first memory item, dismissing the flyout.
|
||||
// Instead, click just below, in the gutter to the left of the trash can.
|
||||
var body = this.ObjectModel.Body;
|
||||
int height = body.BoundingRectangle.Height;
|
||||
body.DoubleClick(PointerButtons.Primary, Constants.ClickMargin, height + Constants.ClickMargin);
|
||||
}
|
||||
|
||||
public void OpenBody()
|
||||
{
|
||||
using (EtwWaiter waiter = new EtwWaiter(Constants.CalculatorETWProviderGUID, Constants.HistoryBodyOpenedETWEventName))
|
||||
{
|
||||
// Only one exists at a given time.
|
||||
if (this.ObjectModel.IsHistoryButtonVisible)
|
||||
{
|
||||
if (!this.ObjectModel.IsBodyOpen)
|
||||
{
|
||||
this.ObjectModel.HistoryButton.Invoke();
|
||||
waiter.Wait();
|
||||
}
|
||||
}
|
||||
else if (!this.ObjectModel.HistoryPivot.IsSelected)
|
||||
{
|
||||
this.ObjectModel.HistoryPivot.Click();
|
||||
waiter.Wait();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,29 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using MS.Internal.Mita.Foundation;
|
||||
using MS.Internal.Mita.Foundation.Controls;
|
||||
|
||||
namespace Calculator.UIAutomationLibrary.Components
|
||||
{
|
||||
public class HistoryPom : UIObject
|
||||
{
|
||||
private const string HistoryButtonId = "HistoryButton";
|
||||
private const string HistoryPivotId = "HistoryLabel";
|
||||
private const string BodyId = "HistoryListView";
|
||||
|
||||
public HistoryPom(UIObject uiObject) : base(uiObject)
|
||||
{
|
||||
}
|
||||
|
||||
public Button HistoryButton => new Button(this.Descendants.Find(HistoryButtonId));
|
||||
|
||||
public bool IsHistoryButtonVisible => this.DoesDescendantExist(HistoryButtonId);
|
||||
|
||||
public TabItem HistoryPivot => new TabItem(this.Descendants.Find(HistoryPivotId));
|
||||
|
||||
public UIObject Body => this.Descendants.Find(BodyId);
|
||||
|
||||
public bool IsBodyOpen => this.DoesDescendantExist(BodyId);
|
||||
}
|
||||
}
|
@@ -0,0 +1,15 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
namespace Calculator.UIAutomationLibrary.Components
|
||||
{
|
||||
public interface ICanFocusWithClicks
|
||||
{
|
||||
/// <summary>
|
||||
/// Sets focus on an object by clicking on it, without causing further action.
|
||||
/// Supports AccSpot scans by raising click events.
|
||||
/// </summary>
|
||||
void FocusWithClicks();
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,51 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using System;
|
||||
using Etw.Managed;
|
||||
using MS.Internal.Mita.Foundation;
|
||||
using MS.Internal.Mita.Foundation.Waiters;
|
||||
using WEX.Logging.Interop;
|
||||
|
||||
namespace Calculator.UIAutomationLibrary.Components
|
||||
{
|
||||
public class MemoryLfm : ICanFocusWithClicks
|
||||
{
|
||||
public MemoryLfm(MemoryPom memoryPom)
|
||||
{
|
||||
this.ObjectModel = memoryPom;
|
||||
}
|
||||
|
||||
public MemoryPom ObjectModel { get; }
|
||||
|
||||
public void FocusWithClicks()
|
||||
{
|
||||
// On the Programming calc, the default click location can land on the first memory item, dismissing the flyout.
|
||||
// Instead, click just below, in the gutter to the left of the trash can.
|
||||
var body = this.ObjectModel.Body;
|
||||
int height = body.BoundingRectangle.Height;
|
||||
body.DoubleClick(PointerButtons.Primary, Constants.ClickMargin, height + Constants.ClickMargin);
|
||||
}
|
||||
|
||||
public void OpenBody()
|
||||
{
|
||||
using (EtwWaiter waiter = new EtwWaiter(Constants.CalculatorETWProviderGUID, Constants.MemoryBodyOpenedETWEventName))
|
||||
{
|
||||
// Only one exists at a given time
|
||||
if (this.ObjectModel.IsMemoryButtonVisible)
|
||||
{
|
||||
if (!this.ObjectModel.IsBodyOpen)
|
||||
{
|
||||
this.ObjectModel.MemoryButton.Invoke();
|
||||
waiter.Wait();
|
||||
}
|
||||
}
|
||||
else if (!this.ObjectModel.MemoryPivot.IsSelected)
|
||||
{
|
||||
this.ObjectModel.MemoryPivot.Click();
|
||||
waiter.Wait();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,44 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using MS.Internal.Mita.Foundation;
|
||||
using MS.Internal.Mita.Foundation.Controls;
|
||||
|
||||
namespace Calculator.UIAutomationLibrary.Components
|
||||
{
|
||||
public class MemoryPom : UIObject
|
||||
{
|
||||
private const string ClearMemoryButtonId = "ClearMemoryButton";
|
||||
private const string RecallButtonId = "MemRecall";
|
||||
private const string PlusButtonId = "MemPlus";
|
||||
private const string MinusButtonId = "MemMinus";
|
||||
private const string SetButtonId = "memButton";
|
||||
private const string MemoryButtonId = "MemoryButton";
|
||||
private const string MemoryPivotId = "MemoryLabel";
|
||||
private const string BodyId = "MemoryListView";
|
||||
|
||||
public MemoryPom(UIObject uiObject) : base(uiObject)
|
||||
{
|
||||
}
|
||||
|
||||
public Button ClearButton => new Button(this.Descendants.Find(ClearMemoryButtonId));
|
||||
|
||||
public Button RecallButton => new Button(this.Descendants.Find(RecallButtonId));
|
||||
|
||||
public Button PlusButton => new Button(this.Descendants.Find(PlusButtonId));
|
||||
|
||||
public Button MinusButton => new Button(this.Descendants.Find(MinusButtonId));
|
||||
|
||||
public Button SetButton => new Button(this.Descendants.Find(SetButtonId));
|
||||
|
||||
public Button MemoryButton => new Button(this.Descendants.Find(MemoryButtonId));
|
||||
|
||||
public bool IsMemoryButtonVisible => this.DoesDescendantExist(MemoryButtonId);
|
||||
|
||||
public TabItem MemoryPivot => new TabItem(this.Descendants.Find(MemoryPivotId));
|
||||
|
||||
public UIObject Body => this.Descendants.Find(BodyId);
|
||||
|
||||
public bool IsBodyOpen => this.DoesDescendantExist(BodyId);
|
||||
}
|
||||
}
|
@@ -0,0 +1,49 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using MS.Internal.Mita.Foundation;
|
||||
using MS.Internal.Mita.Foundation.Controls;
|
||||
|
||||
namespace Calculator.UIAutomationLibrary.Components
|
||||
{
|
||||
public class NumberPadPom : UIObject
|
||||
{
|
||||
private const string OneButtonId = "num1Button";
|
||||
private const string TwoButtonId = "num2Button";
|
||||
private const string ThreeButtonId = "num3Button";
|
||||
private const string FourButtonId = "num4Button";
|
||||
private const string FiveButtonId = "num5Button";
|
||||
private const string SixButtonId = "num6Button";
|
||||
private const string SevenButtonId = "num7Button";
|
||||
private const string EightButtonId = "num8Button";
|
||||
private const string NineButtonId = "num9Button";
|
||||
private const string ZeroButtonId = "num0Button";
|
||||
private const string DecimalButtonId = "decimalSeparatorButton";
|
||||
|
||||
public NumberPadPom(UIObject uiObject) : base(uiObject)
|
||||
{
|
||||
}
|
||||
|
||||
public Button ZeroButton => new Button(this.Children.Find(ZeroButtonId));
|
||||
|
||||
public Button OneButton => new Button(this.Children.Find(OneButtonId));
|
||||
|
||||
public Button TwoButton => new Button(this.Children.Find(TwoButtonId));
|
||||
|
||||
public Button ThreeButton => new Button(this.Children.Find(ThreeButtonId));
|
||||
|
||||
public Button FourButton => new Button(this.Children.Find(FourButtonId));
|
||||
|
||||
public Button FiveButton => new Button(this.Children.Find(FiveButtonId));
|
||||
|
||||
public Button SixButton => new Button(this.Children.Find(SixButtonId));
|
||||
|
||||
public Button SevenButton => new Button(this.Children.Find(SevenButtonId));
|
||||
|
||||
public Button EightButton => new Button(this.Children.Find(EightButtonId));
|
||||
|
||||
public Button NineButton => new Button(this.Children.Find(NineButtonId));
|
||||
|
||||
public Button DecimalButton => new Button(this.Children.Find(DecimalButtonId));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user