Skip to content

Commit

Permalink
Add tests for painting of ProgressBarCounter class.
Browse files Browse the repository at this point in the history
  • Loading branch information
przemek83 committed Dec 21, 2024
1 parent 41961f3 commit 5e5bb07
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 0 deletions.
29 changes: 29 additions & 0 deletions tests/ProgressBarCounterTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,32 @@ void ProgressBarCounterTest::testReseting()
ProgressBarCounter progressBar(QLatin1String(""), max_);
ProgressBarCommon::checkReseting(progressBar);
}

void ProgressBarCounterTest::checkInitialPaint()
{
ProgressBarCounter progressBar(QLatin1String("Initial"), max_);
auto actual{progressBar.grab().toImage()};
QImage expected(":/counterInitial.png");
expected = expected.convertToFormat(actual.format());
QCOMPARE(actual, expected);
}

void ProgressBarCounterTest::checkPaintAfterUpdate()
{
ProgressBarCounter progressBar(QLatin1String("Updated"), max_);
progressBar.updateProgress(10);
auto actual{progressBar.grab().toImage()};
QImage expected(":/counterUpdated.png");
expected = expected.convertToFormat(actual.format());
QCOMPARE(actual, expected);
}

void ProgressBarCounterTest::checkPaintFinished()
{
ProgressBarCounter progressBar(QLatin1String("Finished"), max_);
progressBar.updateProgress(100);
auto actual{progressBar.grab().toImage()};
QImage expected(":/counterFinished.png");
expected = expected.convertToFormat(actual.format());
QCOMPARE(actual, expected);
}
6 changes: 6 additions & 0 deletions tests/ProgressBarCounterTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ private Q_SLOTS:

static void testReseting();

static void checkInitialPaint();

static void checkPaintAfterUpdate();

static void checkPaintFinished();

private:
static constexpr int max_{100};
};
Binary file added tests/counterFinished.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/counterInitial.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/counterUpdated.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions tests/testResources.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@
<qresource prefix="/">
<file>infinityInitial.png</file>
<file>infinityUpdated.png</file>
<file>counterInitial.png</file>
<file>counterUpdated.png</file>
<file>counterFinished.png</file>
</qresource>
</RCC>

0 comments on commit 5e5bb07

Please sign in to comment.