forked from qt-creator/qt-creator
Squish: Test first commit in git repo
Task-number: QTCREATORBUG-12755 Change-Id: Idf27f4bc19ec62ce10ca9367e0b32b8d2b031587 Reviewed-by: Christian Stenger <christian.stenger@theqtcompany.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
#############################################################################
|
#############################################################################
|
||||||
##
|
##
|
||||||
## Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
|
## Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies).
|
||||||
## Contact: http://www.qt-project.org/legal
|
## Contact: http://www.qt-project.org/legal
|
||||||
##
|
##
|
||||||
## This file is part of Qt Creator.
|
## This file is part of Qt Creator.
|
||||||
@@ -72,23 +72,26 @@ def checkOrFixCommitterInformation(labelName, lineEditName, expected):
|
|||||||
test.log("Commit information invalid or missing - entering dummy value (%s)" % expected)
|
test.log("Commit information invalid or missing - entering dummy value (%s)" % expected)
|
||||||
replaceEditorContent(lineEd, expected)
|
replaceEditorContent(lineEd, expected)
|
||||||
|
|
||||||
def verifyClickCommit():
|
# Opens a commit's diff from a diff log
|
||||||
|
# param count is the number of the commit (1-based) in chronologic order
|
||||||
|
def __clickCommit__(count):
|
||||||
gitEditor = waitForObject(":Qt Creator_Git::Internal::GitEditor")
|
gitEditor = waitForObject(":Qt Creator_Git::Internal::GitEditor")
|
||||||
fileName = waitForObject(":Qt Creator_FilenameQComboBox")
|
fileName = waitForObject(":Qt Creator_FilenameQComboBox")
|
||||||
test.verify(waitFor('str(fileName.currentText).startswith("Git Log")', 1000),
|
test.verify(waitFor('str(fileName.currentText).startswith("Git Log")', 1000),
|
||||||
"Verifying Qt Creator still displays git log inside editor.")
|
"Verifying Qt Creator still displays git log inside editor.")
|
||||||
|
waitFor("'Initial Commit' in str(gitEditor.plainText)", 3000)
|
||||||
content = str(gitEditor.plainText)
|
content = str(gitEditor.plainText)
|
||||||
noOfCommits = content.count("commit")
|
|
||||||
commit = None
|
commit = None
|
||||||
# find second commit
|
# find commit
|
||||||
try:
|
try:
|
||||||
line = filter(lambda line: line.startswith("commit"), content.splitlines())[-2]
|
# Commits are listed in reverse chronologic order, so we have to invert count
|
||||||
|
line = filter(lambda line: line.startswith("commit"), content.splitlines())[-count]
|
||||||
commit = line.split(" ", 1)[1]
|
commit = line.split(" ", 1)[1]
|
||||||
except:
|
except:
|
||||||
test.fail("Could not find the second commit - leaving test")
|
test.fail("Could not find the %d. commit - leaving test" % count)
|
||||||
return
|
return False
|
||||||
placeCursorToLine(gitEditor, line)
|
placeCursorToLine(gitEditor, line)
|
||||||
for i in range(5):
|
for i in range(30):
|
||||||
type(gitEditor, "<Left>")
|
type(gitEditor, "<Left>")
|
||||||
# get the current cursor rectangle which should be positioned on the commit ID
|
# get the current cursor rectangle which should be positioned on the commit ID
|
||||||
rect = gitEditor.cursorRect()
|
rect = gitEditor.cursorRect()
|
||||||
@@ -97,9 +100,9 @@ def verifyClickCommit():
|
|||||||
expected = 'Git Show "%s"' % commit
|
expected = 'Git Show "%s"' % commit
|
||||||
test.verify(waitFor('str(fileName.currentText) == expected', 5000),
|
test.verify(waitFor('str(fileName.currentText) == expected', 5000),
|
||||||
"Verifying editor switches to Git Show.")
|
"Verifying editor switches to Git Show.")
|
||||||
diffShow = waitForObject(":Qt Creator_DiffEditor::Internal::DescriptionEditorWidget")
|
description = waitForObject(":Qt Creator_DiffEditor::Internal::DescriptionEditorWidget")
|
||||||
waitFor('len(str(diffShow.plainText)) != 0', 5000)
|
waitFor('len(str(description.plainText)) != 0', 5000)
|
||||||
show = str(diffShow.plainText)
|
show = str(description.plainText)
|
||||||
expected = [{"commit %s" % commit:False},
|
expected = [{"commit %s" % commit:False},
|
||||||
{"Author: Nobody <nobody@nowhere.com>": False},
|
{"Author: Nobody <nobody@nowhere.com>": False},
|
||||||
{"Date:\s+\w{3} \w{3} \d{1,2} \d{2}:\d{2}:\d{2} \d{4}.*":True}]
|
{"Date:\s+\w{3} \w{3} \d{1,2} \d{2}:\d{2}:\d{2} \d{4}.*":True}]
|
||||||
@@ -110,26 +113,43 @@ def verifyClickCommit():
|
|||||||
test.verify(re.match(expLine, line), "Verifying commit header line '%s'" % line)
|
test.verify(re.match(expLine, line), "Verifying commit header line '%s'" % line)
|
||||||
else:
|
else:
|
||||||
test.compare(line, expLine, "Verifying commit header line.")
|
test.compare(line, expLine, "Verifying commit header line.")
|
||||||
changed = waitForObject(":Qt Creator_DiffEditor::SideDiffEditorWidget")
|
test.verify(description.readOnly,
|
||||||
original = waitForObject(":Qt Creator_DiffEditor::SideDiffEditorWidget2")
|
"Verifying description editor widget is readonly.")
|
||||||
waitFor('str(changed.plainText) != "Waiting for data..." '
|
return True
|
||||||
'and str(original.plainText) != "Waiting for data..."', 5000)
|
|
||||||
# content of diff editors is merge of modified files
|
def verifyClickCommit():
|
||||||
diffOriginal = str(original.plainText)
|
for i in range(1, 3):
|
||||||
diffChanged = str(changed.plainText)
|
if not __clickCommit__(i):
|
||||||
# diffChanged must completely contain the pointless_header.h
|
continue
|
||||||
pointlessHeader = readFile(os.path.join(srcPath, projectName, "pointless_header.h"))
|
changed = waitForObject(":Qt Creator_DiffEditor::SideDiffEditorWidget")
|
||||||
test.verify(pointlessHeader in diffChanged,
|
original = waitForObject(":Qt Creator_DiffEditor::SideDiffEditorWidget2")
|
||||||
"Verifying whether diff editor contains pointless_header.h file.")
|
waitFor('str(changed.plainText) != "Waiting for data..." '
|
||||||
test.verify(pointlessHeader not in diffOriginal,
|
'and str(original.plainText) != "Waiting for data..."', 5000)
|
||||||
"Verifying whether original does not contain pointless_header.h file.")
|
# content of diff editors is merge of modified files
|
||||||
test.verify("HEADERS += mainwindow.h \\\n pointless_header.h\n" in diffChanged,
|
diffOriginal = str(original.plainText)
|
||||||
"Verifying whether diff editor has pointless_header.h listed in pro file.")
|
diffChanged = str(changed.plainText)
|
||||||
test.verify("HEADERS += mainwindow.h\n\n" in diffOriginal
|
if i == 1:
|
||||||
and "pointless_header.h" not in diffOriginal,
|
# diffChanged must completely contain main.cpp
|
||||||
"Verifying whether original has no additional header in pro file.")
|
mainCPP = readFile(os.path.join(srcPath, projectName, "main.cpp"))
|
||||||
test.verify(original.readOnly and changed.readOnly and diffShow.readOnly,
|
test.verify(mainCPP in diffChanged,
|
||||||
"Verifying all diff editor widgets are readonly.")
|
"Verifying whether diff editor contains main.cpp file.")
|
||||||
|
test.verify(mainCPP not in diffOriginal,
|
||||||
|
"Verifying whether original does not contain main.cpp file.")
|
||||||
|
elif i == 2:
|
||||||
|
# diffChanged must completely contain the pointless_header.h
|
||||||
|
pointlessHeader = readFile(os.path.join(srcPath, projectName, "pointless_header.h"))
|
||||||
|
test.verify(pointlessHeader in diffChanged,
|
||||||
|
"Verifying whether diff editor contains pointless_header.h file.")
|
||||||
|
test.verify(pointlessHeader not in diffOriginal,
|
||||||
|
"Verifying whether original does not contain pointless_header.h file.")
|
||||||
|
test.verify("HEADERS += mainwindow.h \\\n pointless_header.h\n" in diffChanged,
|
||||||
|
"Verifying whether diff editor has pointless_header.h listed in pro file.")
|
||||||
|
test.verify("HEADERS += mainwindow.h\n\n" in diffOriginal
|
||||||
|
and "pointless_header.h" not in diffOriginal,
|
||||||
|
"Verifying whether original has no additional header in pro file.")
|
||||||
|
test.verify(original.readOnly and changed.readOnly,
|
||||||
|
"Verifying that the actual diff editor widgets are readonly.")
|
||||||
|
invokeMenuItem("Tools", "Git", "Local Repository", "Log")
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
startApplication("qtcreator" + SettingsPath)
|
startApplication("qtcreator" + SettingsPath)
|
||||||
|
Reference in New Issue
Block a user