Fix tests build with wxNO_IMPLICIT_WXSTRING_ENCODING

Add wxASCII_STR to the tests sources too.
This commit is contained in:
Arrigo Marchiori
2020-04-09 22:35:36 +02:00
committed by Vadim Zeitlin
parent 57e136d9e1
commit d16787e1af
2 changed files with 26 additions and 23 deletions

View File

@@ -109,9 +109,10 @@ static wxString FormatAssertMessage(const wxString& file,
const wxString& msg) const wxString& msg)
{ {
wxString str; wxString str;
str << "wxWidgets assert: " << cond << " failed " str << wxASCII_STR("wxWidgets assert: ") << cond
"at " << file << ":" << line << " in " << func << wxASCII_STR(" failed at ") << file << wxASCII_STR(":") << line
<< " with message '" << msg << "'"; << wxASCII_STR(" in ") << func << wxASCII_STR(" with message '")
<< msg << wxASCII_STR("'");
return str; return str;
} }
@@ -133,7 +134,7 @@ static void TestAssertHandler(const wxString& file,
{ {
// Exceptions thrown from worker threads are not caught currently and // Exceptions thrown from worker threads are not caught currently and
// so we'd just die without any useful information -- abort instead. // so we'd just die without any useful information -- abort instead.
abortReason << assertMessage << "in a worker thread."; abortReason << assertMessage << wxASCII_STR("in a worker thread.");
} }
#if __cplusplus >= 201703L || wxCHECK_VISUALC_VERSION(14) #if __cplusplus >= 201703L || wxCHECK_VISUALC_VERSION(14)
else if ( uncaught_exceptions() ) else if ( uncaught_exceptions() )
@@ -146,12 +147,14 @@ static void TestAssertHandler(const wxString& file,
// about why the test failed then. // about why the test failed then.
if ( s_lastAssertMessage.empty() ) if ( s_lastAssertMessage.empty() )
{ {
abortReason << assertMessage << "while handling an exception"; abortReason << assertMessage
<< wxASCII_STR("while handling an exception");
} }
else // In this case the exception is due to a previous assert. else // In this case the exception is due to a previous assert.
{ {
abortReason << s_lastAssertMessage << "\n and another " abortReason << s_lastAssertMessage
<< assertMessage << " while handling it."; << wxASCII_STR("\n and another ") << assertMessage
<< wxASCII_STR(" while handling it.");
} }
} }
else // Can "safely" throw from here. else // Can "safely" throw from here.
@@ -229,8 +232,8 @@ public:
// show some details about the exception along the way. // show some details about the exception along the way.
virtual bool OnExceptionInMainLoop() wxOVERRIDE virtual bool OnExceptionInMainLoop() wxOVERRIDE
{ {
wxFprintf(stderr, "Unhandled exception in the main loop: %s\n", wxFprintf(stderr, wxASCII_STR("Unhandled exception in the main loop: %s\n"),
Catch::translateActiveException()); wxASCII_STR(Catch::translateActiveException().c_str()));
throw; throw;
} }
@@ -358,7 +361,7 @@ extern bool IsNetworkAvailable()
// under Travis to avoid false positives. // under Travis to avoid false positives.
static int s_isTravis = -1; static int s_isTravis = -1;
if ( s_isTravis == -1 ) if ( s_isTravis == -1 )
s_isTravis = wxGetEnv("TRAVIS", NULL); s_isTravis = wxGetEnv(wxASCII_STR("TRAVIS"), NULL);
if ( s_isTravis ) if ( s_isTravis )
return false; return false;
@@ -369,7 +372,7 @@ extern bool IsNetworkAvailable()
wxSocketBase::Initialize(); wxSocketBase::Initialize();
wxIPV4address addr; wxIPV4address addr;
if (!addr.Hostname("www.google.com") || !addr.Service("www")) if (!addr.Hostname(wxASCII_STR("www.google.com")) || !addr.Service(wxASCII_STR("www")))
{ {
wxSocketBase::Shutdown(); wxSocketBase::Shutdown();
return false; return false;
@@ -392,18 +395,18 @@ extern bool IsAutomaticTest()
// Allow setting an environment variable to emulate buildslave user for // Allow setting an environment variable to emulate buildslave user for
// testing. // testing.
wxString username; wxString username;
if ( !wxGetEnv("WX_TEST_USER", &username) ) if ( !wxGetEnv(wxASCII_STR("WX_TEST_USER"), &username) )
username = wxGetUserId(); username = wxGetUserId();
username.MakeLower(); username.MakeLower();
s_isAutomatic = username == "buildbot" || s_isAutomatic = username == wxASCII_STR("buildbot") ||
username.Matches("sandbox*"); username.Matches(wxASCII_STR("sandbox*"));
// Also recognize Travis and AppVeyor CI environments. // Also recognize Travis and AppVeyor CI environments.
if ( !s_isAutomatic ) if ( !s_isAutomatic )
{ {
s_isAutomatic = wxGetEnv("TRAVIS", NULL) || s_isAutomatic = wxGetEnv(wxASCII_STR("TRAVIS"), NULL) ||
wxGetEnv("APPVEYOR", NULL); wxGetEnv(wxASCII_STR("APPVEYOR"), NULL);
} }
} }
@@ -416,7 +419,7 @@ extern bool IsRunningUnderXVFB()
if ( s_isRunningUnderXVFB == -1 ) if ( s_isRunningUnderXVFB == -1 )
{ {
wxString value; wxString value;
s_isRunningUnderXVFB = wxGetEnv("wxUSE_XVFB", &value) && value == "1"; s_isRunningUnderXVFB = wxGetEnv(wxASCII_STR("wxUSE_XVFB"), &value) && value == wxASCII_STR("1");
} }
return s_isRunningUnderXVFB == 1; return s_isRunningUnderXVFB == 1;
@@ -446,14 +449,14 @@ bool EnableUITests()
// Allow explicitly configuring this via an environment variable under // Allow explicitly configuring this via an environment variable under
// all platforms. // all platforms.
wxString enabled; wxString enabled;
if ( wxGetEnv("WX_UI_TESTS", &enabled) ) if ( wxGetEnv(wxASCII_STR("WX_UI_TESTS"), &enabled) )
{ {
if ( enabled == "1" ) if ( enabled == wxASCII_STR("1") )
s_enabled = 1; s_enabled = 1;
else if ( enabled == "0" ) else if ( enabled == wxASCII_STR("0") )
s_enabled = 0; s_enabled = 0;
else else
wxFprintf(stderr, "Unknown \"WX_UI_TESTS\" value \"%s\" ignored.\n", enabled); wxFprintf(stderr, wxASCII_STR("Unknown \"WX_UI_TESTS\" value \"%s\" ignored.\n"), enabled);
} }
if ( s_enabled == -1 ) if ( s_enabled == -1 )
@@ -616,7 +619,7 @@ int TestApp::RunTests()
// Switch off logging to avoid interfering with the tests output unless // Switch off logging to avoid interfering with the tests output unless
// WXTRACE is set, as otherwise setting it would have no effect while // WXTRACE is set, as otherwise setting it would have no effect while
// running the tests. // running the tests.
if ( !wxGetEnv("WXTRACE", NULL) ) if ( !wxGetEnv(wxASCII_STR("WXTRACE"), NULL) )
wxLog::EnableLogging(false); wxLog::EnableLogging(false);
#endif #endif

View File

@@ -16,7 +16,7 @@
#include "wx/app.h" #include "wx/app.h"
#include "testableframe.h" #include "testableframe.h"
wxTestableFrame::wxTestableFrame() : wxFrame(NULL, wxID_ANY, "Test Frame") wxTestableFrame::wxTestableFrame() : wxFrame(NULL, wxID_ANY, wxASCII_STR("Test Frame"))
{ {
// Use fixed position to facilitate debugging. // Use fixed position to facilitate debugging.
Move(200, 200); Move(200, 200);