chromium/content/public/test/text_input_test_utils.cc

// Copyright 2016 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "content/public/test/text_input_test_utils.h"

#include <memory>
#include <unordered_set>

#include "base/memory/raw_ptr.h"
#include "base/strings/utf_string_conversions.h"
#include "components/input/render_widget_host_view_input_observer.h"
#include "content/browser/renderer_host/frame_tree.h"
#include "content/browser/renderer_host/frame_tree_node.h"
#include "content/browser/renderer_host/render_frame_host_impl.h"
#include "content/browser/renderer_host/render_widget_host_impl.h"
#include "content/browser/renderer_host/render_widget_host_view_base.h"
#include "content/browser/renderer_host/text_input_manager.h"
#include "content/browser/web_contents/web_contents_impl.h"
#include "content/public/browser/render_widget_host_view.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_observer.h"
#include "content/public/test/test_utils.h"
#include "ui/base/ime/ime_text_span.h"
#include "ui/base/ime/input_method.h"
#include "ui/base/ime/input_method_observer.h"
#include "ui/base/ime/mojom/text_input_state.mojom.h"

#if defined(USE_AURA)
#include "content/browser/renderer_host/render_widget_host_view_aura.h"
#endif

namespace ui {
class TextInputClient;
}

namespace content {

// This class is an observer of TextInputManager associated with the provided
// WebContents. An instance of this class is used in TextInputManagerTester to
// expose the required API for testing outside of content/.
class TextInputManagerTester::InternalObserver
    : public TextInputManager::Observer,
      public WebContentsObserver {};

// This class observes the lifetime of a RenderWidgetHostView. An instance of
// this class is used in TestRenderWidgetHostViewDestructionObserver to expose
// the required observer API for testing outside of content/.
class TestRenderWidgetHostViewDestructionObserver::InternalObserver
    : public input::RenderWidgetHostViewInputObserver {};

#if defined(USE_AURA)
class InputMethodObserverAura : public TestInputMethodObserver,
                                public ui::InputMethodObserver {};
#endif

ui::TextInputType GetTextInputTypeFromWebContents(WebContents* web_contents) {}

const ui::mojom::TextInputState* GetTextInputStateFromWebContents(
    WebContents* web_contents) {}

bool GetTextInputTypeForView(WebContents* web_contents,
                             RenderWidgetHostView* view,
                             ui::TextInputType* type) {}

bool RequestCompositionInfoFromActiveWidget(WebContents* web_contents) {}

bool DoesFrameHaveFocusedEditableElement(RenderFrameHost* frame) {}

void SendImeCommitTextToWidget(
    RenderWidgetHost* rwh,
    const std::u16string& text,
    const std::vector<ui::ImeTextSpan>& ime_text_spans,
    const gfx::Range& replacement_range,
    int relative_cursor_pos) {}

void SendImeSetCompositionTextToWidget(
    RenderWidgetHost* rwh,
    const std::u16string& text,
    const std::vector<ui::ImeTextSpan>& ime_text_spans,
    const gfx::Range& replacement_range,
    int selection_start,
    int selection_end) {}

void SendTextInputStateChangedToWidget(RenderWidgetHost* rwh,
                                       ui::mojom::TextInputStatePtr state) {}

bool DestroyRenderWidgetHost(int32_t process_id,
                             int32_t local_root_routing_id) {}

size_t GetRegisteredViewsCountFromTextInputManager(WebContents* web_contents) {}

RenderWidgetHostView* GetActiveViewFromWebContents(WebContents* web_contents) {}

TextInputManagerTester::TextInputManagerTester(WebContents* web_contents)
    :{}

TextInputManagerTester::~TextInputManagerTester() {}

void TextInputManagerTester::SetUpdateTextInputStateCalledCallback(
    base::RepeatingClosure callback) {}

void TextInputManagerTester::SetOnSelectionBoundsChangedCallback(
    base::RepeatingClosure callback) {}

void TextInputManagerTester::SetOnImeCompositionRangeChangedCallback(
    base::RepeatingClosure callback) {}

void TextInputManagerTester::SetOnTextSelectionChangedCallback(
    base::RepeatingClosure callback) {}

bool TextInputManagerTester::GetTextInputType(ui::TextInputType* type) {}

bool TextInputManagerTester::GetTextInputValue(std::string* value) {}

bool TextInputManagerTester::GetTextInputVkPolicy(
    ui::mojom::VirtualKeyboardPolicy* vk_policy) {}

bool TextInputManagerTester::GetTextInputVkVisibilityRequest(
    ui::mojom::VirtualKeyboardVisibilityRequest* last_vk_visibility_request) {}

bool TextInputManagerTester::GetTextInputShowImeIfNeeded(
    bool* show_ime_if_needed) {}

const RenderWidgetHostView* TextInputManagerTester::GetActiveView() {}

RenderWidgetHostView* TextInputManagerTester::GetUpdatedView() {}

bool TextInputManagerTester::GetCurrentTextSelectionLength(size_t* length) {}

bool TextInputManagerTester::GetLastCompositionRangeLength(uint32_t* length) {}

bool TextInputManagerTester::IsTextInputStateChanged() {}

TextInputManagerObserverBase::TextInputManagerObserverBase(
    content::WebContents* web_contents)
    :{}

TextInputManagerObserverBase::~TextInputManagerObserverBase() = default;

void TextInputManagerObserverBase::Wait() {}

void TextInputManagerObserverBase::OnSuccess() {}

TextInputManagerValueObserver::TextInputManagerValueObserver(
    content::WebContents* web_contents,
    const std::string& expected_value)
    :{}

void TextInputManagerValueObserver::VerifyValue() {}

TextInputManagerTypeObserver::TextInputManagerTypeObserver(
    content::WebContents* web_contents,
    ui::TextInputType expected_type)
    :{}

void TextInputManagerTypeObserver::VerifyType() {}

TestRenderWidgetHostViewDestructionObserver::
    TestRenderWidgetHostViewDestructionObserver(RenderWidgetHostView* view)
    :{}

TestRenderWidgetHostViewDestructionObserver::
    ~TestRenderWidgetHostViewDestructionObserver() {}

void TestRenderWidgetHostViewDestructionObserver::Wait() {}

TextInputStateSender::TextInputStateSender(RenderWidgetHostView* view)
    :{}

TextInputStateSender::~TextInputStateSender() {}

void TextInputStateSender::Send() {}

void TextInputStateSender::SetFromCurrentState() {}

void TextInputStateSender::SetType(ui::TextInputType type) {}

void TextInputStateSender::SetMode(ui::TextInputMode mode) {}

void TextInputStateSender::SetFlags(int flags) {}

void TextInputStateSender::SetCanComposeInline(bool can_compose_inline) {}

void TextInputStateSender::SetShowVirtualKeyboardIfEnabled(
    bool show_ime_if_needed) {}

#if defined(USE_AURA)
void TextInputStateSender::SetLastPointerType(
    ui::EventPointerType last_pointer_type) {}
#endif

TestInputMethodObserver::TestInputMethodObserver() {}

TestInputMethodObserver::~TestInputMethodObserver() {}

// static
std::unique_ptr<TestInputMethodObserver> TestInputMethodObserver::Create(
    WebContents* web_contents) {}

}  // namespace content