MockRemoteProcess.cpp 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. * Copyright (C) 2023 KeePassXC Team <team@keepassxc.org>
  3. *
  4. * This program is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation, either version 2 or (at your option)
  7. * version 3 of the License.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. #include <QFile>
  18. #include "MockRemoteProcess.h"
  19. MockRemoteProcess::MockRemoteProcess(QObject* parent, QString dbPath)
  20. : RemoteProcess(parent)
  21. , m_dbPath(std::move(dbPath))
  22. {
  23. }
  24. void MockRemoteProcess::start(const QString&)
  25. {
  26. QFile::copy(m_dbPath, m_tempFileLocation);
  27. }
  28. qint64 MockRemoteProcess::write(const QString& data)
  29. {
  30. m_data.append(data.toUtf8());
  31. return data.length();
  32. }
  33. bool MockRemoteProcess::waitForBytesWritten()
  34. {
  35. return true;
  36. }
  37. void MockRemoteProcess::closeWriteChannel()
  38. {
  39. // nothing to do
  40. }
  41. bool MockRemoteProcess::waitForFinished(int)
  42. {
  43. return true; // no need to wait
  44. }
  45. int MockRemoteProcess::exitCode() const
  46. {
  47. return 0; // always return success
  48. }
  49. QString MockRemoteProcess::readOutput()
  50. {
  51. return {};
  52. }
  53. QString MockRemoteProcess::readError()
  54. {
  55. return {};
  56. }