Commit fdb7874d by Shahbaz Youssefi Committed by Commit Bot

Gracefully fail end2end tests if no window support

EGL_WINDOW_BIT is now specifically requested for tests that open a window (those that aren't WithNoFixture). This makes sure pbuffer-only configs are not selected for the window. Additionally, a few WithNoFixture tests are made more robust in the presence of no-window configs. In the context of crbug.com/1034840, this means that a subset of end2end tests would be able to run in a remote desktop environment. Tested on Linux/X11 by turning a subset of configs PBUFFER-only. Bug: chromium:1034840 Change-Id: I09fd149d43d3b865856fe6b9491c5f333f4a2efc Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2378922Reviewed-by: 's avatarJonah Ryan-Davis <jonahr@google.com> Reviewed-by: 's avatarback sept 10 - Jamie Madill <jmadill@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
parent e3db3d20
......@@ -62,14 +62,31 @@ class EGLRobustnessTest : public ANGLETest
ASSERT_TRUE(eglGetConfigs(mDisplay, nullptr, 0, &nConfigs) == EGL_TRUE);
ASSERT_LE(1, nConfigs);
std::vector<EGLConfig> allConfigs(nConfigs);
int nReturnedConfigs = 0;
ASSERT_TRUE(eglGetConfigs(mDisplay, &mConfig, 1, &nReturnedConfigs) == EGL_TRUE);
ASSERT_EQ(1, nReturnedConfigs);
ASSERT_TRUE(eglGetConfigs(mDisplay, allConfigs.data(), nConfigs, &nReturnedConfigs) ==
EGL_TRUE);
ASSERT_EQ(nConfigs, nReturnedConfigs);
mWindow = eglCreateWindowSurface(mDisplay, mConfig, mOSWindow->getNativeWindow(), nullptr);
ASSERT_EGL_SUCCESS();
for (const EGLConfig &config : allConfigs)
{
EGLint surfaceType;
eglGetConfigAttrib(mDisplay, config, EGL_SURFACE_TYPE, &surfaceType);
if ((surfaceType & EGL_WINDOW_BIT) != 0)
{
mConfig = config;
mInitialized = true;
break;
}
}
mInitialized = true;
if (mInitialized)
{
mWindow =
eglCreateWindowSurface(mDisplay, mConfig, mOSWindow->getNativeWindow(), nullptr);
ASSERT_EGL_SUCCESS();
}
}
void testTearDown() override
......
......@@ -58,10 +58,25 @@ class MultisampleTest : public ANGLETestWithParam<MultisampleTestParams>
ANGLE_SKIP_TEST_IF(IsNexus5X() || IsNexus6P());
// Find a config that uses RGBA8 and allows 4x multisampling.
const EGLint configAttributes[] = {
EGL_RED_SIZE, 8, EGL_GREEN_SIZE, 8, EGL_BLUE_SIZE, 8,
EGL_ALPHA_SIZE, 8, EGL_DEPTH_SIZE, 24, EGL_STENCIL_SIZE, 8,
EGL_SAMPLE_BUFFERS, 1, EGL_SAMPLES, 4, EGL_NONE};
const EGLint configAttributes[] = {EGL_SURFACE_TYPE,
EGL_WINDOW_BIT,
EGL_RED_SIZE,
8,
EGL_GREEN_SIZE,
8,
EGL_BLUE_SIZE,
8,
EGL_ALPHA_SIZE,
8,
EGL_DEPTH_SIZE,
24,
EGL_STENCIL_SIZE,
8,
EGL_SAMPLE_BUFFERS,
1,
EGL_SAMPLES,
4,
EGL_NONE};
EGLint configCount;
EGLConfig multisampledConfig;
......
......@@ -453,7 +453,7 @@ void ANGLETestBase::initOSWindow()
mFixture->osWindow->disableErrorMessageDialog();
if (!mFixture->osWindow->initialize(windowName.c_str(), 128, 128))
{
std::cerr << "Failed to initialize OS Window.";
std::cerr << "Failed to initialize OS Window.\n";
}
if (IsAndroid())
......@@ -463,6 +463,11 @@ void ANGLETestBase::initOSWindow()
}
}
if (!mFixture->osWindow->valid())
{
return;
}
// On Linux we must keep the test windows visible. On Windows it doesn't seem to need it.
setWindowVisible(getOSWindow(), !IsWindows());
......@@ -556,6 +561,16 @@ void ANGLETestBase::ANGLETestSetUp()
mLastLoadedDriver = mCurrentParams->driver;
}
if (gEnableANGLEPerTestCaptureLabel)
{
SetupEnvironmentVarsForCaptureReplay();
}
if (!mFixture->osWindow->valid())
{
return;
}
// Resize the window before creating the context so that the first make current
// sets the viewport and scissor box to the right size.
bool needSwap = false;
......@@ -567,10 +582,6 @@ void ANGLETestBase::ANGLETestSetUp()
}
needSwap = true;
}
if (gEnableANGLEPerTestCaptureLabel)
{
SetupEnvironmentVarsForCaptureReplay();
}
// WGL tests are currently disabled.
if (mFixture->wglWindow)
{
......@@ -632,7 +643,7 @@ void ANGLETestBase::ANGLETestTearDown()
WriteDebugMessage("Exiting %s.%s\n", info->test_case_name(), info->name());
}
if (mCurrentParams->noFixture)
if (mCurrentParams->noFixture || !mFixture->osWindow->valid())
{
return;
}
......
......@@ -279,6 +279,8 @@ bool EGLWindow::initializeSurface(OSWindow *osWindow,
const char *displayExtensions = eglQueryString(mDisplay, EGL_EXTENSIONS);
std::vector<EGLint> configAttributes = {
EGL_SURFACE_TYPE,
EGL_WINDOW_BIT,
EGL_RED_SIZE,
(mConfigParams.redBits >= 0) ? mConfigParams.redBits : EGL_DONT_CARE,
EGL_GREEN_SIZE,
......@@ -605,7 +607,9 @@ bool EGLWindow::isGLInitialized() const
}
// Find an EGLConfig that is an exact match for the specified attributes. EGL_FALSE is returned if
// the EGLConfig is found. This indicates that the EGLConfig is not supported.
// the EGLConfig is found. This indicates that the EGLConfig is not supported. Surface type is
// special-cased as it's possible for a config to return support for both EGL_WINDOW_BIT and
// EGL_PBUFFER_BIT even though only one of them is requested.
EGLBoolean EGLWindow::FindEGLConfig(EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *config)
{
EGLint numConfigs = 0;
......@@ -625,7 +629,9 @@ EGLBoolean EGLWindow::FindEGLConfig(EGLDisplay dpy, const EGLint *attrib_list, E
EGLint actualValue = EGL_DONT_CARE;
eglGetConfigAttrib(dpy, allConfigs[i], curAttrib[0], &actualValue);
if (curAttrib[1] != actualValue)
if ((curAttrib[0] == EGL_SURFACE_TYPE &&
(curAttrib[1] & actualValue) != curAttrib[1]) ||
(curAttrib[0] != EGL_SURFACE_TYPE && curAttrib[1] != actualValue))
{
matchFound = false;
break;
......
......@@ -351,6 +351,12 @@ OSWindow::OSWindow() : mX(0), mY(0), mWidth(0), mHeight(0) {}
OSWindow::~OSWindow() {}
bool OSWindow::initialize(const std::string &name, int width, int height)
{
mValid = initializeImpl(name, width, height);
return mValid;
}
int OSWindow::getX() const
{
return mX;
......
......@@ -25,9 +25,9 @@ class ANGLE_UTIL_EXPORT OSWindow
static OSWindow *New();
static void Delete(OSWindow **osWindow);
virtual bool initialize(const std::string &name, int width, int height) = 0;
virtual void destroy() = 0;
virtual void disableErrorMessageDialog() = 0;
bool initialize(const std::string &name, int width, int height);
virtual void destroy() = 0;
virtual void disableErrorMessageDialog() = 0;
int getX() const;
int getY() const;
......@@ -65,16 +65,23 @@ class ANGLE_UTIL_EXPORT OSWindow
// Pops events look for the test event
bool didTestEventFire();
// Whether window has been successfully initialized.
bool valid() const { return mValid; }
protected:
OSWindow();
virtual ~OSWindow();
virtual bool initializeImpl(const std::string &name, int width, int height) = 0;
int mX;
int mY;
int mWidth;
int mHeight;
std::list<Event> mEvents;
bool mValid;
};
#endif // UTIL_OSWINDOW_H_
......@@ -60,7 +60,7 @@ AndroidWindow::AndroidWindow() {}
AndroidWindow::~AndroidWindow() {}
bool AndroidWindow::initialize(const std::string &name, int width, int height)
bool AndroidWindow::initializeImpl(const std::string &name, int width, int height)
{
return resize(width, height);
}
......@@ -73,7 +73,7 @@ void AndroidWindow::resetNativeWindow() {}
EGLNativeWindowType AndroidWindow::getNativeWindow() const
{
// Return the entire Activity Surface for now
// sApp->window is valid only after sInitWindowDone, which is true after initialize()
// sApp->window is valid only after sInitWindowDone, which is true after initializeImpl()
return sApp->window;
}
......@@ -180,7 +180,7 @@ void android_main(struct android_app *app)
// Message loop, polling for events indefinitely (due to -1 timeout)
// Must be here in order to handle APP_CMD_INIT_WINDOW event,
// which occurs after AndroidWindow::initialize(), but before AndroidWindow::messageLoop
// which occurs after AndroidWindow::initializeImpl(), but before AndroidWindow::messageLoop
while (ALooper_pollAll(-1, nullptr, &events, reinterpret_cast<void **>(&source)) >= 0)
{
if (source != nullptr)
......
......@@ -17,7 +17,6 @@ class AndroidWindow : public OSWindow
AndroidWindow();
~AndroidWindow() override;
bool initialize(const std::string &name, int width, int height) override;
void disableErrorMessageDialog() override;
void destroy() override;
......@@ -34,6 +33,9 @@ class AndroidWindow : public OSWindow
void setVisible(bool isVisible) override;
void signalTestEvent() override;
private:
bool initializeImpl(const std::string &name, int width, int height) override;
};
#endif /* UTIL_ANDROID_WINDOW_H_ */
......@@ -80,7 +80,7 @@ ScenicWindow::~ScenicWindow()
destroy();
}
bool ScenicWindow::initialize(const std::string &name, int width, int height)
bool ScenicWindow::initializeImpl(const std::string &name, int width, int height)
{
// Set up scenic resources.
mShape.SetEventMask(fuchsia::ui::gfx::kMetricsEventMask);
......
......@@ -43,7 +43,6 @@ class ANGLE_UTIL_EXPORT ScenicWindow : public OSWindow
~ScenicWindow() override;
// OSWindow:
bool initialize(const std::string &name, int width, int height) override;
void disableErrorMessageDialog() override;
void destroy() override;
void resetNativeWindow() override;
......@@ -71,6 +70,7 @@ class ANGLE_UTIL_EXPORT ScenicWindow : public OSWindow
void onViewProperties(const fuchsia::ui::gfx::ViewProperties &properties);
private:
bool initializeImpl(const std::string &name, int width, int height) override;
void updateViewSize();
// ScenicWindow async loop.
......
......@@ -35,7 +35,6 @@ class OSXWindow : public OSWindow
OSXWindow();
~OSXWindow() override;
bool initialize(const std::string &name, int width, int height) override;
void disableErrorMessageDialog() override;
void destroy() override;
......@@ -56,6 +55,8 @@ class OSXWindow : public OSWindow
NSWindow *getNSWindow() const;
private:
bool initializeImpl(const std::string &name, int width, int height) override;
NSWindow *mWindow;
WindowDelegate *mDelegate;
ContentView *mView;
......
......@@ -622,7 +622,7 @@ OSXWindow::~OSXWindow()
destroy();
}
bool OSXWindow::initialize(const std::string &name, int width, int height)
bool OSXWindow::initializeImpl(const std::string &name, int width, int height)
{
if (!InitializeAppKit())
{
......
......@@ -16,7 +16,7 @@ OzoneWindow::OzoneWindow() {}
OzoneWindow::~OzoneWindow() {}
bool OzoneWindow::initialize(const std::string &name, int width, int height)
bool OzoneWindow::initializeImpl(const std::string &name, int width, int height)
{
mNative.x = mX = 0;
mNative.y = mY = 0;
......
......@@ -19,7 +19,6 @@ class OzoneWindow : public OSWindow
OzoneWindow();
~OzoneWindow() override;
bool initialize(const std::string &name, int width, int height) override;
void disableErrorMessageDialog() override;
void destroy() override;
......@@ -38,6 +37,8 @@ class OzoneWindow : public OSWindow
void signalTestEvent() override;
private:
bool initializeImpl(const std::string &name, int width, int height) override;
struct Native
{
int32_t x;
......
......@@ -498,7 +498,7 @@ Win32Window::~Win32Window()
destroy();
}
bool Win32Window::initialize(const std::string &name, int width, int height)
bool Win32Window::initializeImpl(const std::string &name, int width, int height)
{
destroy();
......
......@@ -21,7 +21,6 @@ class Win32Window : public OSWindow
Win32Window();
~Win32Window() override;
bool initialize(const std::string &name, int width, int height) override;
void destroy() override;
void disableErrorMessageDialog() override;
......@@ -44,6 +43,7 @@ class Win32Window : public OSWindow
void signalTestEvent() override;
private:
bool initializeImpl(const std::string &name, int width, int height) override;
static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
std::string mParentClassName;
......
......@@ -277,7 +277,7 @@ X11Window::~X11Window()
destroy();
}
bool X11Window::initialize(const std::string &name, int width, int height)
bool X11Window::initializeImpl(const std::string &name, int width, int height)
{
destroy();
......
......@@ -24,7 +24,6 @@ class ANGLE_UTIL_EXPORT X11Window : public OSWindow
X11Window(int visualId);
~X11Window() override;
bool initialize(const std::string &name, int width, int height) override;
void disableErrorMessageDialog() override;
void destroy() override;
......@@ -43,6 +42,7 @@ class ANGLE_UTIL_EXPORT X11Window : public OSWindow
void signalTestEvent() override;
private:
bool initializeImpl(const std::string &name, int width, int height) override;
void processEvent(const XEvent &event);
Atom WM_DELETE_WINDOW;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment