结构优化
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
#include <QPushButton>
|
||||
#include <QThread>
|
||||
#include <QWheelEvent>
|
||||
#include <gtest/gtest.h>
|
||||
#include <memory>
|
||||
namespace {
|
||||
QPushButton* find_performance_button(QWidget* control) {
|
||||
@@ -41,7 +42,7 @@ void wheel_plot(QWidget* plot, const QPoint& pos, int delta) {
|
||||
QWheelEvent event(pos, plot->mapToGlobal(pos), QPoint(), QPoint(0, delta), Qt::NoButton, Qt::NoModifier, Qt::NoScrollPhase, false);
|
||||
QApplication::sendEvent(plot, &event);
|
||||
}
|
||||
bool pump(QApplication& app, renderive::Plot& plot, int milliseconds) {
|
||||
bool pump(QApplication& app, renderive::Latency_Eager_Plot& plot, int milliseconds) {
|
||||
QElapsedTimer timer;
|
||||
timer.start();
|
||||
while (timer.elapsed() < milliseconds) {
|
||||
@@ -52,12 +53,10 @@ bool pump(QApplication& app, renderive::Plot& plot, int milliseconds) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
int main(int argc, char** argv) {
|
||||
qputenv("QT_QPA_PLATFORM", "offscreen");
|
||||
qputenv("RENDERIVE_PERFORMANCE_LOG", "0");
|
||||
QApplication app(argc, argv);
|
||||
TEST(Performance_Shower_Interaction, RepeatedToggleDoubleClickAndWheelStayResponsive) {
|
||||
QApplication& app = *qobject_cast<QApplication*>(QApplication::instance());
|
||||
renderive::start_render_scheduler();
|
||||
renderive::Plot plot;
|
||||
renderive::Latency_Eager_Plot plot;
|
||||
plot.resize(320, 240);
|
||||
plot.init();
|
||||
plot.show();
|
||||
@@ -66,15 +65,13 @@ int main(int argc, char** argv) {
|
||||
control->show();
|
||||
app.processEvents();
|
||||
QPushButton* performance_button = find_performance_button(control.get());
|
||||
if (!performance_button)
|
||||
return 1;
|
||||
ASSERT_NE(performance_button, nullptr);
|
||||
QElapsedTimer total;
|
||||
total.start();
|
||||
for (int i = 0; i < 40; ++i) {
|
||||
click_button(performance_button);
|
||||
pump(app, plot, 15);
|
||||
if (total.elapsed() > 5000)
|
||||
return 2;
|
||||
ASSERT_LE(total.elapsed(), 5000);
|
||||
}
|
||||
double_click_button(performance_button);
|
||||
pump(app, plot, 200);
|
||||
@@ -93,8 +90,13 @@ int main(int argc, char** argv) {
|
||||
pump(app, plot, 10);
|
||||
}
|
||||
pump(app, plot, 200);
|
||||
if (!plot.get_use_performance_shower())
|
||||
return 3;
|
||||
EXPECT_TRUE(plot.get_use_performance_shower());
|
||||
plot.pause_render();
|
||||
return 0;
|
||||
}
|
||||
int main(int argc, char** argv) {
|
||||
qputenv("QT_QPA_PLATFORM", "offscreen");
|
||||
qputenv("RENDERIVE_PERFORMANCE_LOG", "0");
|
||||
QApplication app(argc, argv);
|
||||
testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user