• Jeroen Dhollander's avatar
    Fix tablet mode crash when virtual keyboard is disabled. · 65454010
    Jeroen Dhollander authored
    If a physical keyboard is connected to a tablet, the virtual keyboard is
    disabled and trying to show/hide it will trigger a DCHECK.
    
    My newly introduced code in |AssistantDialogPlate| did not take that
    into account (it now checks KeyboardUiController::IsEnabled()).
    
    While writing the unittest to test this, I discovered the existing
    |AshTestBase::SetTouchKeyboardEnabled| did not actually work:
       - Trying to enable the keyboard by using
         |SetTouchKeyboardEnabled(true)| does not actually enable the
         keyboard, as it was immediately disabled again as soon as the
         |DeviceDataManager| detected the presence of the actual physical
         keyboard connected to the test PC.
         To work around this, everybody who used this method also set the
         command line switch |kEnableVirtualKeyboard|, which simply
         overruled the value set by |SetTouchKeyboardEnabled|.
       - Trying to disable the keyboard later on by using
         |SetTouchKeyboardEnabled(false)| didn't disable the keyboard as
         the change was overruled by the command line switch
         |kEnableVirtualKeyboard|.
    So to solve this, I removed the |SetTouchKeyboardEnabled| and replaced
    it with a |AshTestBase::SetVirtualKeyboardEnabled| method which uses a
    different set of flags (|kPolicyEnabled|/|kPolicyDisabled|) which are
    always respected during the unittests.
    
    Bug: b/147700828
    TBR: shend@
    Change-Id: I6137993a4ce5200cff400e882820580fa87d592c
    Tests: New ash_unittest |AssistantPageViewTabletModeTest.ShouldNotShowKeyboardWhenItsDisabled|.
    Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2002742
    Commit-Queue: Jeroen Dhollander <jeroendh@google.com>
    Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
    Reviewed-by: default avatarXiaohui Chen <xiaohuic@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#734188}
    65454010
ash_test_base.cc 19.8 KB