2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2021 The Qt Company Ltd.
|
2022-12-21 10:12:09 +01:00
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
2021-05-06 15:19:56 +02:00
|
|
|
|
|
|
|
|
#include "avdmanageroutputparser.h"
|
|
|
|
|
|
|
|
|
|
#include <QtTest>
|
|
|
|
|
|
|
|
|
|
using namespace Android;
|
|
|
|
|
using namespace Android::Internal;
|
|
|
|
|
|
|
|
|
|
class tst_AvdManagerOutputParser : public QObject
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
|
void parse_data();
|
|
|
|
|
void parse();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
void tst_AvdManagerOutputParser::parse_data()
|
|
|
|
|
{
|
|
|
|
|
QTest::addColumn<QString>("input");
|
|
|
|
|
QTest::addColumn<AndroidDeviceInfoList>("output");
|
2022-11-25 19:43:34 +01:00
|
|
|
QTest::addColumn<Utils::FilePaths>("errorPaths");
|
2021-05-06 15:19:56 +02:00
|
|
|
|
2021-05-07 11:17:29 +02:00
|
|
|
QTest::newRow("none") << "Available Android Virtual Devices:\n"
|
2022-11-25 19:43:34 +01:00
|
|
|
<< AndroidDeviceInfoList() << Utils::FilePaths();
|
2021-05-07 11:17:29 +02:00
|
|
|
|
2021-05-06 15:19:56 +02:00
|
|
|
QTest::newRow("one") << "Available Android Virtual Devices:\n"
|
|
|
|
|
" Name: Test\n"
|
|
|
|
|
" Device: Galaxy Nexus (Google)\n"
|
2022-08-08 09:21:46 +02:00
|
|
|
" Path: :/Test.avd\n"
|
2021-05-06 15:19:56 +02:00
|
|
|
" Target: Google APIs (Google Inc.)\n"
|
|
|
|
|
" Based on: Android API 30 Tag/ABI: google_apis/x86\n"
|
|
|
|
|
" Sdcard: 512 MB\n"
|
|
|
|
|
<< AndroidDeviceInfoList({{"",
|
|
|
|
|
"Test",
|
|
|
|
|
{"x86"},
|
|
|
|
|
-1,
|
2021-10-06 22:35:12 +03:00
|
|
|
IDevice::DeviceConnected,
|
2021-10-13 21:16:47 +03:00
|
|
|
IDevice::Emulator,
|
2022-08-08 09:21:46 +02:00
|
|
|
Utils::FilePath::fromString(":/Test.avd")}})
|
2022-11-25 19:43:34 +01:00
|
|
|
<< Utils::FilePaths();
|
2021-05-06 15:19:56 +02:00
|
|
|
|
|
|
|
|
QTest::newRow("two") << "Available Android Virtual Devices:\n"
|
|
|
|
|
" Name: Test\n"
|
|
|
|
|
" Device: Galaxy Nexus (Google)\n"
|
2022-08-08 09:21:46 +02:00
|
|
|
" Path: :/Test.avd\n"
|
2021-05-06 15:19:56 +02:00
|
|
|
" Target: Google APIs (Google Inc.)\n"
|
|
|
|
|
" Based on: Android API 30 Tag/ABI: google_apis/x86\n"
|
|
|
|
|
" Sdcard: 512 MB\n"
|
|
|
|
|
"---------\n"
|
|
|
|
|
" Name: TestTablet\n"
|
|
|
|
|
" Device: 7in WSVGA (Tablet) (Generic)\n"
|
2022-08-08 09:21:46 +02:00
|
|
|
" Path: :/TestTablet.avd\n"
|
2021-05-06 15:19:56 +02:00
|
|
|
" Target: Google APIs (Google Inc.)\n"
|
|
|
|
|
" Based on: Android API 30 Tag/ABI: google_apis/x86\n"
|
|
|
|
|
" Sdcard: 256 MB\n"
|
|
|
|
|
<< AndroidDeviceInfoList({{"",
|
|
|
|
|
"Test",
|
|
|
|
|
{"x86"},
|
|
|
|
|
-1,
|
2021-10-06 22:35:12 +03:00
|
|
|
IDevice::DeviceConnected,
|
2021-10-13 21:16:47 +03:00
|
|
|
IDevice::Emulator,
|
2022-08-08 09:21:46 +02:00
|
|
|
Utils::FilePath::fromString(":/Test.avd")},
|
2021-05-06 15:19:56 +02:00
|
|
|
{"",
|
|
|
|
|
"TestTablet",
|
|
|
|
|
{"x86"},
|
|
|
|
|
-1,
|
2021-10-06 22:35:12 +03:00
|
|
|
IDevice::DeviceConnected,
|
2021-10-13 21:16:47 +03:00
|
|
|
IDevice::Emulator,
|
2022-08-08 09:21:46 +02:00
|
|
|
Utils::FilePath::fromString(":/TestTablet.avd")}}
|
2021-10-13 21:16:47 +03:00
|
|
|
)
|
2022-11-25 19:43:34 +01:00
|
|
|
<< Utils::FilePaths();
|
2021-05-06 15:19:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void tst_AvdManagerOutputParser::parse()
|
|
|
|
|
{
|
|
|
|
|
QFETCH(QString, input);
|
|
|
|
|
QFETCH(AndroidDeviceInfoList, output);
|
2022-11-25 19:43:34 +01:00
|
|
|
QFETCH(Utils::FilePaths, errorPaths);
|
2021-05-06 15:19:56 +02:00
|
|
|
|
2022-11-25 19:43:34 +01:00
|
|
|
Utils::FilePaths avdErrorPaths;
|
2021-05-06 15:19:56 +02:00
|
|
|
const auto result = parseAvdList(input, &avdErrorPaths);
|
|
|
|
|
QCOMPARE(result, output);
|
|
|
|
|
QCOMPARE(avdErrorPaths, errorPaths);
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-10 12:21:30 +02:00
|
|
|
QTEST_GUILESS_MAIN(tst_AvdManagerOutputParser)
|
2021-05-06 15:19:56 +02:00
|
|
|
|
|
|
|
|
#include "tst_avdmanageroutputparser.moc"
|