#ifndef CONTENT_PUBLIC_TEST_TEXT_INPUT_TEST_UTILS_H_
#define CONTENT_PUBLIC_TEST_TEXT_INPUT_TEST_UTILS_H_
#include <string>
#include <vector>
#include "base/functional/callback.h"
#include "base/memory/raw_ptr.h"
#include "build/build_config.h"
#include "content/public/test/test_utils.h"
#include "ui/base/ime/mojom/text_input_state.mojom.h"
#include "ui/base/ime/mojom/virtual_keyboard_types.mojom.h"
#include "ui/base/ime/text_input_mode.h"
#include "ui/base/ime/text_input_type.h"
#if defined(USE_AURA)
#include "ui/events/event_constants.h"
#endif
#if BUILDFLAG(IS_MAC)
#include "content/public/test/fake_local_frame.h"
#include "mojo/public/cpp/bindings/associated_remote.h"
#endif
namespace gfx {
class Range;
}
namespace ui {
struct ImeTextSpan;
}
namespace content {
class RenderFrameHost;
class RenderWidgetHost;
class RenderWidgetHostView;
class RenderWidgetHostViewBase;
class WebContents;
ui::TextInputType GetTextInputTypeFromWebContents(WebContents* web_contents);
const ui::mojom::TextInputState* GetTextInputStateFromWebContents(
WebContents* web_contents);
bool GetTextInputTypeForView(WebContents* web_contents,
RenderWidgetHostView* view,
ui::TextInputType* type);
size_t GetRegisteredViewsCountFromTextInputManager(WebContents* web_contents);
RenderWidgetHostView* GetActiveViewFromWebContents(WebContents* web_contents);
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);
class TextInputManagerTester { … };
class TextInputManagerObserverBase { … };
class TextInputManagerValueObserver : public TextInputManagerObserverBase { … };
class TextInputManagerTypeObserver : public TextInputManagerObserverBase { … };
class TestRenderWidgetHostViewDestructionObserver { … };
class TextInputStateSender { … };
class TestInputMethodObserver { … };
#if BUILDFLAG(IS_MAC)
class TextInputTestLocalFrame : public FakeLocalFrame {
public:
TextInputTestLocalFrame();
TextInputTestLocalFrame(const TextInputTestLocalFrame&) = delete;
TextInputTestLocalFrame& operator=(const TextInputTestLocalFrame&) = delete;
~TextInputTestLocalFrame() override;
void SetUp(content::RenderFrameHost* render_frame_host);
void WaitForGetStringForRange();
void SetStringForRangeCallback(base::RepeatingClosure callback);
std::string GetStringFromRange() { return string_from_range_; }
void SetStringFromRange(std::string string_from_range) {
string_from_range_ = string_from_range;
}
void GetStringForRange(const gfx::Range& range,
GetStringForRangeCallback callback) override;
private:
base::OnceClosure quit_closure_;
base::RepeatingClosure string_for_range_callback_;
std::string string_from_range_;
mojo::AssociatedRemote<blink::mojom::LocalFrame> local_frame_;
};
void AskForLookUpDictionaryForRange(RenderWidgetHostView* tab_view,
const gfx::Range& range);
#endif
}
#endif