Avi Drissman | 3a215d1e | 2022-09-07 19:43:09 | [diff] [blame] | 1 | // Copyright 2019 The Chromium Authors |
Matthew Mourgos | 105a91f | 2019-05-08 23:30:48 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include <memory> |
Matthew Mourgos | a6330ce | 2021-06-24 04:19:13 | [diff] [blame] | 6 | #include <string> |
Ahmed Fakhry | 1b6ea0b | 2020-07-09 01:45:24 | [diff] [blame] | 7 | #include <utility> |
Matthew Mourgos | 105a91f | 2019-05-08 23:30:48 | [diff] [blame] | 8 | #include <vector> |
| 9 | |
Katie Dektar | 582ae10 | 2023-12-13 03:15:54 | [diff] [blame] | 10 | #include "ash/accessibility/accessibility_controller.h" |
Alex Newcomer | fe77603 | 2021-06-16 21:17:08 | [diff] [blame] | 11 | #include "ash/app_list/app_list_bubble_presenter.h" |
Matthew Mourgos | 105a91f | 2019-05-08 23:30:48 | [diff] [blame] | 12 | #include "ash/app_list/app_list_controller_impl.h" |
Matthew Mourgos | 4c287d6 | 2019-10-25 22:46:16 | [diff] [blame] | 13 | #include "ash/app_list/app_list_metrics.h" |
Toni Barzic | 8014351 | 2021-10-29 15:41:45 | [diff] [blame] | 14 | #include "ash/app_list/app_list_model_provider.h" |
James Cook | 4f4c361 | 2021-05-27 21:45:22 | [diff] [blame] | 15 | #include "ash/app_list/app_list_presenter_impl.h" |
James Cook | 1c61793 | 2021-04-01 16:42:09 | [diff] [blame] | 16 | #include "ash/app_list/model/app_list_test_model.h" |
Matthew Mourgos | 105a91f | 2019-05-08 23:30:48 | [diff] [blame] | 17 | #include "ash/app_list/model/search/search_model.h" |
| 18 | #include "ash/app_list/test/app_list_test_helper.h" |
Matthew Mourgos | 105a91f | 2019-05-08 23:30:48 | [diff] [blame] | 19 | #include "ash/app_list/views/app_list_item_view.h" |
| 20 | #include "ash/app_list/views/app_list_main_view.h" |
| 21 | #include "ash/app_list/views/app_list_view.h" |
| 22 | #include "ash/app_list/views/apps_container_view.h" |
Matthew Mourgos | 105a91f | 2019-05-08 23:30:48 | [diff] [blame] | 23 | #include "ash/app_list/views/contents_view.h" |
Matthew Mourgos | a205f30 | 2021-09-08 22:28:21 | [diff] [blame] | 24 | #include "ash/app_list/views/paged_apps_grid_view.h" |
James Cook | 44ddf21 | 2022-07-26 17:49:23 | [diff] [blame] | 25 | #include "ash/app_list/views/recent_apps_view.h" |
Matthew Mourgos | 105a91f | 2019-05-08 23:30:48 | [diff] [blame] | 26 | #include "ash/app_list/views/search_result_container_view.h" |
| 27 | #include "ash/app_list/views/search_result_page_view.h" |
Alex Newcomer | fe77603 | 2021-06-16 21:17:08 | [diff] [blame] | 28 | #include "ash/constants/ash_features.h" |
Xiyuan Xia | 68b3b2c | 2019-05-28 18:50:39 | [diff] [blame] | 29 | #include "ash/public/cpp/app_list/app_list_types.h" |
Matthew Mourgos | 105a91f | 2019-05-08 23:30:48 | [diff] [blame] | 30 | #include "ash/public/cpp/shelf_item_delegate.h" |
| 31 | #include "ash/public/cpp/shelf_model.h" |
Matthew Mourgos | 4c287d6 | 2019-10-25 22:46:16 | [diff] [blame] | 32 | #include "ash/shelf/home_button.h" |
Matthew Mourgos | 105a91f | 2019-05-08 23:30:48 | [diff] [blame] | 33 | #include "ash/shelf/shelf.h" |
Manu Cornet | 759eed9 | 2020-01-15 23:30:26 | [diff] [blame] | 34 | #include "ash/shelf/shelf_navigation_widget.h" |
Matthew Mourgos | 105a91f | 2019-05-08 23:30:48 | [diff] [blame] | 35 | #include "ash/shelf/shelf_view.h" |
| 36 | #include "ash/shelf/shelf_view_test_api.h" |
| 37 | #include "ash/shell.h" |
| 38 | #include "ash/test/ash_test_base.h" |
| 39 | #include "ash/wm/tablet_mode/tablet_mode_controller.h" |
Arthur Sonzogni | 834e018f | 2023-04-22 10:20:02 | [diff] [blame] | 40 | #include "base/memory/raw_ptr.h" |
Matthew Mourgos | 105a91f | 2019-05-08 23:30:48 | [diff] [blame] | 41 | #include "base/test/metrics/histogram_tester.h" |
Alex Newcomer | fe77603 | 2021-06-16 21:17:08 | [diff] [blame] | 42 | #include "base/test/scoped_feature_list.h" |
Ana Salazar | be73a3d | 2023-06-23 01:37:43 | [diff] [blame] | 43 | #include "ui/compositor/scoped_animation_duration_scale_mode.h" |
Eriko Kurimoto | c6585fc | 2023-11-20 06:03:32 | [diff] [blame] | 44 | #include "ui/display/display_observer.h" |
Matthew Mourgos | 105a91f | 2019-05-08 23:30:48 | [diff] [blame] | 45 | #include "ui/display/screen.h" |
Eriko Kurimoto | c6585fc | 2023-11-20 06:03:32 | [diff] [blame] | 46 | #include "ui/display/tablet_state.h" |
Matthew Mourgos | 105a91f | 2019-05-08 23:30:48 | [diff] [blame] | 47 | |
| 48 | namespace ash { |
| 49 | |
| 50 | namespace { |
| 51 | |
Manu Cornet | 47126715 | 2019-06-19 20:38:18 | [diff] [blame] | 52 | constexpr int kBrowserAppIndexOnShelf = 0; |
| 53 | |
Matthew Mourgos | 105a91f | 2019-05-08 23:30:48 | [diff] [blame] | 54 | // A test shelf item delegate that simulates an activated window when a shelf |
Ana Salazar | be73a3d | 2023-06-23 01:37:43 | [diff] [blame] | 55 | // item is selected. When |wait_for_tablet_mode_| is set, the delegate will wait |
| 56 | // for tablet mode animation start to run the callback that activates the |
| 57 | // window. |
Eriko Kurimoto | c6585fc | 2023-11-20 06:03:32 | [diff] [blame] | 58 | class TestShelfItemDelegate : public ShelfItemDelegate, |
| 59 | display::DisplayObserver { |
Matthew Mourgos | 105a91f | 2019-05-08 23:30:48 | [diff] [blame] | 60 | public: |
| 61 | explicit TestShelfItemDelegate(const ShelfID& shelf_id) |
| 62 | : ShelfItemDelegate(shelf_id) {} |
| 63 | |
Ana Salazar | be73a3d | 2023-06-23 01:37:43 | [diff] [blame] | 64 | TestShelfItemDelegate(const ShelfID& shelf_id, bool wait_for_tablet_mode) |
| 65 | : ShelfItemDelegate(shelf_id), |
| 66 | wait_for_tablet_mode_(wait_for_tablet_mode) { |
| 67 | if (wait_for_tablet_mode_) { |
Eriko Kurimoto | c6585fc | 2023-11-20 06:03:32 | [diff] [blame] | 68 | display::Screen::GetScreen()->AddObserver(this); |
Ana Salazar | be73a3d | 2023-06-23 01:37:43 | [diff] [blame] | 69 | } |
| 70 | } |
| 71 | |
Eriko Kurimoto | c6585fc | 2023-11-20 06:03:32 | [diff] [blame] | 72 | ~TestShelfItemDelegate() override { |
| 73 | display::Screen::GetScreen()->RemoveObserver(this); |
| 74 | } |
| 75 | |
Matthew Mourgos | 105a91f | 2019-05-08 23:30:48 | [diff] [blame] | 76 | void ItemSelected(std::unique_ptr<ui::Event> event, |
| 77 | int64_t display_id, |
| 78 | ash::ShelfLaunchSource source, |
Ahmed Fakhry | 1b6ea0b | 2020-07-09 01:45:24 | [diff] [blame] | 79 | ItemSelectedCallback callback, |
| 80 | const ItemFilterPredicate& filter_predicate) override { |
Ana Salazar | be73a3d | 2023-06-23 01:37:43 | [diff] [blame] | 81 | if (wait_for_tablet_mode_) { |
| 82 | callback_ = std::move(callback); |
| 83 | return; |
| 84 | } |
Mike Wasserman | 3bfabb19 | 2019-05-17 01:08:34 | [diff] [blame] | 85 | std::move(callback).Run(SHELF_ACTION_WINDOW_ACTIVATED, {}); |
Matthew Mourgos | 105a91f | 2019-05-08 23:30:48 | [diff] [blame] | 86 | } |
| 87 | void ExecuteCommand(bool from_context_menu, |
| 88 | int64_t command_id, |
| 89 | int32_t event_flags, |
| 90 | int64_t display_id) override {} |
| 91 | void Close() override {} |
Ana Salazar | be73a3d | 2023-06-23 01:37:43 | [diff] [blame] | 92 | |
Eriko Kurimoto | c6585fc | 2023-11-20 06:03:32 | [diff] [blame] | 93 | void OnDisplayTabletStateChanged(display::TabletState state) override { |
| 94 | if (!callback_ || state != display::TabletState::kEnteringTabletMode) { |
Ana Salazar | be73a3d | 2023-06-23 01:37:43 | [diff] [blame] | 95 | return; |
| 96 | } |
| 97 | std::move(callback_).Run(SHELF_ACTION_WINDOW_ACTIVATED, {}); |
| 98 | } |
| 99 | |
Ana Salazar | be73a3d | 2023-06-23 01:37:43 | [diff] [blame] | 100 | private: |
| 101 | bool wait_for_tablet_mode_ = false; |
| 102 | ItemSelectedCallback callback_; |
Matthew Mourgos | 105a91f | 2019-05-08 23:30:48 | [diff] [blame] | 103 | }; |
| 104 | |
| 105 | } // namespace |
| 106 | |
| 107 | int64_t GetPrimaryDisplayId() { |
| 108 | return display::Screen::GetScreen()->GetPrimaryDisplay().id(); |
| 109 | } |
| 110 | |
| 111 | // Used to test that app launched metrics are properly recorded. |
James Cook | 4b85115 | 2021-12-28 21:38:26 | [diff] [blame] | 112 | class AppListMetricsTest : public AshTestBase { |
Matthew Mourgos | 105a91f | 2019-05-08 23:30:48 | [diff] [blame] | 113 | public: |
James Cook | 4b85115 | 2021-12-28 21:38:26 | [diff] [blame] | 114 | AppListMetricsTest() = default; |
Peter Boström | ec31a04 | 2021-09-16 23:37:34 | [diff] [blame] | 115 | |
James Cook | 4b85115 | 2021-12-28 21:38:26 | [diff] [blame] | 116 | AppListMetricsTest(const AppListMetricsTest&) = delete; |
| 117 | AppListMetricsTest& operator=(const AppListMetricsTest&) = delete; |
Peter Boström | ec31a04 | 2021-09-16 23:37:34 | [diff] [blame] | 118 | |
James Cook | 4b85115 | 2021-12-28 21:38:26 | [diff] [blame] | 119 | ~AppListMetricsTest() override = default; |
Matthew Mourgos | 105a91f | 2019-05-08 23:30:48 | [diff] [blame] | 120 | |
| 121 | void SetUp() override { |
Matthew Mourgos | 105a91f | 2019-05-08 23:30:48 | [diff] [blame] | 122 | AshTestBase::SetUp(); |
| 123 | |
Toni Barzic | 8014351 | 2021-10-29 15:41:45 | [diff] [blame] | 124 | search_model_ = AppListModelProvider::Get()->search_model(); |
Matthew Mourgos | 105a91f | 2019-05-08 23:30:48 | [diff] [blame] | 125 | |
Andrew Xu | b940f4d | 2019-09-17 01:06:50 | [diff] [blame] | 126 | shelf_test_api_ = std::make_unique<ShelfViewTestAPI>( |
| 127 | GetPrimaryShelf()->GetShelfViewForTesting()); |
Matthew Mourgos | 105a91f | 2019-05-08 23:30:48 | [diff] [blame] | 128 | } |
| 129 | |
Matthew Mourgos | 105a91f | 2019-05-08 23:30:48 | [diff] [blame] | 130 | protected: |
Ana Salazar | be73a3d | 2023-06-23 01:37:43 | [diff] [blame] | 131 | void CreateShelfItem(bool wait_for_tablet_mode = false) { |
Andrew Xu | b940f4d | 2019-09-17 01:06:50 | [diff] [blame] | 132 | // Add shelf item to be launched. Waits for the shelf view's bounds |
| 133 | // animations to end. |
Matthew Mourgos | 105a91f | 2019-05-08 23:30:48 | [diff] [blame] | 134 | ShelfItem shelf_item; |
Manu Cornet | 164f6a2 | 2019-12-20 16:37:33 | [diff] [blame] | 135 | shelf_item.id = ShelfID("app_id"); |
Matthew Mourgos | 105a91f | 2019-05-08 23:30:48 | [diff] [blame] | 136 | shelf_item.type = TYPE_BROWSER_SHORTCUT; |
Ana Salazar | be73a3d | 2023-06-23 01:37:43 | [diff] [blame] | 137 | ShelfModel::Get()->Add(shelf_item, |
| 138 | std::make_unique<TestShelfItemDelegate>( |
| 139 | shelf_item.id, wait_for_tablet_mode)); |
Andrew Xu | b940f4d | 2019-09-17 01:06:50 | [diff] [blame] | 140 | shelf_test_api_->RunMessageLoopUntilAnimationsDone(); |
Ana Salazar | be73a3d | 2023-06-23 01:37:43 | [diff] [blame] | 141 | } |
Matthew Mourgos | 105a91f | 2019-05-08 23:30:48 | [diff] [blame] | 142 | |
Ana Salazar | be73a3d | 2023-06-23 01:37:43 | [diff] [blame] | 143 | void CreateAndClickShelfItem() { |
| 144 | CreateShelfItem(); |
Matthew Mourgos | 105a91f | 2019-05-08 23:30:48 | [diff] [blame] | 145 | ClickShelfItem(); |
| 146 | } |
| 147 | |
| 148 | void ClickShelfItem() { |
| 149 | // Get location of the shelf item. |
Andrew Xu | b940f4d | 2019-09-17 01:06:50 | [diff] [blame] | 150 | const views::ViewModel* view_model = |
| 151 | GetPrimaryShelf()->GetShelfViewForTesting()->view_model_for_test(); |
James Cook | d737936 | 2021-12-30 00:54:09 | [diff] [blame] | 152 | LeftClickOn(view_model->view_at(kBrowserAppIndexOnShelf)); |
Matthew Mourgos | 105a91f | 2019-05-08 23:30:48 | [diff] [blame] | 153 | } |
| 154 | |
Joanmarie Diggs | 3384284 | 2022-09-08 18:47:44 | [diff] [blame] | 155 | void PopulateAndLaunchAppInGrid(int num = 4) { |
Matthew Mourgos | 105a91f | 2019-05-08 23:30:48 | [diff] [blame] | 156 | // Populate apps in the root app grid. |
Toni Barzic | 8014351 | 2021-10-29 15:41:45 | [diff] [blame] | 157 | AppListModel* model = AppListModelProvider::Get()->model(); |
Joanmarie Diggs | 3384284 | 2022-09-08 18:47:44 | [diff] [blame] | 158 | for (int i = 0; i < num; i++) { |
| 159 | AppListItem* item = model->AddItem( |
| 160 | std::make_unique<AppListItem>(base::StringPrintf("item %d", i))); |
| 161 | // Give each item a name so that the accessibility paint checks pass. |
| 162 | // (Focusable items should have accessible names.) |
| 163 | model->SetItemName(item, item->id()); |
| 164 | } |
Matthew Mourgos | 105a91f | 2019-05-08 23:30:48 | [diff] [blame] | 165 | |
Manu Cornet | 191c314 | 2019-10-09 06:31:32 | [diff] [blame] | 166 | AppListView::TestApi test_api( |
James Cook | 26dd002 | 2022-01-10 23:28:28 | [diff] [blame] | 167 | Shell::Get()->app_list_controller()->fullscreen_presenter()->GetView()); |
Matthew Mourgos | 105a91f | 2019-05-08 23:30:48 | [diff] [blame] | 168 | |
| 169 | // Focus the first item in the root app grid. |
| 170 | test_api.GetRootAppsGridView()->GetItemViewAt(0)->RequestFocus(); |
| 171 | |
| 172 | // Press return to simulate an app launch from a grid item. |
James Cook | 70501b2 | 2021-08-09 17:19:18 | [diff] [blame] | 173 | PressAndReleaseKey(ui::KeyboardCode::VKEY_RETURN); |
Matthew Mourgos | 105a91f | 2019-05-08 23:30:48 | [diff] [blame] | 174 | } |
| 175 | |
| 176 | private: |
Bartek Nowierski | deb7584 | 2023-12-27 02:32:42 | [diff] [blame] | 177 | raw_ptr<SearchModel, DanglingUntriaged> search_model_ = nullptr; |
Andrew Xu | b940f4d | 2019-09-17 01:06:50 | [diff] [blame] | 178 | std::unique_ptr<ShelfViewTestAPI> shelf_test_api_; |
Matthew Mourgos | 105a91f | 2019-05-08 23:30:48 | [diff] [blame] | 179 | }; |
| 180 | |
Ana Salazar | f5b5706 | 2022-10-25 17:47:37 | [diff] [blame] | 181 | // Suite for tests that run in tablet mode. |
| 182 | class AppListMetricsTabletTest : public AppListMetricsTest { |
James Cook | 4b85115 | 2021-12-28 21:38:26 | [diff] [blame] | 183 | public: |
Ana Salazar | f5b5706 | 2022-10-25 17:47:37 | [diff] [blame] | 184 | AppListMetricsTabletTest() = default; |
James Cook | 4b85115 | 2021-12-28 21:38:26 | [diff] [blame] | 185 | ~AppListMetricsTabletTest() override = default; |
Ana Salazar | f5b5706 | 2022-10-25 17:47:37 | [diff] [blame] | 186 | void SetUp() override { |
| 187 | AppListMetricsTest::SetUp(); |
| 188 | Shell::Get()->tablet_mode_controller()->SetEnabledForTest(true); |
| 189 | GetAppListTestHelper()->CheckState(AppListViewState::kFullscreenAllApps); |
| 190 | } |
James Cook | 4b85115 | 2021-12-28 21:38:26 | [diff] [blame] | 191 | }; |
James Cook | 4b85115 | 2021-12-28 21:38:26 | [diff] [blame] | 192 | |
Matthew Mourgos | 105a91f | 2019-05-08 23:30:48 | [diff] [blame] | 193 | // Test that the histogram records an app launch from the shelf while the |
| 194 | // homecher all apps state is showing. |
Ana Salazar | f5b5706 | 2022-10-25 17:47:37 | [diff] [blame] | 195 | TEST_F(AppListMetricsTabletTest, HomecherAllAppsLaunchFromShelf) { |
Matthew Mourgos | 105a91f | 2019-05-08 23:30:48 | [diff] [blame] | 196 | base::HistogramTester histogram_tester; |
| 197 | |
Matthew Mourgos | 105a91f | 2019-05-08 23:30:48 | [diff] [blame] | 198 | CreateAndClickShelfItem(); |
| 199 | |
| 200 | histogram_tester.ExpectBucketCount( |
| 201 | "Apps.AppListAppLaunchedV2.HomecherAllApps", |
Timothy Loh | 72c8799 | 2019-05-22 07:11:34 | [diff] [blame] | 202 | AppListLaunchedFrom::kLaunchedFromShelf, |
Matthew Mourgos | 105a91f | 2019-05-08 23:30:48 | [diff] [blame] | 203 | 1 /* Number of times launched from shelf */); |
| 204 | } |
| 205 | |
Ana Salazar | be73a3d | 2023-06-23 01:37:43 | [diff] [blame] | 206 | // Test that the histogram records an app launch from the shelf while the |
| 207 | // the tablet animation is running. |
| 208 | TEST_F(AppListMetricsTest, TapOnItemDuringTabletModeAnimation) { |
| 209 | base::HistogramTester histogram_tester; |
| 210 | Shell::Get()->tablet_mode_controller()->SetEnabledForTest(false); |
| 211 | |
| 212 | CreateShelfItem(/*wait_for_tablet_mode=*/true); |
| 213 | |
| 214 | std::unique_ptr<views::Widget> widget = CreateTestWidget(); |
| 215 | ui::ScopedAnimationDurationScaleMode non_zero_duration_mode( |
| 216 | ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION); |
| 217 | ClickShelfItem(); |
| 218 | |
| 219 | Shell::Get()->tablet_mode_controller()->SetEnabledForTest(true); |
| 220 | GetPrimaryShelf()->shelf_widget()->LayoutRootViewIfNecessary(); |
| 221 | GetAppListTestHelper()->CheckVisibility(false); |
| 222 | |
| 223 | histogram_tester.ExpectBucketCount( |
| 224 | "Apps.AppListAppLaunchedV2.Closed", |
| 225 | AppListLaunchedFrom::kLaunchedFromShelf, |
| 226 | 1 /* Number of times launched from shelf */); |
| 227 | } |
| 228 | |
Matthew Mourgos | 105a91f | 2019-05-08 23:30:48 | [diff] [blame] | 229 | // Test that the histogram records an app launch from the app grid while the |
| 230 | // homecher all apps state is showing. |
Ana Salazar | f5b5706 | 2022-10-25 17:47:37 | [diff] [blame] | 231 | TEST_F(AppListMetricsTabletTest, HomecherAllAppsLaunchFromGrid) { |
Matthew Mourgos | 105a91f | 2019-05-08 23:30:48 | [diff] [blame] | 232 | base::HistogramTester histogram_tester; |
Matthew Mourgos | 105a91f | 2019-05-08 23:30:48 | [diff] [blame] | 233 | PopulateAndLaunchAppInGrid(); |
| 234 | |
| 235 | histogram_tester.ExpectBucketCount( |
| 236 | "Apps.AppListAppLaunchedV2.HomecherAllApps", |
Timothy Loh | 72c8799 | 2019-05-22 07:11:34 | [diff] [blame] | 237 | AppListLaunchedFrom::kLaunchedFromGrid, |
Matthew Mourgos | 105a91f | 2019-05-08 23:30:48 | [diff] [blame] | 238 | 1 /* Number of times launched from grid */); |
| 239 | } |
| 240 | |
Matthew Mourgos | 105a91f | 2019-05-08 23:30:48 | [diff] [blame] | 241 | // Test that the histogram records an app launch from the shelf while the |
| 242 | // homecher search state is showing. |
Ana Salazar | f5b5706 | 2022-10-25 17:47:37 | [diff] [blame] | 243 | TEST_F(AppListMetricsTabletTest, HomecherSearchLaunchFromShelf) { |
Matthew Mourgos | 105a91f | 2019-05-08 23:30:48 | [diff] [blame] | 244 | base::HistogramTester histogram_tester; |
| 245 | |
Matthew Mourgos | 105a91f | 2019-05-08 23:30:48 | [diff] [blame] | 246 | // Press a letter key, the AppListView should transition to kFullscreenSearch. |
James Cook | 70501b2 | 2021-08-09 17:19:18 | [diff] [blame] | 247 | PressAndReleaseKey(ui::KeyboardCode::VKEY_H); |
Matthew Mourgos | 105a91f | 2019-05-08 23:30:48 | [diff] [blame] | 248 | GetAppListTestHelper()->WaitUntilIdle(); |
Manu Cornet | 164f6a2 | 2019-12-20 16:37:33 | [diff] [blame] | 249 | GetAppListTestHelper()->CheckState(AppListViewState::kFullscreenSearch); |
Matthew Mourgos | 105a91f | 2019-05-08 23:30:48 | [diff] [blame] | 250 | |
| 251 | CreateAndClickShelfItem(); |
| 252 | |
| 253 | histogram_tester.ExpectBucketCount( |
| 254 | "Apps.AppListAppLaunchedV2.HomecherSearch", |
Timothy Loh | 72c8799 | 2019-05-22 07:11:34 | [diff] [blame] | 255 | AppListLaunchedFrom::kLaunchedFromShelf, |
Matthew Mourgos | 105a91f | 2019-05-08 23:30:48 | [diff] [blame] | 256 | 1 /* Number of times launched from shelf */); |
| 257 | } |
| 258 | |
Ana Salazar | 1df6735 | 2021-11-17 00:34:12 | [diff] [blame] | 259 | // Test that the histogram records an app launch from a recent app suggestion |
| 260 | // while the bubble launcher all apps is showing. |
Ana Salazar | addeb8c | 2022-10-18 23:31:47 | [diff] [blame] | 261 | TEST_F(AppListMetricsTest, BubbleAllAppsLaunchFromRecentApps) { |
Ana Salazar | 1df6735 | 2021-11-17 00:34:12 | [diff] [blame] | 262 | base::HistogramTester histogram_tester; |
| 263 | auto* helper = GetAppListTestHelper(); |
| 264 | |
| 265 | helper->WaitUntilIdle(); |
| 266 | |
| 267 | helper->AddRecentApps(5); |
| 268 | helper->AddAppItems(5); |
| 269 | helper->ShowAppList(); |
| 270 | |
| 271 | helper->WaitUntilIdle(); |
| 272 | views::View* recent_apps = helper->GetBubbleRecentAppsView(); |
| 273 | |
| 274 | // Get focus on the first chip. |
| 275 | recent_apps->children().front()->RequestFocus(); |
| 276 | helper->WaitUntilIdle(); |
| 277 | |
| 278 | // Press return to simulate an app launch from the recent apps. |
| 279 | PressAndReleaseKey(ui::KeyboardCode::VKEY_RETURN); |
| 280 | helper->WaitUntilIdle(); |
| 281 | |
| 282 | histogram_tester.ExpectBucketCount( |
| 283 | "Apps.AppListAppLaunchedV2.BubbleAllApps", |
| 284 | AppListLaunchedFrom::kLaunchedFromRecentApps, |
| 285 | 1 /* Number of times launched from chip */); |
| 286 | } |
| 287 | |
Ana Salazar | addeb8c | 2022-10-18 23:31:47 | [diff] [blame] | 288 | TEST_F(AppListMetricsTest, HideContinueSectionMetricInClamshellMode) { |
James Cook | 42577bc | 2022-05-02 17:40:17 | [diff] [blame] | 289 | base::HistogramTester histograms; |
| 290 | |
| 291 | // Show the app list with a full continue section. |
| 292 | auto* helper = GetAppListTestHelper(); |
| 293 | helper->AddContinueSuggestionResults(4); |
| 294 | helper->AddRecentApps(5); |
| 295 | helper->AddAppItems(5); |
| 296 | helper->ShowAppList(); |
| 297 | |
| 298 | // Metric is recorded in false bucket. |
| 299 | const int false_bucket = 0; |
| 300 | histograms.ExpectBucketCount( |
| 301 | "Apps.AppList.ContinueSectionHiddenByUser.ClamshellMode", false_bucket, |
| 302 | 1); |
| 303 | helper->Dismiss(); |
| 304 | |
| 305 | // Hide the continue section, then show the app list. |
| 306 | Shell::Get()->app_list_controller()->SetHideContinueSection(true); |
| 307 | helper->ShowAppList(); |
| 308 | |
| 309 | // Metric is recorded in true bucket. |
| 310 | const int true_bucket = 1; |
| 311 | histograms.ExpectBucketCount( |
| 312 | "Apps.AppList.ContinueSectionHiddenByUser.ClamshellMode", true_bucket, 1); |
| 313 | helper->Dismiss(); |
| 314 | } |
| 315 | |
Ana Salazar | addeb8c | 2022-10-18 23:31:47 | [diff] [blame] | 316 | TEST_F(AppListMetricsTest, HideContinueSectionMetricInTabletMode) { |
James Cook | 42577bc | 2022-05-02 17:40:17 | [diff] [blame] | 317 | base::HistogramTester histograms; |
| 318 | |
| 319 | // Show the tablet mode app list with a full continue section. |
| 320 | auto* helper = GetAppListTestHelper(); |
| 321 | helper->AddContinueSuggestionResults(4); |
| 322 | helper->AddRecentApps(5); |
| 323 | helper->AddAppItems(5); |
| 324 | Shell::Get()->tablet_mode_controller()->SetEnabledForTest(true); |
| 325 | |
| 326 | // Metric is recorded in false bucket. |
| 327 | const int false_bucket = 0; |
| 328 | histograms.ExpectBucketCount( |
| 329 | "Apps.AppList.ContinueSectionHiddenByUser.TabletMode", false_bucket, 1); |
| 330 | Shell::Get()->tablet_mode_controller()->SetEnabledForTest(false); |
| 331 | |
| 332 | // Hide the continue section, then show the tablet mode app list. |
| 333 | Shell::Get()->app_list_controller()->SetHideContinueSection(true); |
| 334 | Shell::Get()->tablet_mode_controller()->SetEnabledForTest(true); |
| 335 | |
| 336 | // Metric is recorded in true bucket. |
| 337 | const int true_bucket = 1; |
| 338 | histograms.ExpectBucketCount( |
| 339 | "Apps.AppList.ContinueSectionHiddenByUser.TabletMode", true_bucket, 1); |
| 340 | } |
| 341 | |
Ana Salazar | 1df6735 | 2021-11-17 00:34:12 | [diff] [blame] | 342 | // Test that the histogram records an app launch from a recent app suggestion |
| 343 | // while the homecher all apps is showing. |
Ana Salazar | addeb8c | 2022-10-18 23:31:47 | [diff] [blame] | 344 | TEST_F(AppListMetricsTest, HomecherLaunchFromRecentApps) { |
Ana Salazar | 1df6735 | 2021-11-17 00:34:12 | [diff] [blame] | 345 | base::HistogramTester histogram_tester; |
| 346 | auto* helper = GetAppListTestHelper(); |
| 347 | |
| 348 | helper->WaitUntilIdle(); |
| 349 | |
| 350 | helper->AddRecentApps(5); |
| 351 | helper->AddAppItems(5); |
| 352 | Shell::Get()->tablet_mode_controller()->SetEnabledForTest(true); |
| 353 | |
| 354 | helper->WaitUntilIdle(); |
| 355 | views::View* recent_apps = helper->GetFullscreenRecentAppsView(); |
| 356 | |
| 357 | // Get focus on the first chip. |
| 358 | recent_apps->children().front()->RequestFocus(); |
| 359 | helper->WaitUntilIdle(); |
| 360 | |
| 361 | // Press return to simulate an app launch from the recent apps. |
| 362 | PressAndReleaseKey(ui::KeyboardCode::VKEY_RETURN); |
| 363 | helper->WaitUntilIdle(); |
| 364 | |
| 365 | histogram_tester.ExpectBucketCount( |
| 366 | "Apps.AppListAppLaunchedV2.HomecherAllApps", |
| 367 | AppListLaunchedFrom::kLaunchedFromRecentApps, |
| 368 | 1 /* Number of times launched from chip */); |
| 369 | } |
| 370 | |
Matthew Mourgos | 4c287d6 | 2019-10-25 22:46:16 | [diff] [blame] | 371 | class AppListShowSourceMetricTest : public AshTestBase { |
| 372 | public: |
| 373 | AppListShowSourceMetricTest() = default; |
Peter Boström | ec31a04 | 2021-09-16 23:37:34 | [diff] [blame] | 374 | |
| 375 | AppListShowSourceMetricTest(const AppListShowSourceMetricTest&) = delete; |
| 376 | AppListShowSourceMetricTest& operator=(const AppListShowSourceMetricTest&) = |
| 377 | delete; |
| 378 | |
Matthew Mourgos | 4c287d6 | 2019-10-25 22:46:16 | [diff] [blame] | 379 | ~AppListShowSourceMetricTest() override = default; |
| 380 | |
| 381 | protected: |
| 382 | void ClickHomeButton() { |
James Cook | d737936 | 2021-12-30 00:54:09 | [diff] [blame] | 383 | LeftClickOn(GetPrimaryShelf()->navigation_widget()->GetHomeButton()); |
Matthew Mourgos | 4c287d6 | 2019-10-25 22:46:16 | [diff] [blame] | 384 | } |
Matthew Mourgos | 4c287d6 | 2019-10-25 22:46:16 | [diff] [blame] | 385 | }; |
| 386 | |
| 387 | // In tablet mode, test that AppListShowSource metric is only recorded when |
| 388 | // pressing home button when not already home. Any presses on the home button |
| 389 | // when already home should do nothing. |
| 390 | TEST_F(AppListShowSourceMetricTest, TabletInAppToHome) { |
| 391 | base::HistogramTester histogram_tester; |
| 392 | |
Alex Newcomer | fe77603 | 2021-06-16 21:17:08 | [diff] [blame] | 393 | // Enable accessibility feature that forces home button to be shown in tablet |
| 394 | // mode. |
| 395 | Shell::Get() |
| 396 | ->accessibility_controller() |
| 397 | ->SetTabletModeShelfNavigationButtonsEnabled(true); |
Toni Barzic | 4c37d1e0 | 2020-02-15 01:40:05 | [diff] [blame] | 398 | |
Matthew Mourgos | 4c287d6 | 2019-10-25 22:46:16 | [diff] [blame] | 399 | std::unique_ptr<views::Widget> widget = CreateTestWidget(); |
| 400 | Shell::Get()->tablet_mode_controller()->SetEnabledForTest(true); |
| 401 | |
| 402 | ClickHomeButton(); |
| 403 | histogram_tester.ExpectBucketCount( |
Lei Zhang | b9109ac | 2022-09-19 20:03:53 | [diff] [blame] | 404 | "Apps.AppListShowSource", AppListShowSource::kShelfButton, |
Matthew Mourgos | 4c287d6 | 2019-10-25 22:46:16 | [diff] [blame] | 405 | 1 /* Number of times app list is shown with a shelf button */); |
| 406 | histogram_tester.ExpectBucketCount( |
Lei Zhang | b9109ac | 2022-09-19 20:03:53 | [diff] [blame] | 407 | "Apps.AppListShowSource", AppListShowSource::kTabletMode, |
Matthew Mourgos | 4c287d6 | 2019-10-25 22:46:16 | [diff] [blame] | 408 | 0 /* Number of times app list is shown by tablet mode transition */); |
| 409 | |
| 410 | GetAppListTestHelper()->CheckVisibility(true); |
| 411 | |
| 412 | // Ensure that any subsequent clicks while already at home do not count as |
| 413 | // showing the app list. |
| 414 | ClickHomeButton(); |
| 415 | histogram_tester.ExpectBucketCount( |
Lei Zhang | b9109ac | 2022-09-19 20:03:53 | [diff] [blame] | 416 | "Apps.AppListShowSource", AppListShowSource::kShelfButton, |
Matthew Mourgos | 4c287d6 | 2019-10-25 22:46:16 | [diff] [blame] | 417 | 1 /* Number of times app list shown with a shelf button */); |
James Cook | 233288d | 2021-04-30 19:00:29 | [diff] [blame] | 418 | histogram_tester.ExpectTotalCount("Apps.AppListShowSource", 1); |
Matthew Mourgos | 4c287d6 | 2019-10-25 22:46:16 | [diff] [blame] | 419 | } |
| 420 | |
| 421 | // Ensure that app list is not recorded as shown when going to tablet mode with |
| 422 | // a window open. |
| 423 | TEST_F(AppListShowSourceMetricTest, TabletModeWithWindowOpen) { |
| 424 | base::HistogramTester histogram_tester; |
| 425 | |
| 426 | std::unique_ptr<views::Widget> widget = CreateTestWidget(); |
| 427 | Shell::Get()->tablet_mode_controller()->SetEnabledForTest(true); |
| 428 | GetAppListTestHelper()->CheckVisibility(false); |
| 429 | |
Alex Newcomer | fe77603 | 2021-06-16 21:17:08 | [diff] [blame] | 430 | // Ensure that no AppListShowSource metric was recorded. |
James Cook | 233288d | 2021-04-30 19:00:29 | [diff] [blame] | 431 | histogram_tester.ExpectTotalCount("Apps.AppListShowSource", 0); |
Matthew Mourgos | 4c287d6 | 2019-10-25 22:46:16 | [diff] [blame] | 432 | } |
| 433 | |
| 434 | // Ensure that app list is recorded as shown when going to tablet mode with no |
| 435 | // other windows open. |
| 436 | TEST_F(AppListShowSourceMetricTest, TabletModeWithNoWindowOpen) { |
| 437 | base::HistogramTester histogram_tester; |
| 438 | |
| 439 | Shell::Get()->tablet_mode_controller()->SetEnabledForTest(true); |
| 440 | GetAppListTestHelper()->CheckVisibility(true); |
| 441 | |
| 442 | histogram_tester.ExpectBucketCount( |
Lei Zhang | b9109ac | 2022-09-19 20:03:53 | [diff] [blame] | 443 | "Apps.AppListShowSource", AppListShowSource::kTabletMode, |
Matthew Mourgos | 4c287d6 | 2019-10-25 22:46:16 | [diff] [blame] | 444 | 1 /* Number of times app list shown after entering tablet mode */); |
| 445 | } |
| 446 | |
James Cook | b661f380 | 2021-09-30 21:43:20 | [diff] [blame] | 447 | // Tests that showing the bubble launcher in clamshell mode records the proper |
Alex Newcomer | fe77603 | 2021-06-16 21:17:08 | [diff] [blame] | 448 | // metrics for Apps.AppListBubbleShowSource. |
Ana Salazar | addeb8c | 2022-10-18 23:31:47 | [diff] [blame] | 449 | TEST_F(AppListShowSourceMetricTest, ClamshellModeHomeButton) { |
Alex Newcomer | fe77603 | 2021-06-16 21:17:08 | [diff] [blame] | 450 | base::HistogramTester histogram_tester; |
| 451 | auto* app_list_bubble_presenter = |
| 452 | Shell::Get()->app_list_controller()->bubble_presenter_for_test(); |
| 453 | // Show the Bubble AppList. |
| 454 | GetAppListTestHelper()->ShowAndRunLoop(GetPrimaryDisplayId()); |
| 455 | EXPECT_TRUE(app_list_bubble_presenter->IsShowing()); |
| 456 | |
| 457 | // Test that the proper histogram is logged. |
| 458 | histogram_tester.ExpectTotalCount("Apps.AppListBubbleShowSource", 1); |
| 459 | |
| 460 | // Hide the Bubble AppList. |
| 461 | GetAppListTestHelper()->Dismiss(); |
| 462 | EXPECT_FALSE(app_list_bubble_presenter->IsShowing()); |
| 463 | |
| 464 | // Test that no histograms were logged. |
| 465 | histogram_tester.ExpectTotalCount("Apps.AppListBubbleShowSource", 1); |
| 466 | |
| 467 | // Show the Bubble AppList one more time. |
| 468 | GetAppListTestHelper()->ShowAndRunLoop(GetPrimaryDisplayId()); |
| 469 | EXPECT_TRUE(app_list_bubble_presenter->IsShowing()); |
| 470 | |
| 471 | // Test that the histogram records 2 total shows. |
| 472 | histogram_tester.ExpectTotalCount("Apps.AppListBubbleShowSource", 2); |
| 473 | |
| 474 | // Test that no fullscreen app list metrics were recorded. |
| 475 | histogram_tester.ExpectTotalCount("Apps.AppListShowSource", 0); |
| 476 | } |
| 477 | |
| 478 | // Test that tablet mode launcher operations do not record AppListBubble |
| 479 | // metrics. |
Ana Salazar | addeb8c | 2022-10-18 23:31:47 | [diff] [blame] | 480 | TEST_F(AppListShowSourceMetricTest, TabletModeDoesNotRecordAppListBubbleShow) { |
Alex Newcomer | fe77603 | 2021-06-16 21:17:08 | [diff] [blame] | 481 | base::HistogramTester histogram_tester; |
| 482 | // Enable accessibility feature that forces home button to be shown in tablet |
| 483 | // mode. |
| 484 | Shell::Get() |
| 485 | ->accessibility_controller() |
| 486 | ->SetTabletModeShelfNavigationButtonsEnabled(true); |
| 487 | |
| 488 | // Go to tablet mode, the tablet mode (non bubble) launcher will show. Create |
| 489 | // a test widget so the launcher will show in the background. |
| 490 | std::unique_ptr<views::Widget> widget = CreateTestWidget(); |
| 491 | Shell::Get()->tablet_mode_controller()->SetEnabledForTest(true); |
| 492 | auto* app_list_bubble_presenter = |
| 493 | Shell::Get()->app_list_controller()->bubble_presenter_for_test(); |
| 494 | EXPECT_FALSE(app_list_bubble_presenter->IsShowing()); |
| 495 | |
| 496 | // Ensure that no AppListBubbleShowSource metric was recorded. |
| 497 | histogram_tester.ExpectTotalCount("Apps.AppListBubbleShowSource", 0); |
| 498 | |
| 499 | // Press the Home Button, which hides `widget` and shows the tablet mode |
| 500 | // launcher. |
| 501 | ClickHomeButton(); |
| 502 | EXPECT_FALSE(app_list_bubble_presenter->IsShowing()); |
| 503 | |
James Cook | b661f380 | 2021-09-30 21:43:20 | [diff] [blame] | 504 | // Test that no bubble launcher metrics were recorded. |
Alex Newcomer | fe77603 | 2021-06-16 21:17:08 | [diff] [blame] | 505 | histogram_tester.ExpectTotalCount("Apps.AppListBubbleShowSource", 0); |
| 506 | } |
| 507 | |
James Cook | b661f380 | 2021-09-30 21:43:20 | [diff] [blame] | 508 | // Tests that toggling the bubble launcher does not record metrics when the |
| 509 | // result of the toggle is that the launcher is hidden. |
Ana Salazar | addeb8c | 2022-10-18 23:31:47 | [diff] [blame] | 510 | TEST_F(AppListShowSourceMetricTest, ToggleDoesNotRecordOnHide) { |
Alex Newcomer | fe77603 | 2021-06-16 21:17:08 | [diff] [blame] | 511 | base::HistogramTester histogram_tester; |
| 512 | auto* app_list_controller = Shell::Get()->app_list_controller(); |
| 513 | |
James Cook | b661f380 | 2021-09-30 21:43:20 | [diff] [blame] | 514 | // Toggle the app list to show it. |
Alex Newcomer | fe77603 | 2021-06-16 21:17:08 | [diff] [blame] | 515 | app_list_controller->ToggleAppList(GetPrimaryDisplayId(), |
| 516 | AppListShowSource::kSearchKey, |
| 517 | base::TimeTicks::Now()); |
| 518 | auto* app_list_bubble_presenter = |
| 519 | Shell::Get()->app_list_controller()->bubble_presenter_for_test(); |
| 520 | ASSERT_TRUE(app_list_bubble_presenter->IsShowing()); |
| 521 | |
James Cook | b661f380 | 2021-09-30 21:43:20 | [diff] [blame] | 522 | // Toggle the app list once more, to hide it. |
Alex Newcomer | fe77603 | 2021-06-16 21:17:08 | [diff] [blame] | 523 | app_list_controller->ToggleAppList(GetPrimaryDisplayId(), |
| 524 | AppListShowSource::kSearchKey, |
| 525 | base::TimeTicks::Now()); |
| 526 | ASSERT_FALSE(app_list_bubble_presenter->IsShowing()); |
| 527 | // Test that only one show was recorded. |
| 528 | histogram_tester.ExpectTotalCount("Apps.AppListBubbleShowSource", 1); |
| 529 | } |
| 530 | |
James Cook | f76e858 | 2022-05-19 23:46:53 | [diff] [blame] | 531 | using AppListPeriodicMetricsTest = AshTestBase; |
Matthew Mourgos | a6330ce | 2021-06-24 04:19:13 | [diff] [blame] | 532 | |
| 533 | // Verify that the number of items in the app list are recorded correctly. |
James Cook | f76e858 | 2022-05-19 23:46:53 | [diff] [blame] | 534 | TEST_F(AppListPeriodicMetricsTest, PeriodicAppListMetrics_NumberOfApps) { |
Matthew Mourgos | a6330ce | 2021-06-24 04:19:13 | [diff] [blame] | 535 | base::HistogramTester histogram; |
| 536 | histogram.ExpectTotalCount("Apps.AppList.NumberOfApps", 0); |
| 537 | histogram.ExpectTotalCount("Apps.AppList.NumberOfRootLevelItems", 0); |
| 538 | |
Toni Barzic | 8014351 | 2021-10-29 15:41:45 | [diff] [blame] | 539 | AppListModel* model = AppListModelProvider::Get()->model(); |
Matthew Mourgos | a6330ce | 2021-06-24 04:19:13 | [diff] [blame] | 540 | |
| 541 | // Add 5 items to the app list. |
| 542 | for (int i = 0; i < 5; i++) { |
| 543 | model->AddItem( |
| 544 | std::make_unique<AppListItem>(base::StringPrintf("app_id_%d", i))); |
| 545 | } |
| 546 | |
| 547 | // Check that 5 items are recorded as being in the app list. |
| 548 | RecordPeriodicAppListMetrics(); |
| 549 | histogram.ExpectBucketCount("Apps.AppList.NumberOfApps", 5, 1); |
| 550 | histogram.ExpectBucketCount("Apps.AppList.NumberOfRootLevelItems", 5, 1); |
| 551 | histogram.ExpectTotalCount("Apps.AppList.NumberOfApps", 1); |
| 552 | histogram.ExpectTotalCount("Apps.AppList.NumberOfRootLevelItems", 1); |
| 553 | |
| 554 | // Create a folder and add 3 items to it. |
Toni Barzic | 2fcc8034 | 2021-11-04 18:18:45 | [diff] [blame] | 555 | const std::string folder_id = "folder_id"; |
Wen-Chien Wang | 3ff6625 | 2022-07-07 20:21:55 | [diff] [blame] | 556 | model->CreateFolderItem(folder_id); |
Matthew Mourgos | a6330ce | 2021-06-24 04:19:13 | [diff] [blame] | 557 | for (int i = 0; i < 3; i++) { |
| 558 | auto item = |
| 559 | std::make_unique<AppListItem>(base::StringPrintf("id_in_folder_%d", i)); |
| 560 | model->AddItemToFolder(std::move(item), folder_id); |
| 561 | } |
| 562 | |
| 563 | // Check that the folder and its items are recorded in the metrics. |
| 564 | RecordPeriodicAppListMetrics(); |
| 565 | histogram.ExpectBucketCount("Apps.AppList.NumberOfApps", 8, 1); |
| 566 | histogram.ExpectBucketCount("Apps.AppList.NumberOfRootLevelItems", 6, 1); |
| 567 | } |
| 568 | |
James Cook | f76e858 | 2022-05-19 23:46:53 | [diff] [blame] | 569 | TEST_F(AppListPeriodicMetricsTest, RecordFolderMetrics_ZeroFolders) { |
| 570 | base::HistogramTester histogram; |
| 571 | GetAppListTestHelper()->model()->PopulateApps(2); |
| 572 | |
| 573 | RecordPeriodicAppListMetrics(); |
| 574 | |
| 575 | // 1 sample in the 0 folders bucket. |
| 576 | EXPECT_EQ(1, histogram.GetBucketCount("Apps.AppList.NumberOfFolders", 0)); |
| 577 | // 1 sample in the 0 folders bucket. |
| 578 | EXPECT_EQ( |
| 579 | 1, histogram.GetBucketCount("Apps.AppList.NumberOfNonSystemFolders", 0)); |
| 580 | // 1 sample in the 0 apps bucket. |
| 581 | EXPECT_EQ(1, histogram.GetBucketCount( |
| 582 | "Apps.AppList.NumberOfAppsInNonSystemFolders", 0)); |
| 583 | } |
| 584 | |
| 585 | TEST_F(AppListPeriodicMetricsTest, RecordFolderMetrics_OneRegularFolder) { |
| 586 | base::HistogramTester histogram; |
| 587 | GetAppListTestHelper()->model()->CreateAndPopulateFolderWithApps(2); |
| 588 | |
| 589 | RecordPeriodicAppListMetrics(); |
| 590 | |
| 591 | // 1 sample in the 1 folder bucket. |
| 592 | EXPECT_EQ(1, histogram.GetBucketCount("Apps.AppList.NumberOfFolders", 1)); |
| 593 | // 1 sample in the 1 folder bucket. |
| 594 | EXPECT_EQ( |
| 595 | 1, histogram.GetBucketCount("Apps.AppList.NumberOfNonSystemFolders", 1)); |
| 596 | // 1 sample in the 2 apps bucket. |
| 597 | EXPECT_EQ(1, histogram.GetBucketCount( |
| 598 | "Apps.AppList.NumberOfAppsInNonSystemFolders", 2)); |
| 599 | } |
| 600 | |
James Cook | 5382b63 | 2022-05-20 00:32:20 | [diff] [blame] | 601 | TEST_F(AppListPeriodicMetricsTest, RecordFolderMetrics_SystemFolder) { |
James Cook | f76e858 | 2022-05-19 23:46:53 | [diff] [blame] | 602 | base::HistogramTester histogram; |
| 603 | AppListFolderItem* folder = |
| 604 | GetAppListTestHelper()->model()->CreateSingleItemFolder("folder_id", |
| 605 | "item_id"); |
James Cook | 5382b63 | 2022-05-20 00:32:20 | [diff] [blame] | 606 | folder->SetIsSystemFolder(true); |
James Cook | f76e858 | 2022-05-19 23:46:53 | [diff] [blame] | 607 | |
| 608 | RecordPeriodicAppListMetrics(); |
| 609 | |
| 610 | // 1 sample in the 1 folder bucket. |
| 611 | EXPECT_EQ(1, histogram.GetBucketCount("Apps.AppList.NumberOfFolders", 1)); |
| 612 | // 1 sample in the 0 folders bucket, because the folder is a system folder. |
| 613 | EXPECT_EQ( |
| 614 | 1, histogram.GetBucketCount("Apps.AppList.NumberOfNonSystemFolders", 0)); |
| 615 | // 1 sample in the 0 apps bucket, because items in system folders don't count. |
| 616 | EXPECT_EQ(1, histogram.GetBucketCount( |
| 617 | "Apps.AppList.NumberOfAppsInNonSystemFolders", 0)); |
| 618 | } |
| 619 | |
Matthew Mourgos | 105a91f | 2019-05-08 23:30:48 | [diff] [blame] | 620 | } // namespace ash |