Commit 1926595a authored by Denis Steckelmacher's avatar Denis Steckelmacher

Test symbols declared in one file and used in another using dedicated unit tests

Filetest can parse the files it tests in any order, which breaks when there are
dependencies between files (first parse the file that uses a symbol, then check
in the file that declare it that it has been used). The two tests requiring this
strict ordering have been moved to dedicated unit tests.
parent 20038ab7
......@@ -129,7 +129,6 @@ bool containsItemForDeclarationNamed(const CompletionParameters& params, const Q
}
}
qWarning() << "could not find declaration with name" << itemName;
return false;
}
......@@ -186,7 +185,7 @@ void QmlCompletionTest::testContainsDeclaration_data()
// Basic QML tests
QTest::newRow("qml_basic_property") << "Item { id: foo\n property int prop\n %INVOKE }" << "%CURSOR" << "prop" << true;
QTest::newRow("qml_basic_instance") << "Item { id: foo\n onTest: %INVOKE }" << "%CURSOR" << "foo" << true;
QTest::newRow("qml_basic_instance") << "Item { id: foo\n %INVOKE }" << "onTest: %CURSOR" << "foo" << true;
QTest::newRow("qml_skip_separators") << "Item { id: foo\n Item { id: bar\n property int prop }\n %INVOKE" << "onTest: bar.%CURSOR" << "prop" << true;
// QML inheritance
......
import QtQuick 2.0
/**
* "type" : { "toString" : "CustomComponent" },
* "useCount" : 1
*/
Text {
id: toplevel_component
}
\ No newline at end of file
CustomComponent {
id: instance
}
\ No newline at end of file
/**
* "useCount" : 1
*/
var im_used_in_another_file;
\ No newline at end of file
console.log(im_used_in_another_file);
......@@ -109,8 +109,4 @@ Module {
return;
}
}
test {
id: i_come_from_test_qml
}
}
import QtQuick 2.0
/**
* "type" : { "toString" : "test" },
* "useCount" : 1
*/
Text {
/*
* "toString" : "test someId",
......
......@@ -41,5 +41,3 @@ var nested_conditions = (simple_compare && b < 3);
* "type" : { "toString" : "int" }
*/
var simple_shift = (a << 2);
im_used_in_types_js = "and I'm a string";
......@@ -22,8 +22,3 @@ func(global, i);
*/
var line;
online = false; // onFoo replaced by foo when foo is a QML signal
/**
* "useCount" : 1
*/
var im_used_in_types_js;
......@@ -57,6 +57,18 @@ void TestFiles::cleanupTestCase()
TestCore::shutdown();
}
void TestFiles::testQMLCustomComponent()
{
parseAndCheck(TEST_FILES_DIR "/custom_component/CustomComponentUser.qml");
parseAndCheck(TEST_FILES_DIR "/custom_component/CustomComponent.qml");
}
void TestFiles::testJSUsesBetweenFiles()
{
parseAndCheck(TEST_FILES_DIR "/js_cross_file_uses/js_variable_use.js");
parseAndCheck(TEST_FILES_DIR "/js_cross_file_uses/js_variable_definition.js");
}
void TestFiles::testFiles_data()
{
QTest::addColumn<QString>("fileName");
......@@ -70,6 +82,11 @@ void TestFiles::testFiles_data()
void TestFiles::testFiles()
{
QFETCH(QString, fileName);
parseAndCheck(fileName);
}
void TestFiles::parseAndCheck(const QString& fileName)
{
const IndexedString indexedFileName(fileName);
ReferencedTopDUContext top =
DUChain::self()->waitForUpdate(indexedFileName, KDevelop::TopDUContext::AllDeclarationsContextsAndUses);
......
......@@ -28,8 +28,13 @@ class TestFiles : public QObject
private slots:
void initTestCase();
void cleanupTestCase();
void testQMLCustomComponent();
void testJSUsesBetweenFiles();
void testFiles_data();
void testFiles();
private:
void parseAndCheck(const QString& fileName);
};
#endif // TEST_FILES_H
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