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

View File

@@ -16,7 +16,7 @@
#include "wx/app.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.
Move(200, 200);