-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWindow.cpp
More file actions
118 lines (85 loc) · 2.21 KB
/
Window.cpp
File metadata and controls
118 lines (85 loc) · 2.21 KB
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
/*
* File: Window.cpp
* Author: saucelabs
*
* Created on December 23, 2014, 2:40 PM
*/
#include "Window.h"
#include "Routes.h"
#include "HttpClient.h"
//Window::Window() {
//}
//
//Window::Window(const Window& orig) {
//}
//
//Window::~Window() {
//}
std::pair<int, int> Window::position()
{
auto url = makeUrl(Routes::WINDOW_POSITION);
auto response = HttpClient::get(url);
return { response->value()["x"].asInt(), response->value()["y"].asInt() };
}
std::pair<int, int> Window::size()
{
auto url = makeUrl(Routes::WINDOW_SIZE);
auto response = HttpClient::get(url);
return { response->value()["width"].asInt(), response->value()["height"].asInt() };
}
void Window::setPosition(int x, int y)
{
auto url = makeUrl(Routes::WINDOW_POSITION);
HttpClient::post(url, {{"x", x}, {"y", y}});
}
void Window::setSize(int width, int height)
{
auto url = makeUrl(Routes::WINDOW_SIZE);
HttpClient::post(url, {{"width", width}, {"height", height}});
}
void Window::maximize()
{
auto url = makeUrl(Routes::WINDOW_MAXIMIZE);
HttpClient::post(url);
}
void Window::acceptAlert()
{
auto url = makeUrl(Routes::CONTEXT_ACCEPT_ALERT);
HttpClient::post(url);
}
void Window::dismissAlert()
{
auto url = makeUrl(Routes::CONTEXT_DISMISS_ALERT);
HttpClient::post(url);
}
std::string Window::alertText()
{
auto url = makeUrl(Routes::CONTEXT_ALERT_TEXT);
auto response = HttpClient::get(url);
return response->value().asStr();
}
void Window::sendKeysToAlert(const std::string& keys)
{
auto url = makeUrl(Routes::CONTEXT_ALERT_TEXT);
HttpClient::post(url, {{"text", keys}});
}
void Window::_buttonAction(const MouseButton& btn, const std::string& url)
{
HttpClient::post(url, {{"button", btn}});
}
void Window::buttonDown(const MouseButton& btn)
{
_buttonAction(btn, makeUrl(Routes::CONTEXT_BUTTONDOWN));
}
void Window::buttonUp(const MouseButton& btn)
{
_buttonAction(btn, makeUrl(Routes::CONTEXT_BUTTONUP));
}
void Window::buttonClick(const MouseButton& btn)
{
_buttonAction(btn, makeUrl(Routes::CONTEXT_CLICK));
}
void Window::buttonDblClick(const MouseButton& btn)
{
_buttonAction(btn, makeUrl(Routes::CONTEXT_DOUBLECLICK ));
}