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

Unified Diff: third_party/WebKit/Source/core/fetch/ResourceFetcherTest.cpp

Issue 2511313002: transferSize implementation (Closed)
Patch Set: addressed comments Created 4 years 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/fetch/ResourceFetcherTest.cpp
diff --git a/third_party/WebKit/Source/core/fetch/ResourceFetcherTest.cpp b/third_party/WebKit/Source/core/fetch/ResourceFetcherTest.cpp
index 80ff9d0efa36623385b3cdd5de9bea31237f7063..83c82de1d4eec1aab50d9f39bd349bbef0b704be 100644
--- a/third_party/WebKit/Source/core/fetch/ResourceFetcherTest.cpp
+++ b/third_party/WebKit/Source/core/fetch/ResourceFetcherTest.cpp
@@ -144,6 +144,47 @@ TEST_F(ResourceFetcherTest, Vary) {
memoryCache()->remove(resource);
}
+TEST_F(ResourceFetcherTest, NavigationTimingInfo) {
+ KURL url(ParsedURLString, "http://127.0.0.1:8000/foo.html");
+ ResourceResponse response;
+ response.setURL(url);
+ response.setHTTPStatusCode(200);
+
+ ResourceFetcher* fetcher = ResourceFetcher::create(
+ MockFetchContext::create(MockFetchContext::kShouldLoadNewResource));
+ ResourceRequest resourceRequest(url);
+ resourceRequest.setFrameType(WebURLRequest::FrameTypeNested);
+ resourceRequest.setRequestContext(WebURLRequest::RequestContextForm);
+ FetchRequest fetchRequest =
+ FetchRequest(resourceRequest, FetchInitiatorInfo());
+ Platform::current()->getURLLoaderMockFactory()->registerURL(
+ url, WebURLResponse(), "");
+ Resource* resource =
+ RawResource::fetchMainResource(fetchRequest, fetcher, SubstituteData());
+ resource->responseReceived(response, nullptr);
+ EXPECT_EQ(resource->getType(), Resource::MainResource);
+
+ ResourceTimingInfo* navigationTimingInfo = fetcher->getNavigationTimingInfo();
+ ASSERT_TRUE(navigationTimingInfo);
+ long long encodedDataLength = 123;
+ resource->loader()->didFinishLoading(0.0, encodedDataLength, 0);
+ EXPECT_EQ(navigationTimingInfo->transferSize(), encodedDataLength);
+
+ // When there are redirects.
+ KURL redirectURL(ParsedURLString, "http://127.0.0.1:8000/redirect.html");
+ ResourceResponse redirectResponse;
+ redirectResponse.setURL(redirectURL);
+ redirectResponse.setHTTPStatusCode(200);
+ long long redirectEncodedDataLength = 123;
+ redirectResponse.setEncodedDataLength(redirectEncodedDataLength);
+ ResourceRequest redirectResourceRequest(url);
+ fetcher->willFollowRedirect(resource, redirectResourceRequest,
+ redirectResponse);
+ EXPECT_EQ(navigationTimingInfo->transferSize(),
+ encodedDataLength + redirectEncodedDataLength);
+ Platform::current()->getURLLoaderMockFactory()->unregisterURL(url);
+}
+
TEST_F(ResourceFetcherTest, VaryOnBack) {
MockFetchContext* context =
MockFetchContext::create(MockFetchContext::kShouldLoadNewResource);
« no previous file with comments | « third_party/WebKit/Source/core/fetch/ResourceFetcher.cpp ('k') | third_party/WebKit/Source/core/loader/DocumentLoader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698