Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
136 changes: 136 additions & 0 deletions src/app/test/app_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <string>
#include <filesystem>
#include <fstream>
#include <optional>
#include <unordered_set>
#include "rocprofvis_settings_manager.h"
#include "rocprofvis_utils.h"
Expand Down Expand Up @@ -2858,6 +2859,141 @@ void RegisterAppTests(ImGuiTestEngine* e)
IM_CHECK(rows_after != rows_before);
};

// A column filter that matches no rows keeps the header and filter row, and
// must not size the scroll area as if the table had 2^64 rows.
t = IM_REGISTER_TEST(e, "app", "sys_event_table_empty_filter_scroll");
t->TestFunc = [](ImGuiTestContext* ctx)
{
TraceView* tv = GetTraceViewOrSkip(ctx);
if (!tv) return;
TimelineView* tlv = TraceViewTestPeer{*tv}.TimelineViewPtr();
IM_CHECK(tlv != nullptr);
if (tlv == nullptr) return;
AnalysisView* av = TraceViewTestPeer{*tv}.AnalysisViewPtr();
IM_CHECK(av != nullptr);
if (av == nullptr) return;
InfiniteScrollTable* table = AnalysisViewTestPeer{*av}.EventTablePtr();
IM_CHECK(table != nullptr);
if (table == nullptr) return;
std::shared_ptr<TimelineSelection> sel = tv->GetTimelineSelection();
IM_CHECK(sel != nullptr);
if (sel == nullptr) return;
DataProvider* dp = tv->GetDataProvider();
IM_CHECK(dp != nullptr);
if (dp == nullptr) return;
InfiniteScrollTableTestPeer peer{*table};

const bool details_visible =
SettingsManager::GetInstance().GetAppWindowSettings().show_details_panel;
tv->SetAnalysisViewVisibility(true);
const bool sidebar_visible =
SettingsManager::GetInstance().GetAppWindowSettings().show_sidebar;
tv->SetSidebarViewVisibility(true);
std::string tab_label;
av->SelectTab("Event Table", tab_label);
ctx->Yield(3);

auto drain_event_table = [&]()
{
ctx->Yield(3);
for (int i = 0; i < 200 &&
dp->IsRequestPending(DataProvider::EVENT_TABLE_REQUEST_ID); i++)
ctx->Yield(2);
ctx->Yield(5);
};
auto restore = [&]()
{
peer.SetColumnFilter("duration", "");
drain_event_table();
sel->UnselectAllTracks();
tv->SetAnalysisViewVisibility(details_visible);
tv->SetSidebarViewVisibility(sidebar_visible);
ctx->Yield(3);
};
// Height of what this table's ImGui table window laid out last frame. A
// runaway spacer overflows ImGui's float-to-int truncation of the content
// size, so it shows up here as a huge or negative height, not as scroll.
auto table_content_height = [&]() -> std::optional<float>
{
const std::string& name = peer.WidgetName();
for (ImGuiWindow* w : ctx->UiContext->Windows)
{
if (!w->WasActive) continue;
const char* found = strstr(w->Name, name.c_str());
if (found && strstr(found, "/infinite_scroll_table_"))
return w->DC.CursorMaxPos.y - w->DC.CursorStartPos.y;
}
return std::nullopt;
};

std::vector<FlameTrackItem*> flames;
for (int i = 0; i < 60; i++)
{
flames = TimelineViewTestPeer{*tlv}.DisplayedFlameTracks();
if (!flames.empty()) break;
ctx->Yield(2);
}
if (flames.empty())
{
ctx->LogWarning("SKIP: no displayed flame track to fill the event table");
restore();
return;
}
sel->UnselectAllTracks();
drain_event_table();

ImGuiWindow* sidebar = FindSidebarWindow(ctx);
if (sidebar == nullptr) restore();
IM_CHECK(sidebar != nullptr);
SetRefWindow(ctx, sidebar);
ImGuiTestItemList sidebar_items;
ctx->GatherItems(&sidebar_items, "");
ImGuiID button = 0;
for (FlameTrackItem* flame : flames)
{
button = TrackButtonId(sidebar_items, flame->GetName());
if (button != 0) break;
}
if (button == 0)
{
ctx->LogWarning("SKIP: no flame track row button found in the sidebar");
restore();
return;
}
CtrlClick(ctx, button);
drain_event_table();

const TablesModel& tables = dp->DataModel().GetTables();
if (tables.GetTableTotalRowCount(TableType::kEventTable) == 0)
{
ctx->LogWarning("SKIP: event table is empty, nothing to filter out");
restore();
return;
}
if (!peer.FilterRowShown())
{
ctx->LogWarning("SKIP: event table is not in basic filter mode");
restore();
return;
}

const bool filter_set = peer.SetColumnFilter("duration", "< 0");
drain_event_table();
const uint64_t rows_after = tables.GetTableTotalRowCount(TableType::kEventTable);
const std::optional<float> content = table_content_height();
const float row_height = ImGui::GetTextLineHeightWithSpacing();

restore();

IM_CHECK(filter_set);
IM_CHECK(rows_after == 0);
IM_CHECK(content.has_value());
if (!content.has_value()) return;
// Header plus filter row only.
IM_CHECK_GE(*content, 0.0f);
IM_CHECK_LT(*content, row_height * 10.0f);
};

