Allow resetting IE emulation level to fail in the tests

Warn about it, but don't fail the test if it fails, as it does this in
the GitHub Actions "windows-2019" environment without any apparent ill
effects.
This commit is contained in:
Vadim Zeitlin
2021-08-24 16:20:37 +02:00
parent 6a99b2d9a8
commit 7f8bd498ce

View File

@@ -259,27 +259,40 @@ TEST_CASE_METHOD(WebViewTestCase, "WebView", "[wxWebView]")
wxString result;
#if wxUSE_WEBVIEW_IE && !wxUSE_WEBVIEW_EDGE
CHECK(wxWebViewIE::MSWSetModernEmulationLevel());
// Define a specialized scope guard ensuring that we reset the emulation
// level to its default value even if any asserts below fail.
class ResetEmulationLevel
{
public:
ResetEmulationLevel()
{
// Allow this to fail because it doesn't work in GitHub Actions
// environment, but the tests below still pass there.
if ( !wxWebViewIE::MSWSetModernEmulationLevel() )
{
WARN("Setting IE modern emulation level failed.");
m_reset = false;
}
else
{
m_reset = true;
}
}
bool DoReset()
void DoReset()
{
if ( m_reset )
{
m_reset = false;
return wxWebViewIE::MSWSetModernEmulationLevel(false);
if ( !wxWebViewIE::MSWSetModernEmulationLevel(false) )
{
WARN("Resetting IE modern emulation level failed.");
}
}
}
~ResetEmulationLevel()
{
if ( m_reset )
DoReset();
}
@@ -299,7 +312,7 @@ TEST_CASE_METHOD(WebViewTestCase, "WebView", "[wxWebView]")
&result));
CHECK(result == "\"2017-10-08T21:30:40.000Z\"");
CHECK(resetEmulationLevel.DoReset());
resetEmulationLevel.DoReset();
#endif // wxUSE_WEBVIEW_IE
CHECK(m_browser->RunScript("document.write(\"Hello World!\");"));