Skip to content

Commit cfc5940

Browse files
Andrii BoichukAndrii Boichuk
authored andcommitted
2 parents 4c4e989 + 97434ae commit cfc5940

17 files changed

+1803
-321
lines changed

src/Test/main.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@
99
#include <QtWidgets/QApplication>
1010
#else
1111
#include <QtCore/QtConcurrentRun>
12+
//#include <QDebug>
13+
1214
#include <QtGui/QApplication>
15+
1316
#include <QtWebKit/QtWebKit>
1417
#endif
1518

@@ -36,7 +39,6 @@ int main(int argc, char *argv[])
3639
QWebSettings::globalSettings()->setOfflineStoragePath("./web/html5");
3740
QWebSettings::globalSettings()->setOfflineWebApplicationCachePath("./web/html5");
3841

39-
//Test
4042
regitsterView<QWebView>("QWebView");
4143
regitsterView<QWidget>("QWidget");
4244

src/base/debug/debugger_posix.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,8 @@ bool BeingDebugged() {
224224
#endif
225225
#elif defined(ARCH_CPU_MIPS_FAMILY)
226226
#define DEBUG_BREAK() asm("break 2")
227+
#elif defined(__SH4__)
228+
#define DEBUG_BREAK() abort()
227229
#else
228230
#define DEBUG_BREAK() asm("int3")
229231
#endif

src/chrome/test/automation/automation_json_requests.cc

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -111,15 +111,15 @@ WebViewId WebViewId::ForView(const AutomationId& view_id)
111111
return id;
112112
}
113113

114-
WebViewId WebViewId::ForQtView(QWebView *view)
114+
WebViewId WebViewId::ForQtView(QWidget *view)
115115
{
116116
WebViewId id;
117117
id.old_style_ = false;
118-
id.webView_ = view;
118+
id.view_ = view;
119119

120120
int automationId;
121121
QVariant viewAutomationId = view->property("automationId");
122-
122+
QWebView* pView = qobject_cast<QWebView*>(view);
123123
if (viewAutomationId.isValid())
124124
automationId = viewAutomationId.toInt();
125125
else
@@ -128,11 +128,21 @@ WebViewId WebViewId::ForQtView(QWebView *view)
128128
automationId = qrand();
129129
view->setProperty("automationId", automationId);
130130
}
131-
AutomationId aId(AutomationId::kTypeTab, QString::number(automationId).toStdString());
132-
id.id_ = aId;
131+
132+
if (pView != NULL)
133+
{
134+
AutomationId aId(AutomationId::kTypeTab, QString::number(automationId).toStdString());
135+
id.id_ = aId;
136+
}
137+
else
138+
{
139+
AutomationId aId(AutomationId::kTypeAppShell, QString::number(automationId).toStdString());
140+
id.id_ = aId;
141+
}
133142
return id;
134143
}
135144

145+
136146
// static
137147
//WebViewId WebViewId::ForOldStyleTab(int tab_id, QWebView *view)
138148
WebViewId WebViewId::ForOldStyleTab(int tab_id)
@@ -147,7 +157,7 @@ WebViewId WebViewId::ForOldStyleTab(int tab_id)
147157

148158
WebViewId::WebViewId()
149159
: old_style_(true),
150-
webView_(NULL)
160+
view_(NULL)
151161
{}
152162

