Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(737)

Side by Side Diff: chrome/browser/renderer_host/site_per_process_text_input_browsertest.cc

Issue 1948343002: [reland] Browser Side Text Input State Tracking for OOPIF (Aura Only) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase (Code changed during CQ Dry-run) Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/test/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include <vector>
6
7 #include "base/command_line.h"
8 #include "chrome/browser/ui/browser.h"
9 #include "chrome/browser/ui/tabs/tab_strip_model.h"
10 #include "chrome/test/base/in_process_browser_test.h"
11 #include "chrome/test/base/ui_test_utils.h"
12 #include "content/public/browser/render_frame_host.h"
13 #include "content/public/browser/render_process_host.h"
14 #include "content/public/browser/web_contents.h"
15 #include "content/public/test/browser_test_utils.h"
16 #include "content/public/test/content_browser_test_utils.h"
17 #include "content/public/test/test_utils.h"
18 #include "content/public/test/text_input_test_utils.h"
19 #include "net/dns/mock_host_resolver.h"
20 #include "net/test/embedded_test_server/embedded_test_server.h"
21 #include "ui/base/ime/text_input_client.h"
22 #include "ui/base/ime/text_input_mode.h"
23 #include "ui/base/ime/text_input_type.h"
24 #include "url/gurl.h"
25
26 // TODO(ekaramad): The following tests are only active on aura platforms. After
27 // fixing crbug.com/578168 for all platforms, the following tests should be
28 // activated for other platforms, e.g., Mac and Android (crbug.com/602723).
29
30 ///////////////////////////////////////////////////////////////////////////////
31 // TextInputManager and IME Tests
32 //
33 // The following tests verify the correctness of TextInputState tracking on the
34 // browser side. They also make sure the IME logic works correctly. The baseline
35 // for comparison is the default functionality in the non-OOPIF case (i.e., the
36 // legacy implementation in RWHV's other than RWHVCF).
37 // These tests live outside content/ because they rely on being part of the
38 // interactive UI test framework (to avoid flakiness).
39
40 namespace {
41 using IndexVector = std::vector<size_t>;
42
43 // TextInputManager Observers
44
45 // A base class for observing the TextInputManager owned by the given
46 // WebContents. Subclasses could observe the TextInputManager for different
47 // changes. The class wraps a public tester which accepts callbacks that
48 // are run after specific changes in TextInputManager. Different observers can
49 // be subclassed from this by providing their specific callback methods.
50 class TextInputManagerObserverBase {
51 public:
52 explicit TextInputManagerObserverBase(content::WebContents* web_contents)
53 : tester_(new content::TextInputManagerTester(web_contents)),
54 success_(false) {}
55
56 virtual ~TextInputManagerObserverBase() {}
57
58 // Wait for derived class's definition of success.
59 void Wait() {
60 if (success_)
61 return;
62 message_loop_runner_ = new content::MessageLoopRunner();
63 message_loop_runner_->Run();
64 }
65
66 bool success() const { return success_; }
67
68 protected:
69 content::TextInputManagerTester* tester() { return tester_.get(); }
70
71 void OnSuccess() {
72 success_ = true;
73 if (message_loop_runner_)
74 message_loop_runner_->Quit();
75 }
76
77 private:
78 std::unique_ptr<content::TextInputManagerTester> tester_;
79 bool success_;
80 scoped_refptr<content::MessageLoopRunner> message_loop_runner_;
81
82 DISALLOW_COPY_AND_ASSIGN(TextInputManagerObserverBase);
83 };
84
85 // This class observes TextInputManager for changes in |TextInputState.value|.
86 class TextInputManagerValueObserver : public TextInputManagerObserverBase {
87 public:
88 TextInputManagerValueObserver(content::WebContents* web_contents,
89 const std::string& expected_value)
90 : TextInputManagerObserverBase(web_contents),
91 expected_value_(expected_value) {
92 tester()->SetUpdateTextInputStateCalledCallback(base::Bind(
93 &TextInputManagerValueObserver::VerifyValue, base::Unretained(this)));
94 }
95
96 private:
97 void VerifyValue(content::TextInputManagerTester* text_input_manager_tester) {
98 ASSERT_EQ(tester(), text_input_manager_tester);
99 std::string value;
100 if (tester()->GetTextInputValue(&value) && expected_value_ == value)
101 OnSuccess();
102 }
103
104 const std::string expected_value_;
105
106 DISALLOW_COPY_AND_ASSIGN(TextInputManagerValueObserver);
107 };
108
109 // This class observes TextInputManager for changes in |TextInputState.type|.
110 class TextInputManagerTypeObserver : public TextInputManagerObserverBase {
111 public:
112 TextInputManagerTypeObserver(content::WebContents* web_contents,
113 ui::TextInputType expected_type)
114 : TextInputManagerObserverBase(web_contents),
115 expected_type_(expected_type) {
116 tester()->SetUpdateTextInputStateCalledCallback(base::Bind(
117 &TextInputManagerTypeObserver::VerifyType, base::Unretained(this)));
118 }
119
120 private:
121 void VerifyType(content::TextInputManagerTester* text_input_manager_tester) {
122 ASSERT_EQ(tester(), text_input_manager_tester);
123 ui::TextInputType type =
124 tester()->GetTextInputType(&type) ? type : ui::TEXT_INPUT_TYPE_NONE;
125 if (expected_type_ == type)
126 OnSuccess();
127 }
128
129 const ui::TextInputType expected_type_;
130
131 DISALLOW_COPY_AND_ASSIGN(TextInputManagerTypeObserver);
132 };
133
134 // This class observes TextInputManager for the first change in TextInputState.
135 class TextInputManagerChangeObserver : public TextInputManagerObserverBase {
136 public:
137 explicit TextInputManagerChangeObserver(content::WebContents* web_contents)
138 : TextInputManagerObserverBase(web_contents) {
139 tester()->SetUpdateTextInputStateCalledCallback(base::Bind(
140 &TextInputManagerChangeObserver::VerifyChange, base::Unretained(this)));
141 }
142
143 private:
144 void VerifyChange(
145 content::TextInputManagerTester* text_input_manager_tester) {
146 ASSERT_EQ(tester(), text_input_manager_tester);
147 if (tester()->IsTextInputStateChanged())
148 OnSuccess();
149 }
150
151 DISALLOW_COPY_AND_ASSIGN(TextInputManagerChangeObserver);
152 };
153
154 // This class observes |TextInputState.type| for a specific RWHV.
155 class ViewTextInputTypeObserver : public TextInputManagerObserverBase {
156 public:
157 explicit ViewTextInputTypeObserver(content::WebContents* web_contents,
158 content::RenderWidgetHostView* rwhv,
159 ui::TextInputType expected_type)
160 : TextInputManagerObserverBase(web_contents),
161 web_contents_(web_contents),
162 view_(rwhv),
163 expected_type_(expected_type) {
164 tester()->SetUpdateTextInputStateCalledCallback(base::Bind(
165 &ViewTextInputTypeObserver::VerifyType, base::Unretained(this)));
166 }
167
168 private:
169 void VerifyType(content::TextInputManagerTester* tester) {
170 ui::TextInputType type;
171 if (!content::GetTextInputTypeForView(web_contents_, view_, &type))
172 return;
173 if (expected_type_ == type)
174 OnSuccess();
175 }
176
177 content::WebContents* web_contents_;
178 content::RenderWidgetHostView* view_;
179 const ui::TextInputType expected_type_;
180
181 DISALLOW_COPY_AND_ASSIGN(ViewTextInputTypeObserver);
182 };
183
184 } // namespace
185
186 // Main class for all TextInputState and IME related tests.
187 class SitePerProcessTextInputManagerTest : public InProcessBrowserTest {
188 public:
189 SitePerProcessTextInputManagerTest() {}
190 ~SitePerProcessTextInputManagerTest() override {}
191
192 void SetUpCommandLine(base::CommandLine* command_line) override {
193 content::IsolateAllSitesForTesting(command_line);
194 }
195
196 void SetUpOnMainThread() override {
197 host_resolver()->AddRule("*", "127.0.0.1");
198
199 // Add content/test/data 'cross_site_iframe_factory.html'.
200 embedded_test_server()->ServeFilesFromSourceDirectory("content/test/data");
201
202 ASSERT_TRUE(embedded_test_server()->Start());
203 }
204
205 protected:
206 content::WebContents* active_contents() {
207 return browser()->tab_strip_model()->GetActiveWebContents();
208 }
209
210 // static
211 // Adds an <input> field to a given frame by executing javascript code.
212 // The input can be added as the first element or the last element of
213 // |document.body|.
214 static void AddInputFieldToFrame(content::RenderFrameHost* rfh,
215 const std::string& type,
216 const std::string& value,
217 bool append_as_first_child) {
218 std::string script = base::StringPrintf(
219 "var input = document.createElement('input');"
220 "input.setAttribute('type', '%s');"
221 "input.setAttribute('value', '%s');"
222 "document.body.%s;",
223 type.c_str(), value.c_str(),
224 append_as_first_child ? "insertBefore(input, document.body.firstChild)"
225 : "appendChild(input)");
226 EXPECT_TRUE(ExecuteScript(rfh, script));
227 }
228
229 // Uses 'cross_site_iframe_factory.html'. The main frame's domain is
230 // 'a.com'.
231 void CreateIframePage(const std::string& structure) {
232 std::string path = base::StringPrintf("/cross_site_iframe_factory.html?%s",
233 structure.c_str());
234 GURL main_url(embedded_test_server()->GetURL("a.com", path));
235 ui_test_utils::NavigateToURL(browser(), main_url);
236 }
237
238 // Iteratively uses ChildFrameAt(frame, i) to get the i-th child frame
239 // inside frame. For example, for 'a(b(c, d(e)))', [0] returns b, and
240 // [0, 1, 0] returns e;
241 content::RenderFrameHost* GetFrame(const IndexVector& indices) {
242 content::RenderFrameHost* current = active_contents()->GetMainFrame();
243 for (size_t index : indices)
244 current = ChildFrameAt(current, index);
245 return current;
246 }
247
248 private:
249 DISALLOW_COPY_AND_ASSIGN(SitePerProcessTextInputManagerTest);
250 };
251
252 // The following test loads a page with multiple nested <iframe> elements which
253 // are in or out of process with the main frame. Then an <input> field with
254 // unique value is added to every single frame on the frame tree. The test then
255 // creates a sequence of tab presses and verifies that after each key press, the
256 // TextInputState.value reflects that of the focused input, i.e., the
257 // TextInputManager is correctly tracking TextInputState across frames.
258 IN_PROC_BROWSER_TEST_F(SitePerProcessTextInputManagerTest,
259 TrackStateWhenSwitchingFocusedFrames) {
260 CreateIframePage("a(a,b,c(a,b,d(e, f)),g)");
261 std::vector<std::string> values{
262 "main", "node_a", "node_b", "node_c", "node_c_a",
263 "node_c_b", "node_c_d", "node_c_d_e", "node_c_d_f", "node_g"};
264
265 // TODO(ekaramad): The use for explicitly constructing the IndexVector from
266 // initializer list should not be necessary. However, some chromeos bots throw
267 // errors if we do not do it like this.
268 std::vector<content::RenderFrameHost*> frames{
269 GetFrame(IndexVector{}), GetFrame(IndexVector{0}),
270 GetFrame(IndexVector{1}), GetFrame(IndexVector{2}),
271 GetFrame(IndexVector{2, 0}), GetFrame(IndexVector{2, 1}),
272 GetFrame(IndexVector{2, 2}), GetFrame(IndexVector{2, 2, 0}),
273 GetFrame(IndexVector{2, 2, 1}), GetFrame(IndexVector{3})};
274
275 for (size_t i = 0; i < frames.size(); ++i)
276 AddInputFieldToFrame(frames[i], "text", values[i], true);
277
278 for (size_t i = 0; i < frames.size(); ++i) {
279 TextInputManagerValueObserver observer(active_contents(), values[i]);
280 SimulateKeyPress(active_contents(), ui::DomKey::TAB, ui::DomCode::TAB,
281 ui::VKEY_TAB, false, false, false, false);
282 observer.Wait();
283 }
284 }
285
286 // The following test loads a page with two OOPIFs. An <input> is added to both
287 // frames and tab key is pressed until the one in the second OOPIF is focused.
288 // Then, the renderer processes for both frames are crashed. The test verifies
289 // that the TextInputManager stops tracking the RWHVs as well as properly
290 // resets the TextInputState after the second (active) RWHV goes away.
291 IN_PROC_BROWSER_TEST_F(SitePerProcessTextInputManagerTest,
292 StopTrackingCrashedChildFrame) {
293 CreateIframePage("a(b, c)");
294 std::vector<std::string> values{"node_b", "node_c"};
295 std::vector<content::RenderFrameHost*> frames{GetFrame(IndexVector{0}),
296 GetFrame(IndexVector{1})};
297
298 for (size_t i = 0; i < frames.size(); ++i)
299 AddInputFieldToFrame(frames[i], "text", values[i], true);
300
301 // Tab into both inputs and make sure we correctly receive their
302 // TextInputState. For the second tab two IPCs arrive: one from the first
303 // frame to set the state to none, and another one from the second frame to
304 // set it to TEXT. To avoid the race between them, we shall also observe the
305 // first frame setting its state to NONE after the second tab.
306 ViewTextInputTypeObserver view_type_observer(
307 active_contents(), frames[0]->GetView(), ui::TEXT_INPUT_TYPE_NONE);
308
309 for (size_t i = 0; i < frames.size(); ++i) {
310 TextInputManagerValueObserver observer(active_contents(), values[i]);
311 SimulateKeyPress(active_contents(), ui::DomKey::TAB, ui::DomCode::TAB,
312 ui::VKEY_TAB, false, false, false, false);
313 observer.Wait();
314 }
315
316 // Make sure that the first view has set its TextInputState.type to NONE.
317 view_type_observer.Wait();
318
319 // Verify that we are tracking the TextInputState from the first frame.
320 content::RenderWidgetHostView* first_view = frames[0]->GetView();
321 ui::TextInputType first_view_type;
322 EXPECT_TRUE(content::GetTextInputTypeForView(active_contents(), first_view,
323 &first_view_type));
324 EXPECT_EQ(ui::TEXT_INPUT_TYPE_NONE, first_view_type);
325
326 // Now that the second frame's <input> is focused, we crash the first frame
327 // and observe that text input state is updated for the view.
328 std::unique_ptr<content::TestRenderWidgetHostViewDestructionObserver>
329 destruction_observer(
330 new content::TestRenderWidgetHostViewDestructionObserver(first_view));
331 frames[0]->GetProcess()->Shutdown(0, false);
332 destruction_observer->Wait();
333
334 // Verifying that the TextInputManager is no longer tracking TextInputState
335 // for |first_view|. Note that |first_view| is now a dangling pointer.
336 EXPECT_FALSE(content::GetTextInputTypeForView(active_contents(), first_view,
337 &first_view_type));
338
339 // Now crash the second <iframe> which has an active view.
340 content::RenderWidgetHostView* second_view = frames[1]->GetView();
341 TextInputManagerChangeObserver change_observer(active_contents());
342 frames[1]->GetProcess()->Shutdown(0, false);
343 change_observer.Wait();
344 EXPECT_EQ(ui::TEXT_INPUT_TYPE_NONE,
345 content::GetTextInputTypeFromWebContents(active_contents()));
346 EXPECT_FALSE(!!content::GetActiveViewFromWebContents(active_contents()));
347 ui::TextInputType second_view_type;
348 EXPECT_FALSE(content::GetTextInputTypeForView(active_contents(), second_view,
349 &second_view_type));
350 }
351
352 // The following test loads a page with two child frames: one in process and one
353 // out of process with main frame. The test inserts an <input> inside each frame
354 // and focuses the first frame and observes the TextInputManager setting the
355 // state to ui::TEXT_INPUT_TYPE_TEXT. Then, the frame is detached and the test
356 // observes that the state type is reset to ui::TEXT_INPUT_TYPE_NONE. The same
357 // sequence of actions is then performed on the out of process frame.
358 IN_PROC_BROWSER_TEST_F(SitePerProcessTextInputManagerTest,
359 ResetStateAfterFrameDetached) {
360 CreateIframePage("a(a, b)");
361 std::vector<content::RenderFrameHost*> frames{GetFrame(IndexVector{0}),
362 GetFrame(IndexVector{1})};
363
364 for (size_t i = 0; i < frames.size(); ++i)
365 AddInputFieldToFrame(frames[i], "text", "", true);
366
367 // Press tab key to focus the <input> in the first frame.
368 TextInputManagerTypeObserver type_observer_text_a(active_contents(),
369 ui::TEXT_INPUT_TYPE_TEXT);
370 SimulateKeyPress(active_contents(), ui::DomKey::TAB, ui::DomCode::TAB,
371 ui::VKEY_TAB, false, false, false, false);
372 type_observer_text_a.Wait();
373
374 std::string remove_first_iframe_script =
375 "var frame = document.querySelector('iframe');"
376 "frame.parentNode.removeChild(frame);";
377 // Detach first frame and observe |TextInputState.type| resetting to
378 // ui::TEXT_INPUT_TYPE_NONE.
379 TextInputManagerTypeObserver type_observer_none_a(active_contents(),
380 ui::TEXT_INPUT_TYPE_NONE);
381 EXPECT_TRUE(ExecuteScript(active_contents(), remove_first_iframe_script));
382 type_observer_none_a.Wait();
383
384 // Press tab to focus the <input> in the second frame.
385 TextInputManagerTypeObserver type_observer_text_b(active_contents(),
386 ui::TEXT_INPUT_TYPE_TEXT);
387 SimulateKeyPress(active_contents(), ui::DomKey::TAB, ui::DomCode::TAB,
388 ui::VKEY_TAB, false, false, false, false);
389 type_observer_text_b.Wait();
390
391 // Detach first frame and observe |TextInputState.type| resetting to
392 // ui::TEXT_INPUT_TYPE_NONE.
393 TextInputManagerTypeObserver type_observer_none_b(active_contents(),
394 ui::TEXT_INPUT_TYPE_NONE);
395 EXPECT_TRUE(ExecuteScript(active_contents(), remove_first_iframe_script));
396 type_observer_none_b.Wait();
397 }
398
399 // This test creates a page with one OOPIF and adds an <input> to it. Then, the
400 // <input> is focused and the test verfies that the |TextInputState.type| is set
401 // to ui::TEXT_INPUT_TYPE_TEXT. Next, the child frame is navigated away and the
402 // test verifies that |TextInputState.type| resets to ui::TEXT_INPUT_TYPE_NONE.
403 IN_PROC_BROWSER_TEST_F(SitePerProcessTextInputManagerTest,
404 ResetStateAfterChildNavigation) {
405 CreateIframePage("a(b)");
406 content::RenderFrameHost* main_frame = GetFrame(IndexVector{});
407 content::RenderFrameHost* child_frame = GetFrame(IndexVector{0});
408
409 AddInputFieldToFrame(child_frame, "text", "child", false);
410
411 // Focus <input> in child frame and verify the |TextInputState.value|.
412 TextInputManagerValueObserver child_set_state_observer(active_contents(),
413 "child");
414 SimulateKeyPress(active_contents(), ui::DomKey::TAB, ui::DomCode::TAB,
415 ui::VKEY_TAB, false, false, false, false);
416 child_set_state_observer.Wait();
417
418 // Navigate the child frame to about:blank and verify that TextInputManager
419 // correctly sets its |TextInputState.type| to ui::TEXT_INPUT_TYPE_NONE.
420 TextInputManagerTypeObserver child_reset_state_observer(
421 active_contents(), ui::TEXT_INPUT_TYPE_NONE);
422 EXPECT_TRUE(ExecuteScript(
423 main_frame, "document.querySelector('iframe').src = 'about:blank'"));
424 child_reset_state_observer.Wait();
425 }
426
427 // This test creates a blank page and adds an <input> to it. Then, the <input>
428 // is focused and the test verfies that the |TextInputState.type| is set to
429 // ui::TEXT_INPUT_TYPE_TEXT. Next, the browser is navigated away and the test
430 // verifies that |TextInputState.type| resets to ui::TEXT_INPUT_TYPE_NONE.
431 IN_PROC_BROWSER_TEST_F(SitePerProcessTextInputManagerTest,
432 ResetStateAfterBrowserNavigation) {
433 CreateIframePage("a()");
434 content::RenderFrameHost* main_frame = GetFrame(IndexVector{});
435 AddInputFieldToFrame(main_frame, "text", "", false);
436
437 TextInputManagerTypeObserver set_state_observer(active_contents(),
438 ui::TEXT_INPUT_TYPE_TEXT);
439 SimulateKeyPress(active_contents(), ui::DomKey::TAB, ui::DomCode::TAB,
440 ui::VKEY_TAB, false, false, false, false);
441 set_state_observer.Wait();
442
443 TextInputManagerTypeObserver reset_state_observer(active_contents(),
444 ui::TEXT_INPUT_TYPE_NONE);
445 ui_test_utils::NavigateToURL(browser(), GURL("about:blank"));
446 reset_state_observer.Wait();
447 }
448
449 // TODO(ekaramad): The following tests are specifically written for Aura and are
450 // based on InputMethodObserver. Write similar tests for Mac/Android/Mus
451 // (crbug.com/602723).
452
453 // Observes current input method for state changes.
454 class InputMethodObserverBase {
455 public:
456 explicit InputMethodObserverBase(content::WebContents* web_contents)
457 : success_(false),
458 test_observer_(content::TestInputMethodObserver::Create(web_contents)) {
459 }
460
461 void Wait() {
462 if (success_)
463 return;
464 message_loop_runner_ = new content::MessageLoopRunner();
465 message_loop_runner_->Run();
466 }
467
468 bool success() const { return success_; }
469
470 protected:
471 content::TestInputMethodObserver* test_observer() {
472 return test_observer_.get();
473 }
474
475 const base::Closure success_closure() {
476 return base::Bind(&InputMethodObserverBase::OnSuccess,
477 base::Unretained(this));
478 }
479
480 private:
481 void OnSuccess() {
482 success_ = true;
483 if (message_loop_runner_)
484 message_loop_runner_->Quit();
485 }
486
487 bool success_;
488 std::unique_ptr<content::TestInputMethodObserver> test_observer_;
489 scoped_refptr<content::MessageLoopRunner> message_loop_runner_;
490
491 DISALLOW_COPY_AND_ASSIGN(InputMethodObserverBase);
492 };
493
494 class InputMethodObserverForShowIme : public InputMethodObserverBase {
495 public:
496 explicit InputMethodObserverForShowIme(content::WebContents* web_contents)
497 : InputMethodObserverBase(web_contents) {
498 test_observer()->SetOnShowImeIfNeededCallback(success_closure());
499 }
500
501 private:
502 DISALLOW_COPY_AND_ASSIGN(InputMethodObserverForShowIme);
503 };
504
505 // This test verifies that the IME for Aura is shown if and only if the current
506 // client's |TextInputState.type| is not ui::TEXT_INPUT_TYPE_NONE and the flag
507 // |TextInputState.show_ime_if_needed| is true. This should happen even when
508 // the TextInputState has not changed (according to the platform), e.g., in
509 // aura when receiving two consecutive updates with same |TextInputState.type|.
510 // TODO(ekaramad): This test is actually a unit test not necessarily an OOPIF
511 // test. We should move it to somewhere more relevant.
512 IN_PROC_BROWSER_TEST_F(SitePerProcessTextInputManagerTest,
513 CorrectlyShowImeIfNeeded) {
514 // We only need the <iframe> page to create RWHV.
515 CreateIframePage("a()");
516 content::RenderFrameHost* main_frame = GetFrame(IndexVector{});
517 content::RenderWidgetHostView* view = main_frame->GetView();
518 content::WebContents* web_contents = active_contents();
519
520 content::TextInputStateSender sender(view);
521
522 auto send_and_check_show_ime = [&sender, &web_contents]() {
523 InputMethodObserverForShowIme observer(web_contents);
524 sender.Send();
525 return observer.success();
526 };
527
528 // Sending an empty state should not trigger ime.
529 EXPECT_FALSE(send_and_check_show_ime());
530
531 // Set |TextInputState.type| to text. Expect no IME.
532 sender.SetType(ui::TEXT_INPUT_TYPE_TEXT);
533 EXPECT_FALSE(send_and_check_show_ime());
534
535 // Set |TextInputState.show_ime_if_needed| to true. Expect IME.
536 sender.SetShowImeIfNeeded(true);
537 EXPECT_TRUE(send_and_check_show_ime());
538
539 // Send the same message. Expect IME (no change).
540 EXPECT_TRUE(send_and_check_show_ime());
541
542 // Reset |TextInputState.show_ime_if_needed|. Expect no IME.
543 sender.SetShowImeIfNeeded(false);
544 EXPECT_FALSE(send_and_check_show_ime());
545
546 // Setting an irrelevant field. Expect no IME.
547 sender.SetMode(ui::TEXT_INPUT_MODE_LATIN);
548 EXPECT_FALSE(send_and_check_show_ime());
549
550 // Set |TextInputState.show_ime_if_needed|. Expect IME.
551 sender.SetShowImeIfNeeded(true);
552 EXPECT_TRUE(send_and_check_show_ime());
553
554 // Set |TextInputState.type| to ui::TEXT_INPUT_TYPE_NONE. Expect no IME.
555 sender.SetType(ui::TEXT_INPUT_TYPE_NONE);
556 EXPECT_FALSE(send_and_check_show_ime());
557 }
OLDNEW
« no previous file with comments | « no previous file | chrome/test/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698