fantest.cpp 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*
  2. * Copyright 2015 <copyright holder> <email>
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License as
  6. * published by the Free Software Foundation; either version 2 of
  7. * the License or (at your option) version 3 or any later version
  8. * accepted by the membership of KDE e.V. (or its successor approved
  9. * by the membership of KDE e.V.), which shall act as a proxy
  10. * defined in Section 14 of version 3 of the license.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. *
  20. */
  21. #include "fantest.h"
  22. #include <QtTest/QtTest>
  23. void FanTest::initTestCase()
  24. {
  25. m_rpmString = QStringLiteral("500");
  26. m_fan = new TestFan(&m_rpmString);
  27. }
  28. void FanTest::cleanupTestCase()
  29. {
  30. delete m_fan;
  31. }
  32. void FanTest::init()
  33. {
  34. // Called before each testfunction is executed
  35. }
  36. void FanTest::cleanup()
  37. {
  38. // Called after every testfunction
  39. }
  40. void FanTest::nameTest_data()
  41. {
  42. QTest::addColumn<QString>("name");
  43. QTest::newRow("BigFan") << "BigFan";
  44. QTest::newRow("fan2") << "fan2";
  45. }
  46. void FanTest::nameTest()
  47. {
  48. QFETCH(QString, name);
  49. m_fan->setName(name);
  50. QCOMPARE(m_fan->name(), name);
  51. }
  52. void FanTest::rpmTest_data()
  53. {
  54. QTest::addColumn<QString>("value");
  55. QTest::addColumn<int>("result");
  56. QTest::newRow("0") << "0" << 0;
  57. QTest::newRow("100") << "100" << 100;
  58. QTest::newRow("1000") << "1000" << 1000;
  59. QTest::newRow("5500") << "5500" << 5500;
  60. }
  61. void FanTest::rpmTest()
  62. {
  63. QFETCH(QString, value);
  64. QFETCH(int, result);
  65. m_rpmString = value;
  66. m_fan->update();
  67. QCOMPARE(m_fan->rpm(), result);
  68. }
  69. QTEST_MAIN(FanTest)