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

Side by Side Diff: content/browser/loader/resource_hints_browsertest.cc

Issue 2043753002: Declarative resource hints go through mojo IPC to //content Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: kinuko@ review: comments and remove PlatformMojoMock.h from gypi Created 4 years, 6 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
« no previous file with comments | « content/browser/DEPS ('k') | content/browser/loader/resource_hints_handler_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "content/public/test/browser_test_utils.h"
6 #include "content/public/test/content_browser_test.h"
7 #include "content/public/test/content_browser_test_utils.h"
8 #include "content/shell/browser/shell.h"
9 #include "net/dns/host_resolver_proc.h"
10 #include "net/dns/mock_host_resolver.h"
11 #include "testing/gmock/include/gmock/gmock.h"
12 #include "testing/gtest/include/gtest/gtest.h"
13
14 namespace content {
15
16 using ::testing::_;
17
18 class MockHostResolverProc : public net::HostResolverProc {
19 public:
20 MockHostResolverProc() : net::HostResolverProc(nullptr) {}
21
22 MOCK_METHOD5(Resolve,
23 int(const std::string& host,
24 net::AddressFamily address_family,
25 net::HostResolverFlags flags,
26 net::AddressList* addresses,
27 int* os_error));
28
29 private:
30 ~MockHostResolverProc() override {}
31 };
32
33 class ResourceHintsBrowserTest : public ContentBrowserTest {
34 public:
35 ResourceHintsBrowserTest()
36 : mock_host_resolver_proc_(new MockHostResolverProc),
37 scoped_host_resolver_proc_(nullptr) {}
38
39 protected:
40 scoped_refptr<MockHostResolverProc> mock_host_resolver_proc_;
41 std::unique_ptr<net::ScopedDefaultHostResolverProc>
42 scoped_host_resolver_proc_;
43 };
44
45 IN_PROC_BROWSER_TEST_F(ResourceHintsBrowserTest, DnsPrefetch) {
46 scoped_host_resolver_proc_.reset(
47 new net::ScopedDefaultHostResolverProc(mock_host_resolver_proc_.get()));
48 ASSERT_TRUE(embedded_test_server()->Start());
49
50 EXPECT_CALL(*mock_host_resolver_proc_, Resolve("chromium.org", _, _, _, _))
mmenke 2016/06/17 20:05:36 I'd recommend against using Gmock - it reduces the
Charlie Harrison 2016/06/19 11:01:56 Hm. I think I disagree with you. To extend these t
51 .Times(1);
52 EXPECT_CALL(*mock_host_resolver_proc_,
53 Resolve(testing::Ne("chromium.org"), _, _, _, _))
54 .Times(0);
55 EXPECT_TRUE(NavigateToURL(shell(), embedded_test_server()->GetURL(
56 "/resource_hints/dns_prefetch.html")));
57 EXPECT_TRUE(
58 NavigateToURL(shell(), embedded_test_server()->GetURL("/title1.html")));
59 scoped_host_resolver_proc_.reset();
60 }
61
62 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/DEPS ('k') | content/browser/loader/resource_hints_handler_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698