Skip to content

Commit

Permalink
change manager name and func name
Browse files Browse the repository at this point in the history
  • Loading branch information
Zhaopeng Wang (from Dev Box) committed Jan 26, 2025
1 parent 9fccd86 commit d432866
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

namespace Microsoft.UITests.API
{
public class UIManager
public class APPManager
{
[DllImport("user32.dll")]
private static extern bool SetForegroundWindow(IntPtr hWnd);
Expand Down Expand Up @@ -49,7 +49,7 @@ public struct WinDriver

private Stack<WinDriver> mWindowListTemp = new Stack<WinDriver>();

public UIManager()
public APPManager()
{
if (mWindowList == null)
{
Expand All @@ -67,7 +67,7 @@ public UIManager()
}

// Create a new application and take control of it
public void StartApp(string appName, string windowName, string appPath)
public void StartExe(string appName, string windowName, string appPath)
{
AppiumOptions opts = new AppiumOptions();
opts.AddAdditionalCapability("app", appPath);
Expand All @@ -85,7 +85,7 @@ public void StartApp(string appName, string windowName, string appPath)
}

// Take control of an application that already exists
public void LaunchApp(string appName, string windowName)
public void LaunchModule(string appName, string windowName)
{
if (Root != null)
{
Expand Down
32 changes: 16 additions & 16 deletions src/UITestAPI/src/UITestAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@
using OpenQA.Selenium.Appium.Windows;
using OpenQA.Selenium.Interactions;
using static Microsoft.ApplicationInsights.MetricDimensionNames.TelemetryContext;
using static Microsoft.UITests.API.UIManager;
using static Microsoft.UITests.API.APPManager;

namespace Microsoft.UITests.API
{
public class UITestAPI
{
public UIManager UIManager { get; private set; }
public APPManager APPManager { get; private set; }

private static Process? appDriver;

public UITestAPI()
{
UIManager = new UIManager();
APPManager = new APPManager();
}

[UnconditionalSuppressMessage("SingleFile", "IL3000:Avoid accessing Assembly file path when publishing as a single file", Justification = "<Pending>")]
Expand All @@ -38,9 +38,9 @@ public void Init(string appName, string exePath, string windowName, string winAp
// Launch Exe
string? path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
path += exePath;
UIManager.StartApp(appName, windowName, path);
APPManager.StartExe(appName, windowName, path);

var session = UIManager.GetCurrentWindow();
var session = APPManager.GetCurrentWindow();
Assert.IsNotNull(session, "Session not initialized");

// Set implicit timeout to make element search to retry every 500 ms
Expand All @@ -49,7 +49,7 @@ public void Init(string appName, string exePath, string windowName, string winAp

public void Close(TestContext testContext)
{
var session = UIManager.GetCurrentWindow();
var session = APPManager.GetCurrentWindow();

// Close the session
if (session != null)
Expand All @@ -67,45 +67,45 @@ public void Close(TestContext testContext)
}
}

// ===================================UIManager API================================================
// ===================================APPManager API================================================

// Create a new application and take control of it
public void StartApp(string appName, string windowName, string appPath)
public void StartExe(string appName, string windowName, string appPath)
{
UIManager.StartApp(appName, windowName, appPath);
APPManager.StartExe(appName, windowName, appPath);
}

// Take control of an application that already exists
public void LaunchApp(string appName, string windowName)
public void LaunchModule(string appName, string windowName)
{
UIManager.LaunchApp(appName, windowName);
APPManager.LaunchModule(appName, windowName);
}

// Use the name to switch the current driver
public void SwitchApp(string appName)
{
UIManager.SwitchApp(appName);
APPManager.SwitchApp(appName);
}

public void CloseApp(string appName)
{
UIManager.CloseApp(appName);
APPManager.CloseApp(appName);
}

public WindowsDriver<WindowsElement>? GetWindowInList(string appName)
{
return UIManager.GetWindowInList(appName);
return APPManager.GetWindowInList(appName);
}

public WindowsDriver<WindowsElement>? GetSession(string? appName = null)
{
if (appName == null)
{
return UIManager.GetCurrentWindow();
return APPManager.GetCurrentWindow();
}
else
{
return UIManager.GetWindowInList(appName);
return APPManager.GetWindowInList(appName);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public void RunFancyZones()
mUITestAPI.Click_Element("Launch layout editor");

Thread.Sleep(5000);
mUITestAPI.LaunchApp("PowerToys.FancyZonesEditor", "FancyZones Layout");
mUITestAPI.LaunchModule("PowerToys.FancyZonesEditor", "FancyZones Layout");
mUITestAPI?.Click_CreateNewLayout();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public void EnableKeyboardManager() // verify the session is initialized
mUITestAPI.Enable_Module_from_Dashboard("Keyboard Manager");
mUITestAPI.Click_Element("Remap a key");
Thread.Sleep(5000);
mUITestAPI.LaunchApp("PowerToys.KeyboardManagerEditor", "Remap keys");
mUITestAPI.LaunchModule("PowerToys.KeyboardManagerEditor", "Remap keys");
mUITestAPI.Click_Element("Add key remapping");
mUITestAPI.Click_Element("Cancel");
mUITestAPI.CloseApp("PowerToys.KeyboardManagerEditor");
Expand Down

0 comments on commit d432866

Please sign in to comment.