Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Marco Bubke
flatpak-qt-creator
Commits
9394a431
Commit
9394a431
authored
Nov 05, 2014
by
Christian Stenger
Committed by
Christian Stenger
Dec 04, 2014
Browse files
Add summary to results pane
parent
8e4181c3
Changes
4
Hide whitespace changes
Inline
Side-by-side
plugins/autotest/testresultmodel.cpp
View file @
9394a431
...
...
@@ -108,6 +108,8 @@ void TestResultModel::addTestResult(const TestResult &testResult)
{
beginInsertRows
(
QModelIndex
(),
m_testResults
.
size
(),
m_testResults
.
size
());
m_testResults
.
append
(
testResult
);
int
count
=
m_testResultCount
.
value
(
testResult
.
result
(),
0
);
m_testResultCount
.
insert
(
testResult
.
result
(),
++
count
);
endInsertRows
();
m_availableResultTypes
.
insert
(
testResult
.
result
());
}
...
...
@@ -118,6 +120,7 @@ void TestResultModel::clearTestResults()
return
;
beginRemoveRows
(
QModelIndex
(),
0
,
m_testResults
.
size
()
-
1
);
m_testResults
.
clear
();
m_testResultCount
.
clear
();
m_lastMaxWidthIndex
=
0
;
m_maxWidthOfFileName
=
0
;
m_widthOfLineNumber
=
0
;
...
...
@@ -165,6 +168,11 @@ int TestResultModel::maxWidthOfLineNumber(const QFont &font)
return
m_widthOfLineNumber
;
}
int
TestResultModel
::
resultTypeCount
(
ResultType
type
)
{
return
m_testResultCount
.
value
(
type
,
0
);
}
/********************************** Filter Model **********************************/
TestResultFilterModel
::
TestResultFilterModel
(
TestResultModel
*
sourceModel
,
QObject
*
parent
)
...
...
plugins/autotest/testresultmodel.h
View file @
9394a431
...
...
@@ -53,6 +53,7 @@ public:
void
enableAllResultTypes
();
void
toggleTestResultType
(
ResultType
type
);
bool
hasResultType
(
ResultType
type
)
{
return
m_availableResultTypes
.
contains
(
type
);
}
int
resultTypeCount
(
ResultType
type
);
signals:
...
...
@@ -60,6 +61,7 @@ public slots:
private:
QList
<
TestResult
>
m_testResults
;
QMap
<
ResultType
,
int
>
m_testResultCount
;
int
m_widthOfLineNumber
;
int
m_maxWidthOfFileName
;
int
m_lastMaxWidthIndex
;
...
...
plugins/autotest/testresultspane.cpp
View file @
9394a431
...
...
@@ -28,9 +28,12 @@
#include <texteditor/texteditor.h>
#include <utils/itemviews.h>
#include <utils/theme/theme.h>
#include <QDebug>
#include <QHBoxLayout>
#include <QToolButton>
#include <QVBoxLayout>
namespace
Autotest
{
namespace
Internal
{
...
...
@@ -39,7 +42,31 @@ TestResultsPane::TestResultsPane(QObject *parent) :
Core
::
IOutputPane
(
parent
),
m_context
(
new
Core
::
IContext
(
this
))
{
m_listView
=
new
Utils
::
ListView
;
m_outputWidget
=
new
QWidget
;
QVBoxLayout
*
outputLayout
=
new
QVBoxLayout
;
outputLayout
->
setMargin
(
0
);
outputLayout
->
setSpacing
(
0
);
m_outputWidget
->
setLayout
(
outputLayout
);
QPalette
pal
;
pal
.
setColor
(
QPalette
::
Window
,
Utils
::
creatorTheme
()
->
color
(
Utils
::
Theme
::
SearchResultWidgetBackgroundColor
));
pal
.
setColor
(
QPalette
::
WindowText
,
Utils
::
creatorTheme
()
->
color
(
Utils
::
Theme
::
SearchResultWidgetTextColor
));
m_summaryWidget
=
new
QFrame
;
m_summaryWidget
->
setPalette
(
pal
);
m_summaryWidget
->
setAutoFillBackground
(
true
);
QHBoxLayout
*
layout
=
new
QHBoxLayout
;
layout
->
setMargin
(
6
);
m_summaryWidget
->
setLayout
(
layout
);
m_summaryLabel
=
new
QLabel
;
m_summaryLabel
->
setPalette
(
pal
);
layout
->
addWidget
(
m_summaryLabel
);
m_summaryWidget
->
setVisible
(
false
);
outputLayout
->
addWidget
(
m_summaryWidget
);
m_listView
=
new
Utils
::
ListView
(
m_outputWidget
);
m_model
=
new
TestResultModel
(
this
);
m_filterModel
=
new
TestResultFilterModel
(
m_model
,
this
);
m_filterModel
->
setDynamicSortFilter
(
true
);
...
...
@@ -47,6 +74,8 @@ TestResultsPane::TestResultsPane(QObject *parent) :
TestResultDelegate
*
trd
=
new
TestResultDelegate
(
this
);
m_listView
->
setItemDelegate
(
trd
);
outputLayout
->
addWidget
(
m_listView
);
createToolButtons
();
connect
(
m_listView
,
&
Utils
::
ListView
::
activated
,
this
,
&
TestResultsPane
::
onItemActivated
);
...
...
@@ -117,12 +146,12 @@ void TestResultsPane::addTestResult(const TestResult &result)
QWidget
*
TestResultsPane
::
outputWidget
(
QWidget
*
parent
)
{
if
(
m_
listView
)
{
m_
listView
->
setParent
(
parent
);
if
(
m_
outputWidget
)
{
m_
outputWidget
->
setParent
(
parent
);
}
else
{
m_listView
=
new
Utils
::
ListView
(
parent
)
;
qDebug
()
<<
"This should not happen..."
;
}
return
m_
listView
;
return
m_
outputWidget
;
}
QList
<
QWidget
*>
TestResultsPane
::
toolBarWidgets
()
const
...
...
@@ -144,6 +173,7 @@ void TestResultsPane::clearContents()
{
m_filterModel
->
clearTestResults
();
navigateStateChanged
();
m_summaryWidget
->
setVisible
(
false
);
}
void
TestResultsPane
::
visibilityChanged
(
bool
)
...
...
@@ -242,14 +272,14 @@ void TestResultsPane::onRunSelectedTriggered()
void
TestResultsPane
::
initializeFilterMenu
()
{
QMap
<
ResultType
,
QString
>
textAndType
;
textAndType
.
insert
(
ResultType
::
PASS
,
QLatin1String
(
"Pass"
));
textAndType
.
insert
(
ResultType
::
FAIL
,
QLatin1String
(
"Fail"
));
textAndType
.
insert
(
ResultType
::
EXPECTED_FAIL
,
QLatin1String
(
"Expected Fail"
));
textAndType
.
insert
(
ResultType
::
UNEXPECTED_PASS
,
QLatin1String
(
"Unexpected Pass"
));
textAndType
.
insert
(
ResultType
::
SKIP
,
QLatin1String
(
"Skip"
));
textAndType
.
insert
(
ResultType
::
MESSAGE_DEBUG
,
QLatin1String
(
"Debug Messages"
));
textAndType
.
insert
(
ResultType
::
MESSAGE_WARN
,
QLatin1String
(
"Warning Messages"
));
textAndType
.
insert
(
ResultType
::
MESSAGE_INTERNAL
,
QLatin1String
(
"Internal Messages"
));
textAndType
.
insert
(
ResultType
::
PASS
,
tr
(
"Pass"
));
textAndType
.
insert
(
ResultType
::
FAIL
,
tr
(
"Fail"
));
textAndType
.
insert
(
ResultType
::
EXPECTED_FAIL
,
tr
(
"Expected Fail"
));
textAndType
.
insert
(
ResultType
::
UNEXPECTED_PASS
,
tr
(
"Unexpected Pass"
));
textAndType
.
insert
(
ResultType
::
SKIP
,
tr
(
"Skip"
));
textAndType
.
insert
(
ResultType
::
MESSAGE_DEBUG
,
tr
(
"Debug Messages"
));
textAndType
.
insert
(
ResultType
::
MESSAGE_WARN
,
tr
(
"Warning Messages"
));
textAndType
.
insert
(
ResultType
::
MESSAGE_INTERNAL
,
tr
(
"Internal Messages"
));
foreach
(
ResultType
result
,
textAndType
.
keys
())
{
QAction
*
action
=
new
QAction
(
m_filterMenu
);
action
->
setText
(
textAndType
.
value
(
result
));
...
...
@@ -260,6 +290,23 @@ void TestResultsPane::initializeFilterMenu()
}
}
void
TestResultsPane
::
updateSummaryLabel
()
{
QString
labelText
=
QString
::
fromLatin1
(
"<p><b>Test Summary:</b> %1 %2, %3 %4"
)
.
arg
(
QString
::
number
(
m_model
->
resultTypeCount
(
ResultType
::
PASS
)),
tr
(
"passes"
),
QString
::
number
(
m_model
->
resultTypeCount
(
ResultType
::
FAIL
)),
tr
(
"fails"
));
int
count
=
m_model
->
resultTypeCount
(
ResultType
::
UNEXPECTED_PASS
);
if
(
count
)
labelText
.
append
(
QString
::
fromLatin1
(
", %1 %2"
)
.
arg
(
QString
::
number
(
count
),
tr
(
"unexpected passes"
)));
count
=
m_model
->
resultTypeCount
(
ResultType
::
EXPECTED_FAIL
);
if
(
count
)
labelText
.
append
(
QString
::
fromLatin1
(
", %1 %2"
)
.
arg
(
QString
::
number
(
count
),
tr
(
"expected fails"
)));
labelText
.
append
(
QLatin1String
(
".</p>"
));
m_summaryLabel
->
setText
(
labelText
);
}
void
TestResultsPane
::
updateFilterMenu
()
{
foreach
(
QAction
*
action
,
m_filterMenu
->
actions
())
{
...
...
@@ -279,6 +326,7 @@ void TestResultsPane::onTestRunStarted()
m_stopTestRun
->
setEnabled
(
true
);
m_runAll
->
setEnabled
(
false
);
m_runSelected
->
setEnabled
(
false
);
m_summaryWidget
->
setVisible
(
false
);
}
void
TestResultsPane
::
onTestRunFinished
()
...
...
@@ -286,6 +334,8 @@ void TestResultsPane::onTestRunFinished()
m_stopTestRun
->
setEnabled
(
false
);
m_runAll
->
setEnabled
(
true
);
m_runSelected
->
setEnabled
(
true
);
updateSummaryLabel
();
m_summaryWidget
->
setVisible
(
true
);
}
void
TestResultsPane
::
onTestTreeModelChanged
()
...
...
plugins/autotest/testresultspane.h
View file @
9394a431
...
...
@@ -23,6 +23,8 @@
QT_BEGIN_NAMESPACE
class
QAction
;
class
QFrame
;
class
QLabel
;
class
QModelIndex
;
class
QMenu
;
class
QToolButton
;
...
...
@@ -82,11 +84,15 @@ private slots:
private:
explicit
TestResultsPane
(
QObject
*
parent
=
0
);
void
initializeFilterMenu
();
void
updateSummaryLabel
();
void
createToolButtons
();
void
onTestRunStarted
();
void
onTestRunFinished
();
void
onTestTreeModelChanged
();
QWidget
*
m_outputWidget
;
QFrame
*
m_summaryWidget
;
QLabel
*
m_summaryLabel
;
Utils
::
ListView
*
m_listView
;
TestResultModel
*
m_model
;
TestResultFilterModel
*
m_filterModel
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment