Allow VoiceSearch when VoiceOver is on.

Now that the VoiceSearch component has fixed its issue with working
correctly with VoiceOver, re-enable the ability to access it on
the NTP.

Remove tests that served only test that changing the VO setting
disabled the button. As all of this VO tracking code will be removed in
a followup CL, there's no point updating the tests.

Bug: 1382540
Change-Id: I86a3d5c6a77600a09cdb9a9d4617ece620c2a97a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4013651
Reviewed-by: Rohit Rao <rohitrao@chromium.org>
Reviewed-by: Sylvain Defresne <sdefresne@chromium.org>
Commit-Queue: Mike Pinkerton <pinkerton@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1069899}
diff --git a/ios/chrome/browser/ui/content_suggestions/ntp_home_mediator_unittest.mm b/ios/chrome/browser/ui/content_suggestions/ntp_home_mediator_unittest.mm
index 9a5bb90..801644a 100644
--- a/ios/chrome/browser/ui/content_suggestions/ntp_home_mediator_unittest.mm
+++ b/ios/chrome/browser/ui/content_suggestions/ntp_home_mediator_unittest.mm
@@ -157,19 +157,3 @@
   // Test.
   EXPECT_OCMOCK_VERIFY(consumer_);
 }
-
-// Tests that the voice search button is disabled when VoiceOver is turned on
-// and off.
-TEST_F(NTPHomeMediatorTest, DisableVoiceSearch) {
-  [mediator_ setUp];
-
-  // Enable VoiceOver and verify that voice search is disabled for the consumer.
-  OCMExpect([consumer_ setVoiceSearchIsEnabled:NO]);
-  voice_availability_.SetVoiceOverEnabled(true);
-
-  // Disable VoiceOVer and verify that voice search is enabled again.
-  OCMExpect([consumer_ setVoiceSearchIsEnabled:YES]);
-  voice_availability_.SetVoiceOverEnabled(false);
-
-  EXPECT_OCMOCK_VERIFY(consumer_);
-}
diff --git a/ios/chrome/browser/ui/omnibox/keyboard_assist/BUILD.gn b/ios/chrome/browser/ui/omnibox/keyboard_assist/BUILD.gn
index ade75cc..215e9fa 100644
--- a/ios/chrome/browser/ui/omnibox/keyboard_assist/BUILD.gn
+++ b/ios/chrome/browser/ui/omnibox/keyboard_assist/BUILD.gn
@@ -53,20 +53,3 @@
       [ "//ios/chrome/browser/ui/omnibox:omnibox_internal" ]
   frameworks = [ "UIKit.framework" ]
 }
