-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ScreenController able to manage different type of Planar TV #229
Merged
Merged
Changes from 3 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
78a0437
Added new Planar device suppport
ppodhajski 8c76f78
CR1
cee7f39
cr2
ppodhajski 5f276f6
cr3
ppodhajski efd947c
cmake library fix
ppodhajski 6f3fb9d
Clarify test names a bit
75d3cbd
TideMock: remove extra link libraries
262a82a
correct spacing
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
/*********************************************************************/ | ||
/* Copyright (c) 2018, EPFL/Blue Brain Project */ | ||
/* Pawel Podhajski <pawel.podhajski@epfl.ch> */ | ||
/* All rights reserved. */ | ||
/* */ | ||
/* Redistribution and use in source and binary forms, with or */ | ||
/* without modification, are permitted provided that the following */ | ||
/* conditions are met: */ | ||
/* */ | ||
/* 1. Redistributions of source code must retain the above */ | ||
/* copyright notice, this list of conditions and the following */ | ||
/* disclaimer. */ | ||
/* */ | ||
/* 2. Redistributions in binary form must reproduce the above */ | ||
/* copyright notice, this list of conditions and the following */ | ||
/* disclaimer in the documentation and/or other materials */ | ||
/* provided with the distribution. */ | ||
/* */ | ||
/* THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY OF TEXAS AT */ | ||
/* AUSTIN ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, */ | ||
/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF */ | ||
/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */ | ||
/* DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OF TEXAS AT */ | ||
/* AUSTIN OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */ | ||
/* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES */ | ||
/* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE */ | ||
/* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR */ | ||
/* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF */ | ||
/* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */ | ||
/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */ | ||
/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */ | ||
/* POSSIBILITY OF SUCH DAMAGE. */ | ||
/* */ | ||
/* The views and conclusions contained in the software and */ | ||
/* documentation are those of the authors and should not be */ | ||
/* interpreted as representing official policies, either expressed */ | ||
/* or implied, of Ecole polytechnique federale de Lausanne. */ | ||
/*********************************************************************/ | ||
|
||
#define BOOST_TEST_MODULE MutliScreenControllerTest | ||
|
||
#include <boost/test/unit_test.hpp> | ||
|
||
#include "MockScreenController.h" | ||
#include "MultiScreenController.h" | ||
#include "ScreenController.h" | ||
#include "types.h" | ||
|
||
BOOST_AUTO_TEST_CASE(testUniformScreenStates) | ||
{ | ||
std::vector<std::unique_ptr<ScreenController>> controllers; | ||
controllers.emplace_back(new MockScreenController(ScreenState::UNDEF)); | ||
controllers.emplace_back(new MockScreenController(ScreenState::UNDEF)); | ||
|
||
MultiScreenController multiController(std::move(controllers)); | ||
|
||
BOOST_CHECK_EQUAL(multiController.getState(), ScreenState::UNDEF); | ||
|
||
multiController.powerOn(); | ||
|
||
for (auto& controller : controllers) | ||
{ | ||
BOOST_CHECK( | ||
static_cast<MockScreenController&>(*controller).powerOnCalled); | ||
} | ||
|
||
BOOST_CHECK_EQUAL(multiController.getState(), ScreenState::ON); | ||
|
||
multiController.powerOff(); | ||
|
||
for (auto& controller : controllers) | ||
{ | ||
BOOST_CHECK( | ||
static_cast<MockScreenController&>(*controller).powerOffCalled); | ||
} | ||
BOOST_CHECK_EQUAL(multiController.getState(), ScreenState::OFF); | ||
} | ||
|
||
BOOST_AUTO_TEST_CASE(testDifferentScreenStates) | ||
{ | ||
std::vector<std::unique_ptr<ScreenController>> controllers; | ||
controllers.emplace_back(new MockScreenController(ScreenState::ON)); | ||
controllers.emplace_back(new MockScreenController(ScreenState::OFF)); | ||
|
||
MultiScreenController multiController(std::move(controllers)); | ||
|
||
multiController.getState(); | ||
BOOST_CHECK_EQUAL(multiController.getState(), ScreenState::UNDEF); | ||
} | ||
|
||
BOOST_AUTO_TEST_CASE(testSignal) | ||
{ | ||
std::vector<std::unique_ptr<ScreenController>> controllers; | ||
controllers.emplace_back(new MockScreenController(ScreenState::ON)); | ||
MultiScreenController multiController(std::move(controllers)); | ||
|
||
bool emitted = false; | ||
|
||
QObject::connect(&multiController, &MultiScreenController::powerStateChanged, | ||
[&emitted]() { emitted = true; }); | ||
|
||
multiController.checkPowerState(); | ||
BOOST_CHECK(emitted); | ||
|
||
emitted = false; | ||
multiController.powerOff(); | ||
BOOST_CHECK(emitted); | ||
|
||
emitted = false; | ||
multiController.powerOn(); | ||
BOOST_CHECK_EQUAL(multiController.getState(), ScreenState::ON); | ||
BOOST_CHECK(emitted); | ||
} | ||
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,164 @@ | ||
/*********************************************************************/ | ||
/* Copyright (c) 2018, EPFL/Blue Brain Project */ | ||
/* Pawel Podhajski <pawel.podhajski@epfl.ch> */ | ||
/* All rights reserved. */ | ||
/* */ | ||
/* Redistribution and use in source and binary forms, with or */ | ||
/* without modification, are permitted provided that the following */ | ||
/* conditions are met: */ | ||
/* */ | ||
/* 1. Redistributions of source code must retain the above */ | ||
/* copyright notice, this list of conditions and the following */ | ||
/* disclaimer. */ | ||
/* */ | ||
/* 2. Redistributions in binary form must reproduce the above */ | ||
/* copyright notice, this list of conditions and the following */ | ||
/* disclaimer in the documentation and/or other materials */ | ||
/* provided with the distribution. */ | ||
/* */ | ||
/* THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY OF TEXAS AT */ | ||
/* AUSTIN ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, */ | ||
/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF */ | ||
/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */ | ||
/* DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OF TEXAS AT */ | ||
/* AUSTIN OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */ | ||
/* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES */ | ||
/* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE */ | ||
/* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR */ | ||
/* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF */ | ||
/* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */ | ||
/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */ | ||
/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */ | ||
/* POSSIBILITY OF SUCH DAMAGE. */ | ||
/* */ | ||
/* The views and conclusions contained in the software and */ | ||
/* documentation are those of the authors and should not be */ | ||
/* interpreted as representing official policies, either expressed */ | ||
/* or implied, of Ecole polytechnique federale de Lausanne. */ | ||
/*********************************************************************/ | ||
|
||
#define BOOST_TEST_MODULE ScreenControllerFactoryTest | ||
|
||
#include <boost/test/unit_test.hpp> | ||
|
||
#include "MultiScreenController.h" | ||
#include "PlanarController.h" | ||
#include "ScreenControllerFactory.h" | ||
|
||
#include <QMap> | ||
|
||
inline std::ostream& operator<<(std::ostream& str, | ||
const PlanarController::Type type) | ||
{ | ||
switch (type) | ||
{ | ||
case PlanarController::Type::Matrix: | ||
str << "Matrix"; | ||
break; | ||
case PlanarController::Type::TV_UR9850: | ||
str << "TV_UR9850"; | ||
break; | ||
case PlanarController::Type::TV_UR9851: | ||
str << "TV_UR9851"; | ||
break; | ||
} | ||
return str; | ||
} | ||
|
||
BOOST_AUTO_TEST_CASE(testEmpty) | ||
{ | ||
BOOST_CHECK(!ScreenControllerFactory::create("")); | ||
} | ||
|
||
BOOST_AUTO_TEST_CASE(testException) | ||
{ | ||
BOOST_CHECK_THROW(ScreenControllerFactory::create("/dev/null;/dev/das"), | ||
std::runtime_error); | ||
BOOST_CHECK_THROW(ScreenControllerFactory::create( | ||
"/dev/null#UR9850;/dev/null#UR9851"), | ||
std::runtime_error); | ||
BOOST_CHECK_THROW(ScreenControllerFactory::create("/dev/null#UR9850"), | ||
std::runtime_error); | ||
BOOST_CHECK_THROW(ScreenControllerFactory::create("/dev/null"), | ||
std::runtime_error) | ||
} | ||
|
||
BOOST_AUTO_TEST_CASE(testSingleController) | ||
{ | ||
const QMap<QString, PlanarController::Type> expectedMatrix{ | ||
{"/dev/usb1", PlanarController::Type::Matrix}}; | ||
|
||
const auto processedMatrix = | ||
ScreenControllerFactory::parseInputString("/dev/usb1"); | ||
|
||
BOOST_CHECK_EQUAL_COLLECTIONS(expectedMatrix.begin(), expectedMatrix.end(), | ||
processedMatrix.begin(), | ||
processedMatrix.end()); | ||
|
||
const QMap<QString, PlanarController::Type> expectedUR9850{ | ||
{"/dev/usb1", PlanarController::Type::TV_UR9850}}; | ||
|
||
const auto processedUR9850 = | ||
ScreenControllerFactory::parseInputString("/dev/usb1#UR9850"); | ||
|
||
BOOST_CHECK_EQUAL_COLLECTIONS(expectedUR9850.begin(), expectedUR9850.end(), | ||
processedUR9850.begin(), | ||
processedUR9850.end()); | ||
|
||
const QMap<QString, PlanarController::Type> expectedUR9851{ | ||
{"/dev/usb1", PlanarController::Type::TV_UR9851}}; | ||
|
||
const auto processedUR9851 = | ||
ScreenControllerFactory::parseInputString("/dev/usb1#UR9851"); | ||
|
||
BOOST_CHECK_EQUAL_COLLECTIONS(expectedUR9851.begin(), expectedUR9851.end(), | ||
processedUR9851.begin(), | ||
processedUR9851.end()); | ||
} | ||
|
||
BOOST_AUTO_TEST_CASE(testMultipleConnectionsWithType) | ||
{ | ||
const QMap<QString, PlanarController::Type> expected{ | ||
{"/dev/usb1", PlanarController::Type::Matrix}, | ||
{"/dev/usb2", PlanarController::Type::TV_UR9850}, | ||
{"/dev/usb3", PlanarController::Type::TV_UR9851}}; | ||
|
||
const auto processed = ScreenControllerFactory::parseInputString( | ||
"/dev/usb1;/dev/usb2#UR9850;/dev/usb3#UR9851"); | ||
|
||
BOOST_CHECK_EQUAL_COLLECTIONS(expected.begin(), expected.end(), | ||
processed.begin(), processed.end()); | ||
} | ||
|
||
BOOST_AUTO_TEST_CASE(testMultipleConnectionsWithOneEmpty) | ||
{ | ||
const QMap<QString, PlanarController::Type> expected{ | ||
{"/dev/usb1", PlanarController::Type::Matrix}}; | ||
const auto processed = | ||
ScreenControllerFactory::parseInputString(";/dev/usb1"); | ||
|
||
BOOST_CHECK_EQUAL_COLLECTIONS(expected.begin(), expected.end(), | ||
processed.begin(), processed.end()); | ||
} | ||
|
||
BOOST_AUTO_TEST_CASE(testMultipleConnectionsWithOneEmptyDevice) | ||
{ | ||
const QMap<QString, PlanarController::Type> expected{ | ||
{"/dev/usb1", PlanarController::Type::Matrix}}; | ||
const auto processed = | ||
ScreenControllerFactory::parseInputString("#UR9850;/dev/usb1"); | ||
|
||
BOOST_CHECK_EQUAL_COLLECTIONS(expected.begin(), expected.end(), | ||
processed.begin(), processed.end()); | ||
} | ||
|
||
BOOST_AUTO_TEST_CASE(testConnectionsWithEmptyDeviceType) | ||
{ | ||
const QMap<QString, PlanarController::Type> expected{ | ||
{"/dev/usb1", PlanarController::Type::Matrix}}; | ||
const auto processed = | ||
ScreenControllerFactory::parseInputString("/dev/usb1#"); | ||
|
||
BOOST_CHECK_EQUAL_COLLECTIONS(expected.begin(), expected.end(), | ||
processed.begin(), processed.end()); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/*********************************************************************/ | ||
/* Copyright (c) 2018, EPFL/Blue Brain Project */ | ||
/* Pawel Podhajski <pawel.podhajski@epfl.ch> */ | ||
/* All rights reserved. */ | ||
/* */ | ||
/* Redistribution and use in source and binary forms, with or */ | ||
/* without modification, are permitted provided that the following */ | ||
/* conditions are met: */ | ||
/* */ | ||
/* 1. Redistributions of source code must retain the above */ | ||
/* copyright notice, this list of conditions and the following */ | ||
/* disclaimer. */ | ||
/* */ | ||
/* 2. Redistributions in binary form must reproduce the above */ | ||
/* copyright notice, this list of conditions and the following */ | ||
/* disclaimer in the documentation and/or other materials */ | ||
/* provided with the distribution. */ | ||
/* */ | ||
/* THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY OF TEXAS AT */ | ||
/* AUSTIN ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, */ | ||
/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF */ | ||
/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */ | ||
/* DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OF TEXAS AT */ | ||
/* AUSTIN OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */ | ||
/* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES */ | ||
/* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE */ | ||
/* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR */ | ||
/* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF */ | ||
/* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */ | ||
/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */ | ||
/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */ | ||
/* POSSIBILITY OF SUCH DAMAGE. */ | ||
/* */ | ||
/* The views and conclusions contained in the software and */ | ||
/* documentation are those of the authors and should not be */ | ||
/* interpreted as representing official policies, either expressed */ | ||
/* or implied, of Ecole polytechnique federale de Lausanne. */ | ||
/*********************************************************************/ | ||
|
||
#ifndef MOCKSCREENCONTROLLER_H | ||
#define MOCKSCREENCONTROLLER_H | ||
|
||
#include "ScreenController.h" | ||
#include "types.h" | ||
|
||
#include <QObject> | ||
|
||
class MockScreenController : public ScreenController | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
MockScreenController(ScreenState state) | ||
: _state(state) | ||
{ | ||
} | ||
ScreenState getState() const final { return _state; } | ||
void checkPowerState() final { emit powerStateChanged(_state); } | ||
|
||
bool powerOn() final | ||
{ | ||
_state = ScreenState::ON; | ||
emit powerStateChanged(_state); | ||
powerOnCalled = true; | ||
return true; | ||
} | ||
|
||
bool powerOff() final | ||
{ | ||
_state = ScreenState::OFF; | ||
emit powerStateChanged(_state); | ||
powerOffCalled = true; | ||
return true; | ||
} | ||
|
||
bool powerOffCalled = false; | ||
bool powerOnCalled = false; | ||
|
||
private: | ||
ScreenState _state; | ||
}; | ||
|
||
#endif |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There should be a check that when any of checkPowerState / powerOff / powerOn are called, the MultiController is indeed calling the same functions on all the MockControllers that were passed to it.