Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
24 changes: 23 additions & 1 deletion src/view/src/widgets/rocprofvis_infinite_scroll_table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ constexpr const char* END_TS_COLUMN_NAME = "end";
constexpr const char* DURATION_COLUMN_NAME = "duration";
constexpr const char* FILTER_INPUT_PLACEHOLDER = "Filter";
constexpr const char* FILTER_OPERATORS = "> < = >= <= !=";
constexpr const char* NO_MATCHING_ROWS_TEXT = "No rows match the current filter.";

constexpr float MIN_COLUMN_WIDTH_EM = 6.0f;
constexpr float MAX_COLUMN_FIT_WIDTH_EM = 40.0f;
Expand Down Expand Up @@ -703,7 +704,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 @@ -786,6 +789,25 @@ InfiniteScrollTable::Render()
}
}
ImGui::EndTable(); // End BeginTable

if(total_row_count == 0 && table_data.empty() && !show_loading_indicator)
{
const bool filtered = table_params && !table_params->m_filter.empty();
const char* message = filtered ? NO_MATCHING_ROWS_TEXT
: m_no_data_text.c_str();
if(*message)
{
ImVec2 table_min = ImGui::GetItemRectMin();
ImVec2 table_max = ImGui::GetItemRectMax();
ImVec2 text_size = ImGui::CalcTextSize(message);
ImVec2 text_pos(
std::max(table_min.x,
(table_min.x + table_max.x - text_size.x) * 0.5f),
(table_min.y + table_max.y - text_size.y) * 0.5f);
ImGui::GetWindowDrawList()->AddText(
text_pos, ImGui::GetColorU32(ImGuiCol_TextDisabled), message);
}
}
Comment thread
dhingora-amd marked this conversation as resolved.
Resolved
}
ImGui::PopStyleVar();
RenderContextMenu();
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