How to inject mouse input into a ComponentPeer?

I wrote a tiny host to test our plugins, and I want it able to have random mouse operations to test the UI. I tried to wrote code below by calling handleMouseEvent, but it just have no effect at all:

class UIHolder: public juce::DocumentWindow, public juce::Timer
{
    //......
    void timerCallback() override;
    int m_curr_test_action = -1;
    int m_test_stage = 0;
    float m_test_drag_step = std::numeric_limits< float >::signaling_NaN();
    float m_test_drag_prog = std::numeric_limits< float >::signaling_NaN();
    juce::Point< float > m_test_drag_start;
    juce::Point< float > m_test_drag_end;
    juce::Point< float > m_test_click_pos;
}

enum TestAction
{
    TestClick,
    TestDoubleClick,
    TestRightDoubleClick,
    TestDrag,
    TestActionAmount
};

void UIHolder::timerCallback()
{
    auto* peer = getPeer();
    if ( peer == nullptr ) return;

    auto& prng = juce::Random::getSystemRandom();
    auto win_size = peer->getBounds();

    if ( m_curr_test_action < 0 )
    {
        m_curr_test_action = prng.nextInt( TestActionAmount );
        jassert( m_test_stage == 0 );
    }

    auto ts = juce::Time::getCurrentTime().toMilliseconds();

    if ( m_curr_test_action == TestClick )
    {
        switch ( m_test_stage )
        {
        case 0:
            m_test_click_pos = RANDP;
            peer->handleMouseEvent( juce::MouseInputSource::mouse, m_test_click_pos, juce::ModifierKeys::leftButtonModifier, 0.0f, 0.0f, ts );
            m_test_stage += 1;
            break;
        case 1:
            peer->handleMouseEvent( juce::MouseInputSource::mouse, m_test_click_pos, juce::ModifierKeys::noModifiers, 0.0f, 0.0f, ts );
            m_test_stage = 0;
            m_curr_test_action = -1;
            break;
        default:
            jassertfalse;
        }
    }
    else if ( m_curr_test_action == TestDoubleClick )
    {
        // ......
    }
}

I don’t want to use Windows SendInput calls, because it is global. Is it possible to simulate mouse actions just in JUCE’s scope?

I’m not sure whether there’s a way to do this using existing JUCE functionality. When hosting a plugin, the plugin view is a wrapped OS view (NSView, HWND etc.), and not a plain JUCE component. To create additional mouse events on that view, I think you’d need to use the OS-level APIs.