OLD | NEW |
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/memory/shared_memory.h" | 8 #include "base/memory/shared_memory.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 #include "content/public/test/render_view_test.h" | 28 #include "content/public/test/render_view_test.h" |
29 #include "content/public/test/test_utils.h" | 29 #include "content/public/test/test_utils.h" |
30 #include "content/renderer/accessibility/renderer_accessibility.h" | 30 #include "content/renderer/accessibility/renderer_accessibility.h" |
31 #include "content/renderer/accessibility/renderer_accessibility_complete.h" | 31 #include "content/renderer/accessibility/renderer_accessibility_complete.h" |
32 #include "content/renderer/accessibility/renderer_accessibility_focus_only.h" | 32 #include "content/renderer/accessibility/renderer_accessibility_focus_only.h" |
33 #include "content/renderer/history_controller.h" | 33 #include "content/renderer/history_controller.h" |
34 #include "content/renderer/history_serialization.h" | 34 #include "content/renderer/history_serialization.h" |
35 #include "content/renderer/render_view_impl.h" | 35 #include "content/renderer/render_view_impl.h" |
36 #include "content/shell/browser/shell.h" | 36 #include "content/shell/browser/shell.h" |
37 #include "content/shell/browser/shell_browser_context.h" | 37 #include "content/shell/browser/shell_browser_context.h" |
| 38 #include "content/test/frame_load_waiter.h" |
38 #include "content/test/mock_keyboard.h" | 39 #include "content/test/mock_keyboard.h" |
39 #include "net/base/net_errors.h" | 40 #include "net/base/net_errors.h" |
40 #include "net/cert/cert_status_flags.h" | 41 #include "net/cert/cert_status_flags.h" |
41 #include "testing/gtest/include/gtest/gtest.h" | 42 #include "testing/gtest/include/gtest/gtest.h" |
42 #include "third_party/WebKit/public/platform/WebData.h" | 43 #include "third_party/WebKit/public/platform/WebData.h" |
43 #include "third_party/WebKit/public/platform/WebHTTPBody.h" | 44 #include "third_party/WebKit/public/platform/WebHTTPBody.h" |
44 #include "third_party/WebKit/public/platform/WebString.h" | 45 #include "third_party/WebKit/public/platform/WebString.h" |
45 #include "third_party/WebKit/public/platform/WebURLResponse.h" | 46 #include "third_party/WebKit/public/platform/WebURLResponse.h" |
46 #include "third_party/WebKit/public/web/WebDataSource.h" | 47 #include "third_party/WebKit/public/web/WebDataSource.h" |
47 #include "third_party/WebKit/public/web/WebHistoryItem.h" | 48 #include "third_party/WebKit/public/web/WebHistoryItem.h" |
(...skipping 1959 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2007 FrameMsg_Navigate_Params nav_params; | 2008 FrameMsg_Navigate_Params nav_params; |
2008 nav_params.url = GURL("data:text/html,world"); | 2009 nav_params.url = GURL("data:text/html,world"); |
2009 nav_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 2010 nav_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
2010 nav_params.transition = PAGE_TRANSITION_TYPED; | 2011 nav_params.transition = PAGE_TRANSITION_TYPED; |
2011 nav_params.current_history_list_length = 1; | 2012 nav_params.current_history_list_length = 1; |
2012 nav_params.current_history_list_offset = 0; | 2013 nav_params.current_history_list_offset = 0; |
2013 nav_params.pending_history_list_offset = 1; | 2014 nav_params.pending_history_list_offset = 1; |
2014 nav_params.page_id = -1; | 2015 nav_params.page_id = -1; |
2015 nav_params.frame_to_navigate = "frame"; | 2016 nav_params.frame_to_navigate = "frame"; |
2016 frame()->OnNavigate(nav_params); | 2017 frame()->OnNavigate(nav_params); |
2017 ProcessPendingMessages(); | 2018 FrameLoadWaiter( |
| 2019 RenderFrame::FromWebFrame(frame()->GetWebFrame()->firstChild())).Wait(); |
2018 | 2020 |
2019 // Copy the document content to std::wstring and compare with the | 2021 // Copy the document content to std::wstring and compare with the |
2020 // expected result. | 2022 // expected result. |
2021 const int kMaxOutputCharacters = 256; | 2023 const int kMaxOutputCharacters = 256; |
2022 std::string output = base::UTF16ToUTF8( | 2024 std::string output = base::UTF16ToUTF8( |
2023 GetMainFrame()->contentAsText(kMaxOutputCharacters)); | 2025 GetMainFrame()->contentAsText(kMaxOutputCharacters)); |
2024 EXPECT_EQ(output, "hello \n\nworld"); | 2026 EXPECT_EQ(output, "hello \n\nworld"); |
2025 } | 2027 } |
2026 | 2028 |
2027 // This test ensures that a RenderFrame object is created for the top level | 2029 // This test ensures that a RenderFrame object is created for the top level |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2157 // Start a load that will reach provisional state synchronously, | 2159 // Start a load that will reach provisional state synchronously, |
2158 // but won't complete synchronously. | 2160 // but won't complete synchronously. |
2159 FrameMsg_Navigate_Params params; | 2161 FrameMsg_Navigate_Params params; |
2160 params.page_id = -1; | 2162 params.page_id = -1; |
2161 params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 2163 params.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
2162 params.url = GURL("data:text/html,test data"); | 2164 params.url = GURL("data:text/html,test data"); |
2163 frame()->OnNavigate(params); | 2165 frame()->OnNavigate(params); |
2164 | 2166 |
2165 // An error occurred. | 2167 // An error occurred. |
2166 view()->main_render_frame()->didFailProvisionalLoad(web_frame, error); | 2168 view()->main_render_frame()->didFailProvisionalLoad(web_frame, error); |
2167 ProcessPendingMessages(); | 2169 // The error page itself is loaded asynchronously. |
| 2170 FrameLoadWaiter(frame()).Wait(); |
2168 const int kMaxOutputCharacters = 22; | 2171 const int kMaxOutputCharacters = 22; |
2169 EXPECT_EQ("A suffusion of yellow.", | 2172 EXPECT_EQ("A suffusion of yellow.", |
2170 base::UTF16ToASCII(web_frame->contentAsText(kMaxOutputCharacters))); | 2173 base::UTF16ToASCII(web_frame->contentAsText(kMaxOutputCharacters))); |
2171 } | 2174 } |
2172 | 2175 |
2173 // Tests if IME API's candidatewindow* events sent from browser are handled | 2176 // Tests if IME API's candidatewindow* events sent from browser are handled |
2174 // in renderer. | 2177 // in renderer. |
2175 TEST_F(RenderViewImplTest, SendCandidateWindowEvents) { | 2178 TEST_F(RenderViewImplTest, SendCandidateWindowEvents) { |
2176 // Sends an HTML with an <input> element and scripts to the renderer. | 2179 // Sends an HTML with an <input> element and scripts to the renderer. |
2177 // The script handles all 3 of candidatewindow* events for an | 2180 // The script handles all 3 of candidatewindow* events for an |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2242 // The load started, we should receive a start notification and a progress | 2245 // The load started, we should receive a start notification and a progress |
2243 // update with the minimum progress. | 2246 // update with the minimum progress. |
2244 const IPC::Message* message = render_thread_->sink().GetFirstMessageMatching( | 2247 const IPC::Message* message = render_thread_->sink().GetFirstMessageMatching( |
2245 ViewHostMsg_DidChangeLoadProgress::ID); | 2248 ViewHostMsg_DidChangeLoadProgress::ID); |
2246 EXPECT_TRUE(message); | 2249 EXPECT_TRUE(message); |
2247 Tuple1<double> progress_value; | 2250 Tuple1<double> progress_value; |
2248 ViewHostMsg_DidChangeLoadProgress::Read(message, &progress_value); | 2251 ViewHostMsg_DidChangeLoadProgress::Read(message, &progress_value); |
2249 EXPECT_EQ(0.1, progress_value.a); | 2252 EXPECT_EQ(0.1, progress_value.a); |
2250 render_thread_->sink().ClearMessages(); | 2253 render_thread_->sink().ClearMessages(); |
2251 | 2254 |
2252 ProcessPendingMessages(); | 2255 FrameLoadWaiter(frame()).Wait(); |
2253 | 2256 |
2254 // The data url has loaded, so we should see a progress change to 1.0 (done) | 2257 // The data url has loaded, so we should see a progress change to 1.0 (done) |
2255 // and a stop notification. | 2258 // and a stop notification. |
2256 message = render_thread_->sink().GetFirstMessageMatching( | 2259 message = render_thread_->sink().GetFirstMessageMatching( |
2257 ViewHostMsg_DidChangeLoadProgress::ID); | 2260 ViewHostMsg_DidChangeLoadProgress::ID); |
2258 EXPECT_TRUE(message); | 2261 EXPECT_TRUE(message); |
2259 ViewHostMsg_DidChangeLoadProgress::Read(message, &progress_value); | 2262 ViewHostMsg_DidChangeLoadProgress::Read(message, &progress_value); |
2260 EXPECT_EQ(1.0, progress_value.a); | 2263 EXPECT_EQ(1.0, progress_value.a); |
2261 | 2264 |
2262 EXPECT_TRUE(render_thread_->sink().GetFirstMessageMatching( | 2265 EXPECT_TRUE(render_thread_->sink().GetFirstMessageMatching( |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2358 view()->renderer_accessibility()->GetType()); | 2361 view()->renderer_accessibility()->GetType()); |
2359 | 2362 |
2360 view()->OnSetAccessibilityMode(AccessibilityModeEditableTextOnly); | 2363 view()->OnSetAccessibilityMode(AccessibilityModeEditableTextOnly); |
2361 ASSERT_EQ(AccessibilityModeEditableTextOnly, view()->accessibility_mode()); | 2364 ASSERT_EQ(AccessibilityModeEditableTextOnly, view()->accessibility_mode()); |
2362 ASSERT_NE((RendererAccessibility*) NULL, view()->renderer_accessibility()); | 2365 ASSERT_NE((RendererAccessibility*) NULL, view()->renderer_accessibility()); |
2363 ASSERT_EQ(RendererAccessibilityTypeFocusOnly, | 2366 ASSERT_EQ(RendererAccessibilityTypeFocusOnly, |
2364 view()->renderer_accessibility()->GetType()); | 2367 view()->renderer_accessibility()->GetType()); |
2365 } | 2368 } |
2366 | 2369 |
2367 } // namespace content | 2370 } // namespace content |
OLD | NEW |