Skip to content

Add Component Package Based Unit Test Prototype #5665

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 22 commits into
base: main
Choose a base branch
from

Conversation

Hong-Xiang
Copy link
Contributor

A microsoft employee must use /azp run to validate using the pipelines below.

WARNING:
Comments made by azure-pipelines bot maybe inaccurate.
Please see pipeline link to verify that the build is being ran.

For status checks on the main branch, please use TransportPackage-Foundation-PR
(https://microsoft.visualstudio.com/ProjectReunion/_build?definitionId=81063&_a=summary)
and run the build against your PR branch with the default parameters.

@Hong-Xiang
Copy link
Contributor Author

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@Hong-Xiang
Copy link
Contributor Author

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@Hong-Xiang
Copy link
Contributor Author

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@Hong-Xiang
Copy link
Contributor Author

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@Hong-Xiang
Copy link
Contributor Author

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@Hong-Xiang
Copy link
Contributor Author

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@Hong-Xiang
Copy link
Contributor Author

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@Hong-Xiang
Copy link
Contributor Author

⚠️ AI-Generated Content Warning: This comment was generated using AI assistance and may contain inaccuracies. Please review and verify all technical details before making decisions based on this summary.


PR Summary: Add Component Package Based Unit Test Prototype

Overview

  • Title: Add Component Package Based Unit Test Prototype
  • Author: Hong-Xiang (Microsoft employee)
  • Status: Open (Draft)
  • Branch: user/xianghong/try-add-component-package-based-testmain
  • Created: July 29, 2025
  • Last Updated: July 30, 2025

Purpose

This PR introduces a prototype for component package-based unit testing within the Windows App SDK, specifically targeting the Storage Picker component with a new .NET 6-based test framework.

Key Changes

1. New Test Project Structure

  • Created: test/StoragePickerComponentTests/ directory
  • Framework: .NET 6 targeting Windows 10.0.19041.0
  • Test Type: Component-based unit tests using TAEF (Test Authoring and Execution Framework)

2. Files Added

  1. StoragePickerComponentTests.csproj (50 lines)

    • .NET 6 SDK project with Windows App SDK Foundation package reference
    • Multi-platform support (x86, x64, ARM64)
    • TAEF integration for managed tests
    • CsWinRT for Windows Runtime interop
  2. StoragePickersTest.cs (153 lines)

    • C# test class with async test method SimpleAPlusBTest()
    • Tests FileOpenPicker from Microsoft.Windows.Storage.Pickers
    • Includes sophisticated dialog auto-close mechanism using Win32 APIs
    • Uses TAEF test attributes and verification methods
  3. StoragePickerComponentTests.testdef (11 lines)

    • JSON test definition file for TAEF test discovery
    • Defines test metadata and execution parameters
  4. taeftest.manifest (12 lines)

    • Windows activation context manifest
    • Registers FileOpenPicker as activatable class

3. Build System Updates

  • Directory.Packages.props: Added package references for:

    • Microsoft.NET.Test.Sdk (v17.14.1)
    • Microsoft.Taef and Taef.Managed
    • Microsoft.WindowsAppSDK.Foundation
  • WindowsAppRuntime.sln: Integrated new test project (523 lines added)

4. CI/CD Pipeline Changes

  • WindowsAppSDK-RunTests-Steps.yml: Added support for .NET 6 runtime and TAEF CoreCLR environment setup

5. Minor Cleanup

  • Removed trailing whitespace from PickerLocalization.cpp and PickerLocalization.h

Technical Highlights

Testing Strategy

  • Component-level testing: Tests actual Windows App SDK components rather than mocked implementations
  • Foundation package approach: Uses published Foundation packages for component testing
  • Cross-platform support: Targets x86, x64, and ARM64 architectures

Sophisticated Dialog Handling

The test includes an innovative approach to handle file picker dialogs automatically:

  • Enumerates windows belonging to the test process
  • Identifies file picker dialogs by class name and title patterns
  • Automatically closes dialogs after a delay to prevent test hanging
  • Uses multiple closure methods (WM_CLOSE, Escape key) for reliability

Current Status

  • Build Status: Pending (multiple pipeline runs triggered via /azp run commands)
  • Review Status: No reviews yet
  • Draft Status: Currently marked as draft
  • Pipeline Activity: Active development with 7 pipeline runs initiated

Significance

This PR represents a significant step toward enabling component package-based testing in Windows App SDK, providing a template for testing Windows Runtime components using published Foundation packages rather than requiring full SDK builds. The approach could potentially improve test isolation, reduce build dependencies, and enable more granular component validation.

Statistics

  • Total Changes: 774 additions, 3 deletions across 9 files
  • Commits: 22 commits
  • Comments: 14 issue comments (mostly pipeline runs)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant