Skip to content

armgit / cua

Public Imported from GitHub
0

Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.

11.2 KB
Raw Blame
<Window
    x:Class="CuaTestHarness.WinUI3.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:auto="using:Microsoft.UI.Xaml.Automation"
    Title="CuaTestHarness WinUI3">

    <ScrollViewer>
    <StackPanel Padding="16" Spacing="10">

        <!-- Counter -->
        <StackPanel Orientation="Horizontal" Spacing="8">
            <Button x:Name="BtnIncrement"
                    auto:AutomationProperties.AutomationId="btn-increment"
                    Content="Increment" Width="100"
                    Click="OnIncrementClick"/>
            <Button x:Name="BtnReset"
                    auto:AutomationProperties.AutomationId="btn-reset"
                    Content="Reset" Width="80"
                    Click="OnResetClick"/>
            <TextBlock x:Name="LblCounter"
                       auto:AutomationProperties.AutomationId="lbl-counter"
                       VerticalAlignment="Center"
                       FontFamily="Consolas" FontSize="14"
                       Text="counter=0"/>
        </StackPanel>

        <!-- Click target — records left / right / double clicks. Mirrors the
             WPF harness (same AutomationIds + label format) so the shared
             modality recorder resolves it identically. WinUI3 Button raises
             Click on each tap (so a double-click fires Click twice — caught by
             the timing check), RightTapped on a secondary/barrel tap, and
             DoubleTapped as a backup signal. -->
        <StackPanel Spacing="4">
            <Button x:Name="BtnClickTarget"
                    auto:AutomationProperties.AutomationId="border-click-target"
                    Content="Click target (left / right / double)"
                    Width="260" Height="40" HorizontalAlignment="Left"
                    Click="OnTargetClick"
                    DoubleTapped="OnTargetDoubleTapped"
                    RightTapped="OnTargetRightTapped"/>
            <TextBlock x:Name="LblLastAction"
                       auto:AutomationProperties.AutomationId="lbl-last-action"
                       FontFamily="Consolas"
                       Text="last_action=none"/>
            <TextBlock x:Name="LblClickCount"
                       auto:AutomationProperties.AutomationId="lbl-click-count"
                       FontFamily="Consolas"
                       Text="clicks=0"/>
        </StackPanel>

        <TextBlock auto:AutomationProperties.AutomationId="txt-body"
                   FontFamily="Consolas" TextWrapping="Wrap"
                   Text="HARNESS_TEXT_MARKER_v1 — WinUI3 text body for get_window_state."/>

        <!-- TextBox + mirror -->
        <StackPanel Orientation="Vertical" Spacing="4">
            <TextBox x:Name="TxtInput"
                     auto:AutomationProperties.AutomationId="txt-input"
                     Width="300" HorizontalAlignment="Left"
                     TextChanged="OnInputChanged"/>
            <TextBlock x:Name="LblInputMirror"
                       auto:AutomationProperties.AutomationId="lbl-input-mirror"
                       FontFamily="Consolas"
                       Text="mirror="/>
        </StackPanel>

        <!-- Dedicated real multiline editor for foreground type_text tests. -->
        <TextBox x:Name="TxtMultilineInput"
                 auto:AutomationProperties.AutomationId="txt-multiline-input"
                 Width="420" Height="100" HorizontalAlignment="Left"
                 AcceptsReturn="True" TextWrapping="Wrap"
                 TextChanged="OnMultilineInputChanged"/>

        <!-- Slider -->
        <StackPanel Spacing="4">
            <Slider x:Name="SldValue"
                    auto:AutomationProperties.AutomationId="sld-value"
                    Minimum="0" Maximum="100" Value="0"
                    Width="320" HorizontalAlignment="Left"
                    ValueChanged="OnSliderChanged"/>
            <TextBlock x:Name="LblSliderValue"
                       auto:AutomationProperties.AutomationId="lbl-slider-value"
                       FontFamily="Consolas"
                       Text="slider_value=0"/>
        </StackPanel>

        <!-- Scroll target — a ScrollViewer with tall content and an offset
             label bound to VerticalOffset. Mirrors the WPF harness. WinUI3's
             ScrollViewer does NOT consume the WM_VSCROLL the driver posts to
             the top-level HWND (composition-routed input), so MainWindow
             subclasses the HWND and translates WM_VSCROLL → ChangeView (same
             rationale as WPF's HwndSource hook). -->
        <StackPanel Spacing="4">
            <TextBlock x:Name="LblScrollOffset"
                       auto:AutomationProperties.AutomationId="lbl-scroll-offset"
                       FontFamily="Consolas"
                       Text="scroll_offset=0"/>
            <ScrollViewer x:Name="ScrollTall"
                          auto:AutomationProperties.AutomationId="scroll-tall"
                          Height="120" Width="400" HorizontalAlignment="Left"
                          VerticalScrollBarVisibility="Auto"
                          VerticalScrollMode="Enabled"
                          ViewChanged="OnScrollViewChanged">
                <StackPanel>
                    <TextBlock Text="SCROLL_TOP_MARKER_v1"/>
                    <TextBlock Text="line 02"/><TextBlock Text="line 03"/>
                    <TextBlock Text="line 04"/><TextBlock Text="line 05"/>
                    <TextBlock Text="line 06"/><TextBlock Text="line 07"/>
                    <TextBlock Text="line 08"/><TextBlock Text="line 09"/>
                    <TextBlock Text="line 10"/><TextBlock Text="line 11"/>
                    <TextBlock Text="line 12"/><TextBlock Text="line 13"/>
                    <TextBlock Text="line 14"/><TextBlock Text="line 15"/>
                    <TextBlock Text="line 16"/><TextBlock Text="line 17"/>
                    <TextBlock Text="line 18"/><TextBlock Text="line 19"/>
                    <TextBlock Text="line 20"/><TextBlock Text="line 21"/>
                    <TextBlock Text="line 22"/><TextBlock Text="line 23"/>
                    <TextBlock Text="line 24"/><TextBlock Text="line 25"/>
                    <TextBlock Text="line 26"/><TextBlock Text="line 27"/>
                    <TextBlock Text="line 28"/><TextBlock Text="line 29"/>
                    <TextBlock Text="line 30"/><TextBlock Text="line 31"/>
                    <TextBlock Text="line 32"/><TextBlock Text="line 33"/>
                    <TextBlock Text="line 34"/><TextBlock Text="line 35"/>
                    <TextBlock Text="line 36"/><TextBlock Text="line 37"/>
                    <TextBlock Text="line 38"/><TextBlock Text="line 39"/>
                    <TextBlock Text="SCROLL_BOTTOM_MARKER_v1"/>
                </StackPanel>
            </ScrollViewer>
        </StackPanel>

        <!-- CheckBox + RadioButton group -->
        <StackPanel Spacing="4">
            <CheckBox x:Name="ChkAgreed"
                      auto:AutomationProperties.AutomationId="chk-agreed"
                      Content="I agree"
                      Checked="OnChkChanged" Unchecked="OnChkChanged"/>
            <StackPanel Orientation="Horizontal" Spacing="12">
                <RadioButton x:Name="RdoLow"  Content="Low"
                             auto:AutomationProperties.AutomationId="rdo-low"
                             GroupName="prio" IsChecked="True"
                             Checked="OnRadioChanged"/>
                <RadioButton x:Name="RdoMed"  Content="Medium"
                             auto:AutomationProperties.AutomationId="rdo-med"
                             GroupName="prio"
                             Checked="OnRadioChanged"/>
                <RadioButton x:Name="RdoHigh" Content="High"
                             auto:AutomationProperties.AutomationId="rdo-high"
                             GroupName="prio"
                             Checked="OnRadioChanged"/>
            </StackPanel>
            <TextBlock x:Name="LblChkState"
                       auto:AutomationProperties.AutomationId="lbl-chk-state"
                       FontFamily="Consolas"
                       Text="agreed=False, prio=Low"/>
        </StackPanel>

        <!-- ComboBox -->
        <StackPanel Spacing="4">
            <ComboBox x:Name="CboColor"
                      auto:AutomationProperties.AutomationId="cbo-color"
                      Width="180" HorizontalAlignment="Left"
                      SelectionChanged="OnComboChanged">
                <ComboBoxItem Content="red"    auto:AutomationProperties.AutomationId="cbo-item-red"/>
                <ComboBoxItem Content="green"  auto:AutomationProperties.AutomationId="cbo-item-green" IsSelected="True"/>
                <ComboBoxItem Content="blue"   auto:AutomationProperties.AutomationId="cbo-item-blue"/>
                <ComboBoxItem Content="orange" auto:AutomationProperties.AutomationId="cbo-item-orange"/>
            </ComboBox>
            <TextBlock x:Name="LblComboValue"
                       auto:AutomationProperties.AutomationId="lbl-combo-value"
                       FontFamily="Consolas"
                       Text="color=green"/>
        </StackPanel>

        <!-- CommandBarFlyout trigger -->
        <Button x:Name="BtnOpenFlyout"
                auto:AutomationProperties.AutomationId="btn-open-flyout"
                Content="Open CommandBarFlyout"
                Width="220" HorizontalAlignment="Left"
                Click="OnOpenFlyoutClick">
            <Button.Flyout>
                <CommandBarFlyout x:Name="CmdFlyout">
                    <AppBarButton Icon="Copy"  Label="Copy"
                                  auto:AutomationProperties.AutomationId="flyout-copy"/>
                    <AppBarButton Icon="Paste" Label="Paste"
                                  auto:AutomationProperties.AutomationId="flyout-paste"/>
                </CommandBarFlyout>
            </Button.Flyout>
        </Button>

        <!-- XAML Popup trigger -->
        <Button x:Name="BtnOpenPopup"
                auto:AutomationProperties.AutomationId="btn-open-popup"
                Content="Open XAML Popup"
                Width="220" HorizontalAlignment="Left"
                Click="OnOpenPopupClick"/>

        <Popup x:Name="PopXaml"
               HorizontalOffset="40" VerticalOffset="40">
            <Border Background="#202020" Padding="16" CornerRadius="6"
                    BorderBrush="#FFFFFF" BorderThickness="1">
                <StackPanel Spacing="8">
                    <TextBlock Foreground="White" FontWeight="Bold"
                               Text="XAML Popup (same HWND)"/>
                    <TextBlock Foreground="White"
                               auto:AutomationProperties.AutomationId="txt-popup-body"
                               Text="XAML_POPUP_MARKER_v1 — Popup is NOT a separate HWND; it lives inside the main window."/>
                    <Button Content="Close" Width="80" Click="OnClosePopupClick"/>
                </StackPanel>
            </Border>
        </Popup>

        <!-- Exit -->
        <Button x:Name="BtnExit"
                auto:AutomationProperties.AutomationId="btn-exit"
                Content="Exit" Width="80" HorizontalAlignment="Right"
                Click="OnExitClick"/>

    </StackPanel>
    </ScrollViewer>
</Window>