Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qtesthelpers_p.h
Go to the documentation of this file.
1
// Copyright (C) 2017 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4
#
ifndef
QTESTHELPERS_P_H
5
#
define
QTESTHELPERS_P_H
6
7
//
8
// W A R N I N G
9
// -------------
10
//
11
// This file is not part of the Qt API. It exists purely as an
12
// implementation detail. This header file may change from version to
13
// version without notice, or even be removed.
14
//
15
// We mean it.
16
//
17
18
#
include
<
QtCore
/
QFile
>
19
#
include
<
QtCore
/
QString
>
20
#
include
<
QtCore
/
QChar
>
21
#
include
<
QtCore
/
QPoint
>
22
#
include
<
QtCore
/
private
/
qglobal_p
.
h
>
23
24
#
ifdef
QT_GUI_LIB
25
#
include
<
QtGui
/
QGuiApplication
>
26
#
include
<
QtGui
/
QScreen
>
27
#
include
<
QtGui
/
QWindow
>
28
#
endif
29
30
#
ifdef
QT_WIDGETS_LIB
31
#
include
<
QtWidgets
/
QWidget
>
32
#
endif
33
34
#
ifdef
QT_NETWORK_LIB
35
#
if
QT_CONFIG
(
ssl
)
36
#
include
<
QtCore
/
qoperatingsystemversion
.
h
>
37
#
include
<
QtCore
/
qsystemdetection
.
h
>
38
#
include
<
QtNetwork
/
qsslsocket
.
h
>
39
#
endif
// QT_CONFIG(ssl)
40
#
endif
// QT_NETWORK_LIB
41
42
QT_BEGIN_NAMESPACE
43
44
namespace
QTestPrivate
{
45
46
static
inline
bool
canHandleUnicodeFileNames
()
47
{
48
#
if
defined
(
Q_OS_WIN
)
49
return
true
;
50
#
else
51
// Check for UTF-8 by converting the Euro symbol (see tst_utf8)
52
return
QFile::encodeName(QString(QChar(0x20AC))) == QByteArrayLiteral(
"\342\202\254"
);
53
#
endif
54
}
55
56
#
ifdef
QT_WIDGETS_LIB
57
static
inline
void
centerOnScreen
(
QWidget
*
w
,
const
QSize
&
size
)
58
{
59
const
QPoint
offset
=
QPoint
(
size
.
width
() / 2,
size
.
height
() / 2);
60
w
->
move
(
QGuiApplication
::
primaryScreen
()->
availableGeometry
().
center
() -
offset
);
61
}
62
63
static
inline
void
centerOnScreen
(
QWidget
*
w
)
64
{
65
centerOnScreen
(
w
,
w
->
geometry
().
size
());
66
}
67
68
/*! \internal
69
70
Make a widget frameless to prevent size constraints of title bars from interfering (Windows).
71
*/
72
static
inline
void
setFrameless
(
QWidget
*
w
)
73
{
74
Qt
::
WindowFlags
flags
=
w
->
windowFlags
();
75
flags
|=
Qt
::
FramelessWindowHint
;
76
flags
&= ~(
Qt
::
WindowTitleHint
|
Qt
::
WindowSystemMenuHint
77
|
Qt
::
WindowMinMaxButtonsHint
|
Qt
::
WindowCloseButtonHint
);
78
w
->
setWindowFlags
(
flags
);
79
}
80
81
static
inline
void
androidCompatibleShow
(
QWidget
*
widget
)
82
{
83
// On Android QWidget::show() shows the widget maximized, so if we need
84
// to move or resize the widget, we need to explicitly call
85
// QWidget::setVisible(true) instead, because that's what show() actually
86
// does on desktop platforms.
87
#
ifdef
Q_OS_ANDROID
88
widget
->
setVisible
(
true
);
89
#
else
90
widget
->
show
();
91
#
endif
92
}
93
#
endif
// QT_WIDGETS_LIB
94
95
#
ifdef
QT_GUI_LIB
96
bool
ensurePositionTopLeft
(
QWindow
*
window
)
97
{
98
const
QPoint
availableTopLeft
=
QGuiApplication
::
primaryScreen
()->
availableGeometry
().
topLeft
();
99
window
->
setFramePosition
(
availableTopLeft
);
100
#
ifdef
Q_OS_ANDROID
101
return
true
;
// Android QPA handles the position change synchronously
102
#
endif
103
bool
positionCorrect
=
true
;
104
105
if
(!
window
->
flags
().
testFlag
(
Qt
::
FramelessWindowHint
))
106
positionCorrect
=
QTest
::
qWaitFor
([&]{
return
window
->
framePosition
() !=
window
->
position
() ;});
107
108
const
bool
positionUpdated
=
QTest
::
qWaitFor
([&]{
return
window
->
framePosition
() ==
availableTopLeft
;});
109
if
(!
positionUpdated
)
110
positionCorrect
=
false
;
111
112
return
positionCorrect
;
113
}
114
#
endif
115
116
#
ifdef
QT_NETWORK_LIB
117
inline
bool
isSecureTransportBlockingTest
()
118
{
119
#
ifdef
Q_OS_MACOS
120
#
if
QT_CONFIG
(
ssl
)
121
if
(
QSslSocket
::
activeBackend
() ==
QLatin1String
(
"securetransport"
)) {
122
#
if
QT_MACOS_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE
(
150000
,
180000
)
123
// Starting from macOS 15 our temporary keychain is ignored.
124
// We have to use kSecImportToMemoryOnly/kCFBooleanTrue key/value
125
// instead. This way we don't have to use QT_SSL_USE_TEMPORARY_KEYCHAIN anymore.
126
return
false
;
127
#
else
128
if
(
QOperatingSystemVersion
::
current
() >=
QOperatingSystemVersion
::
MacOSSequoia
) {
129
// We were built with SDK below 15, and running on/above 15, but file-based
130
// keychains are not working anymore on macOS 15, blocking the test execution.
131
return
true
;
132
}
133
#
endif
// Platform SDK.
134
}
135
#
endif
// QT_CONFIG(ssl)
136
#
endif
// Q_OS_MACOS
137
return
false
;
138
}
139
#
endif
// QT_NETWORK_LIB
140
141
}
// namespace QTestPrivate
142
143
QT_END_NAMESPACE
144
145
#
endif
// QTESTHELPERS_P_H
QTestPrivate
Definition
qabstractitemmodeltester.h:29
QTestPrivate::canHandleUnicodeFileNames
static bool canHandleUnicodeFileNames()
Definition
qtesthelpers_p.h:46
qtbase
src
testlib
qtesthelpers_p.h
Generated on
for Qt by
1.14.0