153163
/*void WebViewId::UpdateDictionary(DictionaryValue* dict,
@@ -177,6 +187,10 @@ bool WebViewId::IsTab() const {
177187
return old_style_ || id_.type() == AutomationId::kTypeTab;
178188
}
179189

190+
bool WebViewId::IsApp() const {
191+
return id_.type() == AutomationId::kTypeAppShell;
192+
}
193+
180194
int WebViewId::tab_id() const {
181195
return tab_id_;
182196
}
@@ -186,9 +200,9 @@ bool WebViewId::old_style() const
186200
return old_style_;
187201
}
188202

189-
QWebView* WebViewId::GetWebView() const
203+
QWidget* WebViewId::GetView() const
190204
{
191-
return webView_;
205+
return view_;
192206
}
193207

194208
/*

src/chrome/test/automation/automation_json_requests.h

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,9 @@ class WebViewId {
7171
//static WebViewId ForView(const AutomationId& view_id, QWebView *view);
7272
static WebViewId ForView(const AutomationId& view_id);
7373

74-
// Creates an ID for the given view ID.
74+
// Creates an ID for the given view ID.
7575
//static WebViewId ForView(const AutomationId& view_id, QWebView *view);
76-
static WebViewId ForQtView(QWebView *view);
76+
static WebViewId ForQtView(QWidget *view);
7777

7878
// Creates an ID for the given tab ID.
7979
//WebViewId ForOldStyleTab(int tab_id, QWebView *view);
@@ -97,23 +97,26 @@ class WebViewId {
9797
// Returns whether this ID refers to a tab.
9898
bool IsTab() const;
9999

100+
// Returns whether this ID refers to app.
101+
bool IsApp() const;
102+
100103
int tab_id() const;
101104

102105
// The old style is to use a single integer ID for a tab. The new style is
103106
// to use an automation ID which may refer to a number of different object
104107
// types.
105108
bool old_style() const;
106109

107-
// return pointer to WebView widget
108-
QWebView* GetWebView() const;
110+
// return pointer to view widget
111+
QWidget* GetView() const;
109112

110113
private:
111114
// Whether this ID is an old-style integer tab ID.
112115
bool old_style_;
113116

114117
AutomationId id_;
115118
int tab_id_;
116-
QWebView *webView_;
119+
QWidget *view_;
117120
};
118121

119122
// Used to locate a WebView. The same locator may locate different WebViews

src/chrome/test/webdriver/commands/create_session.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ void CreateSession::ExecutePost(Response* const response) {
3333
return;
3434
}
3535

36+
if (SessionManager::GetInstance()->GetSessions().size() > 0)
37+
{
38+
response->SetError(new Error(kUnknownError, "Cannot start session. WD support only one session at the moment"));
39+
return;
40+
}
3641
// Session manages its own liftime, so do not call delete.
3742
Session* session = new Session();
3843
Error* error = session->Init(dict);

src/chrome/test/webdriver/commands/mouse_commands.cc

Lines changed: 3 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -36,55 +36,15 @@ bool MoveAndClickCommand::DoesPost() {
3636
}
3737

3838
void MoveAndClickCommand::ExecutePost(Response* response) {
39-
std::string tag_name;
40-
Error* error = session_->GetElementTagName(
41-
session_->current_target(), element, &tag_name);
42-
if (error) {
43-
response->SetError(error);
44-
return;
45-
}
39+
Error* error = NULL;
40+
41+
error = session_->MoveAndClickElement(session_->current_target(), element);
4642

47-
if (tag_name == "option") {
48-
const char* kCanOptionBeToggledScript =
49-
"function(option) {"
50-
" for (var parent = option.parentElement;"
51-
" parent;"
52-
" parent = parent.parentElement) {"
53-
" if (parent.tagName.toLowerCase() == 'select') {"
54-
" return parent.multiple;"
55-
" }"
56-
" }"
57-
" throw new Error('Option element is not in a select');"
58-
"}";
59-
bool can_be_toggled;
60-
error = session_->ExecuteScriptAndParse(
61-
session_->current_target(),
62-
kCanOptionBeToggledScript,
63-
"canOptionBeToggled",
64-
CreateListValueFrom(element),
65-
CreateDirectValueParser(&can_be_toggled));
6643
if (error) {
6744
response->SetError(error);
68-
return;
6945
}
7046

71-
if (can_be_toggled) {
72-
error = session_->ToggleOptionElement(
73-
session_->current_target(), element);
74-
} else {
75-
error = session_->SetOptionElementSelected(
76-
session_->current_target(), element, true);
77-
}
78-
} else {
79-
Point location;
80-
error = session_->GetClickableLocation(element, &location);
81-
if (!error)
82-
error = session_->MouseMoveAndClick(location, automation::kLeftButton);
83-
}
84-
if (error) {
85-
response->SetError(error);
8647
return;
87-
}
8848
}
8949

9050
HoverCommand::HoverCommand(const std::vector<std::string>& path_segments,

src/chrome/test/webdriver/commands/target_locator_commands.cc

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,14 @@ void SwitchFrameCommand::ExecutePost(Response* const response) {
115115
int index = 0;
116116
ElementId element;
117117
Error* error = NULL;
118+
119+
// TODO: move this function to session?
120+
if ( session_->current_target().view_id.IsApp() )
121+
{
122+
error = new Error(kUnknownError, "This trget doesnt support switchFrame command");
123+
return;
124+
}
125+
118126
if (GetStringParameter("id", &id)) {
119127
error = session_->SwitchToFrameWithNameOrId(id);
120128
} else if (GetIntegerParameter("id", &index)) {
@@ -158,15 +166,14 @@ bool ActiveElementCommand::DoesPost() {
158166
}
159167

160168
void ActiveElementCommand::ExecutePost(Response* const response) {
161-
ListValue args;
162-
Value* result = NULL;
163-
Error* error = session_->ExecuteScript(
164-
"return document.activeElement || document.body", &args, &result);
165-
if (error) {
166-
response->SetError(error);
167-
return;
168-
}
169-
response->SetValue(result);
169+
ElementId element;
170+
Error* error = session_->ActiveElement(
171+
session_->current_target(), &element);
172+
if (error) {
173+
response->SetError(error);
174+
return;
175+
}
176+
response->SetValue(element.ToValue());
170177
}
171178

172179
} // namespace webdriver

0 commit comments

Comments
 (0)