This repository has been archived by the owner on May 3, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#48 Finish binding View and ViewModels + UnitTests
- Loading branch information
1 parent
d32eae4
commit 387900e
Showing
8 changed files
with
172 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
tests/UnitTests/Presentation/ViewModels/UpdaterViewModelTests.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
#include <catch.hpp> | ||
#include <MellowPlayer/Presentation/ViewModels/UpdaterViewModel.hpp> | ||
#include <Utils/DependencyPool.hpp> | ||
|
||
using namespace MellowPlayer::Application; | ||
using namespace MellowPlayer::Presentation; | ||
using namespace MellowPlayer::Tests; | ||
|
||
|
||
SCENARIO("check for updates") { | ||
DependencyPool pool; | ||
Updater& updater = pool.getUpdater(); | ||
UpdaterViewModel& viewModel = pool.getUpdaterViewModel(); | ||
|
||
GIVEN("current version is 2.2.4 from April 2017") { | ||
Release currentRelease("2.2.4", QDate::fromString("2017-04-29", Qt::ISODate)); | ||
updater.setCurrentRelease(¤tRelease); | ||
|
||
REQUIRE(!viewModel.isBusy()); | ||
REQUIRE(!viewModel.isVisible()); | ||
REQUIRE(viewModel.getMessage().isEmpty()); | ||
REQUIRE(viewModel.getUrl().isEmpty()); | ||
REQUIRE(viewModel.getStatus().isEmpty()); | ||
REQUIRE(!viewModel.isInstallEnabled()); | ||
REQUIRE(!viewModel.isProgressVisible()); | ||
REQUIRE(viewModel.getProgress() == -1); | ||
|
||
WHEN("checking for updates") { | ||
viewModel.check(); | ||
REQUIRE(!viewModel.isBusy()); | ||
|
||
THEN("an update is available") { | ||
REQUIRE(viewModel.isVisible()); | ||
REQUIRE(!viewModel.getMessage().isEmpty()); | ||
REQUIRE(!viewModel.getUrl().isEmpty()); | ||
|
||
AND_WHEN("closing the pane") { | ||
viewModel.close(); | ||
|
||
THEN("visible changed but all other properties remains") { | ||
REQUIRE(!viewModel.isVisible()); | ||
|
||
REQUIRE(!viewModel.getMessage().isEmpty()); | ||
REQUIRE(!viewModel.getUrl().isEmpty()); | ||
} | ||
} | ||
|
||
AND_WHEN("clicking on install") { | ||
viewModel.install(); | ||
|
||
THEN("progress bar appear and updater starts downloading") { | ||
REQUIRE(viewModel.isProgressVisible()); | ||
REQUIRE(viewModel.isBusy()); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
GIVEN("current version is 3.0 from August 2017") { | ||
Release currentRelease("3.0", QDate::fromString("2017-08-12", Qt::ISODate)); | ||
updater.setCurrentRelease(¤tRelease); | ||
|
||
REQUIRE(!viewModel.isBusy()); | ||
REQUIRE(!viewModel.isVisible()); | ||
REQUIRE(viewModel.getMessage().isEmpty()); | ||
REQUIRE(viewModel.getUrl().isEmpty()); | ||
REQUIRE(viewModel.getStatus().isEmpty()); | ||
REQUIRE(!viewModel.isInstallEnabled()); | ||
REQUIRE(!viewModel.isProgressVisible()); | ||
REQUIRE(viewModel.getProgress() == -1); | ||
|
||
WHEN("checking for updates") { | ||
viewModel.check(); | ||
REQUIRE(!viewModel.isBusy()); | ||
|
||
THEN("no update is available") { | ||
REQUIRE(!viewModel.isVisible()); | ||
REQUIRE(viewModel.getMessage().isEmpty()); | ||
REQUIRE(viewModel.getUrl().isEmpty()); | ||
} | ||
} | ||
} | ||
} |