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#endif
28
29#ifdef QT_WIDGETS_LIB
30#include <QtWidgets/QWidget>
31#endif
32
33#ifdef QT_NETWORK_LIB
34#if QT_CONFIG(ssl)
35#include <QtCore/qoperatingsystemversion.h>
36#include <QtCore/qsystemdetection.h>
37#include <QtNetwork/qsslsocket.h>
38#endif // QT_CONFIG(ssl)
39#endif // QT_NETWORK_LIB
40
41QT_BEGIN_NAMESPACE
42
43namespace QTestPrivate {
44
45static inline bool canHandleUnicodeFileNames()
46{
47#if defined(Q_OS_WIN)
48 return true;
49#else
50 // Check for UTF-8 by converting the Euro symbol (see tst_utf8)
51 return QFile::encodeName(QString(QChar(0x20AC))) == QByteArrayLiteral("\342\202\254");
52#endif
53}
54
55#ifdef QT_WIDGETS_LIB
56static inline void centerOnScreen(QWidget *w, const QSize &size)
57{
58 const QPoint offset = QPoint(size.width() / 2, size.height() / 2);
60}
61
62static inline void centerOnScreen(QWidget *w)
63{
65}
66
67/*! \internal
68
69 Make a widget frameless to prevent size constraints of title bars from interfering (Windows).
70*/
71static inline void setFrameless(QWidget *w)
72{
78}
79
80static inline void androidCompatibleShow(QWidget *widget)
81{
82 // On Android QWidget::show() shows the widget maximized, so if we need
83 // to move or resize the widget, we need to explicitly call
84 // QWidget::setVisible(true) instead, because that's what show() actually
85 // does on desktop platforms.
86#ifdef Q_OS_ANDROID
87 widget->setVisible(true);
88#else
89 widget->show();
90#endif
91}
92#endif // QT_WIDGETS_LIB
93
94#ifdef QT_NETWORK_LIB
96{
97#ifdef Q_OS_MACOS
98#if QT_CONFIG(ssl)
99 if (QSslSocket::activeBackend() == QLatin1String("securetransport")) {
100#if QT_MACOS_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(150000, 180000)
101 // Starting from macOS 15 our temporary keychain is ignored.
102 // We have to use kSecImportToMemoryOnly/kCFBooleanTrue key/value
103 // instead. This way we don't have to use QT_SSL_USE_TEMPORARY_KEYCHAIN anymore.
104 return false;
105#else
107 // We were built with SDK below 15, and running on/above 15, but file-based
108 // keychains are not working anymore on macOS 15, blocking the test execution.
109 return true;
110 }
111#endif // Platform SDK.
112 }
113#endif // QT_CONFIG(ssl)
114#endif // Q_OS_MACOS
115 return false;
116}
117#endif // QT_NETWORK_LIB
118
119} // namespace QTestPrivate
120
121QT_END_NAMESPACE
122
123#endif // QTESTHELPERS_P_H
static bool canHandleUnicodeFileNames()