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

Side by Side 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: Addressed Nasko's comments 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2014 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/test/browser_side_navigation_test_utils.h"
6
7 #include "base/command_line.h"
8 #include "base/guid.h"
9 #include "base/lazy_instance.h"
10 #include "content/browser/streams/stream.h"
11 #include "content/browser/streams/stream_registry.h"
12 #include "content/public/browser/browser_thread.h"
13 #include "content/public/browser/stream_handle.h"
14 #include "content/public/common/content_switches.h"
15 #include "content/test/test_navigation_url_loader_factory.h"
16
17 namespace content {
18
19 namespace {
20
21 base::LazyInstance<scoped_ptr<BrowserSideNavigationTestUtils>>
22 browser_side_navigation_test_utils;
23
24 } // namespace
25
26 // static
27 void BrowserSideNavigationTestUtils::SetUp() {
28 DCHECK_CURRENTLY_ON(BrowserThread::UI);
29 browser_side_navigation_test_utils.Get().reset(
30 new BrowserSideNavigationTestUtils);
31 }
32
33 // static
34 void BrowserSideNavigationTestUtils::TearDown() {
35 DCHECK_CURRENTLY_ON(BrowserThread::UI);
36 browser_side_navigation_test_utils.Get().reset(nullptr);
37 }
38
39 // static
40 scoped_ptr<StreamHandle> BrowserSideNavigationTestUtils::MakeEmptyStream() {
41 GURL url(std::string(url::kBlobScheme) + "://" + base::GenerateGUID());
42 StreamRegistry* stream_registry =
43 browser_side_navigation_test_utils.Get()->stream_registry_.get();
44 scoped_refptr<Stream> stream(new Stream(stream_registry, NULL, url));
45 stream->Finalize();
46 return stream->CreateHandle();
47 }
48
49 // static
50 void BrowserSideNavigationTestUtils::EnableBrowserSideNavigation() {
51 CommandLine::ForCurrentProcess()->AppendSwitch(
52 switches::kEnableBrowserSideNavigation);
53 }
54
55 BrowserSideNavigationTestUtils::~BrowserSideNavigationTestUtils() {
56 }
57
58 BrowserSideNavigationTestUtils::BrowserSideNavigationTestUtils()
59 : stream_registry_(new StreamRegistry),
60 loader_factory_(new TestNavigationURLLoaderFactory) {
61 }
62
63 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698