File: spoken_feedback_app_list_browsertest.cc

package info (click to toggle)
chromium 139.0.7258.138-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,120,676 kB
  • sloc: cpp: 35,100,869; ansic: 7,163,530; javascript: 4,103,002; python: 1,436,920; asm: 946,517; xml: 746,709; pascal: 187,653; perl: 88,691; sh: 88,436; objc: 79,953; sql: 51,488; cs: 44,583; fortran: 24,137; makefile: 22,147; tcl: 15,277; php: 13,980; yacc: 8,984; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (1083 lines) | stat: -rw-r--r-- 39,301 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
// Copyright 2019 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "ash/app_list/app_list_controller_impl.h"
#include "ash/app_list/app_list_model_provider.h"
#include "ash/app_list/model/app_list_item.h"
#include "ash/app_list/views/apps_grid_view.h"
#include "ash/constants/ash_features.h"
#include "ash/constants/ash_switches.h"
#include "ash/public/cpp/tablet_mode.h"
#include "ash/public/cpp/test/app_list_test_api.h"
#include "ash/public/cpp/test/shell_test_api.h"
#include "ash/shell.h"
#include "base/memory/raw_ptr_exclusion.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/simple_test_tick_clock.h"
#include "chrome/browser/ash/accessibility/accessibility_test_utils.h"
#include "chrome/browser/ash/accessibility/chromevox_test_utils.h"
#include "chrome/browser/ash/accessibility/spoken_feedback_browsertest.h"
#include "chrome/browser/ash/app_list/app_list_client_impl.h"
#include "chrome/browser/ash/app_list/chrome_app_list_model_updater.h"
#include "chrome/browser/ash/app_list/search/chrome_search_result.h"
#include "chrome/browser/ash/app_list/search/search_controller.h"
#include "chrome/browser/ash/app_list/search/search_provider.h"
#include "chrome/browser/ash/app_list/test/chrome_app_list_test_support.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/grit/generated_resources.h"
#include "chrome/test/base/interactive_test_utils.h"
#include "chromeos/ash/services/assistant/public/cpp/features.h"
#include "components/user_manager/user_names.h"
#include "components/vector_icons/vector_icons.h"
#include "content/public/test/browser_test.h"
#include "extensions/browser/browsertest_util.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/mojom/menu_source_type.mojom.h"
#include "ui/base/ui_base_features.h"
#include "ui/compositor/scoped_animation_duration_scale_mode.h"
#include "ui/display/display.h"
#include "ui/display/manager/display_manager.h"
#include "ui/events/base_event_utils.h"
#include "ui/events/event_constants.h"
#include "ui/events/test/event_generator.h"

using SpokenFeedbackTestVariant = ash::SpokenFeedbackTestVariant;
using SpokenFeedbackTestConfig = ::ash::SpokenFeedbackTestConfig;

namespace ash {

namespace {

void SendKeyPressWithShiftAndControl(ui::test::EventGenerator* generator,
                                     ui::KeyboardCode key) {
  const int flags = ui::EF_CONTROL_DOWN | ui::EF_SHIFT_DOWN;
  generator->PressAndReleaseKeyAndModifierKeys(key, flags);
}

class TestSearchResult : public ChromeSearchResult {
 public:
  TestSearchResult(const std::string& id, double relevance) {
    set_id(id);
    SetTitle(base::UTF8ToUTF16(id));
    SetDisplayScore(relevance);
  }

  TestSearchResult(const TestSearchResult&) = delete;
  TestSearchResult& operator=(const TestSearchResult&) = delete;

  ~TestSearchResult() override = default;

  // ChromeSearchResult overrides:
  void Open(int event_flags) override {}
};

class TestSearchProvider : public app_list::SearchProvider {
 public:
  TestSearchProvider(const std::string& prefix,
                     ChromeSearchResult::DisplayType display_type,
                     ChromeSearchResult::Category category,
                     ChromeSearchResult::ResultType result_type,
                     app_list::SearchCategory search_category)
      : SearchProvider(search_category),
        prefix_(prefix),
        display_type_(display_type),
        category_(category),
        result_type_(result_type) {}

  TestSearchProvider(const TestSearchProvider&) = delete;
  TestSearchProvider& operator=(const TestSearchProvider&) = delete;

  ~TestSearchProvider() override = default;

  // SearchProvider overrides:
  void Start(const std::u16string& query) override {
    auto create_result =
        [this](int index) -> std::unique_ptr<ChromeSearchResult> {
      const std::string id =
          base::StringPrintf("%s %d", prefix_.c_str(), index);
      double relevance = 1.0f - index / 100.0;
      auto result = std::make_unique<TestSearchResult>(id, relevance);

      result->SetDisplayType(display_type_);
      result->SetCategory(category_);
      result->SetResultType(result_type_);

      return result;
    };

    std::vector<std::unique_ptr<ChromeSearchResult>> results;
    for (size_t i = 0; i < count_ + best_match_count_; ++i) {
      std::unique_ptr<ChromeSearchResult> result = create_result(i);
      result->SetBestMatch(i < best_match_count_);
      if (result_type_ == ChromeSearchResult::ResultType::kImageSearch) {
        result->SetIcon(ChromeSearchResult::IconInfo(
            ui::ImageModel::FromVectorIcon(vector_icons::kGoogleColorIcon),
            /*dimension=*/100));
      }
      results.push_back(std::move(result));
    }

    SwapResults(&results);
  }

  ChromeSearchResult::ResultType ResultType() const override {
    return result_type_;
  }

  void set_count(size_t count) { count_ = count; }
  void set_best_match_count(size_t count) { best_match_count_ = count; }

 private:
  std::string prefix_;
  size_t count_ = 0;
  size_t best_match_count_ = 0;
  ChromeSearchResult::DisplayType display_type_;
  ChromeSearchResult::Category category_;
  ChromeSearchResult::ResultType result_type_;
};

// Adds two test providers to `search_controller` - one for app results, and
// another one for omnibox results. Returns pointers to created providers
// through `apps_provder_ptr` and `web_provider_ptr`.
void InitializeTestSearchProviders(
    app_list::SearchController* search_controller,
    raw_ptr<TestSearchProvider>* apps_provider_ptr,
    raw_ptr<TestSearchProvider>* web_provider_ptr,
    raw_ptr<TestSearchProvider>* image_provider_ptr) {
  std::unique_ptr<TestSearchProvider> apps_provider =
      std::make_unique<TestSearchProvider>(
          "app", ChromeSearchResult::DisplayType::kList,
          ChromeSearchResult::Category::kApps,
          ChromeSearchResult::ResultType::kInstalledApp,
          app_list::SearchCategory::kApps);
  *apps_provider_ptr = apps_provider.get();
  search_controller->AddProvider(std::move(apps_provider));

  std::unique_ptr<TestSearchProvider> web_provider =
      std::make_unique<TestSearchProvider>(
          "item", ChromeSearchResult::DisplayType::kList,
          ChromeSearchResult::Category::kWeb,
          ChromeSearchResult::ResultType::kOmnibox,
          app_list::SearchCategory::kWeb);
  *web_provider_ptr = web_provider.get();
  search_controller->AddProvider(std::move(web_provider));

  std::unique_ptr<TestSearchProvider> image_provider =
      std::make_unique<TestSearchProvider>(
          "image", ChromeSearchResult::DisplayType::kImage,
          ChromeSearchResult::Category::kFiles,
          ChromeSearchResult::ResultType::kImageSearch,
          app_list::SearchCategory::kImages);
  *image_provider_ptr = image_provider.get();
  search_controller->AddProvider(std::move(image_provider));
}

}  // namespace

class SpokenFeedbackAppListBaseTest : public LoggedInSpokenFeedbackTest {
 public:
  explicit SpokenFeedbackAppListBaseTest(SpokenFeedbackTestVariant variant)
      : variant_(variant) {}
  ~SpokenFeedbackAppListBaseTest() override = default;

  // LoggedInSpokenFeedbackTest:
  void SetUp() override {
    // Do not run expand arrow hinting animation to avoid msan test crash.
    // (See https://crbug.com/926038)
    zero_duration_mode_ =
        std::make_unique<ui::ScopedAnimationDurationScaleMode>(
            ui::ScopedAnimationDurationScaleMode::ZERO_DURATION);

    // Disable the app list nudge in the spoken feedback app list test.
    AppListTestApi().DisableAppListNudge(true);
    AppListControllerImpl::SetSunfishNudgeDisabledForTest(true);

    scoped_feature_list_.InitWithFeatures(
        {features::kLauncherSearchControl,
         features::kFeatureManagementLocalImageSearch},
        {features::kScannerDogfood, features::kSunfishFeature,
         ash::assistant::features::kEnableNewEntryPoint});

    LoggedInSpokenFeedbackTest::SetUp();
  }

  void TearDown() override {
    LoggedInSpokenFeedbackTest::TearDown();
    zero_duration_mode_.reset();
  }

  void SetUpCommandLine(base::CommandLine* command_line) override {
    if (variant_ == kTestAsGuestUser) {
      command_line->AppendSwitch(switches::kGuestSession);
      command_line->AppendSwitch(::switches::kIncognito);
      command_line->AppendSwitchASCII(switches::kLoginProfile, "user");
      command_line->AppendSwitchASCII(
          switches::kLoginUser, user_manager::GuestAccountId().GetUserEmail());
    }
  }

  void SetUpOnMainThread() override {
    LoggedInSpokenFeedbackTest::SetUpOnMainThread();
    AppListClientImpl::GetInstance()->UpdateProfile();
  }

  // Populate apps grid with |num| items.
  void PopulateApps(size_t num) {
    // Only folders or page breaks are allowed to be added from the Ash side.
    // Therefore new apps should be added through `ChromeAppListModelUpdater`.
    ::test::PopulateDummyAppListItems(num);
  }

  // Moves to the first test app in a populated list of apps.
  // Returns the index of that item.
  int MoveToFirstTestApp() {
    // Focus the shelf. This selects the launcher button.
    sm()->Call([this]() {
      EXPECT_TRUE(PerformAcceleratorAction(AcceleratorAction::kFocusShelf));
    });
    sm()->ExpectSpeechPattern("Launcher");
    sm()->ExpectSpeech("Button");
    sm()->ExpectSpeech("Shelf");
    sm()->ExpectSpeech("Tool bar");

    // Activate the launcher button. This opens bubble launcher.
    sm()->Call([this]() { SendKeyPressWithSearch(ui::VKEY_SPACE); });
    sm()->ExpectSpeechPattern("Search your *");
    sm()->ExpectSpeech("Edit text");

    sm()->Call([this]() { SendKeyPressWithSearch(ui::VKEY_RIGHT); });
    sm()->ExpectSpeech("Button");

    int test_item_index = 0;
    AppListItem* test_item = FindItemByName("app 0", &test_item_index);
    EXPECT_TRUE(test_item);

    // Skip over apps that were installed before the test item.
    // This selects the first app installed by the test.
    for (int i = 0; i < test_item_index; ++i) {
      sm()->Call([this]() { SendKeyPressWithSearch(ui::VKEY_RIGHT); });
    }
    sm()->ExpectSpeech("app 0");
    sm()->ExpectSpeech("Button");

    return test_item_index;
  }