-
-source_set("unit_tests") {
-  testonly = true
-  sources = [
-    "voice_search_keyboard_accessory_button_unittest.mm",
-    "voice_search_keyboard_bar_button_item_unittest.mm",
-  ]
-
-  configs += [ "//build/config/compiler:enable_arc" ]
-
-  deps = [
-    ":keyboard_assist",
-    "//ios/chrome/browser/voice",
-    "//ios/chrome/browser/voice:test_support",
-    "//testing/gtest",
-  ]
-}
diff --git a/ios/chrome/browser/ui/omnibox/keyboard_assist/voice_search_keyboard_accessory_button_unittest.mm b/ios/chrome/browser/ui/omnibox/keyboard_assist/voice_search_keyboard_accessory_button_unittest.mm
deleted file mode 100644
index 4931376..0000000
--- a/ios/chrome/browser/ui/omnibox/keyboard_assist/voice_search_keyboard_accessory_button_unittest.mm
+++ /dev/null
@@ -1,44 +0,0 @@
-// Copyright 2020 The Chromium Authors
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#import "ios/chrome/browser/ui/omnibox/keyboard_assist/voice_search_keyboard_accessory_button.h"
-
-#import "ios/chrome/browser/voice/fake_voice_search_availability.h"
-#import "testing/platform_test.h"
-
-#if !defined(__has_feature) || !__has_feature(objc_arc)
-#error "This file requires ARC support."
-#endif
-
-// Test fixture for VoiceSearchKeyboardAccessoryButton.
-class VoiceSearchKeyboardAccessoryButtonTest : public PlatformTest {
- public:
-  VoiceSearchKeyboardAccessoryButtonTest()
-      : superview_([[UIView alloc] initWithFrame:CGRectZero]) {
-    std::unique_ptr<FakeVoiceSearchAvailability> availability =
-        std::make_unique<FakeVoiceSearchAvailability>();
-    availability_ = availability.get();
-    availability_->SetVoiceOverEnabled(false);
-    availability_->SetVoiceProviderEnabled(true);
-    button_ = [[VoiceSearchKeyboardAccessoryButton alloc]
-        initWithVoiceSearchAvailability:std::move(availability)];
-    [superview_ addSubview:button_];
-  }
-
- protected:
-  FakeVoiceSearchAvailability* availability_ = nullptr;
-  UIView* superview_ = nil;
-  VoiceSearchKeyboardAccessoryButton* button_ = nil;
-};
-
-// Tests that the button is disabled when VoiceOver is enabled.
-TEST_F(VoiceSearchKeyboardAccessoryButtonTest, DisableForVoiceOver) {
-  ASSERT_TRUE(button_.enabled);
-
-  availability_->SetVoiceOverEnabled(true);
-  EXPECT_FALSE(button_.enabled);
-
-  availability_->SetVoiceOverEnabled(false);
-  EXPECT_TRUE(button_.enabled);
-}
diff --git a/ios/chrome/browser/ui/omnibox/keyboard_assist/voice_search_keyboard_bar_button_item_unittest.mm b/ios/chrome/browser/ui/omnibox/keyboard_assist/voice_search_keyboard_bar_button_item_unittest.mm
deleted file mode 100644
index 359dbfc..0000000
--- a/ios/chrome/browser/ui/omnibox/keyboard_assist/voice_search_keyboard_bar_button_item_unittest.mm
+++ /dev/null
@@ -1,45 +0,0 @@
-// Copyright 2020 The Chromium Authors
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#import "ios/chrome/browser/ui/omnibox/keyboard_assist/voice_search_keyboard_bar_button_item.h"
-
-#import "ios/chrome/browser/voice/fake_voice_search_availability.h"
-#import "testing/platform_test.h"
-
-#if !defined(__has_feature) || !__has_feature(objc_arc)
-#error "This file requires ARC support."
-#endif
-
-// Test fixture for VoiceSearchKeyboardBarButtonItem.
-class VoiceSearchKeyboardBarButtonItemTest : public PlatformTest {
- public:
-  VoiceSearchKeyboardBarButtonItemTest() {
-    std::unique_ptr<FakeVoiceSearchAvailability> availability =
-        std::make_unique<FakeVoiceSearchAvailability>();
-    availability_ = availability.get();
-    availability_->SetVoiceOverEnabled(false);
-    availability_->SetVoiceProviderEnabled(true);
-    item_ = [[VoiceSearchKeyboardBarButtonItem alloc]
-                  initWithImage:nil
-                          style:UIBarButtonItemStylePlain
-                         target:nil
-                         action:nil
-        voiceSearchAvailability:std::move(availability)];
-  }
-
- protected:
-  FakeVoiceSearchAvailability* availability_ = nullptr;
-  VoiceSearchKeyboardBarButtonItem* item_ = nil;
-};
-
-// Tests that the item is disabled when VoiceOver is enabled.
-TEST_F(VoiceSearchKeyboardBarButtonItemTest, DisableForVoiceOver) {
-  ASSERT_TRUE(item_.enabled);
-
-  availability_->SetVoiceOverEnabled(true);
-  EXPECT_FALSE(item_.enabled);
-
-  availability_->SetVoiceOverEnabled(false);
-  EXPECT_TRUE(item_.enabled);
-}
diff --git a/ios/chrome/browser/voice/voice_search_availability.mm b/ios/chrome/browser/voice/voice_search_availability.mm
index 7245efc..9eeed10 100644
--- a/ios/chrome/browser/voice/voice_search_availability.mm
+++ b/ios/chrome/browser/voice/voice_search_availability.mm
@@ -41,7 +41,7 @@
 }
 
 bool VoiceSearchAvailability::IsVoiceSearchAvailable() const {
-  return !voice_over_enabled_ && ios::provider::IsVoiceSearchEnabled();
+  return ios::provider::IsVoiceSearchEnabled();
 }
 
 bool VoiceSearchAvailability::IsVoiceOverEnabled() const {
diff --git a/ios/chrome/browser/voice/voice_search_availability_unittest.mm b/ios/chrome/browser/voice/voice_search_availability_unittest.mm
index f14d1c2..90dde05 100644
--- a/ios/chrome/browser/voice/voice_search_availability_unittest.mm
+++ b/ios/chrome/browser/voice/voice_search_availability_unittest.mm
@@ -32,28 +32,6 @@
   id<VoiceSearchAvailabilityObserver> mock_observer_ = nil;
 };
 
-// Tests that the voice search availability properly checks the voice over
-// status and executes observer callbacks.
-TEST_F(VoiceSearchAvailabilityTest, UnavailableDuringVoiceOver) {
-  availability_.SetVoiceProviderEnabled(true);
-  availability_.SetVoiceOverEnabled(false);
-  ASSERT_TRUE(availability_.IsVoiceSearchAvailable());
-
-  // Enable voice search in the fake checker, verifying that the value is
-  // updated and that the observer is notified.
-  OCMExpect([mock_observer_ voiceSearchAvailability:&availability_
-                                updatedAvailability:false]);
-  availability_.SetVoiceOverEnabled(true);
-  EXPECT_FALSE(availability_.IsVoiceSearchAvailable());
-
-  // Disable voice search in the fake checker, verifying that the value is
-  // updated and that the observer is notified.
-  OCMExpect([mock_observer_ voiceSearchAvailability:&availability_
-                                updatedAvailability:true]);
-  availability_.SetVoiceOverEnabled(false);
-  EXPECT_TRUE(availability_.IsVoiceSearchAvailable());
-}
-
 // Tests that the voice search availability properly checks the voice provider
 // status.
 TEST_F(VoiceSearchAvailabilityTest, UnavailableForDisabledProvider) {
diff --git a/ios/chrome/test/BUILD.gn b/ios/chrome/test/BUILD.gn
index cf60037b..e685bec 100644
--- a/ios/chrome/test/BUILD.gn
+++ b/ios/chrome/test/BUILD.gn
@@ -318,7 +318,6 @@
     "//ios/chrome/browser/ui/menu:unit_tests",
     "//ios/chrome/browser/ui/ntp:unit_tests",
     "//ios/chrome/browser/ui/omnibox:unit_tests",
-    "//ios/chrome/browser/ui/omnibox/keyboard_assist:unit_tests",
     "//ios/chrome/browser/ui/omnibox/popup:unit_tests",
     "//ios/chrome/browser/ui/open_in:unit_tests",
     "//ios/chrome/browser/ui/overlays:unit_tests",