OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/data_reduction_proxy/content/browser/content_lofi_ui_servic
e.h" | 5 #include "components/data_reduction_proxy/content/browser/content_lofi_ui_servic
e.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "base/run_loop.h" | 14 #include "base/run_loop.h" |
15 #include "content/public/browser/browser_thread.h" | 15 #include "content/public/browser/browser_thread.h" |
16 #include "content/public/browser/render_frame_host.h" | 16 #include "content/public/browser/render_frame_host.h" |
17 #include "content/public/browser/render_process_host.h" | 17 #include "content/public/browser/render_process_host.h" |
18 #include "content/public/browser/resource_request_info.h" | 18 #include "content/public/browser/resource_request_info.h" |
19 #include "content/public/browser/web_contents.h" | 19 #include "content/public/browser/web_contents.h" |
| 20 #include "content/public/common/previews_state.h" |
20 #include "content/public/test/test_renderer_host.h" | 21 #include "content/public/test/test_renderer_host.h" |
21 #include "net/socket/socket_test_util.h" | 22 #include "net/socket/socket_test_util.h" |
22 #include "net/url_request/url_request.h" | 23 #include "net/url_request/url_request.h" |
23 #include "net/url_request/url_request_test_util.h" | 24 #include "net/url_request/url_request_test_util.h" |
24 #include "testing/gtest/include/gtest/gtest.h" | 25 #include "testing/gtest/include/gtest/gtest.h" |
25 | 26 |
26 namespace data_reduction_proxy { | 27 namespace data_reduction_proxy { |
27 | 28 |
28 class ContentLoFiUIServiceTest : public content::RenderViewHostTestHarness { | 29 class ContentLoFiUIServiceTest : public content::RenderViewHostTestHarness { |
29 public: | 30 public: |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 EXPECT_TRUE( | 66 EXPECT_TRUE( |
66 content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); | 67 content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); |
67 | 68 |
68 std::unique_ptr<net::URLRequest> request = context.CreateRequest( | 69 std::unique_ptr<net::URLRequest> request = context.CreateRequest( |
69 GURL("http://www.google.com/"), net::IDLE, delegate); | 70 GURL("http://www.google.com/"), net::IDLE, delegate); |
70 | 71 |
71 content::ResourceRequestInfo::AllocateForTesting( | 72 content::ResourceRequestInfo::AllocateForTesting( |
72 request.get(), content::RESOURCE_TYPE_SUB_FRAME, NULL, | 73 request.get(), content::RESOURCE_TYPE_SUB_FRAME, NULL, |
73 web_contents()->GetMainFrame()->GetProcess()->GetID(), -1, | 74 web_contents()->GetMainFrame()->GetProcess()->GetID(), -1, |
74 web_contents()->GetMainFrame()->GetRoutingID(), | 75 web_contents()->GetMainFrame()->GetRoutingID(), |
75 false, // is_main_frame | 76 /*is_main_frame=*/false, |
76 false, // parent_is_main_frame | 77 /*parent_is_main_frame=*/false, |
77 false, // allow_download | 78 /*allow_download=*/false, |
78 false, // is_async | 79 /*is_async=*/false, content::SERVER_LOFI_ON); |
79 true); // is_using_lofi | |
80 | 80 |
81 return request; | 81 return request; |
82 } | 82 } |
83 | 83 |
84 void OnLoFiResponseReceivedCallback(content::WebContents* web_contents) { | 84 void OnLoFiResponseReceivedCallback(content::WebContents* web_contents) { |
85 EXPECT_TRUE( | 85 EXPECT_TRUE( |
86 content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 86 content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
87 callback_called_ = true; | 87 callback_called_ = true; |
88 } | 88 } |
89 | 89 |
(...skipping 13 matching lines...) Expand all Loading... |
103 content::BrowserThread::PostTask( | 103 content::BrowserThread::PostTask( |
104 content::BrowserThread::IO, FROM_HERE, | 104 content::BrowserThread::IO, FROM_HERE, |
105 base::Bind(&ContentLoFiUIServiceTest::RunTestOnIOThread, | 105 base::Bind(&ContentLoFiUIServiceTest::RunTestOnIOThread, |
106 base::Unretained(this), &ui_run_loop)); | 106 base::Unretained(this), &ui_run_loop)); |
107 ui_run_loop.Run(); | 107 ui_run_loop.Run(); |
108 base::RunLoop().RunUntilIdle(); | 108 base::RunLoop().RunUntilIdle(); |
109 VerifyOnLoFiResponseReceivedCallback(); | 109 VerifyOnLoFiResponseReceivedCallback(); |
110 } | 110 } |
111 | 111 |
112 } // namespace data_reduction_proxy | 112 } // namespace data_reduction_proxy |
OLD | NEW |