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

Side by Side Diff: chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate_unittest.cc

Issue 1721813002: Adding DRP specfic UMA for FirstContentfulPaint (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Missing Header Include Created 4 years, 7 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
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
bengr 2016/04/29 21:14:21 Wrong year.
RyanSturm 2016/05/02 19:52:20 Done.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate. h"
6
7 #include <memory>
8
9 #include "base/message_loop/message_loop.h"
10 #include "chrome/browser/renderer_host/chrome_navigation_data.h"
11 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_data .h"
12 #include "content/public/browser/navigation_data.h"
13 #include "content/public/test/test_browser_thread.h"
14 #include "net/base/request_priority.h"
15 #include "net/url_request/url_request.h"
16 #include "net/url_request/url_request_context.h"
17 #include "testing/gtest/include/gtest/gtest.h"
18
19 class ChromeResourceDispatcherHostDelegateTest : public testing::Test {
20 public:
21 ChromeResourceDispatcherHostDelegateTest()
22 : ui_thread_(content::BrowserThread::UI, &message_loop_) {}
23 ~ChromeResourceDispatcherHostDelegateTest() override {}
24
25 private:
26 base::MessageLoopForIO message_loop_;
27 content::TestBrowserThread ui_thread_;
28 };
29
30 TEST_F(ChromeResourceDispatcherHostDelegateTest, GetNavigationDataWithDRPData) {
31 std::unique_ptr<net::URLRequestContext> context(new net::URLRequestContext());
32 std::unique_ptr<net::URLRequest> fake_request(context->CreateRequest(
33 GURL("content.request.any.port"), net::RequestPriority::IDLE, nullptr));
bengr 2016/04/29 21:14:21 #include "url/gurl.h"
RyanSturm 2016/05/02 19:52:20 Done.
34 // Add DRP data to URLRequest
bengr 2016/04/29 21:14:21 Add DataReductionProxyData to the URLRequest.
RyanSturm 2016/05/02 19:52:20 Done.
35 data_reduction_proxy::DataReductionProxyData* drp_data =
36 data_reduction_proxy::DataReductionProxyData::DataForRequest(
37 fake_request.get(), true);
38 drp_data->set_used_data_reduction_proxy(true);
39 std::unique_ptr<ChromeResourceDispatcherHostDelegate> delegate(
bengr 2016/04/29 21:14:21 #include "chrome/browser/renderer_host/chrome_reso
RyanSturm 2016/05/02 19:52:20 Done.
40 new ChromeResourceDispatcherHostDelegate());
41 std::unique_ptr<content::NavigationData> navigation_data =
42 delegate->GetNavigationData(fake_request.get());
43 ChromeNavigationData* chrome_navigation_data =
44 static_cast<ChromeNavigationData*>(navigation_data.get());
45 data_reduction_proxy::DataReductionProxyData* drp_data_copy =
bengr 2016/04/29 21:14:21 You should spell out every drp as data_reduction_p
RyanSturm 2016/05/02 19:52:20 Done.
46 chrome_navigation_data->GetDataReductionProxyData();
47 // The DRP_data should be a copy off the one on URLRequest
bengr 2016/04/29 21:14:21 copy off -> deep copy of
RyanSturm 2016/05/02 19:52:20 Done.
48 EXPECT_NE(drp_data_copy, drp_data);
49 // Make sure DRP Data was copied.
bengr 2016/04/29 21:14:21 DataReductionProxyData
RyanSturm 2016/05/02 19:52:20 Done.
50 EXPECT_TRUE(drp_data_copy->get_used_data_reduction_proxy());
51 }
52
53 TEST_F(ChromeResourceDispatcherHostDelegateTest,
54 GetNavigationDataWithoutDRPData) {
55 std::unique_ptr<net::URLRequestContext> context(new net::URLRequestContext());
56 std::unique_ptr<net::URLRequest> fake_request(context->CreateRequest(
57 GURL("content.request.any.port"), net::RequestPriority::IDLE, nullptr));
58 std::unique_ptr<ChromeResourceDispatcherHostDelegate> delegate(
59 new ChromeResourceDispatcherHostDelegate());
60 std::unique_ptr<content::NavigationData> navigation_data =
61 delegate->GetNavigationData(fake_request.get());
62 ChromeNavigationData* chrome_navigation_data =
63 static_cast<ChromeNavigationData*>(navigation_data.get());
64 EXPECT_TRUE(!chrome_navigation_data->GetDataReductionProxyData());
65 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698