summaryrefslogtreecommitdiff
path: root/cpp/test/TestSuite/MainPage.xaml.h
blob: 76997e69f4a7a8c96dd2ab3a5611bc8d1307fd98 (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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
// **********************************************************************
//
// Copyright (c) 2003-2016 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 TestConfiguration
{
    TestConfiguration(const std::string& name = "",
                      const std::vector<std::string>& options = std::vector<std::string>(),
                      const std::vector<std::string>& languages = std::vector<std::string>());

    const std::string name;
    const std::vector<std::string> options;
    const std::vector<std::string> languages;
};
typedef std::shared_ptr<TestConfiguration> TestConfigurationPtr;

struct TestCase
{
    TestCase(const std::string&, const std::string&, const std::string&, const std::string& = "",
             const std::string& = "", const std::string& = "");

    const std::string name;
    const std::string prefix;
    const std::string client;
    const std::string server;
    const std::string serverAMD;
    const std::string collocated;
    bool sslSupport;
    bool ipv6Support;
    bool wsSupport;
    std::vector<TestConfigurationPtr> configurations;
};
typedef std::shared_ptr<TestCase> TestCasePtr;

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<TestCasePtr> _allTests;
    DllCache _dlls;

    Windows::UI::Xaml::Controls::ListBox^ _tests;
    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;
};

}