Skip to content

Commit bc0378c

Browse files
committed
added library for qml_webextension
1 parent b1b60c0 commit bc0378c

File tree

3 files changed

+97
-39
lines changed

3 files changed

+97
-39
lines changed

src/Test/main.cc

Lines changed: 62 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,20 @@
4848

4949
#ifndef OS_IOS
5050
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
51-
// headers for Quick2 extension
52-
#include "extension_qt/quick2_view_creator.h"
53-
#include "extension_qt/quick2_view_executor.h"
54-
#include "extension_qt/quick2_view_enumerator.h"
51+
// headers for Quick2 extension
52+
#include "extension_qt/quick2_view_creator.h"
53+
#include "extension_qt/quick2_view_executor.h"
54+
#include "extension_qt/quick2_view_enumerator.h"
5555
#else
56-
#include <QtDeclarative/QDeclarativeView>
57-
// headers for Quick1 extension
58-
#include "extension_qt/qml_view_creator.h"
59-
#include "extension_qt/qml_view_executor.h"
60-
#include "extension_qt/qml_view_enumerator.h"
56+
#include <QtDeclarative/QDeclarativeView>
57+
// headers for Quick1 extension
58+
#include "extension_qt/qml_view_creator.h"
59+
#include "extension_qt/qml_view_executor.h"
60+
#include "extension_qt/qml_view_enumerator.h"
61+
#if (WD_TEST_ENABLE_WEB_VIEW == 1)
62+
#include "extension_qt/qdeclarativewebview.h"
63+
#include "extension_qt/qml_web_view_enumerator.h"
64+
#endif
6165
#endif
6266
#endif //OS_IOS
6367

@@ -86,6 +90,8 @@
8690
void setQtSettings();
8791
void PrintVersion();
8892
void PrintHelp();
93+
void InitVNCClient();
94+
void InitUInputClient();
8995

9096
int main(int argc, char *argv[])
9197
{
@@ -95,7 +101,7 @@ int main(int argc, char *argv[])
95101
#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
96102
QTextCodec::setCodecForCStrings(QTextCodec::codecForName("utf8"));
97103
#endif
98-
104+
99105
webdriver::ViewRunner::RegisterCustomRunner<webdriver::QViewRunner>();
100106

101107
webdriver::SessionLifeCycleActions::RegisterCustomLifeCycleActions<webdriver::QSessionLifeCycleActions>();
@@ -157,6 +163,16 @@ int main(int argc, char *argv[])
157163
webdriver::ViewEnumerator::AddViewEnumeratorImpl(new webdriver::QmlViewEnumeratorImpl());
158164

159165
webdriver::ViewCmdExecutorFactory::GetInstance()->AddViewCmdExecutorCreator(new webdriver::QQmlViewCmdExecutorCreator());
166+
167+
#if (WD_TEST_ENABLE_WEB_VIEW == 1)
168+
qmlRegisterType<QDeclarativeWebSettings>();
169+
qmlRegisterType<QDeclarativeWebView>("CiscoQtWebKit", 1, 0, "CiscoWebView");
170+
qmlRegisterType<QDeclarativeWebView>("CiscoQtWebKit", 1, 1, "CiscoWebView");
171+
qmlRegisterRevision<QDeclarativeWebView, 0>("CiscoQtWebKit", 1, 0);
172+
qmlRegisterRevision<QDeclarativeWebView, 1>("CiscoQtWebKit", 1, 1);
173+
webdriver::ViewEnumerator::AddViewEnumeratorImpl(new webdriver::QmlWebViewEnumeratorImpl());
174+
#endif
175+
160176
#endif
161177
#endif //OS_IOS
162178

@@ -203,6 +219,39 @@ int main(int argc, char *argv[])
203219
routeTableWithShutdownCommand->Add<webdriver::ShutdownCommand>(shutdownCommandRoute);
204220
wd_server->SetRouteTable(routeTableWithShutdownCommand);
205221

222+
InitVNCClient();
223+
InitUInputClient();
224+
225+
int startError = wd_server->Start();
226+
if (startError)
227+
return startError;
228+
229+
setQtSettings();
230+
231+
return app.exec();
232+
}
233+
234+
void setQtSettings() {
235+
#if (WD_TEST_ENABLE_WEB_VIEW == 1)
236+
QWebSettings::globalSettings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true);
237+
QWebSettings::globalSettings()->setAttribute(QWebSettings::JavascriptEnabled, true);
238+
QWebSettings::globalSettings()->setAttribute(QWebSettings::JavascriptCanOpenWindows, true);
239+
QWebSettings::globalSettings()->setAttribute(QWebSettings::JavascriptCanCloseWindows, true);
240+
QWebSettings::globalSettings()->setAttribute(QWebSettings::LocalStorageEnabled, true);
241+
QWebSettings::globalSettings()->setAttribute(QWebSettings::LocalContentCanAccessRemoteUrls, true);
242+
QWebSettings::globalSettings()->setAttribute(QWebSettings::LocalContentCanAccessFileUrls, true);
243+
QWebSettings::globalSettings()->setAttribute(QWebSettings::OfflineStorageDatabaseEnabled, true);
244+
QWebSettings::globalSettings()->setAttribute(QWebSettings::OfflineWebApplicationCacheEnabled, true);
245+
QWebSettings::globalSettings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true);
246+
QWebSettings::globalSettings()->setAttribute(QWebSettings::PluginsEnabled, true);
247+
QWebSettings::globalSettings()->enablePersistentStorage("./web/html5");
248+
QWebSettings::globalSettings()->setLocalStoragePath("./web/html5");
249+
QWebSettings::globalSettings()->setOfflineStoragePath("./web/html5");
250+
QWebSettings::globalSettings()->setOfflineWebApplicationCachePath("./web/html5");
251+
#endif
252+
}
253+
254+
void InitVNCClient() {
206255
// start VNC module
207256
CommandLine cmdLine = webdriver::Server::GetInstance()->GetCommandLine();
208257
if (cmdLine.HasSwitch(webdriver::Switches::kVNCLogin))
@@ -226,9 +275,12 @@ int main(int argc, char *argv[])
226275

227276
WDEventDispatcher::getInstance()->add(new VNCEventDispatcher(client));
228277
}
278+
}
229279

