aboutsummaryrefslogtreecommitdiffstats
path: root/tools/snippets_translate/tests
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2023-03-28 14:22:16 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2023-03-28 15:59:39 +0200
commita587de6ca1658286eba55ee37a9d64f6ad530d30 (patch)
tree309db19ddf0f60e0e235f2d33cb1dd2fefe8a9e8 /tools/snippets_translate/tests
parent4c84f72846bc25ea56c56175b99dd6b39c54e6cb (diff)
snippets_translate: Improve connect handling
Extend the matching to recognize connects for member variables (m_ui.button), remove smart pointer accessor. Pick-to: 6.5 Task-number: PYSIDE-1106 Change-Id: Ib68df3d9d31a8de64059832c4c60ad4b20bf78e1 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Diffstat (limited to 'tools/snippets_translate/tests')
-rw-r--r--tools/snippets_translate/tests/test_converter.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/tools/snippets_translate/tests/test_converter.py b/tools/snippets_translate/tests/test_converter.py
index 360cb157e..15c42cebc 100644
--- a/tools/snippets_translate/tests/test_converter.py
+++ b/tools/snippets_translate/tests/test_converter.py
@@ -112,6 +112,21 @@ def test_double_colon():
assert st("this, &MyClass::slotError);") == "self.slotError)"
+def test_connects():
+ assert (
+ st("connect(button, &QPushButton::clicked, this, &MyClass::slotClicked);")
+ == "button.clicked.connect(self.slotClicked)"
+ )
+ assert (
+ st("connect(m_ui->button, &QPushButton::clicked, this, &MyClass::slotClicked);")
+ == "m_ui.button.clicked.connect(self.slotClicked)"
+ )
+ assert (
+ st("connect(button.get(), &QPushButton::clicked, this, &MyClass::slotClicked);")
+ == "button.clicked.connect(self.slotClicked)"
+ )
+
+
def test_cout_endl():
assert st("cout << 'hello' << 'world' << endl") == "print('hello', 'world')"
assert st(" cout << 'hallo' << 'welt' << endl") == " print('hallo', 'welt')"