summaryrefslogtreecommitdiffstats
path: root/tests/auto/wasm/selenium/qwasmwindow.py
diff options
context:
space:
mode:
authorEven Oscar Andersen <[email protected]>2024-06-06 14:57:14 +0200
committerEven Oscar Andersen <[email protected]>2024-06-13 19:33:21 +0200
commit1b220e1db85dd332fe8c1eb8efd97dd302f9cee4 (patch)
treee575ac93155ed5810d7bd0f0f4be34c7e04896ef /tests/auto/wasm/selenium/qwasmwindow.py
parent1943183282defdbc846813e4ceb66c1eec28fec5 (diff)
wasm: Fix handling of native windows
There are two problems 1) internal (not toplevel) windows needs to have the frameLess attribute set. Without this attribute the window is not visible 2) The backingstore needs to use the correct window, if not the symptoms are that the display is not always correctly updated. Seen in the qtdoc/examples/demos/documentviewer demo Fixes: QTBUG-125856 Change-Id: I040d963c0c130214cc70a607090faa006c02f981 Reviewed-by: Morten Johan Sørvig <[email protected]>
Diffstat (limited to 'tests/auto/wasm/selenium/qwasmwindow.py')
-rw-r--r--tests/auto/wasm/selenium/qwasmwindow.py57
1 files changed, 51 insertions, 6 deletions
diff --git a/tests/auto/wasm/selenium/qwasmwindow.py b/tests/auto/wasm/selenium/qwasmwindow.py
index 260e9d2d24a..df2d39f5167 100644
--- a/tests/auto/wasm/selenium/qwasmwindow.py
+++ b/tests/auto/wasm/selenium/qwasmwindow.py
@@ -28,6 +28,24 @@ class WidgetTestCase(unittest.TestCase):
self.addTypeEqualityFunc(Color, assert_colors_equal)
self.addTypeEqualityFunc(Rect, assert_rects_equal)
+ #
+ # This is a manual test
+ # The reason is that the color readback works
+ # even if the display is incorrect
+ #
+ def test_native_widgets(self):
+ screen = Screen(self._driver, ScreenPosition.FIXED,
+ x=0, y=0, width=600, height=1200)
+
+ w0 = Widget(self._driver, "w0", 1)
+ w0.show()
+ #time.sleep(3600)
+ color = w0.color_at(100, 150)
+ self.assertEqual(color.r, 255)
+ self.assertEqual(color.g, 255)
+ self.assertEqual(color.b, 255)
+ self.assertEqual(w0.hasFocus(), True)
+
def test_hasFocus_returnsFalse_whenSetNoFocusShowWasCalled(self):
screen = Screen(self._driver, ScreenPosition.FIXED,
x=0, y=0, width=600, height=1200)
@@ -607,15 +625,30 @@ def clearWidgets(driver):
)
class Widget:
- def __init__(self, driver, name):
+ def __init__(self, driver, name, isNative=0):
self.name=name
self.driver=driver
- self.driver.execute_script(
- f'''
- instance.createWidget('{self.name}');
- '''
- )
+ if isNative == 0:
+ self.driver.execute_script(
+ f'''
+ instance.createWidget('{self.name}');
+ '''
+ )
+ if isNative == 1:
+ self.driver.execute_script(
+ f'''
+ instance.createNativeWidget('{self.name}');
+ '''
+ )
+
+ if isNative == 1:
+ information = self.__window_information()
+ self.screen = Screen(self.driver, screen_name=information['screen']['name'])
+
+ self._window_id = self.__window_information()['id']
+ self.element = self.screen.find_element(
+ By.CSS_SELECTOR, f'#qt-window-{self._window_id}')
def setNoFocusShow(self):
self.driver.execute_script(
@@ -641,6 +674,18 @@ class Widget:
'''
)
+ def color_at(self, x, y):
+ raw = self.driver.execute_script(
+ f'''
+ return arguments[0].querySelector('canvas')
+ .getContext('2d').getImageData({x}, {y}, 1, 1).data;
+ ''', self.element)
+ return Color(r=raw[0], g=raw[1], b=raw[2])
+
+ def __window_information(self):
+ information = call_instance_function(self.driver, 'windowInformation')
+ return next(filter(lambda e: e['title'] == "Dialog", information))
+
class Window:
def __init__(self, parent=None, rect=None, title=None, element=None, visible=True, opengl=0):