Skip few Bluetooth autotests on Android emulator
This is to unblock Android-12 emulator deployment on CI which, unlike the earlier emulators, has a bluetooth emulation. This means that the emulator triggers permission confirmation dialogues which would timeout on CI. This commit replaces the1ef066bf7d, which attempted to solve the issue by compile-time configuration. Task-number: QTBUG-106614 Change-Id: Idc155bb8617802054d6ab19993f5417cc254f16e Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> (cherry picked from commit90251f51be) Reviewed-by: Juha Vuolle <juha.vuolle@insta.fi>
This commit is contained in:
parent
a053c1723a
commit
1ac8015041
|
|
@ -1,9 +1,4 @@
|
||||||
if(TARGET Qt::Bluetooth)
|
if(TARGET Qt::Bluetooth)
|
||||||
if(ANDROID)
|
|
||||||
if("$ENV{QTEST_ENVIRONMENT}" STREQUAL "ci")
|
|
||||||
add_compile_definitions(ANDROID_CI_TEST_ENVIRONMENT)
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
add_subdirectory(qbluetoothaddress)
|
add_subdirectory(qbluetoothaddress)
|
||||||
add_subdirectory(qbluetoothdevicediscoveryagent)
|
add_subdirectory(qbluetoothdevicediscoveryagent)
|
||||||
add_subdirectory(qbluetoothdeviceinfo)
|
add_subdirectory(qbluetoothdeviceinfo)
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QLoggingCategory>
|
#include <QLoggingCategory>
|
||||||
|
|
||||||
|
#include "../../shared/bttestutil_p.h"
|
||||||
#include <private/qtbluetoothglobal_p.h>
|
#include <private/qtbluetoothglobal_p.h>
|
||||||
#include <qbluetoothaddress.h>
|
#include <qbluetoothaddress.h>
|
||||||
#include <qbluetoothdevicediscoveryagent.h>
|
#include <qbluetoothdevicediscoveryagent.h>
|
||||||
|
|
@ -153,10 +154,8 @@ void tst_QBluetoothDeviceDiscoveryAgent::deviceDiscoveryDebug(const QBluetoothDe
|
||||||
|
|
||||||
void tst_QBluetoothDeviceDiscoveryAgent::tst_startStopDeviceDiscoveries()
|
void tst_QBluetoothDeviceDiscoveryAgent::tst_startStopDeviceDiscoveries()
|
||||||
{
|
{
|
||||||
#ifdef ANDROID_CI_TEST_ENVIRONMENT
|
if (androidBluetoothEmulator())
|
||||||
if (QNativeInterface::QAndroidApplication::sdkVersion() >= 31)
|
QSKIP("Skipping test on Android 12+ emulator, CI can timeout waiting for user input");
|
||||||
QSKIP("Skipping test on Android 12+, emulator on CI can timeout waiting for user input");
|
|
||||||
#endif
|
|
||||||
QBluetoothDeviceDiscoveryAgent discoveryAgent;
|
QBluetoothDeviceDiscoveryAgent discoveryAgent;
|
||||||
|
|
||||||
QVERIFY(discoveryAgent.error() == discoveryAgent.NoError);
|
QVERIFY(discoveryAgent.error() == discoveryAgent.NoError);
|
||||||
|
|
@ -429,10 +428,9 @@ void tst_QBluetoothDeviceDiscoveryAgent::tst_discoveryTimeout()
|
||||||
|
|
||||||
void tst_QBluetoothDeviceDiscoveryAgent::tst_discoveryMethods()
|
void tst_QBluetoothDeviceDiscoveryAgent::tst_discoveryMethods()
|
||||||
{
|
{
|
||||||
#ifdef ANDROID_CI_TEST_ENVIRONMENT
|
if (androidBluetoothEmulator())
|
||||||
if (QNativeInterface::QAndroidApplication::sdkVersion() >= 31)
|
QSKIP("Skipping test on Android 12+ emulator, CI can timeout waiting for user input");
|
||||||
QSKIP("Skipping test on Android 12+, emulator on CI can timeout waiting for user input");
|
|
||||||
#endif
|
|
||||||
const QBluetoothLocalDevice localDevice;
|
const QBluetoothLocalDevice localDevice;
|
||||||
if (localDevice.allDevices().size() != 1) {
|
if (localDevice.allDevices().size() != 1) {
|
||||||
// On iOS it returns 0 but we still have working BT.
|
// On iOS it returns 0 but we still have working BT.
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
|
#include "../../shared/bttestutil_p.h"
|
||||||
|
|
||||||
#include <private/qtbluetoothglobal_p.h>
|
#include <private/qtbluetoothglobal_p.h>
|
||||||
#include <qbluetoothaddress.h>
|
#include <qbluetoothaddress.h>
|
||||||
|
|
@ -71,12 +72,14 @@ private slots:
|
||||||
private:
|
private:
|
||||||
QBluetoothAddress remoteDevice;
|
QBluetoothAddress remoteDevice;
|
||||||
int numDevices = 0;
|
int numDevices = 0;
|
||||||
bool expectRemoteDevice;
|
bool expectRemoteDevice = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
tst_QBluetoothLocalDevice::tst_QBluetoothLocalDevice()
|
tst_QBluetoothLocalDevice::tst_QBluetoothLocalDevice()
|
||||||
: numDevices(QBluetoothLocalDevice::allDevices().count()), expectRemoteDevice(false)
|
|
||||||
{
|
{
|
||||||
|
if (androidBluetoothEmulator())
|
||||||
|
return;
|
||||||
|
numDevices = QBluetoothLocalDevice::allDevices().size();
|
||||||
const QString remote = qgetenv("BT_TEST_DEVICE");
|
const QString remote = qgetenv("BT_TEST_DEVICE");
|
||||||
if (!remote.isEmpty()) {
|
if (!remote.isEmpty()) {
|
||||||
remoteDevice = QBluetoothAddress(remote);
|
remoteDevice = QBluetoothAddress(remote);
|
||||||
|
|
@ -101,10 +104,8 @@ void tst_QBluetoothLocalDevice::initTestCase()
|
||||||
|
|
||||||
void tst_QBluetoothLocalDevice::tst_powerOn()
|
void tst_QBluetoothLocalDevice::tst_powerOn()
|
||||||
{
|
{
|
||||||
#ifdef ANDROID_CI_TEST_ENVIRONMENT
|
if (androidBluetoothEmulator())
|
||||||
if (QNativeInterface::QAndroidApplication::sdkVersion() >= 31)
|
QSKIP("Skipping test on Android 12+ emulator, CI can timeout waiting for user input");
|
||||||
QSKIP("Skipping test on Android 12+, emulator on CI can timeout waiting for user input");
|
|
||||||
#endif
|
|
||||||
#ifdef Q_OS_OSX
|
#ifdef Q_OS_OSX
|
||||||
QSKIP("Not possible on OS X");
|
QSKIP("Not possible on OS X");
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -141,10 +142,8 @@ void tst_QBluetoothLocalDevice::tst_powerOn()
|
||||||
|
|
||||||
void tst_QBluetoothLocalDevice::tst_powerOff()
|
void tst_QBluetoothLocalDevice::tst_powerOff()
|
||||||
{
|
{
|
||||||
#ifdef ANDROID_CI_TEST_ENVIRONMENT
|
if (androidBluetoothEmulator())
|
||||||
if (QNativeInterface::QAndroidApplication::sdkVersion() >= 31)
|
QSKIP("Skipping test on Android 12+ emulator, CI can timeout waiting for user input");
|
||||||
QSKIP("Skipping test on Android 12+, emulator on CI can timeout waiting for user input");
|
|
||||||
#endif
|
|
||||||
#ifdef Q_OS_OSX
|
#ifdef Q_OS_OSX
|
||||||
QSKIP("Not possible on OS X");
|
QSKIP("Not possible on OS X");
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -199,10 +198,8 @@ void tst_QBluetoothLocalDevice::tst_hostModes_data()
|
||||||
|
|
||||||
void tst_QBluetoothLocalDevice::tst_hostModes()
|
void tst_QBluetoothLocalDevice::tst_hostModes()
|
||||||
{
|
{
|
||||||
#ifdef ANDROID_CI_TEST_ENVIRONMENT
|
if (androidBluetoothEmulator())
|
||||||
if (QNativeInterface::QAndroidApplication::sdkVersion() >= 31)
|
QSKIP("Skipping test on Android 12+ emulator, CI can timeout waiting for user input");
|
||||||
QSKIP("Skipping test on Android 12+, emulator on CI can timeout waiting for user input");
|
|
||||||
#endif
|
|
||||||
#ifdef Q_OS_OSX
|
#ifdef Q_OS_OSX
|
||||||
QSKIP("Not possible on OS X");
|
QSKIP("Not possible on OS X");
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -288,6 +285,8 @@ void tst_QBluetoothLocalDevice::tst_name()
|
||||||
}
|
}
|
||||||
void tst_QBluetoothLocalDevice::tst_isValid()
|
void tst_QBluetoothLocalDevice::tst_isValid()
|
||||||
{
|
{
|
||||||
|
if (androidBluetoothEmulator())
|
||||||
|
QSKIP("Skipping test on Android 12+ emulator, CI can timeout waiting for user input");
|
||||||
#if defined(Q_OS_MACOS) || QT_CONFIG(winrt_bt)
|
#if defined(Q_OS_MACOS) || QT_CONFIG(winrt_bt)
|
||||||
// On OS X we can have a valid device (device.isValid() == true),
|
// On OS X we can have a valid device (device.isValid() == true),
|
||||||
// that has neither a name nor a valid address - this happens
|
// that has neither a name nor a valid address - this happens
|
||||||
|
|
@ -395,10 +394,8 @@ void tst_QBluetoothLocalDevice::tst_pairDevice_data()
|
||||||
|
|
||||||
void tst_QBluetoothLocalDevice::tst_pairDevice()
|
void tst_QBluetoothLocalDevice::tst_pairDevice()
|
||||||
{
|
{
|
||||||
#ifdef ANDROID_CI_TEST_ENVIRONMENT
|
if (androidBluetoothEmulator())
|
||||||
if (QNativeInterface::QAndroidApplication::sdkVersion() >= 31)
|
QSKIP("Skipping test on Android 12+ emulator, CI can timeout waiting for user input");
|
||||||
QSKIP("Skipping test on Android 12+, emulator on CI can timeout waiting for user input");
|
|
||||||
#endif
|
|
||||||
#if defined(Q_OS_MACOS)
|
#if defined(Q_OS_MACOS)
|
||||||
QSKIP("The pair device test fails on macOS");
|
QSKIP("The pair device test fails on macOS");
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
|
#include "../../shared/bttestutil_p.h"
|
||||||
#include <private/qtbluetoothglobal_p.h>
|
#include <private/qtbluetoothglobal_p.h>
|
||||||
#include <qbluetoothserver.h>
|
#include <qbluetoothserver.h>
|
||||||
#include <qbluetoothsocket.h>
|
#include <qbluetoothsocket.h>
|
||||||
|
|
@ -59,7 +60,7 @@ private slots:
|
||||||
void setHostMode(const QBluetoothAddress &localAdapter, QBluetoothLocalDevice::HostMode newHostMode);
|
void setHostMode(const QBluetoothAddress &localAdapter, QBluetoothLocalDevice::HostMode newHostMode);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QBluetoothLocalDevice localDevice;
|
QBluetoothLocalDevice *localDevice = nullptr;
|
||||||
QBluetoothLocalDevice::HostMode initialHostMode;
|
QBluetoothLocalDevice::HostMode initialHostMode;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -107,9 +108,13 @@ void tst_QBluetoothServer::setHostMode(const QBluetoothAddress &localAdapter,
|
||||||
|
|
||||||
void tst_QBluetoothServer::initTestCase()
|
void tst_QBluetoothServer::initTestCase()
|
||||||
{
|
{
|
||||||
|
if (androidBluetoothEmulator())
|
||||||
|
QSKIP("Skipping test on Android 12+ emulator, CI can timeout waiting for user input");
|
||||||
qRegisterMetaType<QBluetooth::SecurityFlags>();
|
qRegisterMetaType<QBluetooth::SecurityFlags>();
|
||||||
qRegisterMetaType<QBluetoothServer::Error>();
|
qRegisterMetaType<QBluetoothServer::Error>();
|
||||||
|
|
||||||
|
localDevice = new QBluetoothLocalDevice(this);
|
||||||
|
|
||||||
QBluetoothLocalDevice device;
|
QBluetoothLocalDevice device;
|
||||||
if (!device.isValid())
|
if (!device.isValid())
|
||||||
return;
|
return;
|
||||||
|
|
@ -122,15 +127,15 @@ void tst_QBluetoothServer::initTestCase()
|
||||||
|
|
||||||
setHostMode(device.address(), QBluetoothLocalDevice::HostConnectable);
|
setHostMode(device.address(), QBluetoothLocalDevice::HostConnectable);
|
||||||
|
|
||||||
QBluetoothLocalDevice::HostMode hostMode= localDevice.hostMode();
|
QBluetoothLocalDevice::HostMode hostMode= localDevice->hostMode();
|
||||||
|
|
||||||
QVERIFY(hostMode != QBluetoothLocalDevice::HostPoweredOff);
|
QVERIFY(hostMode != QBluetoothLocalDevice::HostPoweredOff);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QBluetoothServer::cleanupTestCase()
|
void tst_QBluetoothServer::cleanupTestCase()
|
||||||
{
|
{
|
||||||
QBluetoothLocalDevice device;
|
if (localDevice)
|
||||||
setHostMode(device.address(), initialHostMode);
|
setHostMode(localDevice->address(), initialHostMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QBluetoothServer::tst_construction()
|
void tst_QBluetoothServer::tst_construction()
|
||||||
|
|
@ -169,11 +174,6 @@ void tst_QBluetoothServer::tst_receive()
|
||||||
{
|
{
|
||||||
QFETCH(QBluetoothLocalDevice::HostMode, hostmode);
|
QFETCH(QBluetoothLocalDevice::HostMode, hostmode);
|
||||||
|
|
||||||
#ifdef ANDROID_CI_TEST_ENVIRONMENT
|
|
||||||
if (QNativeInterface::QAndroidApplication::sdkVersion() >= 31)
|
|
||||||
QSKIP("Skipping test on Android 12+, emulator on CI can timeout waiting for user input");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
QBluetoothLocalDevice localDev;
|
QBluetoothLocalDevice localDev;
|
||||||
#ifdef Q_OS_OSX
|
#ifdef Q_OS_OSX
|
||||||
if (localDev.hostMode() == QBluetoothLocalDevice::HostPoweredOff)
|
if (localDev.hostMode() == QBluetoothLocalDevice::HostPoweredOff)
|
||||||
|
|
@ -189,10 +189,10 @@ void tst_QBluetoothServer::tst_receive()
|
||||||
|
|
||||||
if (hostmode == QBluetoothLocalDevice::HostPoweredOff) {
|
if (hostmode == QBluetoothLocalDevice::HostPoweredOff) {
|
||||||
#if !defined(Q_OS_OSX) && !QT_CONFIG(winrt_bt)
|
#if !defined(Q_OS_OSX) && !QT_CONFIG(winrt_bt)
|
||||||
QCOMPARE(localDevice.hostMode(), hostmode);
|
QCOMPARE(localDevice->hostMode(), hostmode);
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
QVERIFY(localDevice.hostMode() != QBluetoothLocalDevice::HostPoweredOff);
|
QVERIFY(localDevice->hostMode() != QBluetoothLocalDevice::HostPoweredOff);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
QBluetoothServer server(QBluetoothServiceInfo::RfcommProtocol);
|
QBluetoothServer server(QBluetoothServiceInfo::RfcommProtocol);
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@
|
||||||
#include <QLoggingCategory>
|
#include <QLoggingCategory>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
|
#include "../../shared/bttestutil_p.h"
|
||||||
|
|
||||||
#include <qbluetoothaddress.h>
|
#include <qbluetoothaddress.h>
|
||||||
#include <qbluetoothdevicediscoveryagent.h>
|
#include <qbluetoothdevicediscoveryagent.h>
|
||||||
|
|
@ -75,7 +76,8 @@ private:
|
||||||
tst_QBluetoothServiceDiscoveryAgent::tst_QBluetoothServiceDiscoveryAgent()
|
tst_QBluetoothServiceDiscoveryAgent::tst_QBluetoothServiceDiscoveryAgent()
|
||||||
{
|
{
|
||||||
QLoggingCategory::setFilterRules(QStringLiteral("qt.bluetooth* = true"));
|
QLoggingCategory::setFilterRules(QStringLiteral("qt.bluetooth* = true"));
|
||||||
|
if (androidBluetoothEmulator())
|
||||||
|
return;
|
||||||
// start Bluetooth if not started
|
// start Bluetooth if not started
|
||||||
#ifndef Q_OS_OSX
|
#ifndef Q_OS_OSX
|
||||||
QBluetoothLocalDevice *device = new QBluetoothLocalDevice();
|
QBluetoothLocalDevice *device = new QBluetoothLocalDevice();
|
||||||
|
|
@ -115,10 +117,9 @@ void tst_QBluetoothServiceDiscoveryAgent::serviceError(const QBluetoothServiceDi
|
||||||
|
|
||||||
void tst_QBluetoothServiceDiscoveryAgent::initTestCase()
|
void tst_QBluetoothServiceDiscoveryAgent::initTestCase()
|
||||||
{
|
{
|
||||||
#ifdef ANDROID_CI_TEST_ENVIRONMENT
|
if (androidBluetoothEmulator())
|
||||||
if (QNativeInterface::QAndroidApplication::sdkVersion() >= 31)
|
QSKIP("Skipping test on Android 12+ emulator, CI can timeout waiting for user input");
|
||||||
QSKIP("Skipping test on Android 12+, emulator on CI can timeout waiting for user input");
|
|
||||||
#endif
|
|
||||||
if (localDeviceAvailable) {
|
if (localDeviceAvailable) {
|
||||||
QBluetoothDeviceDiscoveryAgent discoveryAgent;
|
QBluetoothDeviceDiscoveryAgent discoveryAgent;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,48 @@
|
||||||
|
// Copyright (C) 2022 The Qt Company Ltd.
|
||||||
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
||||||
|
|
||||||
|
#ifndef BTTESTUTIL_P_H
|
||||||
|
#define BTTESTUTIL_P_H
|
||||||
|
|
||||||
|
//
|
||||||
|
// W A R N I N G
|
||||||
|
// -------------
|
||||||
|
//
|
||||||
|
// This file is not part of the Qt API. It exists purely as an
|
||||||
|
// implementation detail. This header file may change from version to
|
||||||
|
// version without notice, or even be removed.
|
||||||
|
//
|
||||||
|
// We mean it.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include <QtCore/qcoreapplication.h>
|
||||||
|
|
||||||
|
#ifdef Q_OS_ANDROID
|
||||||
|
#include <QtCore/QJniObject>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
bool androidBluetoothEmulator()
|
||||||
|
{
|
||||||
|
#ifdef Q_OS_ANDROID
|
||||||
|
// QTBUG-106614, the Android-12+ emulator (API level 31+) emulates bluetooth.
|
||||||
|
// We need to skip tests on the CI to avoid timeouts when Android waits for bluetooth
|
||||||
|
// permission confirmation from the user. Currently the check below skips generally
|
||||||
|
// on emulator though, not only on CI
|
||||||
|
if (QNativeInterface::QAndroidApplication::sdkVersion() >= 31) {
|
||||||
|
const auto property = QJniObject::fromString("ro.kernel.qemu");
|
||||||
|
const auto isQemu = QJniObject::callStaticObjectMethod(
|
||||||
|
"android.os.SystemProperties", "get",
|
||||||
|
"(Ljava/lang/String;)Ljava/lang/String;",
|
||||||
|
property.object<jstring>());
|
||||||
|
if (isQemu.toString() == "1")
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
#endif // BTTESTUTIL_P_H
|
||||||
Loading…
Reference in New Issue