OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "chrome/browser/net/spdyproxy/chrome_data_use_group.h" | 5 #include "chrome/browser/net/spdyproxy/chrome_data_use_group.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "content/public/browser/resource_request_info.h" | 10 #include "content/public/browser/resource_request_info.h" |
| 11 #include "content/public/common/previews_state.h" |
11 #include "content/public/test/test_browser_thread_bundle.h" | 12 #include "content/public/test/test_browser_thread_bundle.h" |
12 #include "net/url_request/url_request.h" | 13 #include "net/url_request/url_request.h" |
13 #include "net/url_request/url_request_test_util.h" | 14 #include "net/url_request/url_request_test_util.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
15 #include "url/gurl.h" | 16 #include "url/gurl.h" |
16 | 17 |
17 class ChromeDataUseGroupTest : public testing::Test { | 18 class ChromeDataUseGroupTest : public testing::Test { |
18 protected: | 19 protected: |
19 void SetUp() override { | 20 void SetUp() override { |
20 std::unique_ptr<net::URLRequest> request = context_.CreateRequest( | 21 std::unique_ptr<net::URLRequest> request = context_.CreateRequest( |
21 GURL("http://foo.com/index.html"), net::IDLE, &test_delegate_); | 22 GURL("http://foo.com/index.html"), net::IDLE, &test_delegate_); |
22 | 23 |
23 content::ResourceRequestInfo::AllocateForTesting( | 24 content::ResourceRequestInfo::AllocateForTesting( |
24 request.get(), content::RESOURCE_TYPE_MAIN_FRAME, nullptr, | 25 request.get(), content::RESOURCE_TYPE_MAIN_FRAME, nullptr, |
25 1, /* render_process_id */ | 26 /*render_process_id=*/1, |
26 -1, /* render_view_id */ | 27 /*render_view_id=*/-1, |
27 1, /* render_frame_id */ | 28 /*render_frame_id=*/1, |
28 true, /* is_main_frame */ | 29 /*is_main_frame=*/true, |
29 false, /* parent_is_main_frame */ | 30 /*parent_is_main_frame=*/false, |
30 true, /* allow_download */ | 31 /*allow_download=*/true, |
31 true, /* is_async */ | 32 /*is_async=*/true, content::PREVIEWS_OFF); |
32 false /* is_using_lofi */); | |
33 | 33 |
34 data_use_group_ = new ChromeDataUseGroup(request.get()); | 34 data_use_group_ = new ChromeDataUseGroup(request.get()); |
35 base::RunLoop().RunUntilIdle(); | 35 base::RunLoop().RunUntilIdle(); |
36 } | 36 } |
37 | 37 |
38 ChromeDataUseGroup* data_use_group() { return data_use_group_.get(); } | 38 ChromeDataUseGroup* data_use_group() { return data_use_group_.get(); } |
39 | 39 |
40 private: | 40 private: |
41 content::TestBrowserThreadBundle thread_bundle_; | 41 content::TestBrowserThreadBundle thread_bundle_; |
42 | 42 |
43 net::TestURLRequestContext context_; | 43 net::TestURLRequestContext context_; |
44 net::TestDelegate test_delegate_; | 44 net::TestDelegate test_delegate_; |
45 scoped_refptr<ChromeDataUseGroup> data_use_group_; | 45 scoped_refptr<ChromeDataUseGroup> data_use_group_; |
46 }; | 46 }; |
47 | 47 |
48 TEST_F(ChromeDataUseGroupTest, GetHostName) { | 48 TEST_F(ChromeDataUseGroupTest, GetHostName) { |
49 EXPECT_EQ("foo.com", data_use_group()->GetHostname()); | 49 EXPECT_EQ("foo.com", data_use_group()->GetHostname()); |
50 } | 50 } |
51 | 51 |
52 TEST_F(ChromeDataUseGroupTest, GetHostNameExplicitInitialize) { | 52 TEST_F(ChromeDataUseGroupTest, GetHostNameExplicitInitialize) { |
53 data_use_group()->Initialize(); | 53 data_use_group()->Initialize(); |
54 base::RunLoop().RunUntilIdle(); | 54 base::RunLoop().RunUntilIdle(); |
55 | 55 |
56 EXPECT_EQ("foo.com", data_use_group()->GetHostname()); | 56 EXPECT_EQ("foo.com", data_use_group()->GetHostname()); |
57 } | 57 } |
OLD | NEW |