forked from qt-creator/qt-creator
SquishTests: Adapt generic highlighter test
The mime database nowadays uses a unified mime type for haskell and literate haskell. Adapt the test accordingly. Change-Id: Ic21ba56f927b6472c2c021bf527dd42f17233eb1 Reviewed-by: Robert Löhning <robert.loehning@qt.io>
This commit is contained in:
@@ -46,8 +46,9 @@ def getOrModifyFilePatternsFor(mimeType, filter='', toBePresent=None):
|
|||||||
if result == ['']:
|
if result == ['']:
|
||||||
test.warning("MIME type '%s' seems to have no file patterns." % mimeType)
|
test.warning("MIME type '%s' seems to have no file patterns." % mimeType)
|
||||||
return result
|
return result
|
||||||
waitFor('model.rowCount() == 1', 2000)
|
waitFor('model.rowCount() == 2', 2000)
|
||||||
if model.rowCount() == 1:
|
if model.rowCount() == 2:
|
||||||
|
test.log("Checking %s" % dumpItems(model)[0])
|
||||||
patternsLineEd = clickTableGetPatternLineEdit(mimeTypeTable, dumpItems(model)[0])
|
patternsLineEd = clickTableGetPatternLineEdit(mimeTypeTable, dumpItems(model)[0])
|
||||||
patterns = str(patternsLineEd.text)
|
patterns = str(patternsLineEd.text)
|
||||||
if toBePresent:
|
if toBePresent:
|
||||||
@@ -80,8 +81,8 @@ def getOrModifyFilePatternsFor(mimeType, filter='', toBePresent=None):
|
|||||||
result = toSuffixArray(patterns)
|
result = toSuffixArray(patterns)
|
||||||
else:
|
else:
|
||||||
result = toSuffixArray(patterns)
|
result = toSuffixArray(patterns)
|
||||||
elif model.rowCount() > 1:
|
elif model.rowCount() > 0:
|
||||||
test.warning("MIME type '%s' has ambiguous results." % mimeType)
|
test.warning("MIME type '%s' has unexpected results." % mimeType)
|
||||||
else:
|
else:
|
||||||
test.log("MIME type '%s' seems to be unknown to the system." % mimeType)
|
test.log("MIME type '%s' seems to be unknown to the system." % mimeType)
|
||||||
clickButton(":Options.Cancel_QPushButton")
|
clickButton(":Options.Cancel_QPushButton")
|
||||||
@@ -121,11 +122,9 @@ def hasSuffix(fileName, suffixPatterns):
|
|||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def displayHintForHighlighterDefinition(fileName, patterns, lPatterns, added, addedLiterate):
|
def displayHintForHighlighterDefinition(fileName, patterns, added):
|
||||||
if hasSuffix(fileName, patterns):
|
if hasSuffix(fileName, patterns):
|
||||||
return not added
|
return not added
|
||||||
if hasSuffix(fileName, lPatterns):
|
|
||||||
return not addedLiterate
|
|
||||||
test.warning("Got an unexpected suffix.", "Filename: %s, Patterns: %s"
|
test.warning("Got an unexpected suffix.", "Filename: %s, Patterns: %s"
|
||||||
% (fileName, str(patterns + lPatterns)))
|
% (fileName, str(patterns + lPatterns)))
|
||||||
return False
|
return False
|
||||||
@@ -138,7 +137,6 @@ def main():
|
|||||||
return
|
return
|
||||||
|
|
||||||
patterns = getOrModifyFilePatternsFor("text/x-haskell", "x-haskell")
|
patterns = getOrModifyFilePatternsFor("text/x-haskell", "x-haskell")
|
||||||
lPatterns = getOrModifyFilePatternsFor("text/x-literate-haskell", "literate-haskell")
|
|
||||||
|
|
||||||
folder = tempDir()
|
folder = tempDir()
|
||||||
filesToTest = ["Main.lhs", "Main.hs"]
|
filesToTest = ["Main.lhs", "Main.hs"]
|
||||||
@@ -150,7 +148,7 @@ def main():
|
|||||||
if editor == None:
|
if editor == None:
|
||||||
earlyExit("Something's really wrong! (did the UI change?)")
|
earlyExit("Something's really wrong! (did the UI change?)")
|
||||||
return
|
return
|
||||||
expectHint = hasSuffix(current, patterns) or hasSuffix(current, lPatterns)
|
expectHint = hasSuffix(current, patterns)
|
||||||
mssg = "Verifying whether hint for missing highlight definition is present. (expected: %s)"
|
mssg = "Verifying whether hint for missing highlight definition is present. (expected: %s)"
|
||||||
try:
|
try:
|
||||||
waitForObject("{text='%s' type='QLabel' unnamed='1' visible='1' "
|
waitForObject("{text='%s' type='QLabel' unnamed='1' visible='1' "
|
||||||
@@ -166,9 +164,8 @@ def main():
|
|||||||
|
|
||||||
invokeMenuItem("File", "Save All")
|
invokeMenuItem("File", "Save All")
|
||||||
invokeMenuItem("File", "Close All")
|
invokeMenuItem("File", "Close All")
|
||||||
addedHaskell, addedLiterateHaskell = addHighlighterDefinition("haskell", "literate-haskell")
|
addedHaskell = addHighlighterDefinition("haskell")
|
||||||
patterns = getOrModifyFilePatternsFor('text/x-haskell', 'x-haskell', ['.hs'])
|
patterns = getOrModifyFilePatternsFor('text/x-haskell', 'x-haskell', ['.hs', '.lhs'])
|
||||||
lPatterns = getOrModifyFilePatternsFor('text/x-literate-haskell', 'literate-haskell', ['.lhs'])
|
|
||||||
|
|
||||||
home = os.path.expanduser("~")
|
home = os.path.expanduser("~")
|
||||||
for current in filesToTest:
|
for current in filesToTest:
|
||||||
@@ -177,8 +174,7 @@ def main():
|
|||||||
recentFile = recentFile.replace(home, "~", 1)
|
recentFile = recentFile.replace(home, "~", 1)
|
||||||
invokeMenuItem("File", "Recent Files", "%d | " + recentFile)
|
invokeMenuItem("File", "Recent Files", "%d | " + recentFile)
|
||||||
editor = getEditorForFileSuffix(current)
|
editor = getEditorForFileSuffix(current)
|
||||||
display = displayHintForHighlighterDefinition(current, patterns, lPatterns,
|
display = displayHintForHighlighterDefinition(current, patterns, addedHaskell)
|
||||||
addedHaskell, addedLiterateHaskell)
|
|
||||||
try:
|
try:
|
||||||
waitForObject("{text='%s' type='QLabel' unnamed='1' visible='1' "
|
waitForObject("{text='%s' type='QLabel' unnamed='1' visible='1' "
|
||||||
"window=':Qt Creator_Core::Internal::MainWindow'}" % miss, 2000)
|
"window=':Qt Creator_Core::Internal::MainWindow'}" % miss, 2000)
|
||||||
|
Reference in New Issue
Block a user