1
0
forked from BRT/arc
arc/automation_script/Script.h
2025-04-27 18:35:22 +04:00

112 lines
3.6 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// Created by Misterio on 24.04.2025.
//
#ifndef SCRIPT_H
#define SCRIPT_H
#include <vector>
#include <string>
#include "AdbUtils.h"
#include "XmlParser.h"
#include "auto_payment/UiElement.h"
#include <QObject>
#include <QThread>
class Script final : public QObject {
Q_OBJECT
public:
explicit Script(QObject *parent = nullptr);
~Script() override;
public slots:
void start(); // Старт фоновой работы
void stop(); // Стоп фоновой работы
signals:
void finished(); // Сигнал о завершении работы
private:
bool m_running = true;
// // Функция для запуска скрипта с передачей параметров
// void runScript(const QString &pin, const QString &last4digits);
//
// // Функции для определения различных экранов и действий
//
// // Проверка, что перед нами экран логина
// bool isLoginScreen(const QList<UiElement> &ui);
//
// // Проверка, что перед нами экран ввода ПИН
// bool isPinScreen(const QList<UiElement> &ui);
//
// // Получение списка кнопок с цифрами для ввода ПИН
// std::vector<UiElement> getPinButtons(const QList<UiElement> &ui);
//
// // Тап по элементу с текстом
// void tapByText(const QList<UiElement> &ui, const QString &text);
//
// // Тап по полю ввода
// void tapInputField(const QList<UiElement> &ui, const QString &fieldText);
//
// // Тап по кнопке "Далее" и её вариациям
// void tapNextButton(const QList<UiElement> &ui);
//
// // Обработка экрана с пост-логин баннерами или диалогами
// bool handlePostLoginScreen(const QList<UiElement> &ui);
//
// // Проверка, что перед нами главный экран
// bool isMainScreen(const QList<UiElement> &ui);
//
// // Тап по главному экрану
// void tapMainScreen(const QList<UiElement> &ui);
//
// // Функция для поиска карты по последним 4 цифрам
// UiElement findCardByLast4Digits(const QList<UiElement> &ui, const QString &last4digits);
//
// // Поиск кнопки "Оплатить" на экране
// UiElement findPayButton(const QList<UiElement> &ui);
private:
enum class State {
HandlingSecurityBanner,
WaitingForPinInput,
ClosingBanner,
OnMainScreen,
SearchingCard,
OnCardDetails,
OnTransferScreen,
Idle
};
// Основной цикл скрипта
void processUiLoop();
// void handleState(const QList<UiElement> &elements);
static void handleSecurityBanner(const QList<UiElement>& elements);
static void inputPinCode(const QString &pinCode);
void handleClosingBanner(const QList<UiElement> &elements);
static void swipeToFindElement(const QString &searchText);
static void handleCardDetailsScreen(const QList<UiElement> &elements);
// void handleTransferScreen(const QList<UiElement> &elements);
static void inputAmount(const QString &amount);
// Утилиты для работы с ADB
AdbUtils adbUtils;
// Парсер XML UI дампов мобильного устройства
XmlParser xmlParser;
// Текущее состояние скрипта автоматизации
State currentState = State::Idle;
};
#endif //SCRIPT_H