Commit 1f763a92 authored by Yulun Wu's avatar Yulun Wu Committed by Commit Bot

Track HomeToOverview nudge dismiss metrics.

Some metrics are missing for home to overview gesture. This CL adds
metrics to HomeToOverviewController::HideNudge().

Bug: 1101105
Change-Id: I166cce0a489925f0e03ed61b0808044af35aaea4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2293459Reviewed-by: default avatarYulun Wu <yulunwu@chromium.org>
Reviewed-by: default avatarToni Baržić <tbarzic@chromium.org>
Commit-Queue: Yulun Wu <yulunwu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#787829}
parent 00c295ea
......@@ -119,6 +119,25 @@ class ObserverToCloseWidget : public ui::ImplicitAnimationObserver {
views::Widget* const widget_;
};
void RecordNudgeMetrics(
HomeToOverviewNudgeController::HideTransition transition) {
switch (transition) {
case (HomeToOverviewNudgeController::HideTransition::kUserTap):
LogNudgeDismissedMetrics(contextual_tooltip::TooltipType::kHomeToOverview,
contextual_tooltip::DismissNudgeReason::kTap);
break;
case (HomeToOverviewNudgeController::HideTransition::kNudgeTimeout):
LogNudgeDismissedMetrics(
contextual_tooltip::TooltipType::kHomeToOverview,
contextual_tooltip::DismissNudgeReason::kTimeout);
break;
case (HomeToOverviewNudgeController::HideTransition::kShelfStateChange):
LogNudgeDismissedMetrics(contextual_tooltip::TooltipType::kHomeToOverview,
contextual_tooltip::DismissNudgeReason::kOther);
break;
}
}
} // namespace
HomeToOverviewNudgeController::HomeToOverviewNudgeController(
......@@ -306,6 +325,8 @@ void HomeToOverviewNudgeController::HideNudge(HideTransition transition) {
if (!nudge_)
return;
RecordNudgeMetrics(transition);
auto animate_hide_transform = [](HideTransition transition,
ui::Layer* layer) {
ui::ScopedLayerAnimationSettings settings(layer->GetAnimator());
......
......@@ -20,6 +20,7 @@
#include "ash/wm/overview/overview_controller.h"
#include "ash/wm/tablet_mode/tablet_mode_controller_test_api.h"
#include "ash/wm/window_state.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/simple_test_clock.h"
#include "ui/compositor/layer.h"
......@@ -226,6 +227,7 @@ TEST_F(HomeToOverviewNudgeControllerTest, NoNudgeBeforeLogin) {
// first time, nudge should remain visible until the hotseat state changes. On
// subsequent shows, the nudge should be hidden after a timeout.
TEST_F(HomeToOverviewNudgeControllerTest, ShownOnHomeScreen) {
base::HistogramTester histogram_tester;
CreateUserSessions(1);
// The nudge should not be shown in clamshell.
......@@ -291,6 +293,9 @@ TEST_F(HomeToOverviewNudgeControllerTest, ShownOnHomeScreen) {
GetNudgeController()->FireHideTimerForTesting();
EXPECT_FALSE(GetNudgeController()->nudge_for_testing());
EXPECT_EQ(gfx::Transform(), GetHotseatWidget()->GetLayer()->transform());
histogram_tester.ExpectBucketCount(
"Ash.ContextualNudgeDismissContext.HomeToOverview",
contextual_tooltip::DismissNudgeReason::kTimeout, 1);
}
// Tests that the nudge eventually stops showing.
......@@ -325,6 +330,7 @@ TEST_F(HomeToOverviewNudgeControllerTest, ShownLimitedNumberOfTimes) {
// Tests that the nudge is hidden when tablet mode exits.
TEST_F(HomeToOverviewNudgeControllerTest, HiddenOnTabletModeExit) {
base::HistogramTester histogram_tester;
TabletModeControllerTestApi().EnterTabletMode();
CreateUserSessions(1);
ScopedWindowList extra_windows = CreateAndMinimizeWindows(2);
......@@ -338,6 +344,10 @@ TEST_F(HomeToOverviewNudgeControllerTest, HiddenOnTabletModeExit) {
EXPECT_FALSE(GetNudgeController()->nudge_for_testing());
EXPECT_EQ(gfx::Transform(),
GetHotseatWidget()->GetLayer()->GetTargetTransform());
histogram_tester.ExpectBucketCount(
"Ash.ContextualNudgeDismissContext.HomeToOverview",
contextual_tooltip::DismissNudgeReason::kOther, 1);
}
// Tests that the nudge show is canceled when tablet mode exits.
......@@ -502,6 +512,7 @@ TEST_F(HomeToOverviewNudgeControllerTest, NoCrashIfNudgeWidgetGetsClosed) {
// Tests that tapping on the nudge hides the nudge.
TEST_F(HomeToOverviewNudgeControllerTest, TapOnTheNudgeClosesTheNudge) {
base::HistogramTester histogram_tester;
TabletModeControllerTestApi().EnterTabletMode();
CreateUserSessions(1);
ScopedWindowList windows = CreateAndMinimizeWindows(2);
......@@ -523,6 +534,10 @@ TEST_F(HomeToOverviewNudgeControllerTest, TapOnTheNudgeClosesTheNudge) {
EXPECT_EQ(gfx::Transform(),
GetHotseatWidget()->GetLayer()->GetTargetTransform());
histogram_tester.ExpectBucketCount(
"Ash.ContextualNudgeDismissContext.HomeToOverview",
contextual_tooltip::DismissNudgeReason::kTap, 1);
}
TEST_F(HomeToOverviewNudgeControllerTest, TapOnTheNudgeDuringShowAnimation) {
......@@ -622,7 +637,7 @@ TEST_F(HomeToOverviewNudgeControllerTest, NoNudgeAfterSuccessfulGestures) {
transition_timer->FireNow();
}));
// No point oof continuing the test if transition to overview failed.
// No point in continuing the test if transition to overview failed.
ASSERT_TRUE(Shell::Get()->overview_controller()->InOverviewSession());
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment