Fix running UI tests on beta branch

This commit is contained in:
David Capello 2021-07-05 19:48:17 -03:00
parent 9ee6f99588
commit 7a3fb9c2ac
2 changed files with 13 additions and 2 deletions

View File

@ -26,10 +26,12 @@ Display::Display(Display* parentDisplay,
, m_nativeWindow(nativeWindow)
, m_containedWidget(containedWidget)
{
#if 0 // When compiling tests all these values can be nullptr
ASSERT(m_nativeWindow);
ASSERT(m_containedWidget);
ASSERT(m_containedWidget->type() == kManagerWidget ||
m_containedWidget->type() == kWindowWidget);
#endif
m_dirtyRegion = bounds();
}
@ -40,7 +42,10 @@ os::Surface* Display::surface() const
gfx::Size Display::size() const
{
ASSERT(m_nativeWindow);
// When running tests this can be nullptr
if (!m_nativeWindow)
return gfx::Size(1, 1);
const int scale = m_nativeWindow->scale();
ASSERT(scale > 0);
return gfx::Size(m_nativeWindow->width() / scale,

View File

@ -181,7 +181,9 @@ Manager::Manager(const os::WindowRef& nativeWindow)
, m_lockedWindow(nullptr)
, m_mouseButton(kButtonNone)
{
nativeWindow->setUserData(&m_display);
// The native window can be nullptr when running tests
if (nativeWindow)
nativeWindow->setUserData(&m_display);
#ifdef DEBUG_UI_THREADS
ASSERT(!manager_thread);
@ -1658,6 +1660,10 @@ void Manager::onNewDisplayConfiguration(Display* display)
container->setBounds(gfx::Rect(displaySize));
}
// The native window can be nullptr when running tests.
if (!display->nativeWindow())
return;
_internal_set_mouse_display(display);
container->invalidate();
container->flushRedraw();