Skip to content

Commit

Permalink
longpress diacritics: Add ActionType for UMA record success.
Browse files Browse the repository at this point in the history
Use existing assistive metrics to get data on success.

Bug: b/241729161
Change-Id: Ie5532db13334a83afe47f90ffc9db4c8b31e8a89
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3815902
Reviewed-by: Darren Shen <shend@chromium.org>
Auto-Submit: jhtin <jhtin@chromium.org>
Commit-Queue: jhtin <jhtin@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1032455}
  • Loading branch information
jhtin authored and Chromium LUCI CQ committed Aug 8, 2022
1 parent fd9e7c0 commit 9837115
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 3 deletions.
19 changes: 19 additions & 0 deletions chrome/browser/ash/input_method/assistive_suggester_unittest.cc
Expand Up @@ -472,6 +472,25 @@ TEST_F(AssistiveSuggesterTest,
EXPECT_EQ(suggestion_handler_->GetSuggestionText(), u"à;á;â;ã;ã;ä;å;ā");
}

TEST_F(AssistiveSuggesterTest, DiacriticsSuggestionOnKeyDownRecordsSuccess) {
base::test::ScopedFeatureList feature_list;
feature_list.InitWithFeatures(
/*enabled_features=*/{features::kDiacriticsOnPhysicalKeyboardLongpress},
/*disabled_features=*/{});
SetInputMethodOptions(*profile_, /*predictive_writing_enabled=*/false,
/*diacritics_on_longpress_enabled=*/true);
assistive_suggester_->OnActivate(kUsEnglishEngineId);
assistive_suggester_->OnFocus(5);

EXPECT_FALSE(assistive_suggester_->OnKeyEvent(PressKey(ui::DomCode::US_A)));
task_environment_.FastForwardBy(base::Seconds(1));
EXPECT_TRUE(assistive_suggester_->OnKeyEvent(PressKey(ui::DomCode::DIGIT1)));

histogram_tester_.ExpectTotalCount("InputMethod.Assistive.Success", 1);
histogram_tester_.ExpectUniqueSample("InputMethod.Assistive.Success",
AssistiveType::kLongpressDiacritics, 1);
}

TEST_F(AssistiveSuggesterTest,
NoDiacriticsSuggestionOnKeyDownLongpressForUSEnglishOnPrefDisabled) {
base::test::ScopedFeatureList feature_list;
Expand Down
Expand Up @@ -230,8 +230,7 @@ void LongpressDiacriticsSuggester::DismissSuggestion() {
}

AssistiveType LongpressDiacriticsSuggester::GetProposeActionType() {
// TODO(b/217560706): Should handle action.
return AssistiveType::kGenericAction;
return AssistiveType::kLongpressDiacritics;
}

bool LongpressDiacriticsSuggester::HasSuggestions() {
Expand Down
Expand Up @@ -9,6 +9,7 @@
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "chrome/browser/ash/input_method/fake_suggestion_handler.h"
#include "chrome/browser/ash/input_method/suggestion_enums.h"
#include "chrome/test/base/testing_profile.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/events/base_event_utils.h"
Expand Down Expand Up @@ -612,6 +613,16 @@ TEST_P(LongpressDiacriticsSuggesterTest, NoDismissSuggestionOnRepeatKeyPress) {
EXPECT_FALSE(suggestion_handler.GetAcceptedSuggestion());
}

TEST_P(LongpressDiacriticsSuggesterTest, ReturnsDiacriticsProposeActionType) {
FakeSuggestionHandler suggestion_handler;
LongpressDiacriticsSuggester suggester =
LongpressDiacriticsSuggester(&suggestion_handler);
suggester.OnFocus(kContextId);

EXPECT_EQ(suggester.GetProposeActionType(),
AssistiveType::kLongpressDiacritics);
}

INSTANTIATE_TEST_SUITE_P(
/* no prefix */,
LongpressDiacriticsSuggesterTest,
Expand Down
3 changes: 2 additions & 1 deletion chrome/browser/ash/input_method/suggestion_enums.h
Expand Up @@ -25,7 +25,8 @@ enum class AssistiveType {
kAutocorrectReverted = 12,
kMultiWordPrediction = 13,
kMultiWordCompletion = 14,
kMaxValue = kMultiWordCompletion,
kLongpressDiacritics = 15,
kMaxValue = kLongpressDiacritics,
};

enum class SuggestionStatus {
Expand Down
1 change: 1 addition & 0 deletions tools/metrics/histograms/enums.xml
Expand Up @@ -49782,6 +49782,7 @@ Called by update_gpu_driver_bug_workaround_entries.py.-->
<int value="12" label="AUTOCORRECT_REVERTED"/>
<int value="13" label="MULTIWORD_PREDICTION"/>
<int value="14" label="MULTIWORD_COMPLETION"/>
<int value="15" label="LONGPRESS_DIACRITICS"/>
</enum>

<enum name="IMEAssistiveDisabledReason">
Expand Down

0 comments on commit 9837115

Please sign in to comment.