Month Two: Week Two
This week, after completing the merging of the unit tests and the main repository, my main task was to begin the test-driven development side of our project. This means I was tasked with going into the unit tests and adding in my new GWindowTests file. In this file I will utilize the interface I wrote for GWindow to create tests for each function that will prove the library is functioning correctly.
The main issue I encountered was a flawed understanding of the Broadcaster / Listener we are using to communicate operating system messages to the end-user. I understood that my GWindow was a broadcaster and the end-user would derive their own listener from our GListener interface, but I didn't understand how the messages were actually being generated and sent. I needed to find a way to test the messaging system of my library, but without this knowledge I really had no idea how to go about it.
I started by looking at the interface my GWindow is derived from, the GBroadcasting interface. It has a RegisterListener function which only adds the id of the listener to a map; I couldn't see anything really about messages or sending or receiving. Next I checked the OnEvent function of the GListener which is run every time the Listener receives a message. I saw within this function the Listener was reacting to GBufferedInput events based on the id of the event passed in. This gave me a hint to go one step further and figure out where OnEvent is actually being called. Because of the parameters of OnEvent, I knew that message had to be sent from whoever was using this function.
Turns out the real cause of the trouble was that a file called GBI_callback.cpp was hidden inside the external dependencies drop-down in one of the many projects in our solution. I had never seen this file before, but it turns out this file actually holds the WndProc for GBufferedInput which captures all the Win32 messages sent to the broadcaster. At this point I saw that the Win3I2 message was being translated into our custom Gateware messages and THEN sent off to each registered Listener with the OnEvent function. Using this knowledge, I added my own if statement that is only true if the sending interface is my GWindow. From here I just increment a simple number to check if the window is maximized or not. At this point I have completely completed my test cases and am moving on to porting the tests to Linux and Mac and starting development.
No comments:
Post a Comment