diff --git a/src/endOfExercise.py b/src/endOfExercise.py index a8ae1a2ab6bc1fdd903e5abc07157a706f764593..6b39d663555d5e6b494532b3d76e09586010fe48 100644 --- a/src/endOfExercise.py +++ b/src/endOfExercise.py @@ -20,42 +20,42 @@ class endOfExe(QWidget): def setUpEndOfExe(self): self.setStyleSheet('background-color: #5A8D6C') - congratsSize = QFont() - congratsSize.setPointSize(40) - congratsSize.setFamily("Segoe UI") - congratsSize.setBold(True) + self.congratsSize = QFont() + self.congratsSize.setPointSize(40) + self.congratsSize.setFamily("Segoe UI") + self.congratsSize.setBold(True) - stayHealSize = QFont() - stayHealSize.setPointSize(20) - stayHealSize.setFamily("Segoe UI") - stayHealSize.setBold(True) + self.stayHealSize = QFont() + self.stayHealSize.setPointSize(20) + self.stayHealSize.setFamily("Segoe UI") + self.stayHealSize.setBold(True) - backSize = QFont() - backSize.setPointSize(15) - backSize.setFamily("Segoe UI") + self.backSize = QFont() + self.backSize.setPointSize(15) + self.backSize.setFamily("Segoe UI") # backSize.setBold(True) - congrats = QLabel(self) - congrats.setText("Congratulations") - congrats.setFont(congratsSize) - congrats.setStyleSheet("color: #EEEEE2") - congrats.move(450, 170) + self.congrats = QLabel(self) + self.congrats.setText("Congratulations") + self.congrats.setFont(self.congratsSize) + self.congrats.setStyleSheet("color: #EEEEE2") + self.congrats.move(450, 170) - done = QLabel(self) - done.setText("you've done the exercise!") - done.setFont(congratsSize) - done.setStyleSheet("color: #EEEEE2") - done.move(325, 250) + self.done = QLabel(self) + self.done.setText("you've done the exercise!") + self.done.setFont(self.congratsSize) + self.done.setStyleSheet("color: #EEEEE2") + self.done.move(325, 250) - stayHealthy = QLabel(self) - stayHealthy.setText("STAY HEALTHY AND POWERFUL!") - stayHealthy.setFont(stayHealSize) - stayHealthy.setStyleSheet("color: #EEEEE2") - stayHealthy.move(435, 375) + self.stayHealthy = QLabel(self) + self.stayHealthy.setText("STAY HEALTHY AND POWERFUL!") + self.stayHealthy.setFont(self.stayHealSize) + self.stayHealthy.setStyleSheet("color: #EEEEE2") + self.stayHealthy.move(435, 375) - backButton = QPushButton(self) - backButton.setText("Back To Dashboard") - backButton.setStyleSheet(''' + self.backButtonon = QPushButton(self) + self.backButtonon.setText("Back To Dashboard") + self.backButtonon.setStyleSheet(''' QPushButton { color: rgba(255, 255, 255, 1); background-color: #174728; @@ -66,11 +66,12 @@ class endOfExe(QWidget): color: #174728; } ''') - backButton.resize(200, 50) - backButton.setFont(backSize) - backButton.setCursor(QCursor(Qt.CursorShape.PointingHandCursor)) - backButton.move(560, 450) - backButton.clicked.connect(self.backToDash) + self.backButtonon.resize(200, 50) + self.backButtonon.setFont(self.backSize) + self.backButtonon.setCursor(QCursor(Qt.CursorShape.PointingHandCursor)) + self.backButtonon.move(560, 450) + self.backButtonon.clicked.connect(self.backToDash) + def backToDash(self): diff --git a/src/test_endOfExe.py b/src/test_endOfExe.py new file mode 100644 index 0000000000000000000000000000000000000000..15d2dbebab098ef7b8a29d0fdffb2a466ef45cee --- /dev/null +++ b/src/test_endOfExe.py @@ -0,0 +1,36 @@ +import sqlite3 +import sys +from PyQt6.QtWidgets import QApplication, QLabel, QWidget, QLineEdit, QPushButton, QRadioButton, QCheckBox, QMessageBox +from PyQt6.QtGui import QFont, QPixmap, QCursor +from PyQt6.QtCore import Qt, pyqtSignal +from endOfExercise import endOfExe +import pytest + +def test_endOfExe(qtbot): + window = endOfExe() + qtbot.addWidget(window) + + + # Check window title and size + assert window.windowTitle() == "FitU - End Of Exercise" + assert window.size() == window.minimumSize() + + # Check presence and properties of all widgets + assert isinstance(window.findChildren(QLabel)[0], QLabel) + assert window.findChildren(QLabel)[0].text() == "Congratulations" + assert isinstance(window.findChildren(QLabel)[1], QLabel) + assert window.findChildren(QLabel)[1].text() == "you've done the exercise!" + assert isinstance(window.findChildren(QLabel)[2], QLabel) + assert window.findChildren(QLabel)[2].text() == "STAY HEALTHY AND POWERFUL!" + assert isinstance(window.findChildren(QPushButton)[0], QPushButton) + assert window.findChildren(QPushButton)[0].text() == "Back To Dashboard" + + # Assume we have a parent widget called 'parentWidget' +# and we want to find a child QLabel with object name 'myLabel' + + + + # Test clicking on the back button emits the signal + # with qtbot.waitSignal(window.switch, raising=True) as blocker: + # qtbot.mouseClick(window.findChild(QPushButton, "backButton"), Qt.MouseButton.LeftButton) + # assert blocker.args == ("dashboard", {}) diff --git a/src/test_plan2.py b/src/test_plan2.py new file mode 100644 index 0000000000000000000000000000000000000000..2eb32847a61f0ca75403b442e0bc435d9a14e506 --- /dev/null +++ b/src/test_plan2.py @@ -0,0 +1,36 @@ +import pytest +from PyQt6.QtWidgets import QApplication, QWidget, QLabel, QPushButton +from PyQt6.QtCore import Qt, QTimer, QTime +from plan2 import plan2 + +@pytest.fixture +def app(qtbot): + test_plan = plan2(1) + qtbot.addWidget(test_plan) + return test_plan + +def test_setUpPlan(app, qtbot): + assert app.nameLabel.text() == 'Push Up' + assert app.repLabel.text() == '' + assert app.timer_label.text() == '10 Rep' + assert app.currEx.movie().fileName() == 'img/exe-pushup.gif' + assert app.prevButton.isEnabled() == True + assert app.nextButton.isEnabled() == True + + qtbot.mouseClick(app.nextButton, Qt.MouseButton.LeftButton) + assert app.nameLabel.text() == 'Bridge' + assert app.currEx.movie().fileName() == 'img/exe-bridges.gif' + assert app.prevButton.isEnabled() == True + assert app.nextButton.isEnabled() == True + + qtbot.mouseClick(app.prevButton, Qt.MouseButton.LeftButton) + assert app.nameLabel.text() == 'Push Up' + assert app.currEx.movie().fileName() == 'img/exe-pushup.gif' + assert app.prevButton.isEnabled() == True + assert app.nextButton.isEnabled() == True + + qtbot.wait(2000) + assert app.remaining_time == 30 + + qtbot.wait(15000) + assert app.remaining_time == 30 diff --git a/src/test_register.py b/src/test_register.py new file mode 100644 index 0000000000000000000000000000000000000000..82b4c96faff74c94395c18619d0cd17fee42765b --- /dev/null +++ b/src/test_register.py @@ -0,0 +1,74 @@ +import pytest +from PyQt6.QtWidgets import QApplication, QLineEdit, QRadioButton, QCheckBox, QPushButton +from PyQt6.QtCore import Qt + +from register import register + +@pytest.fixture +def app(qtbot): + test_register = register() + qtbot.addWidget(test_register) + return test_register + +def test_name_input(app, qtbot): + name_input = app.nameInput + qtbot.keyClicks(name_input, "Test Name") + assert name_input.text() == "Test Name" + +def test_age_input(app, qtbot): + age_input = app.age + qtbot.keyClicks(age_input, "25") + assert age_input.text() == "25" + +def test_height_input(app, qtbot): + height_input = app.height + qtbot.keyClicks(height_input, "180") + assert height_input.text() == "180" + +def test_weight_input(app, qtbot): + weight_input = app.weight + qtbot.keyClicks(weight_input, "75") + assert weight_input.text() == "75" + +def test_gender_selection(app, qtbot): + male_button = app.male + female_button = app.female + + qtbot.mouseClick(male_button, Qt.MouseButton.LeftButton) + assert male_button.isChecked() + + qtbot.mouseClick(female_button, Qt.MouseButton.LeftButton) + assert female_button.isChecked() + +def test_body_type_selection(app, qtbot): + fit_checkbox = app.fit + thin_checkbox = app.thin + + qtbot.mouseClick(fit_checkbox, Qt.MouseButton.LeftButton) + assert fit_checkbox.isChecked() + + qtbot.mouseClick(thin_checkbox, Qt.MouseButton.LeftButton) + assert thin_checkbox.isChecked() + +def test_register_button(app, qtbot): + register_button = app.registerButton + name_input = app.nameInput + age_input = app.age + height_input = app.height + weight_input = app.weight + male_button = app.male + female_button = app.female + fit_checkbox = app.fit + thin_checkbox = app.thin + + # Input test data + qtbot.keyClicks(name_input, "Test Name") + qtbot.keyClicks(age_input, "25") + qtbot.keyClicks(height_input, "180") + qtbot.keyClicks(weight_input, "75") + qtbot.mouseClick(male_button, Qt.MouseButton.LeftButton) + qtbot.mouseClick(fit_checkbox, Qt.MouseButton.LeftButton) + + # Check if switch signal is emitted + # with qtbot.waitSignal(app.switch): + # qtbot.mouseClick(register_button, Qt.MouseButton.LeftButton)