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

Side by Side Diff: content/renderer/render_view_browsertest_mac.mm

Issue 1831423003: Audit test code callsites that need an explicit lifecycle update. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Clean up. Created 4 years, 8 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 | « content/renderer/render_view_browsertest.cc ('k') | content/renderer/render_view_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/strings/string16.h" 5 #include "base/strings/string16.h"
6 #include "base/strings/string_util.h" 6 #include "base/strings/string_util.h"
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "content/public/browser/native_web_keyboard_event.h" 8 #include "content/public/browser/native_web_keyboard_event.h"
9 #include "content/public/common/web_preferences.h" 9 #include "content/public/common/web_preferences.h"
10 #include "content/public/test/render_view_test.h" 10 #include "content/public/test/render_view_test.h"
11 #include "content/renderer/render_view_impl.h" 11 #include "content/renderer/render_view_impl.h"
12 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
13 #include "third_party/WebKit/public/web/WebFrameContentDumper.h" 13 #include "third_party/WebKit/public/web/WebFrameContentDumper.h"
14 #include "third_party/WebKit/public/web/WebLocalFrame.h" 14 #include "third_party/WebKit/public/web/WebLocalFrame.h"
15 #include "third_party/WebKit/public/web/WebView.h"
15 16
16 #include <Carbon/Carbon.h> // for the kVK_* constants. 17 #include <Carbon/Carbon.h> // for the kVK_* constants.
17 #include <Cocoa/Cocoa.h> 18 #include <Cocoa/Cocoa.h>
18 19
19 using blink::WebFrameContentDumper; 20 using blink::WebFrameContentDumper;
20 21
21 namespace content { 22 namespace content {
22 23
23 NSEvent* CmdDeadKeyEvent(NSEventType type, unsigned short code) { 24 NSEvent* CmdDeadKeyEvent(NSEventType type, unsigned short code) {
24 UniChar uniChar = 0; 25 UniChar uniChar = 0;
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 view->set_send_content_state_immediately(true); 101 view->set_send_content_state_immediately(true);
101 LoadHTML(kRawHtml); 102 LoadHTML(kRawHtml);
102 render_thread_->sink().ClearMessages(); 103 render_thread_->sink().ClearMessages();
103 104
104 const char* kArrowDownScrollDown = "40,false,false,true,false\n10144\np1"; 105 const char* kArrowDownScrollDown = "40,false,false,true,false\n10144\np1";
105 view->OnSetEditCommandsForNextKeyEvent( 106 view->OnSetEditCommandsForNextKeyEvent(
106 EditCommands(1, EditCommand("moveToEndOfDocument", ""))); 107 EditCommands(1, EditCommand("moveToEndOfDocument", "")));
107 SendNativeKeyEvent(NativeWebKeyboardEvent(arrowDownKeyDown)); 108 SendNativeKeyEvent(NativeWebKeyboardEvent(arrowDownKeyDown));
108 ProcessPendingMessages(); 109 ProcessPendingMessages();
109 ExecuteJavaScriptForTests("scroll.textContent = window.pageYOffset"); 110 ExecuteJavaScriptForTests("scroll.textContent = window.pageYOffset");
110 output = WebFrameContentDumper::dumpFrameTreeAsText(GetMainFrame(), 111 output = WebFrameContentDumper::dumpWebViewAsText(view->GetWebView(),
111 kMaxOutputCharacters); 112 kMaxOutputCharacters);
112 EXPECT_EQ(kArrowDownScrollDown, base::UTF16ToASCII(output)); 113 EXPECT_EQ(kArrowDownScrollDown, base::UTF16ToASCII(output));
113 114
114 const char* kArrowUpScrollUp = "38,false,false,true,false\n0\np1"; 115 const char* kArrowUpScrollUp = "38,false,false,true,false\n0\np1";
115 view->OnSetEditCommandsForNextKeyEvent( 116 view->OnSetEditCommandsForNextKeyEvent(
116 EditCommands(1, EditCommand("moveToBeginningOfDocument", ""))); 117 EditCommands(1, EditCommand("moveToBeginningOfDocument", "")));
117 SendNativeKeyEvent(NativeWebKeyboardEvent(arrowUpKeyDown)); 118 SendNativeKeyEvent(NativeWebKeyboardEvent(arrowUpKeyDown));
118 ProcessPendingMessages(); 119 ProcessPendingMessages();
119 ExecuteJavaScriptForTests("scroll.textContent = window.pageYOffset"); 120 ExecuteJavaScriptForTests("scroll.textContent = window.pageYOffset");
120 output = WebFrameContentDumper::dumpFrameTreeAsText(GetMainFrame(), 121 output = WebFrameContentDumper::dumpWebViewAsText(view->GetWebView(),
121 kMaxOutputCharacters); 122 kMaxOutputCharacters);
122 EXPECT_EQ(kArrowUpScrollUp, base::UTF16ToASCII(output)); 123 EXPECT_EQ(kArrowUpScrollUp, base::UTF16ToASCII(output));
123 124
124 // Now let javascript eat the key events -- no scrolling should happen. 125 // Now let javascript eat the key events -- no scrolling should happen.
125 // Set a scroll position slightly down the page to ensure that it does not 126 // Set a scroll position slightly down the page to ensure that it does not
126 // move. 127 // move.
127 ExecuteJavaScriptForTests("allowKeyEvents = false; window.scrollTo(0, 100)"); 128 ExecuteJavaScriptForTests("allowKeyEvents = false; window.scrollTo(0, 100)");
128 129
129 const char* kArrowDownNoScroll = "40,false,false,true,false\n100\np1"; 130 const char* kArrowDownNoScroll = "40,false,false,true,false\n100\np1";
130 view->OnSetEditCommandsForNextKeyEvent( 131 view->OnSetEditCommandsForNextKeyEvent(
131 EditCommands(1, EditCommand("moveToEndOfDocument", ""))); 132 EditCommands(1, EditCommand("moveToEndOfDocument", "")));
132 SendNativeKeyEvent(NativeWebKeyboardEvent(arrowDownKeyDown)); 133 SendNativeKeyEvent(NativeWebKeyboardEvent(arrowDownKeyDown));
133 ProcessPendingMessages(); 134 ProcessPendingMessages();
134 ExecuteJavaScriptForTests("scroll.textContent = window.pageYOffset"); 135 ExecuteJavaScriptForTests("scroll.textContent = window.pageYOffset");
135 output = WebFrameContentDumper::dumpFrameTreeAsText(GetMainFrame(), 136 output = WebFrameContentDumper::dumpWebViewAsText(view->GetWebView(),
136 kMaxOutputCharacters); 137 kMaxOutputCharacters);
137 EXPECT_EQ(kArrowDownNoScroll, base::UTF16ToASCII(output)); 138 EXPECT_EQ(kArrowDownNoScroll, base::UTF16ToASCII(output));
138 139
139 const char* kArrowUpNoScroll = "38,false,false,true,false\n100\np1"; 140 const char* kArrowUpNoScroll = "38,false,false,true,false\n100\np1";
140 view->OnSetEditCommandsForNextKeyEvent( 141 view->OnSetEditCommandsForNextKeyEvent(
141 EditCommands(1, EditCommand("moveToBeginningOfDocument", ""))); 142 EditCommands(1, EditCommand("moveToBeginningOfDocument", "")));
142 SendNativeKeyEvent(NativeWebKeyboardEvent(arrowUpKeyDown)); 143 SendNativeKeyEvent(NativeWebKeyboardEvent(arrowUpKeyDown));
143 ProcessPendingMessages(); 144 ProcessPendingMessages();
144 ExecuteJavaScriptForTests("scroll.textContent = window.pageYOffset"); 145 ExecuteJavaScriptForTests("scroll.textContent = window.pageYOffset");
145 output = WebFrameContentDumper::dumpFrameTreeAsText(GetMainFrame(), 146 output = WebFrameContentDumper::dumpWebViewAsText(view->GetWebView(),
146 kMaxOutputCharacters); 147 kMaxOutputCharacters);
147 EXPECT_EQ(kArrowUpNoScroll, base::UTF16ToASCII(output)); 148 EXPECT_EQ(kArrowUpNoScroll, base::UTF16ToASCII(output));
148 } 149 }
149 150
150 } // namespace content 151 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_view_browsertest.cc ('k') | content/renderer/render_view_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698