Skip to content
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 8 commits into from
Jan 22, 2018

Conversation

ppodhajski
Copy link
Contributor

No description provided.

@@ -0,0 +1,96 @@
/*********************************************************************/
/* Copyright (c) 2017, EPFL/Blue Brain Project */
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2018 ;-)

std::vector<std::unique_ptr<ScreenController>> controllers;

controllers.push_back(std::unique_ptr<ScreenController>(mockController1));
controllers.push_back(std::unique_ptr<ScreenController>(mockController2));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

controllers.emplace_back(new MockScreenController(ScreenState::ON));
Naked "new" as you did above are forbidden... :-)

controllers.push_back(std::unique_ptr<ScreenController>(mockController1));
controllers.push_back(std::unique_ptr<ScreenController>(mockController2));

auto multiController = new MultiScreenController(std::move(controllers));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...and here you have a good reason why: this multiController is never deleted! You could have used make_unique() instead, but in fact there is no reason to allocate one on the heap. Just create one on the stack.


multiController->powerOn();
BOOST_CHECK_EQUAL(multiController->getState(), ScreenState::ON);
}
Copy link

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.


}

BOOST_AUTO_TEST_CASE(testSignals)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which signals? I am not seeing the powerStateChanged signal being tested and that's the only one that this class has..?

auto serialports = ports.split(';');
if (serialports.length() == 0)
const auto connections = processInputString(ports);
if (connections.size() == 0)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

connections.empty()

QMap<QString, PlanarController::Type> map;

const auto connections = ports.split(';');
if (connections.length() == 0)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

connections.empty()

const auto connections = ports.split(';');
if (connections.length() == 0)
return map;
for (auto connection : connections)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const auto&


if (connection.contains("#"))
{
auto serialEntity = connection.split("#");
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const

QMap<QString, PlanarController::Type>
ScreenControllerFactory::processInputString(const QString& ports)
{
QMap<QString, PlanarController::Type> map;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use a typedef for QMap<QString, PlanarController::Type>? It's quite long and repeated a lot of times.

if (connection.isEmpty())
continue;

if (!connection.endsWith("#") && connection.contains("#"))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to be reviewed, at least inverse the two conditions for readability. If someone inserts abc#def# this jumps to the second case, which is not the intention. I would still prefer a single code path with a split('#') at the beginning.

std::vector<std::unique_ptr<PlanarController>> controllers;
for (const auto serialport : serialports)
std::vector<std::unique_ptr<ScreenController>> controllers;
for (const auto& kv : connections.toStdMap())
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmmmm... :-S

@ppodhajski ppodhajski force-pushed the master branch 16 times, most recently from f31c2cd to c3432fc Compare January 22, 2018 10:48
Copy link

@rdumusc rdumusc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did 3 minor cleanups, good to merge for me

@ppodhajski ppodhajski merged commit 89cc7ba into BlueBrain:master Jan 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants