Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
PIM
LibKGAPI
Commits
0731d48d
Verified
Commit
0731d48d
authored
Sep 17, 2020
by
Daniel Vrátil
🤖
Browse files
Adapt autotests, CMake
parent
e656592a
Changes
12
Hide whitespace changes
Inline
Side-by-side
autotests/CMakeLists.txt
View file @
0731d48d
...
...
@@ -4,7 +4,7 @@ find_package(Qt5Test CONFIG REQUIRED)
set
(
kgapitest_SRCS
fakeaccountstorage.cpp
fakeauth
widget
.cpp
fakeauth
browser
.cpp
fakenetworkreply.cpp
fakenetworkaccessmanager.cpp
fakenetworkaccessmanagerfactory.cpp
...
...
@@ -24,17 +24,18 @@ set_source_files_properties(
endif
()
add_library
(
kgapitest STATIC
${
kgapitest_SRCS
}
)
target_link_libraries
(
kgapitest Qt5::Core Qt5::Network Qt5::Test KPimGAPICore
)
target_link_libraries
(
kgapitest Qt5::Core Qt5::Network
Qt5::Gui
Qt5::Test KPimGAPICore
)
macro
(
add_libkgapi2_test _module _testname
)
set
(
_extraLibs
${
ARGN
}
)
set
(
testSources
${
_module
}
/
${
_testname
}
.cpp
)
string
(
SUBSTRING
${
_module
}
0 1 moduleFirst
)
string
(
SUBSTRING
${
_module
}
1 -1 moduleLast
)
string
(
TOUPPER
${
moduleFirst
}
moduleFirst
)
string
(
CONCAT moduleName
${
moduleFirst
}
${
moduleLast
}
)
set
(
extraLibs
"KPimGAPI
${
moduleName
}
"
)
set
(
extraLibs
"
${
_extraLibs
}
;
KPimGAPI
${
moduleName
}
"
)
set
(
utilsFile
${
CMAKE_CURRENT_SOURCE_DIR
}
/
${
_module
}
/
${
_module
}
testutils.cpp
)
if
(
EXISTS
${
utilsFile
}
)
list
(
APPEND testSources
${
utilsFile
}
)
...
...
@@ -85,8 +86,8 @@ add_libkgapi2_test(tasks tasklistmodifyjobtest)
add_libkgapi2_test
(
drive aboutfetchjobtest
)
add_libkgapi2_test
(
drive changefetchjobtest
)
add_libkgapi2_test
(
drive filecopyjobtest
)
add_libkgapi2_test
(
drive filecreatejobtest
)
add_libkgapi2_test
(
drive filecopyjobtest
Qt5::Gui
)
add_libkgapi2_test
(
drive filecreatejobtest
Qt5::Gui
)
add_libkgapi2_test
(
drive filesearchquerytest
)
add_libkgapi2_test
(
drive drivescreatejobtest
)
add_libkgapi2_test
(
drive drivesdeletejobtest
)
...
...
autotests/core/accountmanagertest.cpp
View file @
0731d48d
...
...
@@ -11,7 +11,7 @@
#include <QList>
#include "fakeaccountstorage.h"
#include "fakeauth
widget
.h"
#include "fakeauth
browser
.h"
#include "fakenetworkaccessmanagerfactory.h"
#include "fakenetworkaccessmanager.h"
#include "fakenetworkreply.h"
...
...
@@ -68,7 +68,7 @@ private Q_SLOTS:
void
testGetNewAccount
()
{
FakeAuth
WidgetFactory
authFactory
;
FakeAuth
Browser
authBrowser
;
FakeNetworkAccessManagerFactory
::
get
()
->
setScenarios
(
{
scenarioFromFile
(
QFINDTESTDATA
(
"data/accountmanager_part1_request.txt"
),
QFINDTESTDATA
(
"data/accountmanager_part1_response.txt"
),
...
...
@@ -116,7 +116,7 @@ private Q_SLOTS:
void
testMergeAccountScopes
()
{
FakeAuth
WidgetFactory
authFactory
;
FakeAuth
Browser
authBrowser
;
FakeNetworkAccessManagerFactory
::
get
()
->
setScenarios
(
{
scenarioFromFile
(
QFINDTESTDATA
(
"data/accountmanager_part1_request.txt"
),
QFINDTESTDATA
(
"data/accountmanager_part1_response.txt"
),
...
...
@@ -211,7 +211,7 @@ private Q_SLOTS:
void
testRefreshTokens
()
{
FakeAuth
WidgetFactory
authFactory
;
FakeAuth
Browser
authBrowser
;
FakeNetworkAccessManagerFactory
::
get
()
->
setScenarios
(
{
scenarioFromFile
(
QFINDTESTDATA
(
"data/accountmanager_refresh_request.txt"
),
QFINDTESTDATA
(
"data/accountmanager_refresh_response.txt"
),
...
...
autotests/drive/filecopyjobtest.cpp
View file @
0731d48d
...
...
@@ -93,7 +93,7 @@ private Q_SLOTS:
}
};
QTEST_
GUILESS_
MAIN
(
FileCopyJobTest
)
QTEST_MAIN
(
FileCopyJobTest
)
#include "filecopyjobtest.moc"
...
...
autotests/drive/filecreatejobtest.cpp
View file @
0731d48d
...
...
@@ -97,7 +97,7 @@ private Q_SLOTS:
}
};
QTEST_
GUILESS_
MAIN
(
FileCreateJobTest
)
QTEST_MAIN
(
FileCreateJobTest
)
#include "filecreatejobtest.moc"
...
...
autotests/fakeauth
widget
.cpp
→
autotests/fakeauth
browser
.cpp
View file @
0731d48d
...
...
@@ -4,43 +4,27 @@
* SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#include "fakeauthwidget.h"
#include "ui/authwidget_p.h"
#include "fakeauthbrowser.h"
#include <QObject>
#include <QDesktopServices>
#include <QTimer>
#include <QTcpSocket>
#include <QHostAddress>
FakeAuthWidgetFactory
::
FakeAuthWidgetFactory
()
{
sFactory
=
this
;
}
FakeAuthWidgetFactory
::~
FakeAuthWidgetFactory
()
{
sFactory
=
nullptr
;
}
KGAPI2
::
AuthWidget
*
FakeAuthWidgetFactory
::
create
(
QWidget
*
parent
)
{
return
new
FakeAuthWidget
(
parent
);
}
extern
uint16_t
kgapiTcpAuthServerPort
;
// defined in authjob.cpp
class
FakeAuth
Widget
Private
:
public
KGAPI2
::
AuthWidgetPrivate
class
FakeAuth
Browser
::
Private
:
public
QObject
{
Q_OBJECT
public:
FakeAuthWidgetPrivate
(
FakeAuthWidget
*
parent
)
:
KGAPI2
::
AuthWidgetPrivate
(
parent
)
explicit
Private
()
{
s
erverPort
=
42413
;
// random port, but must be stable
kgapiTcpAuthS
erverPort
=
42413
;
}
~
FakeAuthWidgetPrivate
()
override
{}
void
setUrl
(
const
QUrl
&
url
)
override
public
Q_SLOTS
:
void
openUrl
(
const
QUrl
&
url
)
{
Q_UNUSED
(
url
);
...
...
@@ -50,32 +34,27 @@ public:
QTimer
::
singleShot
(
0
,
this
,
[
=
]()
{
QTcpSocket
socket
;
socket
.
connectToHost
(
QHostAddress
::
LocalHost
,
s
erverPort
);
socket
.
connectToHost
(
QHostAddress
::
LocalHost
,
kgapiTcpAuthS
erverPort
);
if
(
!
socket
.
waitForConnected
())
{
qWarning
()
<<
"Failed to connect to internal TCP server!"
;
return
;
}
socket
.
write
(
"GET http://127.0.0.1:424
3
1?code=TheCakeIsALie HTTP/1.1"
);
socket
.
write
(
"GET http://127.0.0.1:4241
3
?code=TheCakeIsALie HTTP/1.1"
);
socket
.
waitForBytesWritten
();
socket
.
close
();
});
}
void
setupUi
()
override
{
// do nothing
}
void
setVisible
(
bool
)
override
{
// do nothing
}
};
FakeAuthBrowser
::
FakeAuthBrowser
()
:
d
(
new
FakeAuthBrowser
::
Private
)
{
QDesktopServices
::
setUrlHandler
(
QStringLiteral
(
"https"
),
d
.
get
(),
"openUrl"
);
}
FakeAuthWidget
::
FakeAuthWidget
(
QWidget
*
parent
)
:
KGAPI2
::
AuthWidget
(
new
FakeAuthWidgetPrivate
(
this
),
parent
)
FakeAuthBrowser
::~
FakeAuthBrowser
()
{
QDesktopServices
::
unsetUrlHandler
(
QStringLiteral
(
"https"
));
}
#include "fakeauth
widget
.moc"
#include "fakeauth
browser
.moc"
autotests/fakeauth
widget
.h
→
autotests/fakeauth
browser
.h
View file @
0731d48d
...
...
@@ -4,26 +4,21 @@
* SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#ifndef KGAPI_FAKEAUTH
WIDGET
_H_
#define KGAPI_FAKEAUTH
WIDGET
_H_
#ifndef KGAPI_FAKEAUTH
BROWSER
_H_
#define KGAPI_FAKEAUTH
BROWSER
_H_
#include "ui/authwidgetfactory_p.h"
#include "ui/authwidget.h"
#include <QScopedPointer>
class
FakeAuth
WidgetFactory
:
public
KGAPI2
::
AuthWidgetFactory
class
FakeAuth
Browser
{
public:
FakeAuthWidgetFactory
();
~
FakeAuth
WidgetFactory
()
override
;
explicit
FakeAuthBrowser
();
~
FakeAuth
Browser
()
;
KGAPI2
::
AuthWidget
*
create
(
QWidget
*
parent
)
override
;
};
class
FakeAuthWidget
:
public
KGAPI2
::
AuthWidget
{
Q_OBJECT
public:
explicit
FakeAuthWidget
(
QWidget
*
parent
);
private:
class
Private
;
QScopedPointer
<
Private
>
const
d
;
friend
class
Private
;
};
#endif
...
...
src/calendar/CMakeLists.txt
View file @
0731d48d
...
...
@@ -52,6 +52,7 @@ target_link_libraries(KPimGAPICalendar
PUBLIC
KPim::GAPICore
KF5::CalendarCore
Qt5::Gui
PRIVATE
Qt5::Network
)
...
...
src/contacts/CMakeLists.txt
View file @
0731d48d
...
...
@@ -47,6 +47,7 @@ target_link_libraries(KPimGAPIContacts
PUBLIC
KPim::GAPICore
KF5::Contacts
Qt5::Gui
PRIVATE
Qt5::Xml
Qt5::Network
...
...
src/core/accountmanager.cpp
View file @
0731d48d
...
...
@@ -84,7 +84,6 @@ public:
account
->
setScopes
(
currentScopes
);
}
AuthJob
*
job
=
new
AuthJob
(
account
,
apiKey
,
apiSecret
);
job
->
setUsername
(
account
->
accountName
());
connect
(
job
,
&
AuthJob
::
finished
,
[
=
]()
{
if
(
job
->
error
()
!=
KGAPI2
::
NoError
)
{
...
...
src/core/authjob.cpp
View file @
0731d48d
...
...
@@ -17,6 +17,7 @@
using
namespace
KGAPI2
;
// Used by fakeauthbrowser in tests
KGAPICORE_EXPORT
uint16_t
kgapiTcpAuthServerPort
=
0
;
class
Q_DECL_HIDDEN
AuthJob
::
Private
...
...
src/drive/CMakeLists.txt
View file @
0731d48d
...
...
@@ -134,6 +134,7 @@ target_include_directories(KPimGAPIDrive INTERFACE "$<INSTALL_INTERFACE:${KDE_IN
target_link_libraries
(
KPimGAPIDrive
PUBLIC
KPim::GAPICore
Qt5::Gui
PRIVATE
Qt5::Network
)
...
...
src/staticmaps/CMakeLists.txt
View file @
0731d48d
...
...
@@ -32,6 +32,7 @@ target_link_libraries(KPimGAPIMaps
PUBLIC
KPim::GAPICore
KF5::Contacts
Qt5::Gui
PRIVATE
Qt5::Network
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment