summaryrefslogtreecommitdiff
path: root/cpp/test/uwp/testSuiteApp/MainPage.xaml.h
blob: 0b4c71bd12f2a59fa91c0b1e6d030eed1879daf2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
// **********************************************************************
//
// Copyright (c) 2003-2017 ZeroC, Inc. All rights reserved.
//
// This copy of Ice is licensed to you under the terms described in the
// ICE_LICENSE file included in this distribution.
//
// **********************************************************************

#pragma once

#include <MainPage.g.h>
#include <collection.h>
#include <vector>
#include <memory>

#include <Ice/Ice.h>

namespace TestSuite
{

struct TestCaseDesc
{
    const std::string name;
    std::string client;
    std::string server;
    const std::vector<std::string> args;
};

struct TestSuiteDesc
{
    const std::string id;
    std::vector<TestCaseDesc> testCases;
};


template<typename T> T^
findChild(Windows::UI::Xaml::DependencyObject^ parent, Platform::String^ name)
{
    int count = VisualTreeHelper::GetChildrenCount(parent);
    for (int i = 0; i < count; ++i)
    {
        DependencyObject^ object = VisualTreeHelper::GetChild(parent, i);
        T^ child = dynamic_cast<T^>(object);
        FrameworkElement^ element = dynamic_cast<FrameworkElement^>(object);

        if(child && element && element->Name == name)
        {
            return child;
        }
        else if(object)
        {
            child = findChild<T>(object, name);
            if(child)
            {
                return child;
            }
        }
    }
    return nullptr;
}

class DllCache
{
public:

    ~DllCache();

    HINSTANCE loadDll(const std::string&);

private:

    std::map<std::string, HINSTANCE> _dlls;
};

[Windows::Foundation::Metadata::WebHostHidden]
public ref class MainPage sealed
{
public:

    MainPage();

    void completed();
    void failed(Platform::String^ reason);
    void printToConsoleOutput(Platform::String^ message, bool newline);

protected:

    virtual void OnNavigatedTo(Windows::UI::Xaml::Navigation::NavigationEventArgs^ e) override;

private:

    void btnRun_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
    void btnStop_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
    void runSelectedTest();

    void Output_Loaded(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
    void Configuration_Loaded(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
    void Tests_Loaded(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
    void Language_SelectionChanged(Platform::Object^ sender, Windows::UI::Xaml::Controls::SelectionChangedEventArgs^ e);


    std::string selectedLanguage();
    std::string selectedProtocol();
    void initializeSupportedProtocols();
    void initializeSupportedTests();

    Ice::CommunicatorPtr communicator();

    Platform::Collections::Vector<Platform::String^>^ _names;
    Platform::Collections::Vector<Platform::String^>^ _protocols;
    Platform::Collections::Vector<Platform::String^>^ _messages;

    std::vector<TestSuiteDesc> _allTests;
    DllCache _dlls;

    Windows::UI::Xaml::Controls::ListBox^ _testSuites;
    Windows::UI::Xaml::Controls::ComboBox^ _language;
    Windows::UI::Xaml::Controls::TextBox^ _host;
    Windows::UI::Xaml::Controls::ComboBox^ _protocol;
    Windows::UI::Xaml::Controls::CheckBox^ _loop;
    Windows::UI::Xaml::Controls::CheckBox^ _serialize;
    Windows::UI::Xaml::Controls::CheckBox^ _ipv6;
    Windows::UI::Xaml::Controls::Button^ _run;
    Windows::UI::Xaml::Controls::Button^ _stop;
    Windows::UI::Xaml::Controls::ListBox^ _output;
    Ice::CommunicatorPtr _communicator;
};

}