这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@devin-ai-integration
Copy link
Contributor

Fix ProfileFacadesTest failures by resolving connection storage and callback issues

Summary

This PR fixes all ProfileFacadesTest failures in the C++ MIDI-CI library by resolving critical issues in the connection storage system and message callback mechanism that prevented profile discovery communication between devices.

Root Cause Analysis

The ProfileFacadesTest failures were caused by three interconnected issues:

  1. Connection Storage Type Mismatch: The MidiCIDevice connection storage methods used uint8_t keys while callers passed uint32_t MUIDs, causing connections to be stored with truncated keys and never found during lookups.

  2. Address Retrieval Bug: The CIRetrieval::get_addressing() method was reading the address from the wrong byte position (byte 4 instead of byte 1) during message deserialization.

  3. Disconnected Callback Systems: The device's message_received_callback_ was never registered with the Messenger's internal callback system, so ProfileReply messages were processed correctly but never reached test callbacks.

Changes Made

1. Fixed Connection Storage Type Mismatch

  • Updated MidiCIDevice::store_connection(), remove_connection(), get_connection() parameter types from uint8_t to uint32_t
  • Changed get_connections() return type to use std::unordered_map<uint32_t, ...>
  • Updated the internal connections_ container to use uint32_t keys
  • Updated corresponding header file declarations

2. Fixed Address Retrieval Bug

  • Modified CIRetrieval::get_addressing() to read from byte position 1 instead of 4
  • This ensures proper address extraction during MIDI-CI message processing

3. Connected Device Callbacks to Messenger

  • Modified MidiCIDevice::set_message_received_callback() to automatically register the callback with the Messenger's callback system
  • This ensures ProfileReply and other messages reach the device's registered callbacks

Test Results

All ProfileFacadesTest cases now pass successfully:

  • ✅ ProfileFacadesTest.configureProfiles
  • ✅ ProfileFacadesTest.configureProfiles2
  • ✅ ProfileFacadesTest.configureProfiles3

Verification

The fix was verified by:

  1. Building the project successfully with cmake --build build
  2. Running the specific ProfileFacadesTest suite: ./build/tests/midicci-gtest --gtest_filter="ProfileFacadesTest.*"
  3. Running the full test suite to ensure no regressions were introduced

Technical Details

The message flow now works correctly:

  1. Device1 sends discovery inquiry to Device2
  2. Device2 processes profile inquiry and generates ProfileReply with correct profile counts
  3. ProfileReply is sent back to Device1 via the TestCIMediator's message routing
  4. Device1's Messenger processes the ProfileReply and calls registered callbacks
  5. Test callback receives the ProfileReply and extracts profile counts successfully

Link to Devin run: https://app.devin.ai/sessions/b86cef761d4c40f985dafa7fa7ea6e4f

Requested by: Atsushi Eno (atsushieno@gmail.com)

…allback issues

- Fix connection storage type mismatch: change from uint8_t to uint32_t keys in MidiCIDevice
- Fix address retrieval bug in CIRetrieval::get_addressing() (read from byte 1 instead of 4)
- Connect device message callbacks to Messenger callback system in set_message_received_callback()
- All ProfileFacadesTest cases now pass: configureProfiles, configureProfiles2, configureProfiles3

The root cause was that ProfileReply messages were being generated correctly but never
reaching the test callbacks due to disconnected callback systems and type mismatches
in the connection storage that prevented proper message routing between devices.

Co-Authored-By: Atsushi Eno <atsushieno@gmail.com>
@atsushieno atsushieno merged commit 0e1cccf into main Jun 19, 2025
3 of 4 checks passed
@atsushieno atsushieno deleted the devin/1750342046-fix-profile-facades-test branch June 19, 2025 14:50
devin-ai-integration bot added a commit that referenced this pull request Jun 19, 2025
- Change uint8_t to uint32_t for MUID variables in CIDeviceModel::on_connections_changed()
- Aligns with core MidiCIDevice interface changes that use uint32_t for MUIDs
- Fixes Qt GUI Device combo box not populating after discovery

The issue was that PR #61 changed the core device to use uint32_t for MUIDs,
but the tooling layer was still using uint8_t vectors, causing a type mismatch
that prevented connection synchronization between core and GUI layers.

Co-Authored-By: Atsushi Eno <atsushieno@gmail.com>
atsushieno added a commit that referenced this pull request Jun 19, 2025
…n-list-regression

Fix connection list regression from PR #61 MUID type change
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