I refactored the input device monitor module from the screen based on the new architecture and used SOLID principles to make this module scalable. I also added test coverage.
What did I do?
Refactored event sender based on the new architecture.
Applied SOLID principles to make the input device monitor scalable.
Test coverage.
How did I do it?
Reviewed the new architecture and its way of working.
S -> avoiding code repetition and giving a single responsibility to the modules.
O -> using generics and abstractions.
L -> concrete implementations can replace their abstraction parents.
I -> creating or passing through parameters an "object" of the type of an interface, we can use only the methods we need, like IEventSerializer event serializer, IEventSender event sender, etc.
D -> using composition with interfaces, so we can pass a specific implementation so that the behavior depends in that particular implementation, such as the IEventSerializer of the socket, the event handlers of the app handler, etc.
Test coverage -> for the input device monitor modules
Why did I do it?
To adapt the old implementation with the new architecture and in case there is another change it can be done without modifying the existing modules, but rather adding implementations and changing the dependency injection for these new implementations.
Type of Change
[ ] β¨ New Feature (non-breaking change which adds functionality)
[ ] π οΈ Bug Fix (non-breaking change which fixes an issue)
[ ] β Breaking Change (fix or feature that would cause existing functionality to change)
[X] π§Ή Code Refactor
[X] β Build Configuration Change
[ ] π Documentation
[ ] ποΈ Chore
Pull Request Checklist
[X] My commit messages are detailed.
[X] My code follows the code style of this project.
[ ] No existing features have been broken without good reason.
[] My change requires a change to the documentation.
[ ] I have updated the documentation accordingly.
[X] I have added tests to cover my changes.
[X] All new and existing tests pass.
How to test?
Running the unit tests:
The client socket tests use a server socket running in another thread and these fail when executed together with the other modules, for this reason they must be executed isolating it:
Run all the tests except those of the client socket:
cargo test --package screen --lib -- input_device_monitor -- --ignored --show-output
Run the socket client tests:
cargo test --package screen --lib -- --test-threads=1 input_device_monitor --ignored --show-output
Running the frontend library server socket and screen client socket
Clone the frontend library (this branch "task-207/input-intermediate" for now until the hotfix is ββmade)
Add this unit test inside the "SocketServerTest" test and run:
@Test
public void runSocketServer() {
KeyboardEventManager keyboardEventManager = new KeyboardEventManager();
MouseEventManager mouseEventManager = new MouseEventManager();
Receiver receiver = new Receiver();
receiver.addBuffer(keyboardEventManager);
receiver.addBuffer(mouseEventManager);
AtomicBoolean atomicBoolean = new AtomicBoolean(true);
Thread thread = startServer(receiver, atomicBoolean);
try {
thread.join();
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
Run the screen client socket running:
cargo run
You will be able to see the communication and if you want to see more details you can debug the socket server:
US Refactor socket client for screen based on the latest architecture
US 216
TASK 228
Description
I refactored the input device monitor module from the screen based on the new architecture and used SOLID principles to make this module scalable. I also added test coverage.
What did I do?
How did I do it?
Why did I do it?
To adapt the old implementation with the new architecture and in case there is another change it can be done without modifying the existing modules, but rather adding implementations and changing the dependency injection for these new implementations.
Type of Change
Pull Request Checklist
How to test?
Running the unit tests:
The client socket tests use a server socket running in another thread and these fail when executed together with the other modules, for this reason they must be executed isolating it:
Run all the tests except those of the client socket:
Run the socket client tests:
Running the frontend library server socket and screen client socket
Clone the frontend library (this branch "task-207/input-intermediate" for now until the hotfix is ββmade)
Add this unit test inside the "SocketServerTest" test and run:
Run the screen client socket running:
You will be able to see the communication and if you want to see more details you can debug the socket server:
![Screenshot from 2024-06-30 14-10-22](https://github.com/Pending-Name-21/screen/assets/135136456/2ba1ffdc-c3ca-4ba0-8e85-73a4899c14a0)