From f248beba9fd967c44bb52e06c392a17c72dcd84d Mon Sep 17 00:00:00 2001 From: NissimHadar Date: Sun, 27 Jan 2019 23:43:07 -0800 Subject: [PATCH] Added device description + running Interface. --- tools/nitpick/src/Nitpick.cpp | 5 +++ tools/nitpick/src/Nitpick.h | 1 + tools/nitpick/src/TestRunnerMobile.cpp | 46 ++++++++++++++++++++------ tools/nitpick/src/TestRunnerMobile.h | 5 +++ tools/nitpick/ui/Nitpick.ui | 22 ++++++++++-- 5 files changed, 65 insertions(+), 14 deletions(-) diff --git a/tools/nitpick/src/Nitpick.cpp b/tools/nitpick/src/Nitpick.cpp index 9e385bcd4d..78ed0ca0af 100644 --- a/tools/nitpick/src/Nitpick.cpp +++ b/tools/nitpick/src/Nitpick.cpp @@ -113,6 +113,7 @@ void Nitpick::setup() { _ui.folderLineEdit, _ui.downloadAPKPushbutton, _ui.installAPKPushbutton, + _ui.runInterfacePushbutton, _ui.runLatestOnMobileCheckBox, _ui.urlOnMobileLineEdit, _ui.statusLabelOnMobile @@ -367,6 +368,10 @@ void Nitpick::on_installAPKPushbutton_clicked() { _testRunnerMobile->installAPK(); } +void Nitpick::on_runInterfacePushbutton_clicked() { + _testRunnerMobile->runInterface(); +} + void Nitpick::on_pullFolderPushbutton_clicked() { _testRunnerMobile->pullFolder(); } diff --git a/tools/nitpick/src/Nitpick.h b/tools/nitpick/src/Nitpick.h index 00516d1e76..29726be3bd 100644 --- a/tools/nitpick/src/Nitpick.h +++ b/tools/nitpick/src/Nitpick.h @@ -101,6 +101,7 @@ private slots: void on_downloadAPKPushbutton_clicked(); void on_installAPKPushbutton_clicked(); + void on_runInterfacePushbutton_clicked(); void on_pullFolderPushbutton_clicked(); diff --git a/tools/nitpick/src/TestRunnerMobile.cpp b/tools/nitpick/src/TestRunnerMobile.cpp index e7191dcfad..10216f248c 100644 --- a/tools/nitpick/src/TestRunnerMobile.cpp +++ b/tools/nitpick/src/TestRunnerMobile.cpp @@ -24,6 +24,7 @@ TestRunnerMobile::TestRunnerMobile( QLineEdit *folderLineEdit, QPushButton* downloadAPKPushbutton, QPushButton* installAPKPushbutton, + QPushButton* runInterfacePushbutton, QCheckBox* runLatest, QLineEdit* url, QLabel* statusLabel, @@ -38,22 +39,16 @@ TestRunnerMobile::TestRunnerMobile( _folderLineEdit = folderLineEdit; _downloadAPKPushbutton = downloadAPKPushbutton; _installAPKPushbutton = installAPKPushbutton; + _runInterfacePushbutton = runInterfacePushbutton; _runLatest = runLatest; _url = url; _statusLabel = statusLabel; folderLineEdit->setText("/sdcard/DCIM/TEST"); -} -TestRunnerMobile::~TestRunnerMobile() { -} + modelNames["SM_G955U1"] = "Samsung S8+ unlocked"; -void TestRunnerMobile::setWorkingFolderAndEnableControls() { - setWorkingFolder(_workingFolderLabel); - - _connectDeviceButton->setEnabled(true); - - // Find ADB (Android Debugging Bridge) before continuing + // Find ADB (Android Debugging Bridge) #ifdef Q_OS_WIN if (QProcessEnvironment::systemEnvironment().contains("ADB_PATH")) { QString adbExePath = QProcessEnvironment::systemEnvironment().value("ADB_PATH") + "/platform-tools"; @@ -78,10 +73,19 @@ void TestRunnerMobile::setWorkingFolderAndEnableControls() { #endif } +TestRunnerMobile::~TestRunnerMobile() { +} + +void TestRunnerMobile::setWorkingFolderAndEnableControls() { + setWorkingFolder(_workingFolderLabel); + + _connectDeviceButton->setEnabled(true); +} + void TestRunnerMobile::connectDevice() { #if defined Q_OS_WIN || defined Q_OS_MAC QString devicesFullFilename{ _workingFolder + "/devices.txt" }; - QString command = _adbCommand + " devices > " + devicesFullFilename; + QString command = _adbCommand + " devices -l > " + devicesFullFilename; system(command.toStdString().c_str()); if (!QFile::exists(devicesFullFilename)) { @@ -103,7 +107,17 @@ void TestRunnerMobile::connectDevice() { QMessageBox::critical(0, "Too many devices detected", "Tests will run only if a single device is attached"); } else { - _detectedDeviceLabel->setText(line2.remove(DEVICE)); + // Line looks like this: 988a1b47335239434b device product:dream2qlteue model:SM_G955U1 device:dream2qlteue transport_id:2 + QStringList tokens = line2.split(QRegExp("[\r\n\t ]+")); + QString deviceID = tokens[0]; + + QString modelID = tokens[3].split(':')[1]; + QString modelName = "UKNOWN"; + if (modelNames.count(modelID) == 1) { + modelName = modelNames[modelID]; + } + + _detectedDeviceLabel->setText(modelName + " [" + deviceID + "]"); _pullFolderButton->setEnabled(true); _folderLineEdit->setEnabled(true); _downloadAPKPushbutton->setEnabled(true); @@ -159,6 +173,16 @@ void TestRunnerMobile::installAPK() { QString command = _adbCommand + " install -r -d " + _workingFolder + "/" + _installerFilename + " >" + _workingFolder + "/installOutput.txt"; system(command.toStdString().c_str()); _statusLabel->setText("Installation complete"); + _runInterfacePushbutton->setEnabled(true); +#endif +} + +void TestRunnerMobile::runInterface() { +#if defined Q_OS_WIN || defined Q_OS_MAC + _statusLabel->setText("Starting Interface"); + QString command = _adbCommand + " shell monkey -p io.highfidelity.hifiinterface -v 1"; + system(command.toStdString().c_str()); + _statusLabel->setText("Interface started"); #endif } diff --git a/tools/nitpick/src/TestRunnerMobile.h b/tools/nitpick/src/TestRunnerMobile.h index 4cf31f6bd4..247f864976 100644 --- a/tools/nitpick/src/TestRunnerMobile.h +++ b/tools/nitpick/src/TestRunnerMobile.h @@ -11,6 +11,7 @@ #ifndef hifi_testRunnerMobile_h #define hifi_testRunnerMobile_h +#include #include #include #include @@ -28,6 +29,7 @@ public: QLineEdit *folderLineEdit, QPushButton* downloadAPKPushbutton, QPushButton* installAPKPushbutton, + QPushButton* runInterfacePushbutton, QCheckBox* runLatest, QLineEdit* url, QLabel* statusLabel, @@ -41,6 +43,7 @@ public: void downloadComplete(); void downloadAPK(); + void runInterface(); void installAPK(); @@ -53,6 +56,7 @@ private: QLineEdit* _folderLineEdit; QPushButton* _downloadAPKPushbutton; QPushButton* _installAPKPushbutton; + QPushButton* _runInterfacePushbutton; #ifdef Q_OS_WIN const QString _adbExe{ "adb.exe" }; @@ -65,5 +69,6 @@ private: QString _adbCommand; + std::map modelNames; }; #endif diff --git a/tools/nitpick/ui/Nitpick.ui b/tools/nitpick/ui/Nitpick.ui index 8d69317369..319452233f 100644 --- a/tools/nitpick/ui/Nitpick.ui +++ b/tools/nitpick/ui/Nitpick.ui @@ -43,7 +43,7 @@ - 0 + 3 @@ -613,7 +613,7 @@ 460 - 350 + 410 160 30 @@ -629,7 +629,7 @@ 10 - 350 + 410 440 30 @@ -725,6 +725,22 @@ Install APK + + + false + + + + 10 + 300 + 160 + 30 + + + + Run Interface + +