summaryrefslogtreecommitdiffstats
path: root/tests/auto/dumpcpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/dumpcpp')
-rw-r--r--tests/auto/dumpcpp/CMakeLists.txt20
-rw-r--r--tests/auto/dumpcpp/dumpcpp.pro11
-rw-r--r--tests/auto/dumpcpp/tst_dumpcpp.cpp119
3 files changed, 103 insertions, 47 deletions
diff --git a/tests/auto/dumpcpp/CMakeLists.txt b/tests/auto/dumpcpp/CMakeLists.txt
index 91da6c3..a5ff2dc 100644
--- a/tests/auto/dumpcpp/CMakeLists.txt
+++ b/tests/auto/dumpcpp/CMakeLists.txt
@@ -1,20 +1,24 @@
-# Generated from dumpcpp.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_dumpcpp Test:
#####################################################################
-qt_add_test(tst_dumpcpp
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_dumpcpp LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
+qt_internal_add_test(tst_dumpcpp
SOURCES
tst_dumpcpp.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::AxContainer
Qt::Gui
Qt::Widgets
)
-#### Keys ignored in scope 1:.:.:dumpcpp.pro:<TRUE>:
-# TYPELIBS = "$$(SystemRoot)\\system32\\ieframe.dll"
-
-## Scopes:
-#####################################################################
+qt6_target_typelibs(tst_dumpcpp LIBRARIES "ieframe.dll")
+qt6_target_typelibs(tst_dumpcpp LIBRARIES "msxml6.dll")
diff --git a/tests/auto/dumpcpp/dumpcpp.pro b/tests/auto/dumpcpp/dumpcpp.pro
deleted file mode 100644
index aae7bd8..0000000
--- a/tests/auto/dumpcpp/dumpcpp.pro
+++ /dev/null
@@ -1,11 +0,0 @@
-CONFIG += testcase
-QT += widgets axcontainer testlib
-SOURCES += tst_dumpcpp.cpp
-TARGET = tst_dumpcpp
-
-# Assume Web Browser type library is available in all windows installations
-TYPELIBS = $$(SystemRoot)\\system32\\ieframe.dll
-
-!exists($$TYPELIBS) {
- message("Web Browser type library for test not found!")
-}
diff --git a/tests/auto/dumpcpp/tst_dumpcpp.cpp b/tests/auto/dumpcpp/tst_dumpcpp.cpp
index 039c090..66cd158 100644
--- a/tests/auto/dumpcpp/tst_dumpcpp.cpp
+++ b/tests/auto/dumpcpp/tst_dumpcpp.cpp
@@ -1,47 +1,55 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QtTest/QtTest>
#include "ieframe.h" // generated header
+#include "msxml6.h" // generated header
#include <QApplication>
+
+struct XmlFixture
+{
+ MSXML2::DOMDocument60 doc;
+ MSXML2::IXMLDOMNodeList *root;
+
+ const QString xml{
+ R"(
+ <root prop="The root property">
+ The value
+ </root>
+ )" };
+};
+
class tst_dumpcpp : public QObject
{
Q_OBJECT
private slots:
+ void init();
void toggleAddressBar();
+ void propertyGetter_ReturnsValue_WhenValueIsInt();
+ void propertyGetter_ReturnsValue_WhenValueIsString();
+ void invokeGetter_ReturnsValue_WhenValueInheritsIDispatch();
+ void propertyGetter_ReturnsValue_WhenValueInheritsIDispatch();
+
+ void propertySetter_SetsValue_WhenValueIsVariantInt();
+ void propertySetter_SetsValue_WhenValueIsString();
+ void invoke_SetsValue_WhenValueDerivesFromIDispatch();
+
+private:
+ XmlFixture m_xml;
};
+void tst_dumpcpp::init()
+{
+ m_xml.doc.loadXML(m_xml.xml);
+ m_xml.root = m_xml.doc.childNodes();
+}
+
// A simple test to verify that an object can be instantiated and interacted with
void tst_dumpcpp::toggleAddressBar()
{
- SHDocVw::WebBrowser* webBrowser = new SHDocVw::WebBrowser;
+ SHDocVw::WebBrowser *webBrowser = new SHDocVw::WebBrowser;
QVERIFY(webBrowser);
bool addressBar = webBrowser->AddressBar();
addressBar = !addressBar;
@@ -50,5 +58,60 @@ void tst_dumpcpp::toggleAddressBar()
delete webBrowser;
}
+void tst_dumpcpp::propertyGetter_ReturnsValue_WhenValueIsInt()
+{
+ int length = m_xml.root->length();
+ QVERIFY(length == 1);
+}
+
+void tst_dumpcpp::invokeGetter_ReturnsValue_WhenValueInheritsIDispatch()
+{
+ // item(...) takes an argument and is called as a function invocation
+ MSXML2::IXMLDOMNode *firstChild = m_xml.root->item(0);
+ QVERIFY(firstChild);
+}
+
+void tst_dumpcpp::propertyGetter_ReturnsValue_WhenValueInheritsIDispatch()
+{
+ // attributes() takes an argument and is called as property getter
+ MSXML2::IXMLDOMNamedNodeMap *attributes = m_xml.root->item(0)->attributes();
+ QVERIFY(attributes);
+}
+
+void tst_dumpcpp::propertyGetter_ReturnsValue_WhenValueIsString()
+{
+ MSXML2::IXMLDOMNamedNodeMap *attributes = m_xml.root->item(0)->attributes();
+
+ // nodeValue is a property getter
+ QVariant p = attributes->getNamedItem("prop")->nodeValue();
+ QCOMPARE(p, "The root property");
+}
+
+void tst_dumpcpp::propertySetter_SetsValue_WhenValueIsVariantInt()
+{
+ MSXML2::IXMLDOMNamedNodeMap *attributes = m_xml.root->item(0)->attributes();
+ MSXML2::IXMLDOMNode *attribNode = attributes->item(0);
+ attribNode->setNodeValue(QVariant { 42 } );
+
+ QVariant p = attributes->getNamedItem("prop")->nodeValue();
+ QCOMPARE(p, 42);
+}
+
+void tst_dumpcpp::propertySetter_SetsValue_WhenValueIsString()
+{
+ m_xml.root->item(0)->setText("The new value");
+ QCOMPARE(m_xml.root->item(0)->text(), "The new value");
+}
+
+void tst_dumpcpp::invoke_SetsValue_WhenValueDerivesFromIDispatch()
+{
+ MSXML2::IXMLDOMNode *node = m_xml.doc.createNode(MSXML2::NODE_ELEMENT, "sometag", "");
+ node->setText("The new text");
+
+ m_xml.root->item(0)->appendChild(node);
+
+ QCOMPARE(m_xml.root->item(0)->childNodes()->item(1)->text(), "The new text");
+}
+
QTEST_MAIN(tst_dumpcpp)
#include "tst_dumpcpp.moc"