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

Side by Side Diff: content/renderer/render_view_browsertest.cc

Issue 2466283002: [WIP Approach 2] Straighten up input method reactivation
Patch Set: Created 4 years, 1 month 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 #include <tuple> 7 #include <tuple>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 1734 matching lines...) Expand 10 before | Expand all | Expand 10 after
1745 TEST_F(RenderViewImplTest, BasicRenderFrame) { 1745 TEST_F(RenderViewImplTest, BasicRenderFrame) {
1746 EXPECT_TRUE(view()->main_render_frame_); 1746 EXPECT_TRUE(view()->main_render_frame_);
1747 } 1747 }
1748 1748
1749 TEST_F(RenderViewImplTest, MessageOrderInDidChangeSelection) { 1749 TEST_F(RenderViewImplTest, MessageOrderInDidChangeSelection) {
1750 LoadHTML("<textarea id=\"test\"></textarea>"); 1750 LoadHTML("<textarea id=\"test\"></textarea>");
1751 1751
1752 view()->SetHandlingInputEventForTesting(true); 1752 view()->SetHandlingInputEventForTesting(true);
1753 ExecuteJavaScriptForTests("document.getElementById('test').focus();"); 1753 ExecuteJavaScriptForTests("document.getElementById('test').focus();");
1754 1754
1755 bool is_input_type_called = false; 1755 int first_input_type = -1;
1756 bool is_selection_called = false; 1756 int first_selection = -1;
1757 size_t last_input_type = 0;
1758 size_t last_selection = 0;
1759 1757
1760 for (size_t i = 0; i < render_thread_->sink().message_count(); ++i) { 1758 for (size_t i = 0; i < render_thread_->sink().message_count(); ++i) {
1761 const uint32_t type = render_thread_->sink().GetMessageAt(i)->type(); 1759 const uint32_t type = render_thread_->sink().GetMessageAt(i)->type();
1762 if (type == ViewHostMsg_TextInputStateChanged::ID) { 1760 if (type == ViewHostMsg_TextInputStateChanged::ID) {
1763 is_input_type_called = true; 1761 if (first_input_type == -1)
1764 last_input_type = i; 1762 first_input_type = static_cast<int>(i);
1765 } else if (type == FrameHostMsg_SelectionChanged::ID) { 1763 } else if (type == FrameHostMsg_SelectionChanged::ID) {
1766 is_selection_called = true; 1764 if (first_selection == -1)
1767 last_selection = i; 1765 first_selection = static_cast<int>(i);
1768 } 1766 }
1769 } 1767 }
1770 1768
1771 EXPECT_TRUE(is_input_type_called); 1769 EXPECT_NE(first_input_type, -1);
1772 EXPECT_TRUE(is_selection_called); 1770 EXPECT_NE(first_selection, -1);
1773 1771 // InputTypeChange should be called earlier than SelectionChanged.
1774 // InputTypeChange shold be called earlier than SelectionChanged. 1772 EXPECT_LT(first_input_type, first_selection);
1775 EXPECT_LT(last_input_type, last_selection);
1776 } 1773 }
1777 1774
1778 class RendererErrorPageTest : public RenderViewImplTest { 1775 class RendererErrorPageTest : public RenderViewImplTest {
1779 public: 1776 public:
1780 ContentRendererClient* CreateContentRendererClient() override { 1777 ContentRendererClient* CreateContentRendererClient() override {
1781 return new TestContentRendererClient; 1778 return new TestContentRendererClient;
1782 } 1779 }
1783 1780
1784 RenderViewImpl* view() { 1781 RenderViewImpl* view() {
1785 return static_cast<RenderViewImpl*>(view_); 1782 return static_cast<RenderViewImpl*>(view_);
(...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after
2538 ExpectPauseAndResume(3); 2535 ExpectPauseAndResume(3);
2539 blink::WebScriptSource source2( 2536 blink::WebScriptSource source2(
2540 WebString::fromUTF8("function func2() { func1(); }; func2();")); 2537 WebString::fromUTF8("function func2() { func1(); }; func2();"));
2541 frame()->GetWebFrame()->executeScriptInIsolatedWorld(17, &source2, 1, 1); 2538 frame()->GetWebFrame()->executeScriptInIsolatedWorld(17, &source2, 1, 1);
2542 2539
2543 EXPECT_FALSE(IsPaused()); 2540 EXPECT_FALSE(IsPaused());
2544 Detach(); 2541 Detach();
2545 } 2542 }
2546 2543
2547 } // namespace content 2544 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698