forked from qt-creator/qt-creator
Android: Create a test for AndroidSdkManager's parseProgress
Quick and dirty as plugin test. Depending on how the upcoming SdkManager parsing tests turn out, these could become standalone tests. Launch qtcreator with command line option "-test Android" Change-Id: I66c1604a1df96d8c2c50006052d664d4a339f5ff Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
This commit is contained in:
@@ -43,6 +43,12 @@ class AndroidPlugin final : public ExtensionSystem::IPlugin
|
||||
void askUserAboutAndroidSetup();
|
||||
|
||||
class AndroidPluginPrivate *d = nullptr;
|
||||
|
||||
#ifdef WITH_TESTS
|
||||
private slots:
|
||||
void testAndroidSdkManagerProgressParser_data();
|
||||
void testAndroidSdkManagerProgressParser();
|
||||
#endif // WITH_TESTS
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
@@ -41,6 +41,11 @@
|
||||
#include <QRegularExpression>
|
||||
#include <QSettings>
|
||||
|
||||
#ifdef WITH_TESTS
|
||||
# include <QTest>
|
||||
# include "androidplugin.h"
|
||||
#endif // WITH_TESTS
|
||||
|
||||
namespace {
|
||||
static Q_LOGGING_CATEGORY(sdkManagerLog, "qtc.android.sdkManager", QtWarningMsg)
|
||||
}
|
||||
@@ -1152,5 +1157,54 @@ void AndroidSdkManagerPrivate::clearPackages()
|
||||
m_allPackages.clear();
|
||||
}
|
||||
|
||||
#ifdef WITH_TESTS
|
||||
void AndroidPlugin::testAndroidSdkManagerProgressParser_data()
|
||||
{
|
||||
QTest::addColumn<QString>("output");
|
||||
QTest::addColumn<int>("progress");
|
||||
QTest::addColumn<bool>("foundAssertion");
|
||||
|
||||
// Output of "sdkmanager --licenses", Android SDK Tools version 4.0
|
||||
QTest::newRow("Loading local repository")
|
||||
<< "Loading local repository... \r"
|
||||
<< -1
|
||||
<< false;
|
||||
|
||||
QTest::newRow("Fetch progress (single line)")
|
||||
<< "[============= ] 34% Fetch remote repository... \r"
|
||||
<< 34
|
||||
<< false;
|
||||
|
||||
QTest::newRow("Fetch progress (multi line)")
|
||||
<< "[============================= ] 73% Fetch remote repository... \r"
|
||||
"[============================= ] 75% Fetch remote repository... \r"
|
||||
<< 75
|
||||
<< false;
|
||||
|
||||
QTest::newRow("Some SDK package licenses not accepted")
|
||||
<< "7 of 7 SDK package licenses not accepted.\n"
|
||||
<< -1
|
||||
<< false;
|
||||
|
||||
QTest::newRow("Unaccepted licenses assertion")
|
||||
<< "\nReview licenses that have not been accepted (y/N)? "
|
||||
<< -1
|
||||
<< true;
|
||||
}
|
||||
|
||||
void AndroidPlugin::testAndroidSdkManagerProgressParser()
|
||||
{
|
||||
QFETCH(QString, output);
|
||||
QFETCH(int, progress);
|
||||
QFETCH(bool, foundAssertion);
|
||||
|
||||
bool actualFoundAssertion = false;
|
||||
const int actualProgress = parseProgress(output, actualFoundAssertion);
|
||||
|
||||
QCOMPARE(progress, actualProgress);
|
||||
QCOMPARE(foundAssertion, actualFoundAssertion);
|
||||
}
|
||||
#endif // WITH_TESTS
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Android
|
||||
|
||||
Reference in New Issue
Block a user