OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <vector> | 5 #include <vector> |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "chrome/browser/ui/browser.h" | 9 #include "chrome/browser/ui/browser.h" |
10 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 10 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
11 #include "chrome/test/base/in_process_browser_test.h" | 11 #include "chrome/test/base/in_process_browser_test.h" |
12 #include "chrome/test/base/ui_test_utils.h" | 12 #include "chrome/test/base/ui_test_utils.h" |
13 #include "content/public/browser/render_frame_host.h" | 13 #include "content/public/browser/render_frame_host.h" |
14 #include "content/public/browser/render_process_host.h" | 14 #include "content/public/browser/render_process_host.h" |
15 #include "content/public/browser/render_widget_host_view.h" | 15 #include "content/public/browser/render_widget_host_view.h" |
16 #include "content/public/browser/web_contents.h" | 16 #include "content/public/browser/web_contents.h" |
17 #include "content/public/test/browser_test_utils.h" | 17 #include "content/public/test/browser_test_utils.h" |
18 #include "content/public/test/content_browser_test_utils.h" | 18 #include "content/public/test/content_browser_test_utils.h" |
19 #include "content/public/test/test_utils.h" | 19 #include "content/public/test/test_utils.h" |
20 #include "content/public/test/text_input_test_utils.h" | 20 #include "content/public/test/text_input_test_utils.h" |
21 #include "net/dns/mock_host_resolver.h" | 21 #include "net/dns/mock_host_resolver.h" |
22 #include "net/test/embedded_test_server/embedded_test_server.h" | 22 #include "net/test/embedded_test_server/embedded_test_server.h" |
23 #include "ui/base/ime/composition_underline.h" | 23 #include "ui/base/ime/composition_underline.h" |
24 #include "ui/base/ime/text_input_client.h" | 24 #include "ui/base/ime/text_input_client.h" |
25 #include "ui/base/ime/text_input_mode.h" | 25 #include "ui/base/ime/text_input_mode.h" |
26 #include "ui/base/ime/text_input_type.h" | 26 #include "ui/base/ime/text_input_type.h" |
27 #include "url/gurl.h" | 27 #include "url/gurl.h" |
28 | 28 |
29 // TODO(ekaramad): The following tests are only active on aura platforms. After | 29 // TODO(ekaramad): The following tests are only active on aura platforms. After |
Charlie Reis
2016/07/22 20:59:35
This looks stale now.
EhsanK
2016/07/25 17:12:02
Acknowledged.
| |
30 // fixing crbug.com/578168 for all platforms, the following tests should be | 30 // fixing crbug.com/578168 for all platforms, the following tests should be |
31 // activated for other platforms, e.g., Mac and Android (crbug.com/602723). | 31 // activated for other platforms, e.g., Mac and Android (crbug.com/602723). |
32 | 32 |
33 /////////////////////////////////////////////////////////////////////////////// | 33 /////////////////////////////////////////////////////////////////////////////// |
34 // TextInputManager and IME Tests | 34 // TextInputManager and IME Tests |
35 // | 35 // |
36 // The following tests verify the correctness of TextInputState tracking on the | 36 // The following tests verify the correctness of TextInputState tracking on the |
37 // browser side. They also make sure the IME logic works correctly. The baseline | 37 // browser side. They also make sure the IME logic works correctly. The baseline |
38 // for comparison is the default functionality in the non-OOPIF case (i.e., the | 38 // for comparison is the default functionality in the non-OOPIF case (i.e., the |
39 // legacy implementation in RWHV's other than RWHVCF). | 39 // legacy implementation in RWHV's other than RWHVCF). |
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
499 SimulateKeyPress(active_contents(), ui::DomKey::TAB, ui::DomCode::TAB, | 499 SimulateKeyPress(active_contents(), ui::DomKey::TAB, ui::DomCode::TAB, |
500 ui::VKEY_TAB, false, false, false, false); | 500 ui::VKEY_TAB, false, false, false, false); |
501 set_state_observer.Wait(); | 501 set_state_observer.Wait(); |
502 | 502 |
503 TextInputManagerTypeObserver reset_state_observer(active_contents(), | 503 TextInputManagerTypeObserver reset_state_observer(active_contents(), |
504 ui::TEXT_INPUT_TYPE_NONE); | 504 ui::TEXT_INPUT_TYPE_NONE); |
505 ui_test_utils::NavigateToURL(browser(), GURL("about:blank")); | 505 ui_test_utils::NavigateToURL(browser(), GURL("about:blank")); |
506 reset_state_observer.Wait(); | 506 reset_state_observer.Wait(); |
507 } | 507 } |
508 | 508 |
509 // TODO(ekaramad): Enable the following tests on other platforms when the | |
510 // corresponding feature is implemented (http://crbug.com/578168). | |
kenrb
2016/07/21 21:48:16
Is it much extra to implement all of it in this CL
Charlie Reis
2016/07/22 20:59:35
I'm ok either way, but I have a slight preference
EhsanK
2016/07/25 17:12:02
I have fixes for some of the other IME-related tra
Charlie Reis
2016/07/25 19:43:55
Let's keep the CLs small and proceed incrementally
| |
511 #if defined(USE_AURA) | |
509 // This test creates a page with multiple child frames and adds an <input> to | 512 // This test creates a page with multiple child frames and adds an <input> to |
510 // each frame. Then, sequentially, each <input> is focused by sending a tab key. | 513 // each frame. Then, sequentially, each <input> is focused by sending a tab key. |
511 // Then, after |TextInputState.type| for a view is changed to text, another key | 514 // Then, after |TextInputState.type| for a view is changed to text, another key |
512 // is pressed (a character) and then the test verifies that TextInputManager | 515 // is pressed (a character) and then the test verifies that TextInputManager |
513 // receives the corresponding update on the change in selection bounds on the | 516 // receives the corresponding update on the change in selection bounds on the |
514 // browser side. | 517 // browser side. |
515 IN_PROC_BROWSER_TEST_F(SitePerProcessTextInputManagerTest, | 518 IN_PROC_BROWSER_TEST_F(SitePerProcessTextInputManagerTest, |
516 TrackSelectionBoundsForAllFrames) { | 519 TrackSelectionBoundsForAllFrames) { |
517 CreateIframePage("a(b,c(a,b),d)"); | 520 CreateIframePage("a(b,c(a,b),d)"); |
518 std::vector<content::RenderFrameHost*> frames{ | 521 std::vector<content::RenderFrameHost*> frames{ |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
574 ViewCompositionRangeChangedObserver range_observer(web_contents, view); | 577 ViewCompositionRangeChangedObserver range_observer(web_contents, view); |
575 content::SetCompositionForRenderWidgetHost( | 578 content::SetCompositionForRenderWidgetHost( |
576 view->GetRenderWidgetHost(), base::ASCIIToUTF16("text"), | 579 view->GetRenderWidgetHost(), base::ASCIIToUTF16("text"), |
577 {ui::CompositionUnderline()}, gfx::Range::InvalidRange(), 0, 0); | 580 {ui::CompositionUnderline()}, gfx::Range::InvalidRange(), 0, 0); |
578 range_observer.Wait(); | 581 range_observer.Wait(); |
579 }; | 582 }; |
580 | 583 |
581 for (auto view : views) | 584 for (auto view : views) |
582 send_tab_set_composition_wait_for_bounds_change(view); | 585 send_tab_set_composition_wait_for_bounds_change(view); |
583 } | 586 } |
587 #endif // USE_AURA | |
584 | 588 |
585 // TODO(ekaramad): The following tests are specifically written for Aura and are | 589 // TODO(ekaramad): The following tests are specifically written for Aura and are |
586 // based on InputMethodObserver. Write similar tests for Mac/Android/Mus | 590 // based on InputMethodObserver. Write similar tests for Mac/Android/Mus |
587 // (crbug.com/602723). | 591 // (crbug.com/602723). |
588 | 592 |
593 #if defined(USE_AURA) | |
589 // Observes current input method for state changes. | 594 // Observes current input method for state changes. |
590 class InputMethodObserverBase { | 595 class InputMethodObserverBase { |
591 public: | 596 public: |
592 explicit InputMethodObserverBase(content::WebContents* web_contents) | 597 explicit InputMethodObserverBase(content::WebContents* web_contents) |
593 : success_(false), | 598 : success_(false), |
594 test_observer_(content::TestInputMethodObserver::Create(web_contents)) { | 599 test_observer_(content::TestInputMethodObserver::Create(web_contents)) { |
595 } | 600 } |
596 | 601 |
597 void Wait() { | 602 void Wait() { |
598 if (success_) | 603 if (success_) |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
684 EXPECT_FALSE(send_and_check_show_ime()); | 689 EXPECT_FALSE(send_and_check_show_ime()); |
685 | 690 |
686 // Set |TextInputState.show_ime_if_needed|. Expect IME. | 691 // Set |TextInputState.show_ime_if_needed|. Expect IME. |
687 sender.SetShowImeIfNeeded(true); | 692 sender.SetShowImeIfNeeded(true); |
688 EXPECT_TRUE(send_and_check_show_ime()); | 693 EXPECT_TRUE(send_and_check_show_ime()); |
689 | 694 |
690 // Set |TextInputState.type| to ui::TEXT_INPUT_TYPE_NONE. Expect no IME. | 695 // Set |TextInputState.type| to ui::TEXT_INPUT_TYPE_NONE. Expect no IME. |
691 sender.SetType(ui::TEXT_INPUT_TYPE_NONE); | 696 sender.SetType(ui::TEXT_INPUT_TYPE_NONE); |
692 EXPECT_FALSE(send_and_check_show_ime()); | 697 EXPECT_FALSE(send_and_check_show_ime()); |
693 } | 698 } |
699 #endif | |
OLD | NEW |