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

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

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
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 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 1259 matching lines...) Expand 10 before | Expand all | Expand 10 after
1270 // Update the status of our IME back-end. 1270 // Update the status of our IME back-end.
1271 // TODO(hbono): we should verify messages to be sent from the back-end. 1271 // TODO(hbono): we should verify messages to be sent from the back-end.
1272 view()->UpdateTextInputState(ShowIme::HIDE_IME, ChangeSource::FROM_NON_IME); 1272 view()->UpdateTextInputState(ShowIme::HIDE_IME, ChangeSource::FROM_NON_IME);
1273 ProcessPendingMessages(); 1273 ProcessPendingMessages();
1274 render_thread_->sink().ClearMessages(); 1274 render_thread_->sink().ClearMessages();
1275 1275
1276 if (ime_message->result) { 1276 if (ime_message->result) {
1277 // Retrieve the content of this page and compare it with the expected 1277 // Retrieve the content of this page and compare it with the expected
1278 // result. 1278 // result.
1279 const int kMaxOutputCharacters = 128; 1279 const int kMaxOutputCharacters = 128;
1280 base::string16 output = WebFrameContentDumper::dumpFrameTreeAsText( 1280 base::string16 output = WebFrameContentDumper::dumpWebViewAsText(
1281 GetMainFrame(), kMaxOutputCharacters); 1281 view()->GetWebView(), kMaxOutputCharacters);
1282 EXPECT_EQ(base::WideToUTF16(ime_message->result), output); 1282 EXPECT_EQ(base::WideToUTF16(ime_message->result), output);
1283 } 1283 }
1284 } 1284 }
1285 } 1285 }
1286 1286
1287 // Test that the RenderView::OnSetTextDirection() function can change the text 1287 // Test that the RenderView::OnSetTextDirection() function can change the text
1288 // direction of the selected input element. 1288 // direction of the selected input element.
1289 TEST_F(RenderViewImplTest, OnSetTextDirection) { 1289 TEST_F(RenderViewImplTest, OnSetTextDirection) {
1290 // Load an HTML page consisting of a <textarea> element and a <div> element. 1290 // Load an HTML page consisting of a <textarea> element and a <div> element.
1291 // This test changes the text direction of the <textarea> element, and 1291 // This test changes the text direction of the <textarea> element, and
(...skipping 27 matching lines...) Expand all
1319 "var result = document.getElementById('result');" 1319 "var result = document.getElementById('result');"
1320 "var node = document.getElementById('test');" 1320 "var node = document.getElementById('test');"
1321 "var style = getComputedStyle(node, null);" 1321 "var style = getComputedStyle(node, null);"
1322 "result.innerText =" 1322 "result.innerText ="
1323 " node.getAttribute('dir') + ',' +" 1323 " node.getAttribute('dir') + ',' +"
1324 " style.getPropertyValue('direction');"); 1324 " style.getPropertyValue('direction');");
1325 1325
1326 // Copy the document content to std::wstring and compare with the 1326 // Copy the document content to std::wstring and compare with the
1327 // expected result. 1327 // expected result.
1328 const int kMaxOutputCharacters = 16; 1328 const int kMaxOutputCharacters = 16;
1329 base::string16 output = WebFrameContentDumper::dumpFrameTreeAsText( 1329 base::string16 output = WebFrameContentDumper::dumpWebViewAsText(
1330 GetMainFrame(), kMaxOutputCharacters); 1330 view()->GetWebView(), kMaxOutputCharacters);
1331 EXPECT_EQ(base::WideToUTF16(kTextDirection[i].expected_result), output); 1331 EXPECT_EQ(base::WideToUTF16(kTextDirection[i].expected_result), output);
1332 } 1332 }
1333 } 1333 }
1334 1334
1335 // Crashy, http://crbug.com/53247. 1335 // Crashy, http://crbug.com/53247.
1336 TEST_F(RenderViewImplTest, DISABLED_DidFailProvisionalLoadWithErrorForError) { 1336 TEST_F(RenderViewImplTest, DISABLED_DidFailProvisionalLoadWithErrorForError) {
1337 GetMainFrame()->enableViewSourceMode(true); 1337 GetMainFrame()->enableViewSourceMode(true);
1338 WebURLError error; 1338 WebURLError error;
1339 error.domain = WebString::fromUTF8(net::kErrorDomain); 1339 error.domain = WebString::fromUTF8(net::kErrorDomain);
1340 error.reason = net::ERR_FILE_NOT_FOUND; 1340 error.reason = net::ERR_FILE_NOT_FOUND;
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
1662 TestRenderFrame* subframe = 1662 TestRenderFrame* subframe =
1663 static_cast<TestRenderFrame*>(RenderFrameImpl::FromWebFrame( 1663 static_cast<TestRenderFrame*>(RenderFrameImpl::FromWebFrame(
1664 view()->webview()->findFrameByName("frame"))); 1664 view()->webview()->findFrameByName("frame")));
1665 subframe->Navigate(common_params, StartNavigationParams(), request_params); 1665 subframe->Navigate(common_params, StartNavigationParams(), request_params);
1666 FrameLoadWaiter(subframe).Wait(); 1666 FrameLoadWaiter(subframe).Wait();
1667 1667
1668 // Copy the document content to std::wstring and compare with the 1668 // Copy the document content to std::wstring and compare with the
1669 // expected result. 1669 // expected result.
1670 const int kMaxOutputCharacters = 256; 1670 const int kMaxOutputCharacters = 256;
1671 std::string output = base::UTF16ToUTF8( 1671 std::string output = base::UTF16ToUTF8(
1672 base::StringPiece16(WebFrameContentDumper::dumpFrameTreeAsText( 1672 base::StringPiece16(WebFrameContentDumper::dumpWebViewAsText(
1673 GetMainFrame(), kMaxOutputCharacters))); 1673 view()->GetWebView(), kMaxOutputCharacters)));
1674 EXPECT_EQ(output, "hello \n\nworld"); 1674 EXPECT_EQ(output, "hello \n\nworld");
1675 } 1675 }
1676 1676
1677 // This test ensures that a RenderFrame object is created for the top level 1677 // This test ensures that a RenderFrame object is created for the top level
1678 // frame in the RenderView. 1678 // frame in the RenderView.
1679 TEST_F(RenderViewImplTest, BasicRenderFrame) { 1679 TEST_F(RenderViewImplTest, BasicRenderFrame) {
1680 EXPECT_TRUE(view()->main_render_frame_); 1680 EXPECT_TRUE(view()->main_render_frame_);
1681 } 1681 }
1682 1682
1683 TEST_F(RenderViewImplTest, GetSSLStatusOfFrame) { 1683 TEST_F(RenderViewImplTest, GetSSLStatusOfFrame) {
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
1783 common_params.url = GURL("data:text/html,test data"); 1783 common_params.url = GURL("data:text/html,test data");
1784 TestRenderFrame* main_frame = static_cast<TestRenderFrame*>(frame()); 1784 TestRenderFrame* main_frame = static_cast<TestRenderFrame*>(frame());
1785 main_frame->Navigate(common_params, StartNavigationParams(), 1785 main_frame->Navigate(common_params, StartNavigationParams(),
1786 RequestNavigationParams()); 1786 RequestNavigationParams());
1787 1787
1788 // An error occurred. 1788 // An error occurred.
1789 main_frame->didFailProvisionalLoad(web_frame, error, 1789 main_frame->didFailProvisionalLoad(web_frame, error,
1790 blink::WebStandardCommit); 1790 blink::WebStandardCommit);
1791 const int kMaxOutputCharacters = 22; 1791 const int kMaxOutputCharacters = 22;
1792 EXPECT_EQ("", base::UTF16ToASCII(base::StringPiece16( 1792 EXPECT_EQ("", base::UTF16ToASCII(base::StringPiece16(
1793 WebFrameContentDumper::dumpFrameTreeAsText( 1793 WebFrameContentDumper::dumpWebViewAsText(
1794 web_frame, kMaxOutputCharacters)))); 1794 view()->GetWebView(), kMaxOutputCharacters))));
1795 } 1795 }
1796 1796
1797 #if defined(OS_ANDROID) 1797 #if defined(OS_ANDROID)
1798 // Crashing on Android: http://crbug.com/311341 1798 // Crashing on Android: http://crbug.com/311341
1799 #define MAYBE_DoesNotSuppress DISABLED_DoesNotSuppress 1799 #define MAYBE_DoesNotSuppress DISABLED_DoesNotSuppress
1800 #else 1800 #else
1801 #define MAYBE_DoesNotSuppress DoesNotSuppress 1801 #define MAYBE_DoesNotSuppress DoesNotSuppress
1802 #endif 1802 #endif
1803 1803
1804 TEST_F(RendererErrorPageTest, MAYBE_DoesNotSuppress) { 1804 TEST_F(RendererErrorPageTest, MAYBE_DoesNotSuppress) {
(...skipping 14 matching lines...) Expand all
1819 1819
1820 // An error occurred. 1820 // An error occurred.
1821 main_frame->didFailProvisionalLoad(web_frame, error, 1821 main_frame->didFailProvisionalLoad(web_frame, error,
1822 blink::WebStandardCommit); 1822 blink::WebStandardCommit);
1823 1823
1824 // The error page itself is loaded asynchronously. 1824 // The error page itself is loaded asynchronously.
1825 FrameLoadWaiter(main_frame).Wait(); 1825 FrameLoadWaiter(main_frame).Wait();
1826 const int kMaxOutputCharacters = 22; 1826 const int kMaxOutputCharacters = 22;
1827 EXPECT_EQ("A suffusion of yellow.", 1827 EXPECT_EQ("A suffusion of yellow.",
1828 base::UTF16ToASCII( 1828 base::UTF16ToASCII(
1829 base::StringPiece16(WebFrameContentDumper::dumpFrameTreeAsText( 1829 base::StringPiece16(WebFrameContentDumper::dumpWebViewAsText(
1830 web_frame, kMaxOutputCharacters)))); 1830 view()->GetWebView(), kMaxOutputCharacters))));
1831 } 1831 }
1832 1832
1833 #if defined(OS_ANDROID) 1833 #if defined(OS_ANDROID)
1834 // Crashing on Android: http://crbug.com/311341 1834 // Crashing on Android: http://crbug.com/311341
1835 #define MAYBE_HttpStatusCodeErrorWithEmptyBody \ 1835 #define MAYBE_HttpStatusCodeErrorWithEmptyBody \
1836 DISABLED_HttpStatusCodeErrorWithEmptyBody 1836 DISABLED_HttpStatusCodeErrorWithEmptyBody
1837 #else 1837 #else
1838 #define MAYBE_HttpStatusCodeErrorWithEmptyBody HttpStatusCodeErrorWithEmptyBody 1838 #define MAYBE_HttpStatusCodeErrorWithEmptyBody HttpStatusCodeErrorWithEmptyBody
1839 #endif 1839 #endif
1840 TEST_F(RendererErrorPageTest, MAYBE_HttpStatusCodeErrorWithEmptyBody) { 1840 TEST_F(RendererErrorPageTest, MAYBE_HttpStatusCodeErrorWithEmptyBody) {
(...skipping 14 matching lines...) Expand all
1855 // Emulate a 4xx/5xx main resource response with an empty body. 1855 // Emulate a 4xx/5xx main resource response with an empty body.
1856 main_frame->didReceiveResponse(1, response); 1856 main_frame->didReceiveResponse(1, response);
1857 main_frame->didFinishDocumentLoad(web_frame); 1857 main_frame->didFinishDocumentLoad(web_frame);
1858 main_frame->runScriptsAtDocumentReady(web_frame, true); 1858 main_frame->runScriptsAtDocumentReady(web_frame, true);
1859 1859
1860 // The error page itself is loaded asynchronously. 1860 // The error page itself is loaded asynchronously.
1861 FrameLoadWaiter(main_frame).Wait(); 1861 FrameLoadWaiter(main_frame).Wait();
1862 const int kMaxOutputCharacters = 22; 1862 const int kMaxOutputCharacters = 22;
1863 EXPECT_EQ("A suffusion of yellow.", 1863 EXPECT_EQ("A suffusion of yellow.",
1864 base::UTF16ToASCII( 1864 base::UTF16ToASCII(
1865 base::StringPiece16(WebFrameContentDumper::dumpFrameTreeAsText( 1865 base::StringPiece16(WebFrameContentDumper::dumpWebViewAsText(
1866 web_frame, kMaxOutputCharacters)))); 1866 view()->GetWebView(), kMaxOutputCharacters))));
1867 } 1867 }
1868 1868
1869 // Ensure the render view sends favicon url update events correctly. 1869 // Ensure the render view sends favicon url update events correctly.
1870 TEST_F(RenderViewImplTest, SendFaviconURLUpdateEvent) { 1870 TEST_F(RenderViewImplTest, SendFaviconURLUpdateEvent) {
1871 // An event should be sent when a favicon url exists. 1871 // An event should be sent when a favicon url exists.
1872 LoadHTML("<html>" 1872 LoadHTML("<html>"
1873 "<head>" 1873 "<head>"
1874 "<link rel='icon' href='http://www.google.com/favicon.ico'>" 1874 "<link rel='icon' href='http://www.google.com/favicon.ico'>"
1875 "</head>" 1875 "</head>"
1876 "</html>"); 1876 "</html>");
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after
2348 FROM_HERE, 2348 FROM_HERE,
2349 base::Bind(&DevToolsAgentTest::CloseWhilePaused, base::Unretained(this))); 2349 base::Bind(&DevToolsAgentTest::CloseWhilePaused, base::Unretained(this)));
2350 ExecuteJavaScriptForTests("debugger;"); 2350 ExecuteJavaScriptForTests("debugger;");
2351 2351
2352 // CloseWhilePaused should resume execution and continue here. 2352 // CloseWhilePaused should resume execution and continue here.
2353 EXPECT_FALSE(IsPaused()); 2353 EXPECT_FALSE(IsPaused());
2354 Detach(); 2354 Detach();
2355 } 2355 }
2356 2356
2357 } // namespace content 2357 } // namespace content
OLDNEW
« no previous file with comments | « chrome/renderer/chrome_render_frame_observer.cc ('k') | content/renderer/render_view_browsertest_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698