Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qtestutil_macos.mm
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
#
include
"qtestutil_macos_p.h"
5
6
#
include
"QtCore/private/qcore_mac_p.h"
7
8
#
import
<
AppKit
/
AppKit
.
h
>
9
10
QT_BEGIN_NAMESPACE
11
12
namespace
QTestPrivate
{
13
14
/*! \internal
15
16
Disables restoration of previously saved window state. This causes tests
17
to start with a clean slate and prevents the "previous restore failed"
18
dialog from showing if there was a test crash.
19
*/
20
void
disableWindowRestore
()
21
{
22
[NSUserDefaults.standardUserDefaults registerDefaults:@{
23
@
"ApplePersistenceIgnoreState"
: @YES
24
}];
25
}
26
27
bool
macCrashReporterWillShowDialog
()
28
{
29
auto
dialogType = QCFType<CFStringRef>(CFPreferencesCopyAppValue(
30
CFSTR(
"DialogType"
), CFSTR(
"com.apple.CrashReporter"
)));
31
32
auto
stringCompare = [](CFStringRef str1, CFStringRef str2) ->
bool
{
33
return
CFStringCompare(str1, str2, kCFCompareCaseInsensitive) == kCFCompareEqualTo;
34
};
35
36
if
(!dialogType || stringCompare(dialogType, CFSTR(
"basic"
))) {
37
// The default (basic) dialog type only shows up if the
38
// application is 'user visible', as indicated by the
39
// activation policy.
40
auto
*runningApp = NSRunningApplication.currentApplication;
41
return
runningApp && runningApp.activationPolicy == NSApplicationActivationPolicyRegular;
42
}
else
if
(stringCompare(dialogType, CFSTR(
"developer"
))
43
|| stringCompare(dialogType, CFSTR(
"crashreport"
))) {
44
// While in developer mode the dialog will show for all
45
// crashed applications, including backgrounded ones.
46
return
true
;
47
}
else
{
48
// Finally, 'server' or 'none' will result in no dialog
49
return
false
;
50
}
51
}
52
53
/*! \internal
54
\class AppNapDisabler
55
\brief Disables App Nap by registering a background activity.
56
57
App Nap remains disabled as long as the AppNapDisabler instance
58
exists.
59
*/
60
61
/*! \internal
62
Creates an AppNapDisabler instance and starts a NSActivityBackground activity.
63
*/
64
AppNapDisabler
::
AppNapDisabler
()
65
{
66
m_activity = [[NSProcessInfo processInfo] beginActivityWithOptions:NSActivityBackground
67
reason:@
"Qt Auto Test"
];
68
[m_activity retain];
69
}
70
71
/*! \internal
72
Destroys the AppNapDisabler instance and ends the NSActivityBackground activity.
73
*/
74
AppNapDisabler
::~
AppNapDisabler
()
75
{
76
[[NSProcessInfo processInfo] endActivity:m_activity];
77
[m_activity release];
78
}
79
}
80
81
QT_END_NAMESPACE
QTestPrivate::AppNapDisabler
Disables App Nap by registering a background activity.
Definition
qtestutil_macos_p.h:28
QTestPrivate::AppNapDisabler::AppNapDisabler
AppNapDisabler()
Definition
qtestutil_macos.mm:64
QTestPrivate::AppNapDisabler::~AppNapDisabler
~AppNapDisabler()
Definition
qtestutil_macos.mm:74
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
QTestPrivate
Definition
qabstractitemmodeltester.h:29
QTestPrivate::disableWindowRestore
void disableWindowRestore()
Definition
qtestutil_macos.mm:20
QTestPrivate::macCrashReporterWillShowDialog
bool macCrashReporterWillShowDialog()
Definition
qtestutil_macos.mm:27
qtbase
src
testlib
qtestutil_macos.mm
Generated on
for Qt by
1.18.0