  AppListItem* FindItemByName(const std::string& name, int* index) {
    AppListModel* const model = AppListModelProvider::Get()->model();
    AppListItemList* item_list = model->top_level_item_list();
    for (size_t i = 0; i < item_list->item_count(); ++i) {
      if (item_list->item_at(i)->name() == name) {
        if (index) {
          *index = i;
        }
        return item_list->item_at(i);
      }
    }
    return nullptr;
  }

  void ReadWindowTitle() {
    chromevox_test_utils()->ExecuteCommandHandlerCommand("readCurrentTitle");
  }

 private:
  base::test::ScopedFeatureList scoped_feature_list_;
  const SpokenFeedbackTestVariant variant_;
  std::unique_ptr<ui::ScopedAnimationDurationScaleMode> zero_duration_mode_;
};

class SpokenFeedbackAppListTest : public SpokenFeedbackAppListBaseTest {
 public:
  SpokenFeedbackAppListTest()
      : SpokenFeedbackAppListBaseTest(GetParam().variant().value()) {}
  ~SpokenFeedbackAppListTest() override = default;
};

INSTANTIATE_TEST_SUITE_P(
    ManifestV2NormalUser,
    SpokenFeedbackAppListTest,
    ::testing::Values(SpokenFeedbackTestConfig(ManifestVersion::kTwo,
                                               kTestAsNormalUser)));

INSTANTIATE_TEST_SUITE_P(
    ManifestV2GuestUser,
    SpokenFeedbackAppListTest,
    ::testing::Values(SpokenFeedbackTestConfig(ManifestVersion::kTwo,
                                               kTestAsGuestUser)));

class NotificationSpokenFeedbackAppListTest : public SpokenFeedbackAppListTest {
 protected:
  NotificationSpokenFeedbackAppListTest() = default;
  ~NotificationSpokenFeedbackAppListTest() override = default;

  void SetUpCommandLine(base::CommandLine* command_line) override {
    SpokenFeedbackAppListTest::SetUpCommandLine(command_line);
    command_line->AppendSwitch(switches::kAshEnableTabletMode);
  }
};

INSTANTIATE_TEST_SUITE_P(
    ManifestV2NormalUser,
    NotificationSpokenFeedbackAppListTest,
    ::testing::Values(SpokenFeedbackTestConfig(ManifestVersion::kTwo,
                                               kTestAsNormalUser)));

INSTANTIATE_TEST_SUITE_P(
    ManifestV2GuestUser,
    NotificationSpokenFeedbackAppListTest,
    ::testing::Values(SpokenFeedbackTestConfig(ManifestVersion::kTwo,
                                               kTestAsGuestUser)));

class SpokenFeedbackAppListSearchTest : public SpokenFeedbackAppListBaseTest {
 public:
  SpokenFeedbackAppListSearchTest()
      : SpokenFeedbackAppListBaseTest(GetParam().variant().value()),
        tablet_mode_(GetParam().tablet_mode().value()) {}
  ~SpokenFeedbackAppListSearchTest() override = default;

  // SpokenFeedbackAppListTest:
  void SetUpOnMainThread() override {
    SpokenFeedbackAppListBaseTest::SetUpOnMainThread();

    AppListClientImpl* app_list_client = AppListClientImpl::GetInstance();

    // Reset default search controller, so the test has better control over the
    // set of results shown in the search result UI.
    std::unique_ptr<app_list::SearchController> search_controller =
        std::make_unique<app_list::SearchController>(
            app_list_client->GetModelUpdaterForTest(), app_list_client, nullptr,
            browser()->profile());
    search_controller->Initialize();
    // Disable ranking, which may override the explicitly set relevance scores
    // and best match status of results.
    search_controller->disable_ranking_for_test();
    InitializeTestSearchProviders(search_controller.get(), &apps_provider_,
                                  &web_provider_, &image_provider_);
    ASSERT_TRUE(apps_provider_);
    ASSERT_TRUE(web_provider_);
    ASSERT_TRUE(image_provider_);
    app_list_client->SetSearchControllerForTest(std::move(search_controller));

    ShellTestApi().SetTabletModeEnabledForTest(tablet_mode_);
  }

  void TearDownOnMainThread() override {
    apps_provider_ = nullptr;
    web_provider_ = nullptr;
    image_provider_ = nullptr;
    AppListClientImpl::GetInstance()->SetSearchControllerForTest(nullptr);
    SpokenFeedbackAppListBaseTest::TearDownOnMainThread();
  }

  void ShowAppList() {
    if (tablet_mode_) {
      // Minimize the test window to transition to tablet mode home screen.
      sm()->Call([this]() { browser()->window()->Minimize(); });
    } else {
      // Focus the home button and press it to open the bubble launcher.
      sm()->Call([this]() {
        EXPECT_TRUE(PerformAcceleratorAction(AcceleratorAction::kFocusShelf));
      });
      sm()->ExpectSpeechPattern("Launcher");
      sm()->ExpectSpeech("Button");
      sm()->ExpectSpeech("Shelf");
      sm()->ExpectSpeech("Tool bar");

      sm()->Call([this]() { SendKeyPressWithSearch(ui::VKEY_SPACE); });
    }
  }

 protected:
  // Whether the test runs in tablet mode.
  const bool tablet_mode_;

