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

Unified Diff: content/test/browser_side_navigation_test_utils.cc

Issue 730553002: PlzNavigate: Refactor unit test helper functions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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
Index: content/test/browser_side_navigation_test_utils.cc
diff --git a/content/test/browser_side_navigation_test_utils.cc b/content/test/browser_side_navigation_test_utils.cc
new file mode 100644
index 0000000000000000000000000000000000000000..9111071f98110e89af3a2169da69ab74f4a5be7f
--- /dev/null
+++ b/content/test/browser_side_navigation_test_utils.cc
@@ -0,0 +1,65 @@
+// Copyright (c) 2014 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/test/browser_side_navigation_test_utils.h"
+
+#include "base/command_line.h"
+#include "base/guid.h"
+#include "base/lazy_instance.h"
+#include "content/browser/streams/stream.h"
+#include "content/browser/streams/stream_registry.h"
+#include "content/public/browser/browser_thread.h"
+#include "content/public/browser/stream_handle.h"
+#include "content/public/common/content_switches.h"
+#include "content/test/test_navigation_url_loader_factory.h"
+
+namespace content {
+
+namespace {
+
+base::LazyInstance<scoped_ptr<BrowserSideNavigationTestUtils>>
carlosk 2014/11/17 10:46:56 As we need to define an Init method anyway to prop
clamy 2014/11/17 12:51:13 It allows to have a global variable of non POD typ
+ browser_side_navigation_test_utils;
+
+} // namespace
+
+// static
+BrowserSideNavigationTestUtils* BrowserSideNavigationTestUtils::Get() {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+ return browser_side_navigation_test_utils.Get().get();
+}
+
+// static
+void BrowserSideNavigationTestUtils::Init() {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+ browser_side_navigation_test_utils.Get().reset(
+ new BrowserSideNavigationTestUtils);
+}
+
+// static
+void BrowserSideNavigationTestUtils::TearDown() {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+ browser_side_navigation_test_utils.Get().reset(nullptr);
+}
+
+BrowserSideNavigationTestUtils::~BrowserSideNavigationTestUtils() {
+}
+
+scoped_ptr<StreamHandle> BrowserSideNavigationTestUtils::MakeEmptyStream() {
+ GURL url(std::string(url::kBlobScheme) + "://" + base::GenerateGUID());
+ scoped_refptr<Stream> stream(new Stream(stream_registry_.get(), NULL, url));
+ stream->Finalize();
+ return stream->CreateHandle();
+}
+
+void BrowserSideNavigationTestUtils::EnableBrowserSideNavigation() {
+ CommandLine::ForCurrentProcess()->AppendSwitch(
+ switches::kEnableBrowserSideNavigation);
+}
+
+BrowserSideNavigationTestUtils::BrowserSideNavigationTestUtils()
nasko 2014/11/15 00:32:51 nit: Constructor should probably live closer to th
clamy 2014/11/17 12:51:13 Changed the ordering in the header file due to all
+ : stream_registry_(new StreamRegistry),
+ loader_factory_(new TestNavigationURLLoaderFactory) {
+}
+
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698