280+
void InitUInputClient() {
230281
// start user input device
231282
#ifdef OS_LINUX
283+
CommandLine cmdLine = webdriver::Server::GetInstance()->GetCommandLine();
232284
if (cmdLine.HasSwitch(webdriver::Switches::kUserInputDevice))
233285
{
234286
UInputManager *manager = UInputManager::getInstance();
@@ -240,34 +292,6 @@ int main(int argc, char *argv[])
240292
WDEventDispatcher::getInstance()->add(new UInputEventDispatcher(manager));
241293
}
242294
#endif // OS_LINUX
243-
244-
int startError = wd_server->Start();
245-
if (startError)
246-
return startError;
247-
248-
setQtSettings();
249-
250-
return app.exec();
251-
}
252-
253-
void setQtSettings() {
254-
#if (WD_TEST_ENABLE_WEB_VIEW == 1)
255-
QWebSettings::globalSettings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true);
256-
QWebSettings::globalSettings()->setAttribute(QWebSettings::JavascriptEnabled, true);
257-
QWebSettings::globalSettings()->setAttribute(QWebSettings::JavascriptCanOpenWindows, true);
258-
QWebSettings::globalSettings()->setAttribute(QWebSettings::JavascriptCanCloseWindows, true);
259-
QWebSettings::globalSettings()->setAttribute(QWebSettings::LocalStorageEnabled, true);
260-
QWebSettings::globalSettings()->setAttribute(QWebSettings::LocalContentCanAccessRemoteUrls, true);
261-
QWebSettings::globalSettings()->setAttribute(QWebSettings::LocalContentCanAccessFileUrls, true);
262-
QWebSettings::globalSettings()->setAttribute(QWebSettings::OfflineStorageDatabaseEnabled, true);
263-
QWebSettings::globalSettings()->setAttribute(QWebSettings::OfflineWebApplicationCacheEnabled, true);
264-
QWebSettings::globalSettings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true);
265-
QWebSettings::globalSettings()->setAttribute(QWebSettings::PluginsEnabled, true);
266-
QWebSettings::globalSettings()->enablePersistentStorage("./web/html5");
267-
QWebSettings::globalSettings()->setLocalStoragePath("./web/html5");
268-
QWebSettings::globalSettings()->setOfflineStoragePath("./web/html5");
269-
QWebSettings::globalSettings()->setOfflineWebApplicationCachePath("./web/html5");
270-
#endif
271295
}
272296

273297
void PrintVersion() {

wd_ext_qt.gyp

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@
9797
} , {
9898

9999
'sources': [
100-
'src/webdriver/extension_qt/declarative_item_view_handle.cc',
101100
'src/webdriver/extension_qt/qml_view_creator.cc',
102101
'src/webdriver/extension_qt/qml_view_enumerator.cc',
103102
'src/webdriver/extension_qt/qml_view_executor.cc',
@@ -107,6 +106,31 @@
107106

108107
], # conditions
109108

109+
} , {
110+
'target_name': 'WebDriver_extension_qt_quick_web',
111+
'type': 'static_library',
112+
'standalone_static_library': 1,
113+
114+
'conditions': [
115+
116+
['<(QT5) == 1', {
117+
118+
'sources': [
119+
# TODO: Quick2 support
120+
],
121+
} , {
122+
123+
'sources': [
124+
'src/webdriver/extension_qt/declarative_item_view_handle.cc',
125+
'src/webdriver/extension_qt/qdeclarativewebview.cc',
126+
'src/webdriver/extension_qt/qml_web_view_enumerator.cc',
127+
#'src/webdriver/extension_qt/qml_web_view_executor.cc',
128+
'inc/extension_qt/qdeclarativewebview.h',
129+
'<(INTERMEDIATE_DIR)/moc_qdeclarativewebview.cc',
130+
],
131+
} ],
132+
133+
], # conditions
110134
} , {
111135
'target_name': 'WebDriver_extension_qt_base_shared',
112136
'type': 'shared_library',
@@ -134,6 +158,15 @@
134158
'dependencies': [
135159
'WebDriver_extension_qt_quick',
136160
],
161+
} , {
162+
'target_name': 'WebDriver_extension_qt_quick_web_shared',
163+
'type': 'shared_library',
164+
165+
'product_name': 'WebDriver_extension_qt_quick_web',
166+
167+
'dependencies': [
168+
'WebDriver_extension_qt_quick_web',
169+
],
137170
}
138171
],
139172
}

wd_test.gyp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@
261261
'wd_ext_qt.gyp:WebDriver_extension_qt_base',
262262
'wd_ext_qt.gyp:WebDriver_extension_qt_web',
263263
'wd_ext_qt.gyp:WebDriver_extension_qt_quick',
264+
'wd_ext_qt.gyp:WebDriver_extension_qt_quick_web',
264265
'test_widgets',
265266
],
266267

0 commit comments

Comments
 (0)