  raw_ptr<TestSearchProvider> apps_provider_ = nullptr;
  raw_ptr<TestSearchProvider> web_provider_ = nullptr;
  raw_ptr<TestSearchProvider> image_provider_ = nullptr;
};

INSTANTIATE_TEST_SUITE_P(
    ManifestV2NormalUserTabletMode,
    SpokenFeedbackAppListSearchTest,
    ::testing::Values(SpokenFeedbackTestConfig(ManifestVersion::kTwo,
                                               kTestAsNormalUser,
                                               /*tablet_mode=*/true)));

INSTANTIATE_TEST_SUITE_P(
    ManifestV2GuestUserTabletMode,
    SpokenFeedbackAppListSearchTest,
    ::testing::Values(SpokenFeedbackTestConfig(ManifestVersion::kTwo,
                                               kTestAsGuestUser,
                                               /*tablet_mode=*/true)));

INSTANTIATE_TEST_SUITE_P(
    ManifestV2NormalUserDesktopMode,
    SpokenFeedbackAppListSearchTest,
    ::testing::Values(SpokenFeedbackTestConfig(ManifestVersion::kTwo,
                                               kTestAsNormalUser,
                                               /*tablet_mode=*/false)));

INSTANTIATE_TEST_SUITE_P(
    ManifestV2GuestUserDesktopMode,
    SpokenFeedbackAppListSearchTest,
    ::testing::Values(SpokenFeedbackTestConfig(ManifestVersion::kTwo,
                                               kTestAsGuestUser,
                                               /*tablet_mode=*/false)));

// Checks that when an app list item with a notification badge is focused, an
// announcement is made that the item requests your attention.
IN_PROC_BROWSER_TEST_P(NotificationSpokenFeedbackAppListTest,
                       AppListItemNotificationBadgeAnnounced) {
  PopulateApps(1);

  int test_item_index = 0;
  AppListItem* test_item = FindItemByName("app 0", &test_item_index);
  ASSERT_TRUE(test_item);
  test_item->UpdateNotificationBadgeForTesting(true);

  chromevox_test_utils()->EnableChromeVox();

  // Focus the shelf. This selects the launcher button.
  sm()->Call([this]() {
    EXPECT_TRUE(PerformAcceleratorAction(AcceleratorAction::kFocusShelf));
  });
  sm()->ExpectSpeechPattern("Launcher");
  sm()->ExpectSpeech("Button");
  sm()->ExpectSpeech("Shelf");
  sm()->ExpectSpeech("Tool bar");

  // Activate the launcher button. This opens bubble launcher.
  sm()->Call([this]() { SendKeyPressWithSearch(ui::VKEY_SPACE); });
  sm()->ExpectSpeechPattern("Search your *");
  sm()->ExpectSpeech("Edit text");

  // Skip over apps that were installed before the test item.
  sm()->Call([this, &test_item_index]() {
    for (int i = 0; i < test_item_index + 1; ++i) {
      SendKeyPressWithSearch(ui::VKEY_RIGHT);
    }
  });

  // Check that the announcement for items with a notification badge occurs.
  sm()->ExpectSpeech("app 0 requests your attention.");
  sm()->Replay();
}

// Checks that when a paused app list item is focused, an announcement 'Paused'
// is made.
IN_PROC_BROWSER_TEST_P(SpokenFeedbackAppListTest,
                       AppListItemPausedAppAnnounced) {
  PopulateApps(1);

  int test_item_index = 0;
  AppListItem* test_item = FindItemByName("app 0", &test_item_index);
  ASSERT_TRUE(test_item);
  test_item->UpdateAppStatusForTesting(AppStatus::kPaused);

  chromevox_test_utils()->EnableChromeVox();

  // Focus the shelf. This selects the launcher button.
  sm()->Call([this]() {
    EXPECT_TRUE(PerformAcceleratorAction(AcceleratorAction::kFocusShelf));
  });
  sm()->ExpectSpeechPattern("Launcher");
  sm()->ExpectSpeech("Button");
  sm()->ExpectSpeech("Shelf");
  sm()->ExpectSpeech("Tool bar");

  // Activate the launcher button. This opens bubble launcher.
  sm()->Call([this]() { SendKeyPressWithSearch(ui::VKEY_SPACE); });
  sm()->ExpectSpeechPattern("Search your *");
  sm()->ExpectSpeech("Edit text");

  // Skip over apps that were installed before the test item.
  sm()->Call([this, &test_item_index]() {
    for (int i = 0; i < test_item_index + 1; ++i) {
      SendKeyPressWithSearch(ui::VKEY_RIGHT);
    }
  });

  // Check that the announcement for items with a pause badge occurs.
  sm()->ExpectSpeech("app 0");
  sm()->ExpectSpeech("Paused");
  sm()->Replay();
}

// Checks that when a blocked app list item is focused, an announcement
// 'Blocked' is made.
IN_PROC_BROWSER_TEST_P(SpokenFeedbackAppListTest,
                       AppListItemBlockedAppAnnounced) {
  PopulateApps(1);

  int test_item_index = 0;
  AppListItem* test_item = FindItemByName("app 0", &test_item_index);
  ASSERT_TRUE(test_item);
  test_item->UpdateAppStatusForTesting(AppStatus::kBlocked);

  chromevox_test_utils()->EnableChromeVox();

  // Focus the shelf. This selects the launcher button.
  sm()->Call([this]() {
    EXPECT_TRUE(PerformAcceleratorAction(AcceleratorAction::kFocusShelf));
  });
  sm()->ExpectSpeechPattern("Launcher");
  sm()->ExpectSpeech("Button");
  sm()->ExpectSpeech("Shelf");
  sm()->ExpectSpeech("Tool bar");

  // Activate the launcher button. This opens bubble launcher.
  sm()->Call([this]() { SendKeyPressWithSearch(ui::VKEY_SPACE); });
  sm()->ExpectSpeechPattern("Search your *");
  sm()->ExpectSpeech("Edit text");

  // Skip over apps that were installed before the test item.
  sm()->Call([this, &test_item_index]() {
    for (int i = 0; i < test_item_index + 1; ++i) {
      SendKeyPressWithSearch(ui::VKEY_RIGHT);
    }
  });

  // Check that the announcement for items with a block badge occurs.
  sm()->ExpectSpeech("app 0");
  sm()->ExpectSpeech("Blocked");
  sm()->Replay();
}

// Checks that entering and exiting tablet mode with a browser window open does
// not generate an accessibility event.
IN_PROC_BROWSER_TEST_P(
    SpokenFeedbackAppListTest,
    HiddenAppListDoesNotCreateAccessibilityEventWhenTransitioningToTabletMode) {
  chromevox_test_utils()->EnableChromeVox();

  sm()->Call([]() { ShellTestApi().SetTabletModeEnabledForTest(true); });
  sm()->ExpectNextSpeechIsNot("Launcher, all apps");
  sm()->Call([]() { ShellTestApi().SetTabletModeEnabledForTest(false); });
  sm()->ExpectNextSpeechIsNot("Launcher, all apps");
  sm()->Replay();
}

// Checks that rotating the display in tablet mode does not generate an
// accessibility event.
IN_PROC_BROWSER_TEST_P(
    SpokenFeedbackAppListTest,
    LauncherAppListScreenRotationDoesNotCreateAccessibilityEvent) {
  display::DisplayManager* display_manager = Shell::Get()->display_manager();
  const int display_id = display_manager->GetDisplayAt(0).id();
  chromevox_test_utils()->EnableChromeVox();

  sm()->Call([]() { ShellTestApi().SetTabletModeEnabledForTest(true); });

  sm()->Call([this]() { browser()->window()->Minimize(); });
  // Set screen rotation to 90 degrees. No ChromeVox event should be created.
  sm()->Call([&, display_manager, display_id]() {
    display_manager->SetDisplayRotation(display_id, display::Display::ROTATE_90,
                                        display::Display::RotationSource::USER);
  });
  sm()->ExpectNextSpeechIsNot("Launcher, all apps");

  // Set screen rotation to 0 degrees. No ChromeVox event should be created.
  sm()->Call([&, display_manager, display_id]() {
    display_manager->SetDisplayRotation(display_id, display::Display::ROTATE_0,
                                        display::Display::RotationSource::USER);
  });
  sm()->ExpectNextSpeechIsNot("Launcher, all apps");

  sm()->Replay();
}

// TODO(https://crbug.com/1393235): Update this browser test to test recent
// apps.
IN_PROC_BROWSER_TEST_P(SpokenFeedbackAppListTest, ClamshellLauncher) {
  PopulateApps(3);

  int test_item_index = 0;
  AppListItem* test_item = FindItemByName("app 0", &test_item_index);
  ASSERT_TRUE(test_item);

  chromevox_test_utils()->EnableChromeVox();

  // Focus the shelf. This selects the launcher button.
  sm()->Call([this]() {
    EXPECT_TRUE(PerformAcceleratorAction(AcceleratorAction::kFocusShelf));
  });
  sm()->ExpectSpeechPattern("Launcher");
  sm()->ExpectSpeech("Button");
  sm()->ExpectSpeech("Shelf");
  sm()->ExpectSpeech("Tool bar");

  // Activate the launcher button. This opens bubble launcher.
  sm()->Call([this]() { SendKeyPressWithSearch(ui::VKEY_SPACE); });
  sm()->ExpectSpeechPattern("Search your *");
  sm()->ExpectSpeech("Edit text");
  sm()->ExpectSpeech("Launcher, all apps");
  sm()->Call([this]() { ReadWindowTitle(); });
  sm()->ExpectSpeech("Launcher");

  sm()->Call([this]() { SendKeyPressWithSearch(ui::VKEY_RIGHT); });
  sm()->ExpectSpeech("Button");

  // Skip over apps that were installed before the test item.
  // This selects the first app installed by the test.
  for (int i = 0; i < test_item_index; ++i) {
    sm()->Call([this]() { SendKeyPressWithSearch(ui::VKEY_RIGHT); });
  }
  sm()->ExpectSpeech("app 0");
  sm()->ExpectSpeech("Button");

  // Move the focused item to the right. The announcement does not include a
  // page because the bubble launcher apps grid is scrollable, not paged.
  sm()->Call([this]() { SendKeyPressWithControl(ui::VKEY_RIGHT); });

  sm()->ExpectSpeech(
      base::StringPrintf("Moved to row 1, column %d.", test_item_index + 2));

  sm()->Replay();
}

// Checks that app list keyboard reordering is announced.
// TODO(mmourgos): The current method of accessibility announcements for item
// reordering uses alerts, this works for spoken feedback but does not work as
// well for braille users. The preferred way to handle this is to actually
// change focus as the user navigates, and to have each object's
// accessible name describe its position. (See crbug.com/1098495)
IN_PROC_BROWSER_TEST_P(SpokenFeedbackAppListTest, AppListReordering) {
  PopulateApps(22);
  chromevox_test_utils()->EnableChromeVox();
  const int test_item_index = MoveToFirstTestApp();

  // The default column of app 0.
  const int original_column = test_item_index + 1;

  // The column of app 0 after rightward move.
  const int column_after_horizontal_move = original_column + 1;

  // Move the first item to the right.
  sm()->Call([this]() { SendKeyPressWithControl(ui::VKEY_RIGHT); });
  sm()->ExpectNextSpeechIsNot("Alert");

  sm()->ExpectSpeech(base::StringPrintf("Moved to row 1, column %d.",
                                        column_after_horizontal_move));

  // Move the focused item down.
  sm()->Call([this]() { SendKeyPressWithControl(ui::VKEY_DOWN); });
  sm()->ExpectNextSpeechIsNot("Alert");
  sm()->ExpectSpeech(base::StringPrintf("Moved to row 2, column %d.",
                                        column_after_horizontal_move));

  // Move the focused item down.
  sm()->Call([this]() { SendKeyPressWithControl(ui::VKEY_DOWN); });
  sm()->ExpectNextSpeechIsNot("Alert");
  sm()->ExpectSpeech(base::StringPrintf("Moved to row 3, column %d.",
                                        column_after_horizontal_move));

  // Move the focused item down.
  sm()->Call([this]() { SendKeyPressWithControl(ui::VKEY_DOWN); });
  sm()->ExpectNextSpeechIsNot("Alert");
  sm()->ExpectSpeech(base::StringPrintf("Moved to row 4, column %d.",
                                        column_after_horizontal_move));

  // Move the focused item left.
  sm()->Call([this]() { SendKeyPressWithControl(ui::VKEY_LEFT); });
  sm()->ExpectNextSpeechIsNot("Alert");
  sm()->ExpectSpeech(
      base::StringPrintf("Moved to row 4, column %d.", original_column));

  // Move the focused item back up.
  sm()->Call([this]() { SendKeyPressWithControl(ui::VKEY_UP); });
  sm()->ExpectNextSpeechIsNot("Alert");
  sm()->ExpectSpeech(
      base::StringPrintf("Moved to row 3, column %d.", original_column));

  sm()->Replay();
}

IN_PROC_BROWSER_TEST_P(SpokenFeedbackAppListTest, AppListFoldering) {
  // Add 3 apps and move to the first one.
  PopulateApps(3);
  chromevox_test_utils()->EnableChromeVox();
  const int test_item_index = MoveToFirstTestApp();

  auto* generator_ptr = event_generator();
  // Combine items and create a new folder.
  sm()->Call([generator_ptr]() {
    SendKeyPressWithShiftAndControl(generator_ptr, ui::VKEY_RIGHT);
  });
  sm()->ExpectNextSpeechIsNot("Alert");
  sm()->ExpectSpeech("Folder Unnamed");
  sm()->ExpectSpeech("Expanded");
  sm()->ExpectSpeech("app 0 combined with app 1 to create new folder.");

  // Move focus to the first item in folder.
  sm()->Call([this]() { SendKeyPress(ui::VKEY_DOWN); });
  sm()->ExpectSpeech("app 1");
  sm()->ExpectSpeech("Button");

  // Remove the first item from the folder back to the top level app list.
  sm()->Call([generator_ptr]() {
    SendKeyPressWithShiftAndControl(generator_ptr, ui::VKEY_LEFT);
  });

  sm()->ExpectSpeech("app 1");
  sm()->ExpectSpeech("Button");
  sm()->ExpectNextSpeechIsNot("Alert");

  sm()->ExpectSpeech(
      base::StringPrintf("Moved to row 1, column %d.", test_item_index + 1));

  sm()->Replay();
}

IN_PROC_BROWSER_TEST_P(SpokenFeedbackAppListTest,
                       CloseFolderMakesA11yAnnouncement) {
  // Add 3 apps and move to the first one.
  PopulateApps(3);
  chromevox_test_utils()->EnableChromeVox();
  MoveToFirstTestApp();

  // Combine items and create a new folder.
  auto* generator_ptr = event_generator();
  sm()->Call([generator_ptr]() {
    SendKeyPressWithShiftAndControl(generator_ptr, ui::VKEY_RIGHT);
  });
  sm()->ExpectNextSpeechIsNot("Alert");
  sm()->ExpectSpeech("Folder Unnamed");
  sm()->ExpectSpeech("Expanded");
  sm()->ExpectSpeech("app 0 combined with app 1 to create new folder.");

  // Move focus to the first item in folder.
  sm()->Call([this]() { SendKeyPress(ui::VKEY_DOWN); });
  sm()->ExpectSpeech("app 1");
  sm()->ExpectSpeech("Button");

  // Press Escape to close the folder. ChromeVox should announce that the
  // folder has been closed.
  sm()->Call([this]() { SendKeyPress(ui::VKEY_ESCAPE); });
  sm()->ExpectSpeech("Close folder");

  sm()->Replay();
}

IN_PROC_BROWSER_TEST_P(SpokenFeedbackAppListTest,
                       SortAppsMakesA11yAnnouncement) {
  // Add 3 apps and move to the first one.
  PopulateApps(3);
  chromevox_test_utils()->EnableChromeVox();
  MoveToFirstTestApp();

  // The AppListTestApi's ReorderByMouseClickAtToplevelAppsGridMenu times out
  // when called with ReorderAnimationEndState::kCompleted due to the run loop
  // in WaitForReorderAnimationAndVerifyItemVisibility. So we do some of that
  // work here manually.

  // Show the context menu for the AppsGridView.
  sm()->Call([]() {
    AppsGridView* grid_view = AppListTestApi().GetTopLevelAppsGridView();
    EXPECT_TRUE(grid_view);
    grid_view->ShowContextMenu(grid_view->GetBoundsInScreen().CenterPoint(),
                               ui::mojom::MenuSourceType::kKeyboard);
  });
  sm()->ExpectSpeech("menu opened");

  // Press N to activate sort by name. This will result in focus being moved
  // to a button to undo the sort just completed.
  sm()->Call([this]() { SendKeyPress(ui::VKEY_N); });
  sm()->ExpectSpeech("Apps are sorted by name");
  sm()->ExpectSpeech("Undo sort order by name");
  sm()->ExpectSpeech("Button");

  // Press the undo button.
  sm()->Call([this]() { SendKeyPress(ui::VKEY_SPACE); });
  sm()->ExpectSpeech("Sort undo successful");

  // Show the context menu for the AppsGridView.
  sm()->Call([]() {
    AppsGridView* grid_view = AppListTestApi().GetTopLevelAppsGridView();
    EXPECT_TRUE(grid_view);
    grid_view->ShowContextMenu(grid_view->GetBoundsInScreen().CenterPoint(),
                               ui::mojom::MenuSourceType::kKeyboard);
  });
  sm()->ExpectSpeech("menu opened");

  // Press C to activate sort by color. This will result in focus being moved
  // to a button to undo the sort just completed.
  sm()->Call([this]() { SendKeyPress(ui::VKEY_C); });
  sm()->ExpectSpeech("Apps are sorted by color");
  sm()->ExpectSpeech("Undo sort order by color");
  sm()->ExpectSpeech("Button");

  // Press the undo button.
  sm()->Call([this]() { SendKeyPress(ui::VKEY_SPACE); });
  sm()->ExpectSpeech("Sort undo successful");

  sm()->Replay();
}

IN_PROC_BROWSER_TEST_P(SpokenFeedbackAppListSearchTest, LauncherSearch) {
  chromevox_test_utils()->EnableChromeVox();
  ShowAppList();

  sm()->ExpectSpeechPattern("Search your *");
  sm()->ExpectSpeech("Edit text");
  sm()->Call([this]() { ReadWindowTitle(); });
  sm()->ExpectSpeech("Launcher");

  sm()->Call([this]() {
    apps_provider_->set_best_match_count(2);
    apps_provider_->set_count(3);
    web_provider_->set_count(4);
    image_provider_->set_count(3);
    SendKeyPress(ui::VKEY_G);
  });

  sm()->ExpectSpeech("G");
  sm()->ExpectSpeech("app 0");
  sm()->ExpectSpeech("List item 1 of 2");
  sm()->ExpectSpeech("Best Match");
  sm()->ExpectSpeech("List box");

  // Traverse best match results;
  for (int i = 1; i < 2; ++i) {
    sm()->Call([this]() { SendKeyPress(ui::VKEY_DOWN); });
    sm()->ExpectSpeech(base::StringPrintf("app %d", i));
    sm()->ExpectSpeech(base::StringPrintf("List item %d of 2", i + 1));
  }

  // Traverse image results.
  for (int i = 0; i < 3; ++i) {
    sm()->Call([this]() { SendKeyPress(ui::VKEY_DOWN); });
    sm()->ExpectSpeech(base::StringPrintf("image %d", i));
    sm()->ExpectSpeech(base::StringPrintf("List item %d of 3", i + 1));
    if (i == 0) {
      sm()->ExpectSpeech("List box");
    }
  }

  // Traverse non-best-match app results.
  for (int i = 2; i < 5; ++i) {
    sm()->Call([this]() { SendKeyPress(ui::VKEY_DOWN); });
    sm()->ExpectSpeech(base::StringPrintf("app %d", i));
    sm()->ExpectSpeech(
        base::StringPrintf("List item %d of 3", (i - 2) % 3 + 1));
    if (i == 2) {
      sm()->ExpectSpeech("Apps");
      sm()->ExpectSpeech("List box");
    }
  }

  // Traverse omnibox results.
  for (int i = 0; i < 3; ++i) {
    sm()->Call([this]() { SendKeyPress(ui::VKEY_DOWN); });
    sm()->ExpectSpeech(base::StringPrintf("item %d", i));
    sm()->ExpectSpeech(base::StringPrintf("List item %d of 3", i + 1));
    if (i == 0) {
      sm()->ExpectSpeech("Websites");
      sm()->ExpectSpeech("List box");
    }
  }

  // Cycle focus to the filter button.
  sm()->Call([this]() { SendKeyPress(ui::VKEY_DOWN); });
  sm()->ExpectSpeech("Toggle search result categories");

  // Move focus to the close button.
  sm()->Call([this]() { SendKeyPress(ui::VKEY_DOWN); });
  sm()->ExpectSpeech("Clear searchbox text");

  // Move focus back to the filter button.
  sm()->Call([this]() { SendKeyPress(ui::VKEY_UP); });
  sm()->ExpectSpeech("Toggle search result categories");

  // Go back to the last result.
  sm()->Call([this]() { SendKeyPress(ui::VKEY_UP); });
  sm()->ExpectSpeech("item 2");

  // Update the query, to initiate new search.
  sm()->Call([this]() {
    apps_provider_->set_best_match_count(0);
    apps_provider_->set_count(3);
    web_provider_->set_count(2);
    image_provider_->set_count(2);
    SendKeyPress(ui::VKEY_A);
  });

  sm()->ExpectSpeech("A");
  sm()->ExpectSpeech("image 0");
  sm()->ExpectSpeech("List item 1 of 2");
  sm()->ExpectSpeech("List box");

  // Traverse image results.
  for (int i = 1; i < 2; ++i) {
    sm()->Call([this]() { SendKeyPress(ui::VKEY_DOWN); });
    sm()->ExpectSpeech(base::StringPrintf("image %d", i));
    sm()->ExpectSpeech(base::StringPrintf("List item %d of 2", i + 1));
  }

  // Verify traversal works after result change.
  for (int i = 0; i < 3; ++i) {
    sm()->Call([this]() { SendKeyPress(ui::VKEY_DOWN); });
    sm()->ExpectSpeech(base::StringPrintf("app %d", i));
    sm()->ExpectSpeech(base::StringPrintf("List item %d of 3", i + 1));
  }

  for (int i = 0; i < 2; ++i) {
    sm()->Call([this]() { SendKeyPress(ui::VKEY_DOWN); });
    sm()->ExpectSpeech(base::StringPrintf("item %d", i));
    sm()->ExpectSpeech(base::StringPrintf("List item %d of 2", i + 1));
    if (i == 0) {
      sm()->ExpectSpeech("Websites");
      sm()->ExpectSpeech("List box");
    }
  }

  sm()->Replay();
}

IN_PROC_BROWSER_TEST_P(SpokenFeedbackAppListSearchTest,
                       TouchExploreLauncherSearchResult) {
  chromevox_test_utils()->EnableChromeVox();
  ShowAppList();

  sm()->ExpectSpeechPattern("Search your *");
  sm()->ExpectSpeech("Edit text");

  sm()->Call([this]() {
    apps_provider_->set_best_match_count(2);
    apps_provider_->set_count(3);
    web_provider_->set_count(4);
    SendKeyPress(ui::VKEY_G);
  });

  sm()->ExpectSpeech("G");
  sm()->ExpectSpeech("Displaying 8 results for g");

  base::SimpleTestTickClock clock;
  clock.SetNowTicks(base::TimeTicks::Now());
  auto* clock_ptr = &clock;
  ui::SetEventTickClockForTesting(clock_ptr);

  auto* generator_ptr = event_generator();

  // Start touch exploration, and go to the third result in the UI (expected to
  // be "app 2").
  sm()->Call([clock_ptr, generator_ptr]() {
    views::View* target_view =
        AppListTestApi().GetVisibleSearchResultView(/*index=*/2);
    ASSERT_TRUE(target_view);

    gfx::Point touch_point = target_view->GetBoundsInScreen().CenterPoint();
    ui::TouchEvent touch_press(
        ui::EventType::kTouchPressed, touch_point, base::TimeTicks::Now(),
        ui::PointerDetails(ui::EventPointerType::kTouch, 0));
    generator_ptr->Dispatch(&touch_press);

    clock_ptr->Advance(base::Seconds(1));

    ui::TouchEvent touch_move(
        ui::EventType::kTouchMoved, touch_point, base::TimeTicks::Now(),
        ui::PointerDetails(ui::EventPointerType::kTouch, 0));
    generator_ptr->Dispatch(&touch_move);
  });

  // The result under touch pointer should be announced.
  sm()->ExpectSpeech("app 2");
  sm()->ExpectSpeech("List item 1 of 3");
  sm()->ExpectSpeech("Apps");
  sm()->Replay();
}

IN_PROC_BROWSER_TEST_P(SpokenFeedbackAppListSearchTest, VocalizeResultCount) {
  chromevox_test_utils()->EnableChromeVox();
  ShowAppList();

  sm()->ExpectSpeechPattern("Search your *");
  sm()->ExpectSpeech("Edit text");

  sm()->Call([this]() {
    apps_provider_->set_best_match_count(2);
    apps_provider_->set_count(3);
    web_provider_->set_count(4);
    SendKeyPress(ui::VKEY_G);
  });

  sm()->ExpectSpeech("G");
  sm()->ExpectSpeech("Displaying 8 results for g");

  // Update the query, to initiate new search.
  sm()->Call([this]() {
    apps_provider_->set_best_match_count(0);
    apps_provider_->set_count(3);
    web_provider_->set_count(2);
    SendKeyPress(ui::VKEY_A);
  });

  sm()->ExpectSpeech("A");
  sm()->ExpectSpeech("Displaying 5 results for ga");

  sm()->Replay();
}

IN_PROC_BROWSER_TEST_P(SpokenFeedbackAppListSearchTest, SearchCategoryFilter) {
  chromevox_test_utils()->EnableChromeVox();
  ShowAppList();

  sm()->ExpectSpeechPattern("Search your *");
  sm()->ExpectSpeech("Edit text");

  sm()->Call([this]() {
    apps_provider_->set_best_match_count(2);
    apps_provider_->set_count(3);
    web_provider_->set_count(4);
    SendKeyPress(ui::VKEY_G);
  });

  sm()->ExpectSpeech("G");
  sm()->ExpectSpeech("Displaying 8 results for g");

  // Move focus to the close button.
  sm()->Call([this]() { SendKeyPress(ui::VKEY_UP); });
  sm()->ExpectSpeech("Clear searchbox text");

  // Move focus to the filter button.
  sm()->Call([this]() { SendKeyPress(ui::VKEY_UP); });
  sm()->ExpectSpeech("Toggle search result categories");

  // Open the filter menu.
  sm()->Call([this]() { SendKeyPress(ui::VKEY_RETURN); });
  sm()->ExpectSpeech("menu opened");

  // Move focus to the category options.
  sm()->Call([this]() { SendKeyPress(ui::VKEY_DOWN); });
  sm()->ExpectSpeech("Apps");
  sm()->ExpectSpeech("Checked");
  sm()->ExpectSpeech("Your installed apps");

  sm()->Call([this]() { SendKeyPress(ui::VKEY_DOWN); });
  sm()->ExpectSpeech("Images");
  sm()->ExpectSpeech("Checked");
  sm()->ExpectSpeech("Image search by content and image previews");

  sm()->Call([this]() { SendKeyPress(ui::VKEY_DOWN); });
  sm()->ExpectSpeech("Websites");
  sm()->ExpectSpeech("Checked");
  sm()->ExpectSpeech("Websites including pages you've visited and open pages");

  // Toggle the websites search category.
  sm()->Call([this]() { SendKeyPress(ui::VKEY_RETURN); });
  sm()->ExpectSpeech("Websites");
  sm()->ExpectSpeech("Not checked");
  sm()->ExpectSpeech("Websites including pages you've visited and open pages");

  sm()->Call([this]() { SendKeyPress(ui::VKEY_ESCAPE); });
  sm()->Replay();
}

}  // namespace ash