Add auxiliary API for Proxy#313
Conversation
bitmouse
left a comment
There was a problem hiding this comment.
Please add unit tests or/and test showing the usage of new functionality.
49e8038 to
34a29fd
Compare
bitmouse
left a comment
There was a problem hiding this comment.
I do not understand the test. Are you testing setter/getter pair?
| 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) ); |
65649c8 to
5dd42d0
Compare
| 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]); | ||
| } | ||
|
|
There was a problem hiding this comment.
What do you test?
Could you test the actual usage of new functionality?
There was a problem hiding this comment.
This is not a complete test cases. I will inform you.
Wait, please.
5dd42d0 to
2b38638
Compare
kunichik
left a comment
There was a problem hiding this comment.
Please align the code ( curly braces etc)
2b38638 to
cc5fa36
Compare
| { | ||
| Q_OBJECT | ||
| public: | ||
| virtual void onReadyChanged(std::shared_ptr<QMetaObject::Connection> connection) = 0; |
There was a problem hiding this comment.
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.
| 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") |
There was a problem hiding this comment.
verify if it's enough to use if(GMOCK_LIBRARY-NOTFOUND) instead and reverse logic
a09fa13 to
9c55e92
Compare
9c55e92 to
8dfd591
Compare
kunichik
left a comment
There was a problem hiding this comment.
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!
|
|
||
| public: | ||
| using InterfaceType = AdapterType; | ||
| IsReadyObserver m_readyObserver{}; |
There was a problem hiding this comment.
Why is it here? We discussed that already that we do not want to extend this class.
There was a problem hiding this comment.
Please move it from this class. We do not want it here!
| { | ||
| Q_OBJECT | ||
| public: | ||
| virtual void onReadyChanged(std::shared_ptr<QMetaObject::Connection> connection) = 0; |
There was a problem hiding this comment.
IObserver::onReadyChanged? I think this method should be in IsReadyObserver.
| public: | ||
| Counter c1; | ||
| Counter c2; | ||
| StandartObserver < std::function<void()> > * obs1 = new StandartObserver < std::function<void()> > (std::bind(&Counter::incValue, &c1) ); |
There was a problem hiding this comment.
std::unique_ptr?
Why not just make it a member of the class (not a pointer)?
| // Check values after signal call | ||
| ASSERT_EQ(c1.getValue(), 3); // for StandartObserver | ||
| ASSERT_EQ(c2.getValue(), 1); // for SingleTimeObserver | ||
| } |
There was a problem hiding this comment.
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".
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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:
- Functionality check and main life cycle of components (creation, execution, completion)
- Processing of erroneous or incorrect data
- Memory leaks and undefined behavior
- Load testing for performance (performance, latency, metrics).
- Stress testing for failure
Possible points 1-4 are minimal necessary.
dab4130 to
348bc4e
Compare
348bc4e to
6b91de3
Compare
fc6256e to
e1fb63b
Compare
fa68d46 to
0b53b18
Compare
kunichik
left a comment
There was a problem hiding this comment.
add observer.cpp and move an appropriate code there
acf860f to
acd86a1
Compare
bitmouse
left a comment
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
What is this method? Why?
| 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.") |
There was a problem hiding this comment.
It should be warning! If there are not gtest installed, we just ignore these!
| ) | ||
| else() | ||
| message(WARNING "Required package google test not found!") | ||
| message(ERROR "Required package google test not found!") |
| /********************************************************************** | ||
| ** 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. | ||
| **********************************************************************/ |
There was a problem hiding this comment.
- 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.
- This formatting is like from 90'. Please remove unnecessary stars.
There was a problem hiding this comment.
Just for convenience. I did remove it.
Done
| /********************************************************************** | ||
| ** INPUT: property of Proxy ready() in state disabled, trigger changeReady() is toggles 3 times. | ||
| ** OUTPUT: No observer should be executed. | ||
| **********************************************************************/ |
There was a problem hiding this comment.
remove or make it readable
| /********************************************************************** | ||
| ** INPUT: property of Proxy ready() in state enabled, trigger changeReady() is toggles 3 times. | ||
| ** OUTPUT: All observer should be executed. | ||
| **********************************************************************/ |
03ef53d to
508f66c
Compare
| /** | ||
| * @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 | ||
| */ |
There was a problem hiding this comment.
this is not a place for doxygen documentation!!!!
96b3ee5 to
4f8b2c9
Compare
cad5b4c to
af34354
Compare
No description provided.