none
Enable Coded UI Testing of my Custom Controls

    Soru

  • Hello,

    I have an open source application, in which I can import shapes from CAD files like.iges, .step, .brep. After import, I can set some properties of shapes like material, color, transparency etc. The UI of application is written in C#, but the data model and viewer is written in C++.  I want that coded UI test builder could recognize my imported shape.

    My code looks like this:

    public class Form2 : System.Windows.Forms.Form
    {
        public Form2()
        {
            //Some code....
            myView = new shell();
            //Some code....
        }

        public void InitV3D()
        {
            if( !myView.InitViewer(this.Handle) )
                MessageBox.Show("Fatal Error during the graphic initialisation", "Error!", 
                    MessageBoxButtons.OK, MessageBoxIcon.Error);
        }

        public void ImportModel(ModelFormat format)
        {
            //Some code....
            if (!myView.TranslateModel(filename, theformat, true))
                MessageBox.Show("Cann't read this file", "Error!", 
                    MessageBoxButtons.OK, MessageBoxIcon.Warning);        
            //Some code...
        }

        //Some code...
    private:
        shell myView;
    }    


    public ref class shell
    {

    private:
        Viewer* myViewer;

    public:
        bool InitViewer(System::IntPtr wnd)
        {
            if (myViewer != NULL)
                return myViewer->InitViewer(wnd.ToPointer());
            else
                return false;
        }

        bool TranslateModel(System::String^ filename, int format, bool IsImport)
        {
            //Some code...
            bool res=myViewer->ImportBRep(fname);
            //Some code...
            return res;
        }

        //Some code...
    }

    //In file Viewer.h
    class Viewer
    {
    public:
        __declspec(dllexport) Viewer(void);
        __declspec(dllexport) ~Viewer(void);
    private:
        Context myContext;    
    public:
        __declspec(dllexport) bool InitViewer(void* wnd);
        __declspec(dllexport) bool ImportBRep(char* filename);
        //Some functions...
    }

    //In file Viewer.cpp
    bool Viewer::ImportBRep(char* filename)
    {
        string aFileName = (string) filename;
        Shape aShape;
        Builder aBuilder;
        bool result = Tools::Read(aShape,aFileName,aBuilder);
        if (!result)
            return false;
        if(myContext->HasOpenedContext())
            myContext->CloseLocalContext();
        myContext->Display(new AIS_Shape(aShape));
        return true;
    }

    Note: Shape and AIS_Shape is different classes.

    I have wrapped the class AIS_Shape so it can be used from C#.  First of all I want to get the accessible information of my shape. I have explored the sample "
    Enable Coded UI Testing of Your Custom Controls". I started with "Chart Control" example. In this example the CurveLegend control used like a field of ChartControl which derives from System.Windows.Forms.UserControl, but my shape doesn't use like field in any class. I just have the class "shell" which is a field of my form, and the class "Viewer" which is a field of the class "shell".

     Unfortunately, I can't get enough information from sample to do this. 
    Could you help me, please?


    • Düzenleyen Quatrefoil 30 Mart 2012 Cuma 06:39
    • Taşıyan Forrest Guo 01 Nisan 2012 Pazar 13:20 move to more appropriate forum. (From:Visual Studio UI Automation Testing (includes CodedUI))
    29 Mart 2012 Perşembe 17:20

Tüm Yanıtlar

  • Hi Quatrefoil,

    I am trying to involve someone familiar with this topic to further look at this issue. There might be some time delay. Appreciate your patience.

    Thank you for your understanding and support.

     

    Tony Xiao [MSFT]
    MSDN Community Support | Feedback to us

    30 Mart 2012 Cuma 09:35