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

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

Issue 1259673002: Make UTF16ToASCII and UTF16TOUTF8 take a StringPiece (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 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_frame_impl.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/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/bind.h" 6 #include "base/bind.h"
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/memory/shared_memory.h" 9 #include "base/memory/shared_memory.h"
10 #include "base/single_thread_task_runner.h" 10 #include "base/single_thread_task_runner.h"
(...skipping 1325 matching lines...) Expand 10 before | Expand all | Expand 10 after
1336 "%d,%s", // texts in the third <div> element 1336 "%d,%s", // texts in the third <div> element
1337 key_code, kModifierData[j].expected_result, 1337 key_code, kModifierData[j].expected_result,
1338 static_cast<int>(char_code[0]), 1338 static_cast<int>(char_code[0]),
1339 kModifierData[j].expected_result, 1339 kModifierData[j].expected_result,
1340 key_code, kModifierData[j].expected_result); 1340 key_code, kModifierData[j].expected_result);
1341 1341
1342 // Retrieve the text in the test page and compare it with the expected 1342 // Retrieve the text in the test page and compare it with the expected
1343 // text created from a virtual-key code, a character code, and the 1343 // text created from a virtual-key code, a character code, and the
1344 // modifier-key status. 1344 // modifier-key status.
1345 const int kMaxOutputCharacters = 1024; 1345 const int kMaxOutputCharacters = 1024;
1346 std::string output = base::UTF16ToUTF8( 1346 std::string output = base::UTF16ToUTF8(base::StringPiece16(
1347 GetMainFrame()->contentAsText(kMaxOutputCharacters)); 1347 GetMainFrame()->contentAsText(kMaxOutputCharacters)));
1348 EXPECT_EQ(expected_result, output); 1348 EXPECT_EQ(expected_result, output);
1349 } 1349 }
1350 } 1350 }
1351 } 1351 }
1352 #else 1352 #else
1353 NOTIMPLEMENTED(); 1353 NOTIMPLEMENTED();
1354 #endif 1354 #endif
1355 } 1355 }
1356 1356
1357 // Test that our EditorClientImpl class can insert characters when we send 1357 // Test that our EditorClientImpl class can insert characters when we send
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after
1905 1905
1906 TestRenderFrame* subframe = 1906 TestRenderFrame* subframe =
1907 static_cast<TestRenderFrame*>(RenderFrameImpl::FromWebFrame( 1907 static_cast<TestRenderFrame*>(RenderFrameImpl::FromWebFrame(
1908 view()->webview()->findFrameByName("frame"))); 1908 view()->webview()->findFrameByName("frame")));
1909 subframe->Navigate(common_params, StartNavigationParams(), request_params); 1909 subframe->Navigate(common_params, StartNavigationParams(), request_params);
1910 FrameLoadWaiter(subframe).Wait(); 1910 FrameLoadWaiter(subframe).Wait();
1911 1911
1912 // Copy the document content to std::wstring and compare with the 1912 // Copy the document content to std::wstring and compare with the
1913 // expected result. 1913 // expected result.
1914 const int kMaxOutputCharacters = 256; 1914 const int kMaxOutputCharacters = 256;
1915 std::string output = base::UTF16ToUTF8( 1915 std::string output = base::UTF16ToUTF8(base::StringPiece16(
1916 GetMainFrame()->contentAsText(kMaxOutputCharacters)); 1916 GetMainFrame()->contentAsText(kMaxOutputCharacters)));
1917 EXPECT_EQ(output, "hello \n\nworld"); 1917 EXPECT_EQ(output, "hello \n\nworld");
1918 } 1918 }
1919 1919
1920 // This test ensures that a RenderFrame object is created for the top level 1920 // This test ensures that a RenderFrame object is created for the top level
1921 // frame in the RenderView. 1921 // frame in the RenderView.
1922 TEST_F(RenderViewImplTest, BasicRenderFrame) { 1922 TEST_F(RenderViewImplTest, BasicRenderFrame) {
1923 EXPECT_TRUE(view()->main_render_frame_); 1923 EXPECT_TRUE(view()->main_render_frame_);
1924 } 1924 }
1925 1925
1926 TEST_F(RenderViewImplTest, GetSSLStatusOfFrame) { 1926 TEST_F(RenderViewImplTest, GetSSLStatusOfFrame) {
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
2027 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; 2027 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL;
2028 common_params.url = GURL("data:text/html,test data"); 2028 common_params.url = GURL("data:text/html,test data");
2029 TestRenderFrame* main_frame = static_cast<TestRenderFrame*>(frame()); 2029 TestRenderFrame* main_frame = static_cast<TestRenderFrame*>(frame());
2030 main_frame->Navigate(common_params, StartNavigationParams(), 2030 main_frame->Navigate(common_params, StartNavigationParams(),
2031 RequestNavigationParams()); 2031 RequestNavigationParams());
2032 2032
2033 // An error occurred. 2033 // An error occurred.
2034 main_frame->didFailProvisionalLoad(web_frame, error, 2034 main_frame->didFailProvisionalLoad(web_frame, error,
2035 blink::WebStandardCommit); 2035 blink::WebStandardCommit);
2036 const int kMaxOutputCharacters = 22; 2036 const int kMaxOutputCharacters = 22;
2037 EXPECT_EQ("", 2037 EXPECT_EQ("", base::UTF16ToASCII(
2038 base::UTF16ToASCII(web_frame->contentAsText(kMaxOutputCharacters))); 2038 base::StringPiece16(web_frame->contentAsText(kMaxOutputCharacters))));
2039 } 2039 }
2040 2040
2041 #if defined(OS_ANDROID) 2041 #if defined(OS_ANDROID)
2042 // Crashing on Android: http://crbug.com/311341 2042 // Crashing on Android: http://crbug.com/311341
2043 #define MAYBE_DoesNotSuppress DISABLED_DoesNotSuppress 2043 #define MAYBE_DoesNotSuppress DISABLED_DoesNotSuppress
2044 #else 2044 #else
2045 #define MAYBE_DoesNotSuppress DoesNotSuppress 2045 #define MAYBE_DoesNotSuppress DoesNotSuppress
2046 #endif 2046 #endif
2047 2047
2048 TEST_F(RendererErrorPageTest, MAYBE_DoesNotSuppress) { 2048 TEST_F(RendererErrorPageTest, MAYBE_DoesNotSuppress) {
(...skipping 13 matching lines...) Expand all
2062 RequestNavigationParams()); 2062 RequestNavigationParams());
2063 2063
2064 // An error occurred. 2064 // An error occurred.
2065 main_frame->didFailProvisionalLoad(web_frame, error, 2065 main_frame->didFailProvisionalLoad(web_frame, error,
2066 blink::WebStandardCommit); 2066 blink::WebStandardCommit);
2067 2067
2068 // The error page itself is loaded asynchronously. 2068 // The error page itself is loaded asynchronously.
2069 FrameLoadWaiter(main_frame).Wait(); 2069 FrameLoadWaiter(main_frame).Wait();
2070 const int kMaxOutputCharacters = 22; 2070 const int kMaxOutputCharacters = 22;
2071 EXPECT_EQ("A suffusion of yellow.", 2071 EXPECT_EQ("A suffusion of yellow.",
2072 base::UTF16ToASCII(web_frame->contentAsText(kMaxOutputCharacters))); 2072 base::UTF16ToASCII(base::StringPiece16(
2073 web_frame->contentAsText(kMaxOutputCharacters))));
2073 } 2074 }
2074 2075
2075 #if defined(OS_ANDROID) 2076 #if defined(OS_ANDROID)
2076 // Crashing on Android: http://crbug.com/311341 2077 // Crashing on Android: http://crbug.com/311341
2077 #define MAYBE_HttpStatusCodeErrorWithEmptyBody \ 2078 #define MAYBE_HttpStatusCodeErrorWithEmptyBody \
2078 DISABLED_HttpStatusCodeErrorWithEmptyBody 2079 DISABLED_HttpStatusCodeErrorWithEmptyBody
2079 #else 2080 #else
2080 #define MAYBE_HttpStatusCodeErrorWithEmptyBody HttpStatusCodeErrorWithEmptyBody 2081 #define MAYBE_HttpStatusCodeErrorWithEmptyBody HttpStatusCodeErrorWithEmptyBody
2081 #endif 2082 #endif
2082 TEST_F(RendererErrorPageTest, MAYBE_HttpStatusCodeErrorWithEmptyBody) { 2083 TEST_F(RendererErrorPageTest, MAYBE_HttpStatusCodeErrorWithEmptyBody) {
(...skipping 12 matching lines...) Expand all
2095 RequestNavigationParams()); 2096 RequestNavigationParams());
2096 2097
2097 // Emulate a 4xx/5xx main resource response with an empty body. 2098 // Emulate a 4xx/5xx main resource response with an empty body.
2098 main_frame->didReceiveResponse(web_frame, 1, response); 2099 main_frame->didReceiveResponse(web_frame, 1, response);
2099 main_frame->didFinishDocumentLoad(web_frame, true); 2100 main_frame->didFinishDocumentLoad(web_frame, true);
2100 2101
2101 // The error page itself is loaded asynchronously. 2102 // The error page itself is loaded asynchronously.
2102 FrameLoadWaiter(main_frame).Wait(); 2103 FrameLoadWaiter(main_frame).Wait();
2103 const int kMaxOutputCharacters = 22; 2104 const int kMaxOutputCharacters = 22;
2104 EXPECT_EQ("A suffusion of yellow.", 2105 EXPECT_EQ("A suffusion of yellow.",
2105 base::UTF16ToASCII(web_frame->contentAsText(kMaxOutputCharacters))); 2106 base::UTF16ToASCII(base::StringPiece16(
2107 web_frame->contentAsText(kMaxOutputCharacters))));
2106 } 2108 }
2107 2109
2108 // Ensure the render view sends favicon url update events correctly. 2110 // Ensure the render view sends favicon url update events correctly.
2109 TEST_F(RenderViewImplTest, SendFaviconURLUpdateEvent) { 2111 TEST_F(RenderViewImplTest, SendFaviconURLUpdateEvent) {
2110 // An event should be sent when a favicon url exists. 2112 // An event should be sent when a favicon url exists.
2111 LoadHTML("<html>" 2113 LoadHTML("<html>"
2112 "<head>" 2114 "<head>"
2113 "<link rel='icon' href='http://www.google.com/favicon.ico'>" 2115 "<link rel='icon' href='http://www.google.com/favicon.ico'>"
2114 "</head>" 2116 "</head>"
2115 "</html>"); 2117 "</html>");
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
2357 FROM_HERE, 2359 FROM_HERE,
2358 base::Bind(&DevToolsAgentTest::CloseWhilePaused, base::Unretained(this))); 2360 base::Bind(&DevToolsAgentTest::CloseWhilePaused, base::Unretained(this)));
2359 ExecuteJavaScriptForTests("debugger;"); 2361 ExecuteJavaScriptForTests("debugger;");
2360 2362
2361 // CloseWhilePaused should resume execution and continue here. 2363 // CloseWhilePaused should resume execution and continue here.
2362 EXPECT_FALSE(IsPaused()); 2364 EXPECT_FALSE(IsPaused());
2363 Detach(); 2365 Detach();
2364 } 2366 }
2365 2367
2366 } // namespace content 2368 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_frame_impl.cc ('k') | content/renderer/render_view_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698