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

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

Issue 180113003: Prepare for per frame did{Start,Stop}Loading calls (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix progress calculation, add test Created 6 years, 9 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 | Annotate | Revision Log
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/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 2203 matching lines...) Expand 10 before | Expand all | Expand 10 after
2214 // An event should not be sent if no favicon url exists. This is an assumption 2214 // An event should not be sent if no favicon url exists. This is an assumption
2215 // made by some of Chrome's favicon handling. 2215 // made by some of Chrome's favicon handling.
2216 LoadHTML("<html>" 2216 LoadHTML("<html>"
2217 "<head>" 2217 "<head>"
2218 "</head>" 2218 "</head>"
2219 "</html>"); 2219 "</html>");
2220 EXPECT_FALSE(render_thread_->sink().GetFirstMessageMatching( 2220 EXPECT_FALSE(render_thread_->sink().GetFirstMessageMatching(
2221 ViewHostMsg_UpdateFaviconURL::ID)); 2221 ViewHostMsg_UpdateFaviconURL::ID));
2222 } 2222 }
2223 2223
2224 // Test progress tracker messages.
2225 TEST_F(RenderViewImplTest, SendProgressCompletionUpdates) {
2226 std::string data_url_string = "data:text/html,<body>placeholder</body>";
2227 GURL url(data_url_string);
2228 GetMainFrame()->loadRequest(blink::WebURLRequest(url));
2229
2230 EXPECT_TRUE(render_thread_->sink().GetFirstMessageMatching(
2231 FrameHostMsg_DidStartLoading::ID));
2232
2233 // The load started, we should receive a start notification and a progress
2234 // update withe minimum progress.
Charlie Reis 2014/03/11 21:51:12 nit: with the
2235 const IPC::Message* message = render_thread_->sink().GetFirstMessageMatching(
2236 ViewHostMsg_DidChangeLoadProgress::ID);
2237 EXPECT_TRUE(message);
2238 Tuple1<double> progress_value;
2239 ViewHostMsg_DidChangeLoadProgress::Read(message, &progress_value);
2240 EXPECT_EQ(0.1, progress_value.a);
2241 render_thread_->sink().ClearMessages();
2242
2243 ProcessPendingMessages();
2244
2245 // The data url has loaded, so we should see a progress change to 1.0 (done)
2246 // and a stop notification.
2247 message = render_thread_->sink().GetFirstMessageMatching(
2248 ViewHostMsg_DidChangeLoadProgress::ID);
2249 EXPECT_TRUE(message);
2250 ViewHostMsg_DidChangeLoadProgress::Read(message, &progress_value);
2251 EXPECT_EQ(1.0, progress_value.a);
2252
2253 EXPECT_TRUE(render_thread_->sink().GetFirstMessageMatching(
2254 FrameHostMsg_DidStopLoading::ID));
2255 render_thread_->sink().ClearMessages();
2256 }
2257
2224 TEST_F(RenderViewImplTest, FocusElementCallsFocusedNodeChanged) { 2258 TEST_F(RenderViewImplTest, FocusElementCallsFocusedNodeChanged) {
2225 LoadHTML("<input id='test1' value='hello1'></input>" 2259 LoadHTML("<input id='test1' value='hello1'></input>"
2226 "<input id='test2' value='hello2'></input>"); 2260 "<input id='test2' value='hello2'></input>");
2227 2261
2228 ExecuteJavaScript("document.getElementById('test1').focus();"); 2262 ExecuteJavaScript("document.getElementById('test1').focus();");
2229 const IPC::Message* msg1 = render_thread_->sink().GetFirstMessageMatching( 2263 const IPC::Message* msg1 = render_thread_->sink().GetFirstMessageMatching(
2230 ViewHostMsg_FocusedNodeChanged::ID); 2264 ViewHostMsg_FocusedNodeChanged::ID);
2231 EXPECT_TRUE(msg1); 2265 EXPECT_TRUE(msg1);
2232 2266
2233 ViewHostMsg_FocusedNodeChanged::Param params; 2267 ViewHostMsg_FocusedNodeChanged::Param params;
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
2288 request.setTargetType(blink::WebURLRequest::TargetIsSubresource); 2322 request.setTargetType(blink::WebURLRequest::TargetIsSubresource);
2289 blink::WebURLResponse redirect_response; 2323 blink::WebURLResponse redirect_response;
2290 frame()->willSendRequest(GetMainFrame(), 0, request, redirect_response); 2324 frame()->willSendRequest(GetMainFrame(), 0, request, redirect_response);
2291 extra_data = static_cast<RequestExtraData*>(request.extraData()); 2325 extra_data = static_cast<RequestExtraData*>(request.extraData());
2292 ASSERT_TRUE(extra_data); 2326 ASSERT_TRUE(extra_data);
2293 EXPECT_EQ(extra_data->service_worker_provider_id(), 2327 EXPECT_EQ(extra_data->service_worker_provider_id(),
2294 provider->provider_id()); 2328 provider->provider_id());
2295 } 2329 }
2296 2330
2297 } // namespace content 2331 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698