Commit a903f923 authored by Andrew Xu's avatar Andrew Xu Committed by Commit Bot

Add metrics for home button and back button

This CL adds user actions for pressing the home button and the back
button.

Bug: 1018916
Change-Id: I0d97812cbe53a0334dff7c32bbe016bd82d41c8e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1900389Reviewed-by: default avatarMark Pearson <mpearson@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Andrew Xu <andrewxu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#713570}
parent 96cefcfa
...@@ -8,6 +8,8 @@ ...@@ -8,6 +8,8 @@
#include "ash/shelf/shelf.h" #include "ash/shelf/shelf.h"
#include "ash/shelf/shelf_focus_cycler.h" #include "ash/shelf/shelf_focus_cycler.h"
#include "ash/strings/grit/ash_strings.h" #include "ash/strings/grit/ash_strings.h"
#include "base/metrics/user_metrics.h"
#include "base/metrics/user_metrics_action.h"
#include "ui/aura/window.h" #include "ui/aura/window.h"
#include "ui/aura/window_tree_host.h" #include "ui/aura/window_tree_host.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
...@@ -57,6 +59,8 @@ void BackButton::OnShelfButtonAboutToRequestFocusFromTabTraversal( ...@@ -57,6 +59,8 @@ void BackButton::OnShelfButtonAboutToRequestFocusFromTabTraversal(
void BackButton::ButtonPressed(views::Button* sender, void BackButton::ButtonPressed(views::Button* sender,
const ui::Event& event, const ui::Event& event,
views::InkDrop* ink_drop) { views::InkDrop* ink_drop) {
base::RecordAction(base::UserMetricsAction("AppList_BackButtonPressed"));
// Send up event as well as down event as ARC++ clients expect this sequence. // Send up event as well as down event as ARC++ clients expect this sequence.
// TODO: Investigate if we should be using the current modifiers. // TODO: Investigate if we should be using the current modifiers.
aura::Window* root_window = GetWidget()->GetNativeWindow()->GetRootWindow(); aura::Window* root_window = GetWidget()->GetNativeWindow()->GetRootWindow();
......
...@@ -14,6 +14,8 @@ ...@@ -14,6 +14,8 @@
#include "ash/shell.h" #include "ash/shell.h"
#include "ash/wm/tablet_mode/tablet_mode_controller.h" #include "ash/wm/tablet_mode/tablet_mode_controller.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/metrics/user_metrics.h"
#include "base/metrics/user_metrics_action.h"
#include "chromeos/strings/grit/chromeos_strings.h" #include "chromeos/strings/grit/chromeos_strings.h"
#include "ui/aura/window.h" #include "ui/aura/window.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
...@@ -85,8 +87,14 @@ void HomeButton::OnShelfButtonAboutToRequestFocusFromTabTraversal( ...@@ -85,8 +87,14 @@ void HomeButton::OnShelfButtonAboutToRequestFocusFromTabTraversal(
void HomeButton::ButtonPressed(views::Button* sender, void HomeButton::ButtonPressed(views::Button* sender,
const ui::Event& event, const ui::Event& event,
views::InkDrop* ink_drop) { views::InkDrop* ink_drop) {
Shell::Get()->metrics()->RecordUserMetricsAction( if (Shell::Get()->tablet_mode_controller()->InTabletMode()) {
UMA_LAUNCHER_CLICK_ON_APPLIST_BUTTON); base::RecordAction(
base::UserMetricsAction("AppList_HomeButtonPressedTablet"));
} else {
base::RecordAction(
base::UserMetricsAction("AppList_HomeButtonPressedClamshell"));
}
const AppListShowSource show_source = const AppListShowSource show_source =
event.IsShiftDown() ? kShelfButtonFullscreen : kShelfButton; event.IsShiftDown() ? kShelfButtonFullscreen : kShelfButton;
OnPressed(show_source, event.time_stamp()); OnPressed(show_source, event.time_stamp());
......
...@@ -1440,6 +1440,45 @@ TEST_F(ShelfViewTest, ShelfAlignmentClosesTooltip) { ...@@ -1440,6 +1440,45 @@ TEST_F(ShelfViewTest, ShelfAlignmentClosesTooltip) {
EXPECT_FALSE(tooltip_manager->IsVisible()); EXPECT_FALSE(tooltip_manager->IsVisible());
} }
// Verifies that the time of button press is recorded correctly in clamshell.
TEST_F(ShelfViewTest, HomeButtonMetricsInClamshell) {
const HomeButton* home_button = shelf_view_->shelf_widget()->GetHomeButton();
// Make sure we're not showing the app list.
EXPECT_FALSE(home_button->IsShowingAppList());
base::UserActionTester user_action_tester;
ASSERT_EQ(0, user_action_tester.GetActionCount(
"AppList_HomeButtonPressedClamshell"));
GetEventGenerator()->GestureTapAt(
home_button->GetBoundsInScreen().CenterPoint());
ASSERT_EQ(1, user_action_tester.GetActionCount(
"AppList_HomeButtonPressedClamshell"));
EXPECT_TRUE(home_button->IsShowingAppList());
}
// Verifies that the time of button press is recorded correctly in tablet.
TEST_F(ShelfViewTest, HomeButtonMetricsInTablet) {
Shell::Get()->tablet_mode_controller()->SetEnabledForTest(true);
const HomeButton* home_button = shelf_view_->shelf_widget()->GetHomeButton();
// Make sure we're not showing the app list.
std::unique_ptr<aura::Window> window = CreateTestWindow();
wm::ActivateWindow(window.get());
EXPECT_FALSE(home_button->IsShowingAppList());
base::UserActionTester user_action_tester;
ASSERT_EQ(
0, user_action_tester.GetActionCount("AppList_HomeButtonPressedTablet"));
GetEventGenerator()->GestureTapAt(
home_button->GetBoundsInScreen().CenterPoint());
ASSERT_EQ(
1, user_action_tester.GetActionCount("AppList_HomeButtonPressedTablet"));
EXPECT_TRUE(home_button->IsShowingAppList());
}
class HotseatShelfViewTest : public ShelfViewTest, class HotseatShelfViewTest : public ShelfViewTest,
public testing::WithParamInterface<bool> { public testing::WithParamInterface<bool> {
public: public:
......
...@@ -2360,6 +2360,11 @@ should be able to be added at any place in this file. ...@@ -2360,6 +2360,11 @@ should be able to be added at any place in this file.
<description>Please enter the description of this user action.</description> <description>Please enter the description of this user action.</description>
</action> </action>
<action name="AppList_BackButtonPressed">
<owner>andrewxu@chromium.org</owner>
<description>User pressed the back button.</description>
</action>
<action name="AppList_ClickOnApp"> <action name="AppList_ClickOnApp">
<owner>vadimt@chromium.org</owner> <owner>vadimt@chromium.org</owner>
<description> <description>
...@@ -2403,6 +2408,16 @@ should be able to be added at any place in this file. ...@@ -2403,6 +2408,16 @@ should be able to be added at any place in this file.
<description>CrOS Launcher went from full to peeking state.</description> <description>CrOS Launcher went from full to peeking state.</description>
</action> </action>
<action name="AppList_HomeButtonPressedClamshell">
<owner>andrewxu@chromium.org</owner>
<description>User pressed the launcher button in clamshell.</description>
</action>
<action name="AppList_HomeButtonPressedTablet">
<owner>andrewxu@chromium.org</owner>
<description>User pressed the launcher button in tablet.</description>
</action>
<action name="AppList_HomeLauncherToMRUWindow"> <action name="AppList_HomeLauncherToMRUWindow">
<owner>newcomer@chromium.org</owner> <owner>newcomer@chromium.org</owner>
<owner>sammiequon@chromium.org</owner> <owner>sammiequon@chromium.org</owner>
......
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