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

Add auxiliary API for Proxy #313

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

zusage
Copy link
Collaborator

@zusage zusage commented Oct 14, 2020

No description provided.

@zusage zusage requested a review from bitmouse October 14, 2020 18:27
Copy link
Collaborator

@bitmouse bitmouse left a comment

Choose a reason for hiding this comment

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

Please add unit tests or/and test showing the usage of new functionality.

src/ipc/ipc-common/IPCProxyBase.h Outdated Show resolved Hide resolved
@zusage zusage requested a review from kunichik October 15, 2020 13:57
src/ipc/ipc-common/observer.h Outdated Show resolved Hide resolved
src/ipc/ipc-common/observer.h Outdated Show resolved Hide resolved
src/ipc/ipc-common/observer.h Outdated Show resolved Hide resolved
src/ipc/ipc-common/observer.h Outdated Show resolved Hide resolved
src/ipc/ipc-common/observer.h Outdated Show resolved Hide resolved
src/ipc/ipc-common/observer.h Show resolved Hide resolved
src/ipc/ipc-common/observer.h Outdated Show resolved Hide resolved
src/ipc/ipc-common/observer.h Outdated Show resolved Hide resolved
src/ipc/ipc-common/IPCProxyBase.h Outdated Show resolved Hide resolved
src/ipc/ipc-common/IPCProxyBase.h Outdated Show resolved Hide resolved
Copy link
Collaborator

@bitmouse bitmouse left a comment

Choose a reason for hiding this comment

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

I do not understand the test. Are you testing setter/getter pair?

Comment on lines 29 to 31
StandartObserver < std::function<void()> > * obs1 = new StandartObserver < std::function<void()> >(std::bind(&Counter::setValue1, &c1) );
SingleTimeObserver< std::function<void()> > * obs2 = new SingleTimeObserver< std::function<void()> >(std::bind(&Counter::setValue2, &c2) );
Copy link
Collaborator

Choose a reason for hiding this comment

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

mem leak x 2

tests/unittest_observer/FaceliftObserverTest.cpp Outdated Show resolved Hide resolved
@zusage zusage force-pushed the api_proxy_clean branch 2 times, most recently from 65649c8 to 5dd42d0 Compare October 16, 2020 15:30
Comment on lines 42 to 75
TEST_F(IPCProxyBaseTest, setObservers)
{
const auto expected = std::vector<IObserver*>{obs1, obs2,};
proxyBase.m_readyObserver.setObservers(expected);
const auto actual = proxyBase.m_readyObserver.getObservers();
EXPECT_EQ(expected.size(), actual.size());
EXPECT_EQ(expected[0], actual[0]);
EXPECT_EQ(expected[1], actual[1]);
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

What do you test?
Could you test the actual usage of new functionality?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is not a complete test cases. I will inform you.

Wait, please.

Copy link
Collaborator

@kunichik kunichik left a comment

Choose a reason for hiding this comment

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

Please align the code ( curly braces etc)

src/ipc/ipc-common/observer.h Show resolved Hide resolved
src/ipc/ipc-common/observer.h Show resolved Hide resolved
src/ipc/ipc-common/observer.h Outdated Show resolved Hide resolved
{
Q_OBJECT
public:
virtual void onReadyChanged(std::shared_ptr<QMetaObject::Connection> connection) = 0;
Copy link
Collaborator

Choose a reason for hiding this comment

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

why do you use std::shared_ptr ?
Isn't it enough to use std::unique_ptr + std::make_unique ?
Of course, this also applies to other parts of PR.

src/ipc/ipc-common/observer.h Outdated Show resolved Hide resolved
src/ipc/ipc-common/observer.h Outdated Show resolved Hide resolved
src/ipc/ipc-common/observer.h Outdated Show resolved Hide resolved
src/ipc/ipc-common/observer.h Outdated Show resolved Hide resolved
find_package(GTest)
if(${GTEST_FOUND})
find_library(GMOCK_LIBRARY gmock REQUIRED HINTS "${CMAKE_SYSTEM_PREFIX_PATH}")
if(NOT ${GMOCK_LIBRARY} STREQUAL "GMOCK_LIBRARY-NOTFOUND")
Copy link
Collaborator

Choose a reason for hiding this comment

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

verify if it's enough to use if(GMOCK_LIBRARY-NOTFOUND) instead and reverse logic

tests/unittest_observer/CMakeLists.txt Outdated Show resolved Hide resolved
tests/unittest_observer/CMakeLists.txt Outdated Show resolved Hide resolved
@zusage zusage force-pushed the api_proxy_clean branch 2 times, most recently from a09fa13 to 9c55e92 Compare October 19, 2020 10:10
@zusage zusage requested a review from bitmouse October 19, 2020 11:20
@kunichik kunichik self-requested a review October 19, 2020 11:27
src/ipc/ipc-common/IPCProxyBase.h Outdated Show resolved Hide resolved
src/ipc/ipc-common/observer.h Outdated Show resolved Hide resolved
Copy link
Collaborator

@kunichik kunichik left a comment

Choose a reason for hiding this comment

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

I ask you reply all the comments!
At least: "Done", "not needed", "to be done", or answer to the question.
Otherwise I cannot see any reason for wasting the time and doing reviews when
your comments picked selectively and yours questions are ignored!

src/ipc/ipc-common/observer.h Outdated Show resolved Hide resolved
src/ipc/ipc-common/observer.h Outdated Show resolved Hide resolved
src/ipc/ipc-common/observer.h Outdated Show resolved Hide resolved
src/ipc/ipc-common/observer.h Outdated Show resolved Hide resolved
tests/unittest_observer/CMakeLists.txt Outdated Show resolved Hide resolved
tests/unittest_observer/FaceliftObserverTest.cpp Outdated Show resolved Hide resolved
tests/unittest_observer/FaceliftObserverTest.cpp Outdated Show resolved Hide resolved
tests/unittest_observer/FaceliftObserverTest.cpp Outdated Show resolved Hide resolved
@@ -49,10 +49,12 @@ class IPCProxyBase : public AdapterType, protected IPCProxyBaseBase

public:
using InterfaceType = AdapterType;
IsReadyObserver m_readyObserver{};
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is it here? We discussed that already that we do not want to extend this class.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Please move it from this class. We do not want it here!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

{
Q_OBJECT
public:
virtual void onReadyChanged(std::shared_ptr<QMetaObject::Connection> connection) = 0;
Copy link
Collaborator

Choose a reason for hiding this comment

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

IObserver::onReadyChanged? I think this method should be in IsReadyObserver.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

tests/unittest_observer/CMakeLists.txt Outdated Show resolved Hide resolved
public:
Counter c1;
Counter c2;
StandartObserver < std::function<void()> > * obs1 = new StandartObserver < std::function<void()> > (std::bind(&Counter::incValue, &c1) );
Copy link
Collaborator

Choose a reason for hiding this comment

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

std::unique_ptr?
Why not just make it a member of the class (not a pointer)?

Copy link
Collaborator Author

@zusage zusage Oct 20, 2020

Choose a reason for hiding this comment

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

Done.

tests/unittest_observer/FaceliftObserverTest.cpp Outdated Show resolved Hide resolved
// Check values after signal call
ASSERT_EQ(c1.getValue(), 3); // for StandartObserver
ASSERT_EQ(c2.getValue(), 1); // for SingleTimeObserver
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

You do not test the functionality. Also I am not quite sure how to use your observer, which was meant to be similar to discussed "callOnceReady" and "callOnReady".

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I added comments for the test, which briefly describes the sequence of work and interaction between "Proxy", "IsReadyObserver" and observers for "callOnReady", "callOnceReady". Instead "Proxy" there may be a different type and signal.

Copy link
Collaborator Author

@zusage zusage Oct 22, 2020

Choose a reason for hiding this comment

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

The main goal is to have a flexible service, present as independent/extern component, that reacts on certain states of one object of inspection and execute vary callbacks either once or permanent.
In general it is intend for a Qt objects a certain kind of types, that has the "ready" state, it is necessary to provide the ability to track this state using the "IsReadyObserver" component and an arbitrary number of observers of two types: "callOnReady" and "callOnceReady", which are callbacks. The ready state is determined by a specific signal that emitted from inspected object and "ready" state. The "IsReadyObserver" is the watcher of the signal of interest in "Proxy" and contain observers with callback to execute.
INSTALLATION: the user creates an "IsReadyObserver" and sets in it: the object's address, the object's interface signal and the object's readiness function. After that set/load observers to "IsReadyObserver".
For example:
readyObserver.watch( &proxy, &IPCProxy<InterfaceBase>::readyChanged, &IPCProxy<InterfaceBase>::ready );
CONDITION FOR PROCESSING: for the inspected object, the interface signal has changed, while the ready property is in the "ready" state. In this case, the callback in observers will be executed once.
If the interface signal for the inspected object has changed, but the ready property is in the "not ready" state. In this case, the callback in observers will not executed.
REQUIREMENT: One change in the interface signal and "ready" state corresponds to a single execution of the callback. No signal can be missed.

Main steps:

  • Creation of main objects: object for inspection "Proxy" (this is one of more possible types), object for observation "IsReadyObserver", objects for executing "Observers".
  • Installing objects/function to be executed in observers depending on the need: "callOnReady" or "callOnceReady".
  • Setting up to "IsReadyObserver" to watch out for signal in "Proxy".
  • Catching signal and execution of callback.
  • Completion of work.

Testing:

  1. Functionality check and main life cycle of components (creation, execution, completion)
  2. Processing of erroneous or incorrect data
  3. Memory leaks and undefined behavior
  4. Load testing for performance (performance, latency, metrics).
  5. Stress testing for failure

Possible points 1-4 are minimal necessary.

@zusage zusage force-pushed the api_proxy_clean branch 2 times, most recently from dab4130 to 348bc4e Compare October 20, 2020 09:48
@kunichik kunichik self-requested a review October 20, 2020 10:03
tests/unittest/CMakeLists.txt Outdated Show resolved Hide resolved
src/ipc/ipc-common/observer.h Show resolved Hide resolved
src/ipc/ipc-common/observer.h Outdated Show resolved Hide resolved
src/ipc/ipc-common/observer.h Outdated Show resolved Hide resolved
src/ipc/ipc-common/observer.h Outdated Show resolved Hide resolved
src/ipc/ipc-common/observer.h Outdated Show resolved Hide resolved
@zusage zusage force-pushed the api_proxy_clean branch 3 times, most recently from fc6256e to e1fb63b Compare October 21, 2020 15:34
@zusage zusage force-pushed the api_proxy_clean branch 3 times, most recently from fa68d46 to 0b53b18 Compare October 21, 2020 18:07
Copy link
Collaborator

@kunichik kunichik left a comment

Choose a reason for hiding this comment

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

add observer.cpp and move an appropriate code there

@zusage zusage force-pushed the api_proxy_clean branch 3 times, most recently from acf860f to acd86a1 Compare October 23, 2020 19:29
@zusage zusage requested a review from bitmouse October 23, 2020 19:54
Copy link
Collaborator

@bitmouse bitmouse left a comment

Choose a reason for hiding this comment

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

Please fix tests. I have not idea what they test, because you created two test cases within the test fixture, but it looks like there should be at least 10 of them. Please split them into separate TEST_F.

I don't understand the point of IObserver and its virtual method. Could you explain it please?

{
Q_OBJECT
public:
virtual void IsReadyObserver(const std::shared_ptr<QMetaObject::Connection> &connection) = 0;
Copy link
Collaborator

Choose a reason for hiding this comment

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

What is this method? Why?

@@ -6,18 +6,34 @@ if(${GTEST_FOUND})
add_library(GTest::GMock UNKNOWN IMPORTED)
set_target_properties(GTest::GMock PROPERTIES IMPORTED_LOCATION ${GMOCK_LIBRARY})
else()
message(WARNING "Google test/mock not found.")
message(ERROR "Google test/mock not found.")
Copy link
Collaborator

Choose a reason for hiding this comment

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

It should be warning! If there are not gtest installed, we just ignore these!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

else()
message(WARNING "Required package google test not found!")
message(ERROR "Required package google test not found!")
Copy link
Collaborator

Choose a reason for hiding this comment

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

WARNING!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

Comment on lines 11 to 27
/**********************************************************************
** The main goal is to have a flexible service, present as independent/extern component, that reacts on certain states of one object of inspection and execute vary functors either once or permanent.
** In general it is intend for a Qt objects a certain kind of types, that has the "ready" state, it is necessary to provide the ability to track this state using the "IsReadyObserver" component and an arbitrary number of observers of two types: "callOnReady" and "callOnceReady", which are functors. The ready state is determined by a specific signal that emitted from inspected object and "ready" state.
** The "IsReadyObserver" is the watcher of the signal of interest in "Proxy" and contain observers with functors to execute.
** INSTALLATION: the user creates an "IsReadyObserver" and sets in it: the object's address, the object's interface signal and the object's readiness function. After that set/load observers to "IsReadyObserver".
** For example:
** readyObserver.watch( &proxy, &IPCProxy<InterfaceBase>::readyChanged, &IPCProxy<InterfaceBase>::ready );
** CONDITION FOR PROCESSING: for the inspected object, the interface signal has changed, while the ready property is in the "ready" state. In this case, the functors in observers will be executed once.
** If the interface signal for the inspected object has changed, but the ready property is in the "not ready" state. In this case, the functors in observers will not executed.
** REQUIREMENT: One change in the interface signal and "ready" state corresponds to a single execution of the functor. No signal can be missed.
** Main steps:
** - Creation of main objects: object for inspection "Proxy" (this is one of more possible types), object for observation "IsReadyObserver", objects for executing "Observers".
** - Installing objects/function to be executed in observers depending on the need: "callOnReady" or "callOnceReady".
** - Setting up to "IsReadyObserver" to watch out for signal in "Proxy".
** - Catching signal and execution of functors.
** - Completion of work.
**********************************************************************/
Copy link
Collaborator

Choose a reason for hiding this comment

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

  1. Why you add something like this here? This is test, not a documentation. I have not checked the content, because it should not be here.
  2. This formatting is like from 90'. Please remove unnecessary stars.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Just for convenience. I did remove it.
Done

Comment on lines 83 to 86
/**********************************************************************
** INPUT: property of Proxy ready() in state disabled, trigger changeReady() is toggles 3 times.
** OUTPUT: No observer should be executed.
**********************************************************************/
Copy link
Collaborator

Choose a reason for hiding this comment

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

remove or make it readable

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

Comment on lines 127 to 130
/**********************************************************************
** INPUT: property of Proxy ready() in state enabled, trigger changeReady() is toggles 3 times.
** OUTPUT: All observer should be executed.
**********************************************************************/
Copy link
Collaborator

Choose a reason for hiding this comment

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

remove

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

Comment on lines 123 to 127
/**
* @brief checking if proxy is ready and signal exists, all observer should be executed.
* @param set to Proxy in state "true"
* @param set 2 observers
*/
Copy link
Collaborator

Choose a reason for hiding this comment

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

this is not a place for doxygen documentation!!!!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

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.

3 participants