t = IM_REGISTER_TEST(e, "app", "sys_event_search_multi_substring");
t->TestFunc = [](ImGuiTestContext* ctx)
{
Expand Down
31 changes: 25 additions & 6 deletions src/view/src/widgets/rocprofvis_infinite_scroll_table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,22 @@ InfiniteScrollTable::Render()
outer_size.y);
}

const bool show_no_data_text = table_data.empty() && !show_loading_indicator;

// An empty table with a filter row keeps only its header and filter row,
// so the no-data text below them isn't drawn over by the column lines.
ImVec2 table_size = outer_size;
if(show_no_data_text && m_display_filter_row)
{
float header_rows_height =
row_height + ImGui::GetFrameHeight() + row_padding_v;
if(m_horizontal_scroll)
{
header_rows_height += style.ScrollbarSize;
}
table_size.y = std::min(outer_size.y, header_rows_height);
}

ImGui::PushStyleColor(ImGuiCol_ChildBg,
m_settings.GetColor(Colors::kFillerColor));
// Filter row is enabled: render when columns are present regardless of data.
Expand All @@ -464,7 +480,7 @@ InfiniteScrollTable::Render()
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, m_settings.GetDefaultStyle().WindowPadding);
if(ImGui::BeginTable("infinite_scroll_table",
static_cast<int>(column_names.size()), table_flags,
outer_size))
table_size))
{
if(m_skip_data_fetch && ImGui::GetScrollY() > 0.0f)
{
Expand Down Expand Up @@ -703,7 +719,9 @@ InfiniteScrollTable::Render()
clipper.End();

float bottom_spacer_height =
(float) (total_row_count - (end_row + 1)) * row_height;
total_row_count > end_row + 1
? (float) (total_row_count - (end_row + 1)) * row_height
: 0.0f;
if(bottom_spacer_height > 0.0f)
{
ImGui::TableNextRow(ImGuiTableRowFlags_None, bottom_spacer_height);
Expand Down Expand Up @@ -790,12 +808,13 @@ InfiniteScrollTable::Render()
ImGui::PopStyleVar();
RenderContextMenu();
}
else if(!m_no_data_text.empty() && !show_loading_indicator &&
ImGui::GetContentRegionAvail().y > ImGui::GetTextLineHeight())
if(show_no_data_text && !m_no_data_text.empty() &&
ImGui::GetContentRegionAvail().y > ImGui::GetTextLineHeight())
{
CenterNextTextItem(m_no_data_text.c_str());
ImGui::SetCursorPosY((ImGui::GetWindowHeight() - ImGui::GetTextLineHeight()) *
0.5f);
ImGui::SetCursorPosY(
ImGui::GetCursorPosY() +
(ImGui::GetContentRegionAvail().y - ImGui::GetTextLineHeight()) * 0.5f);
ImGui::TextDisabled("%s", m_no_data_text.c_str());
}
ImGui::PopStyleColor();
Expand Down
1 change: 1 addition & 0 deletions src/view/src/widgets/rocprofvis_infinite_scroll_table.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class InfiniteScrollTable : public RocWidget
};

friend struct EventSearchTestPeer;
friend struct InfiniteScrollTableTestPeer;

protected:
enum TimeColumns
Expand Down
25 changes: 25 additions & 0 deletions src/view/test/rocprofvis_view_test_access.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "rocprofvis_flame_track_item.h"
#include "rocprofvis_measurement_controller.h"
#include "rocprofvis_minimap.h"
#include "rocprofvis_multi_track_table.h"
#include "rocprofvis_project.h"
#include "rocprofvis_sidebar.h"
#include "rocprofvis_summary_view.h"
Expand Down Expand Up @@ -91,6 +92,12 @@ struct AnalysisViewTestPeer
const AnalysisView& v;
EventsView* EventsViewPtr() const { return v.m_events_view.get(); }
TrackDetails* TrackDetailsPtr() const { return v.m_track_details.get(); }
// The pooled Event Table, or the A source's table in compare mode.
InfiniteScrollTable* EventTablePtr() const
{
if(v.m_event_group.tables.empty()) return nullptr;
return v.m_event_group.tables.front().get();
}
};

// TrackDetails holds one DetailItem per selected track (emplace_front on select,
Expand Down Expand Up @@ -291,6 +298,24 @@ struct EventSearchTestPeer
}
};

// The basic filter row's per-column inputs. SetColumnFilter is what typing into
// the column's box and pressing Enter does; the request goes out on the next render.
struct InfiniteScrollTableTestPeer
{
InfiniteScrollTable& v;
bool FilterRowShown() const { return v.m_display_filter_row; }
// The table's child window, and the ImGui table window inside it, are named under this.
const std::string& WidgetName() const { return v.m_widget_name; }
bool SetColumnFilter(const std::string& column, const std::string& text)
{
auto it = v.m_filter_row_inputs.find(column);
if(it == v.m_filter_row_inputs.end()) return false;
it->second.input = text;
v.m_filter_requested = true;
return true;
}
};

// Chunk size used when a track splits a fetch into requests. Shrinking it makes a
// short trace span several chunks.
struct TrackItemTestPeer
Expand Down
Loading