UITest Framework – MFC support in VS 2010

Introduction

In Visual Studio 2010, CodedUITest provides partial support to MFC applications. It uses MSAA (Microsoft Active Accessibility) which is a part of Windows Automation API 2.0 to drive the automation on MFC controls. The same plugin also supports Winforms and Win32 applications. Microsoft Active Accessibility helps users to get programmatic access to user interface elements from outside the application. The primary condition for UITest to work on any application is proper accessibility implementation from the application. This blogs discusses in detail what partial support means on MFC Applications.

 

Assumption

Since UITest uses Winforms pluggin for MFC also (as both uses MSAA technology), please read the two deep dive blogs that was published on Winforms plugin to know about how this plugin works and how to troubleshoot failures.

UITest framework – Winforms Plugin - Part 1

UITest framework – Winforms Plugin - Part 2

 

 

MFC Controls

MFC applications uses two sets of controls, basic controls and UI Rich Feature Pack controls. 

· Basic controls It includes the basic controls used for UI.

· VS 2008 Feature Pack It is the advanced version and shipped with some complex controls e.g., ribbon, property sheet etc.

 

Quality Summary

Basically in 2010 UITest framework supports most of the basic MFC controls and we might generally work. But if the application contains Feature Pack controls then we do not work and it will not be supported.

Quality Rating*

MFC Basic Controls

VS 2008 Feature Pack controls

Good (No Issues)

25 (63%)

3  (8%)

Fair (No Major issues)

9   (22%)

6 (16%)

Poor (Blocking issues)

6   (15%)

28 (76%)

Total

40

37

 

Basic Controls:

For MFC basic controls UITest support is good at most of the scenarios except some controls where either the accessibility story is different (Spinbutton) as of Winforms or controls do not respond to windows messages that we use for recording/playback (e.g., month calendar, date picker etc.)

  • Toolbar from MFC basic controls is not accessible on XP/2K3 machines but works fine on Win7.
  • TreeView is not accessible on 64bit architecture.
  • There are advanced version of controls where we don’t work. For example UITest does not support (fully/partially) following scenarios:
    1. Editing the label of a list item, Selection of list item using hover, Drag/Drop of list items within list box
    2. Property to know the no of children for a container control (e.g., listbox, MDI Frame)
    3. Controls have additional properties which a tester may try to validate. (e.g., Image on a button)
    4. Color dialog is not supported currently.

Controls with Fair rating

Controls with Poor Rating

Comments

CDateTimeCtrl

· Recorded as raw actions but in Winforms UITest aggregates the date selection. If date changes playback may not work.

· The search is failing for the controls due to its class name being different as of Winforms.

· Get works but not Set

CMonthCalCtrl

Recorded as raw actions but in Winforms we aggregate the Month selection. If date changes playback may not work.

CSpinButtonCtrl

The control hierarchy for SpinControl is different as of NumericUpDown control, so the control is not recognized as SpinControl. Recorder will record raw actions

CIPAddressCtrl

Playback fails here as UITest does not recognize it as IPAddressCtrl as it is not present in MFC. Not a high priority control.

CAnimateCtrl

Recognizing it as WinControl. We will record raw actions. Not a high priority controls

CColorDialog

Not accessible using AccExplorer coming as window –> text.  Not a high priority control

 

Controls with poor rating

Controls with Fair Rating

Comments

CListCtrl

CListView

· In case of HoverSelect if recorder is ON selection of items does not happen on listbox until any item is selected using click but after this recorder is able to record on hovering and play them back.

· Able to work across different view of lists

· List boxes have advanced versions, where just name was not enough for AFN, for example one may want to add a validation on other columns of list which are mapped to description field

· Clicks on List items having checkbox with it are recorded as raw click on list item. if this is followed by a set value the previous action will be eaten up (different behavior from checkedlistbox)

· The list items can have additional support of editing the labels which is not supported by UITest

If the list items do not have any text, let say it is used only to pick a color from a list where UITest records SetValue(Empty). which will pick the first item allways

CMenu Recording raw clicks for checked menu item, playback will work fine though.
CScrollBar Do not aggregate actions on this control playback is working fine.
CToolBar

· Broken on XP and 2K3.

· Nameless buttons are not coming under toolbar they are directly under TLW

In some instances for nameless controls inside tool bar but in action log 'numbered <instance>' is not coming

CTreeCtrl

Broken on 64bit Version

CBitmapButton Though it does have an image in its text but there was no property to access that info.
CCheckListBox

· The checkbox items are coming directly under TLW not under the list box as of Winforms, but using UICL they are under list box

Actions are recorded as click on list items

CDragListBox Dragging across list items is not being recognized

 

 

Feature Pack Controls:

UITest support for MFC Feature pack controls as a whole is Poor due to the following reasons:

    • Accessibility story is not good on majority feature pack controls.
    • Menu bar and Toolbar both are coming as Toolbar and are not accessible further.
    • Advanced controls like ribbon/dock pane etc are not accessible

Control level details are not given for Feature Pack controls as majority of them are not supported. If an application is using a feature pack control then Fast Forward or CodedUITest are not supported on it.

Update:

The blog post was originally written for VS 2010. For folks who are using VS 2012 and wondering if Coded UI test continues to work with MFC in VS 2012, then the answer is yes. Coded UI test in VS 2012 works for MFC with the same set of limitations as outlined above.

Comments

  • Anonymous
    April 18, 2011
    Hi, I was wondering if any future developments will allow VS 2010 UI tests to support the MFC Feature Pack Controls. I'm looking to use TFS 2010 to run coded UI tests to test the Ribbons we use in our application. Does anyone have a solution? Thanks

  • Anonymous
    November 27, 2011
    When is the released planned with support to Ribbons? We have changed the menuitems in our application with Ribbons and want to access the same using coded ui tests.

  • Anonymous
    February 21, 2012
    Im been trying to write providers for some win32 custom controls through UI Automaiton server side providers. Im tryng hands on MFC boound controls in VS 2010 which are not UI Automation aware i.e their child items and fragments are not visible to UI spy. Can anyone suggest some help in writing those providers.It may help me a lot.!!!

  • Anonymous
    March 13, 2012
    Can we use extensions in order to access MFC Feature Pack Controls?

  • Anonymous
    March 28, 2012
    Does Feature pack 2 of Coded UI support the following types of classes? CMFCToolBar CMFCMenuBar CMFCPopupMenu CMDIFrameWndEx CMFCOutlookBar CDockablePane

  • Anonymous
    April 17, 2012
    So what`s the current state in VS11? Any news?

  • Anonymous
    November 27, 2012
    I could not find any link for downloading plugin  for  MFC