REPORTER's HasMessage indicates that any message got reported, not stored.

This commit is contained in:
Alex Shvartzkop 2025-08-23 00:24:58 +03:00
parent 83427c38aa
commit 1dc278488d
3 changed files with 9 additions and 85 deletions

View File

@ -65,12 +65,6 @@ REPORTER& WX_TEXT_CTRL_REPORTER::Report( const wxString& aText, SEVERITY aSeveri
} }
bool WX_TEXT_CTRL_REPORTER::HasMessage() const
{
return !m_textCtrl->IsEmpty();
}
REPORTER& WX_STRING_REPORTER::Report( const wxString& aText, SEVERITY aSeverity ) REPORTER& WX_STRING_REPORTER::Report( const wxString& aText, SEVERITY aSeverity )
{ {
REPORTER::Report( aText, aSeverity ); REPORTER::Report( aText, aSeverity );
@ -93,12 +87,6 @@ void WX_STRING_REPORTER::Clear()
} }
bool WX_STRING_REPORTER::HasMessage() const
{
return !m_string.IsEmpty();
}
REPORTER& NULL_REPORTER::Report( const wxString& aText, SEVERITY aSeverity ) REPORTER& NULL_REPORTER::Report( const wxString& aText, SEVERITY aSeverity )
{ {
return REPORTER::Report( aText, aSeverity ); return REPORTER::Report( aText, aSeverity );
@ -231,12 +219,3 @@ REPORTER& STATUSBAR_REPORTER::Report( const wxString& aText, SEVERITY aSeverity
return *this; return *this;
} }
bool STATUSBAR_REPORTER::HasMessage() const
{
if( m_statusBar )
return !m_statusBar->GetStatusText( m_position ).IsEmpty();
return false;
}

View File

@ -73,7 +73,7 @@ class KICOMMON_API REPORTER
{ {
public: public:
REPORTER() : REPORTER() :
m_severityMask( 0 ) m_reportedSeverityMask( 0 )
{ } { }
virtual ~REPORTER() virtual ~REPORTER()
@ -102,7 +102,7 @@ public:
virtual REPORTER& Report( const wxString& aText, virtual REPORTER& Report( const wxString& aText,
SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED )
{ {
m_severityMask |= aSeverity; m_reportedSeverityMask |= aSeverity;
return *this; return *this;
} }
@ -129,11 +129,11 @@ public:
REPORTER& operator <<( const wxString& aText ) { return Report( aText ); } REPORTER& operator <<( const wxString& aText ) { return Report( aText ); }
/** /**
* Returns true if the reporter client is non-empty. * Returns true if any messages were reported.
*/ */
virtual bool HasMessage() const virtual bool HasMessage() const
{ {
return m_severityMask != 0; return m_reportedSeverityMask != 0;
} }
/** /**
@ -142,7 +142,7 @@ public:
*/ */
virtual bool HasMessageOfSeverity( int aSeverityMask ) const virtual bool HasMessageOfSeverity( int aSeverityMask ) const
{ {
return ( m_severityMask & aSeverityMask ) != 0; return ( m_reportedSeverityMask & aSeverityMask ) != 0;
} }
virtual EDA_UNITS GetUnits() const virtual EDA_UNITS GetUnits() const
@ -152,11 +152,11 @@ public:
virtual void Clear() virtual void Clear()
{ {
m_severityMask = 0; m_reportedSeverityMask = 0;
} }
private: private:
int m_severityMask; int m_reportedSeverityMask;
}; };
@ -179,8 +179,6 @@ public:
REPORTER& Report( const wxString& aText, REPORTER& Report( const wxString& aText,
SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override; SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
bool HasMessage() const override;
private: private:
wxTextCtrl* m_textCtrl; wxTextCtrl* m_textCtrl;
}; };
@ -201,8 +199,6 @@ public:
REPORTER& Report( const wxString& aText, SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override; REPORTER& Report( const wxString& aText, SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
bool HasMessage() const override;
const wxString& GetMessages() const; const wxString& GetMessages() const;
void Clear() override; void Clear() override;
@ -308,8 +304,6 @@ public:
REPORTER& Report( const wxString& aText, SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override; REPORTER& Report( const wxString& aText, SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
bool HasMessage() const override;
private: private:
wxStatusBar* m_statusBar; wxStatusBar* m_statusBar;
int m_position; int m_position;

View File

@ -337,17 +337,6 @@ BOOST_AUTO_TEST_CASE( NullReporter_Singleton )
BOOST_CHECK_EQUAL( &reporter1, &reporter2 ); BOOST_CHECK_EQUAL( &reporter1, &reporter2 );
} }
BOOST_AUTO_TEST_CASE( NullReporter_NoMessages )
{
REPORTER& reporter = NULL_REPORTER::GetInstance();
BOOST_CHECK( !reporter.HasMessage() );
reporter.Report( wxT("Test message"), RPT_SEVERITY_INFO );
BOOST_CHECK( !reporter.HasMessage() ); // Should still report no messages
}
BOOST_AUTO_TEST_CASE( NullReporter_SeverityMask ) BOOST_AUTO_TEST_CASE( NullReporter_SeverityMask )
{ {
REPORTER& reporter = NULL_REPORTER::GetInstance(); REPORTER& reporter = NULL_REPORTER::GetInstance();
@ -368,17 +357,6 @@ BOOST_AUTO_TEST_CASE( CliReporter_Singleton )
BOOST_CHECK_EQUAL( &reporter1, &reporter2 ); BOOST_CHECK_EQUAL( &reporter1, &reporter2 );
} }
BOOST_AUTO_TEST_CASE( CliReporter_NoMessages )
{
REPORTER& reporter = CLI_REPORTER::GetInstance();
BOOST_CHECK( !reporter.HasMessage() );
reporter.Report( wxT("Test message"), RPT_SEVERITY_INFO );
BOOST_CHECK( !reporter.HasMessage() ); // Should not store messages
}
BOOST_AUTO_TEST_CASE( StdoutReporter_Singleton ) BOOST_AUTO_TEST_CASE( StdoutReporter_Singleton )
{ {
REPORTER& reporter1 = STDOUT_REPORTER::GetInstance(); REPORTER& reporter1 = STDOUT_REPORTER::GetInstance();
@ -387,17 +365,6 @@ BOOST_AUTO_TEST_CASE( StdoutReporter_Singleton )
BOOST_CHECK_EQUAL( &reporter1, &reporter2 ); BOOST_CHECK_EQUAL( &reporter1, &reporter2 );
} }
BOOST_AUTO_TEST_CASE( StdoutReporter_NoMessages )
{
REPORTER& reporter = STDOUT_REPORTER::GetInstance();
BOOST_CHECK( !reporter.HasMessage() );
reporter.Report( wxT("Test message"), RPT_SEVERITY_INFO );
BOOST_CHECK( !reporter.HasMessage() ); // Should not store messages
}
BOOST_AUTO_TEST_CASE( WxLogReporter_Singleton ) BOOST_AUTO_TEST_CASE( WxLogReporter_Singleton )
{ {
REPORTER& reporter1 = WXLOG_REPORTER::GetInstance(); REPORTER& reporter1 = WXLOG_REPORTER::GetInstance();
@ -406,17 +373,6 @@ BOOST_AUTO_TEST_CASE( WxLogReporter_Singleton )
BOOST_CHECK_EQUAL( &reporter1, &reporter2 ); BOOST_CHECK_EQUAL( &reporter1, &reporter2 );
} }
BOOST_AUTO_TEST_CASE( WxLogReporter_NoMessages )
{
REPORTER& reporter = WXLOG_REPORTER::GetInstance();
BOOST_CHECK( !reporter.HasMessage() );
reporter.Report( wxT("Test message"), RPT_SEVERITY_INFO );
BOOST_CHECK( !reporter.HasMessage() ); // Should not store messages
}
// Note: WX_TEXT_CTRL_REPORTER and STATUSBAR_REPORTER tests would require // Note: WX_TEXT_CTRL_REPORTER and STATUSBAR_REPORTER tests would require
// actual wxWidgets objects or more sophisticated mocking // actual wxWidgets objects or more sophisticated mocking
@ -428,15 +384,10 @@ BOOST_AUTO_TEST_CASE( ReporterInterface_Polymorphism )
for( auto& reporter : reporters ) for( auto& reporter : reporters )
{ {
reporter->Report( wxT("Polymorphic test"), RPT_SEVERITY_INFO ); reporter->Report( wxT( "Polymorphic test" ), RPT_SEVERITY_INFO );
// WX_STRING_REPORTER and TEST_REPORTER should both store messages
if( dynamic_cast<WX_STRING_REPORTER*>( reporter.get() ) ||
dynamic_cast<TEST_REPORTER*>( reporter.get() ) )
{
BOOST_CHECK( reporter->HasMessage() ); BOOST_CHECK( reporter->HasMessage() );
} }
}
} }
BOOST_AUTO_TEST_CASE( ReporterInterface_ChainedOperations ) BOOST_AUTO_TEST_CASE( ReporterInterface_ChainedOperations )