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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/loader/resource_hints_browsertest.cc
diff --git a/content/browser/loader/resource_hints_browsertest.cc b/content/browser/loader/resource_hints_browsertest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..156c8ccdcdd346dbfeb3b4f6eb9ee48be4cae8ff
--- /dev/null
+++ b/content/browser/loader/resource_hints_browsertest.cc
@@ -0,0 +1,62 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/public/test/browser_test_utils.h"
+#include "content/public/test/content_browser_test.h"
+#include "content/public/test/content_browser_test_utils.h"
+#include "content/shell/browser/shell.h"
+#include "net/dns/host_resolver_proc.h"
+#include "net/dns/mock_host_resolver.h"
+#include "testing/gmock/include/gmock/gmock.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace content {
+
+using ::testing::_;
+
+class MockHostResolverProc : public net::HostResolverProc {
+ public:
+ MockHostResolverProc() : net::HostResolverProc(nullptr) {}
+
+ MOCK_METHOD5(Resolve,
+ int(const std::string& host,
+ net::AddressFamily address_family,
+ net::HostResolverFlags flags,
+ net::AddressList* addresses,
+ int* os_error));
+
+ private:
+ ~MockHostResolverProc() override {}
+};
+
+class ResourceHintsBrowserTest : public ContentBrowserTest {
+ public:
+ ResourceHintsBrowserTest()
+ : mock_host_resolver_proc_(new MockHostResolverProc),
+ scoped_host_resolver_proc_(nullptr) {}
+
+ protected:
+ scoped_refptr<MockHostResolverProc> mock_host_resolver_proc_;
+ std::unique_ptr<net::ScopedDefaultHostResolverProc>
+ scoped_host_resolver_proc_;
+};
+
+IN_PROC_BROWSER_TEST_F(ResourceHintsBrowserTest, DnsPrefetch) {
+ scoped_host_resolver_proc_.reset(
+ new net::ScopedDefaultHostResolverProc(mock_host_resolver_proc_.get()));
+ ASSERT_TRUE(embedded_test_server()->Start());
+
+ 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
+ .Times(1);
+ EXPECT_CALL(*mock_host_resolver_proc_,
+ Resolve(testing::Ne("chromium.org"), _, _, _, _))
+ .Times(0);
+ EXPECT_TRUE(NavigateToURL(shell(), embedded_test_server()->GetURL(
+ "/resource_hints/dns_prefetch.html")));
+ EXPECT_TRUE(
+ NavigateToURL(shell(), embedded_test_server()->GetURL("/title1.html")));
+ scoped_host_resolver_proc_.reset();
+}
+
+} // namespace content
« 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