Skip to content

Commit

Permalink
Add query minimum of 3 for System Info Answer Cards in Launcher
Browse files Browse the repository at this point in the history
Test: Added unit tests, works on DUT
Bug: b/308071854
Change-Id: I71648c62fe36c0086b39de95d17d7b246116d0e4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4983149
Commit-Queue: Lauren Commeignes <laurencom@chromium.org>
Reviewed-by: Dmitry Grebenyuk <dgrebenyuk@google.com>
Cr-Commit-Position: refs/heads/main@{#1216745}
  • Loading branch information
Lauren Commeignes authored and Chromium LUCI CQ committed Oct 30, 2023
1 parent 3568514 commit 5bf0924
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ using AnswerCardInfo = ::ash::SystemInfoAnswerCardData;

constexpr double kMinimumRelevance = 0.0;
constexpr double kRelevanceThreshold = 0.79;
constexpr double kMinimumQueryLength = 3;

double ConvertKBtoBytes(uint32_t amount) {
return static_cast<double>(amount) * 1024;
Expand Down Expand Up @@ -97,6 +98,10 @@ SystemInfoCardProvider::~SystemInfoCardProvider() {
}

void SystemInfoCardProvider::Start(const std::u16string& query) {
if (query.length() < kMinimumQueryLength) {
return;
}

double max_relevance = 0;
SystemInfoKeywordInput* most_relevant_keyword_input;
for (SystemInfoKeywordInput& keyword_input : keywords_) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,33 @@ TEST_F(SystemInfoCardProviderTest, Version) {
EXPECT_TRUE(details.GetTextTags().empty());
}

TEST_F(SystemInfoCardProviderTest, PreventTriggeringOfTooShortQueries) {
auto timer = std::make_unique<base::MockRepeatingTimer>();
provider_->SetCpuUsageTimerForTesting(std::move(timer));

int temp_1 = 40;
int temp_2 = 50;
int temp_3 = 15;
uint32_t core_1_speed = 4000000;
uint32_t core_2_speed = 2000000;
CpuUsageData core_1(1000, 1000, 1000);
CpuUsageData core_2(2000, 2000, 2000);

SetCrosHealthdCpuResponse({core_1, core_2}, {temp_1, temp_2, temp_3},
{core_1_speed, core_2_speed});
StartSearch(u"cp");
Wait();
ASSERT_TRUE(results().empty());

StartSearch(u"c");
Wait();
ASSERT_TRUE(results().empty());

StartSearch(u"cpu");
Wait();
ASSERT_FALSE(results().empty());
}

TEST_F(SystemInfoCardProviderTest, Cpu) {
// Setup Timer
auto timer = std::make_unique<base::MockRepeatingTimer>();
Expand Down

0 comments on commit 5bf0924

Please sign in to comment.