blob: 643704649ce09e63ad6f41c54676eca830946806 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
|
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd
** All rights reserved.
** For any questions to The Qt Company, please use contact form at
** http://www.qt.io/contact-us
**
** This file is part of the Qt Creator Enterprise Auto Test Add-on.
**
** Licensees holding valid Qt Enterprise licenses may use this file in
** accordance with the Qt Enterprise License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company.
**
** If you have questions regarding the use of this file, please use
** contact form at http://www.qt.io/contact-us
**
****************************************************************************/
#include "autotestconstants.h"
#include "testsettingspage.h"
#include "testsettings.h"
#include <coreplugin/icore.h>
#include <utils/hostosinfo.h>
namespace Autotest {
namespace Internal {
TestSettingsWidget::TestSettingsWidget(QWidget *parent)
: QWidget(parent)
{
m_ui.setupUi(this);
m_ui.callgrindRB->setEnabled(Utils::HostOsInfo::isAnyUnixHost()); // valgrind available on UNIX
m_ui.perfRB->setEnabled(Utils::HostOsInfo::isLinuxHost()); // according to docs perf Linux only
}
void TestSettingsWidget::setSettings(const TestSettings &settings)
{
m_ui.timeoutSpin->setValue(settings.timeout / 1000); // we store milliseconds
m_ui.omitInternalMsgCB->setChecked(settings.omitInternalMssg);
m_ui.omitRunConfigWarnCB->setChecked(settings.omitRunConfigWarn);
m_ui.limitResultOutputCB->setChecked(settings.limitResultOutput);
m_ui.autoScrollCB->setChecked(settings.autoScroll);
switch (settings.metrics) {
case MetricsType::Walltime:
m_ui.walltimeRB->setChecked(true);
break;
case MetricsType::TickCounter:
m_ui.tickcounterRB->setChecked(true);
break;
case MetricsType::EventCounter:
m_ui.eventCounterRB->setChecked(true);
break;
case MetricsType::CallGrind:
m_ui.callgrindRB->setChecked(true);
break;
case MetricsType::Perf:
m_ui.perfRB->setChecked(true);
break;
default:
m_ui.walltimeRB->setChecked(true);
}
}
TestSettings TestSettingsWidget::settings() const
{
TestSettings result;
result.timeout = m_ui.timeoutSpin->value() * 1000; // we display seconds
result.omitInternalMssg = m_ui.omitInternalMsgCB->isChecked();
result.omitRunConfigWarn = m_ui.omitRunConfigWarnCB->isChecked();
result.limitResultOutput = m_ui.limitResultOutputCB->isChecked();
result.autoScroll = m_ui.autoScrollCB->isChecked();
if (m_ui.walltimeRB->isChecked())
result.metrics = MetricsType::Walltime;
else if (m_ui.tickcounterRB->isChecked())
result.metrics = MetricsType::TickCounter;
else if (m_ui.eventCounterRB->isChecked())
result.metrics = MetricsType::EventCounter;
else if (m_ui.callgrindRB->isChecked())
result.metrics = MetricsType::CallGrind;
else if (m_ui.perfRB->isChecked())
result.metrics = MetricsType::Perf;
return result;
}
TestSettingsPage::TestSettingsPage(const QSharedPointer<TestSettings> &settings)
: m_settings(settings), m_widget(0)
{
setId("A.AutoTest.General");
setDisplayName(tr("General"));
setCategory(Constants::AUTOTEST_SETTINGS_CATEGORY);
setDisplayCategory(tr("Test Settings"));
setCategoryIcon(QLatin1String(":/images/autotest.png"));
}
TestSettingsPage::~TestSettingsPage()
{
}
QWidget *TestSettingsPage::widget()
{
if (!m_widget) {
m_widget = new TestSettingsWidget;
m_widget->setSettings(*m_settings);
}
return m_widget;
}
void TestSettingsPage::apply()
{
if (!m_widget) // page was not shown at all
return;
const TestSettings newSettings = m_widget->settings();
if (newSettings != *m_settings) {
*m_settings = newSettings;
m_settings->toSettings(Core::ICore::settings());
}
}
} // namespace Internal
} // namespace Autotest
|