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

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: 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>>
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
22 browser_side_navigation_test_utils;
23
24 } // namespace
25
26 // static
27 BrowserSideNavigationTestUtils* BrowserSideNavigationTestUtils::Get() {
28 DCHECK_CURRENTLY_ON(BrowserThread::UI);
29 return browser_side_navigation_test_utils.Get().get();
30 }
31
32 // static
33 void BrowserSideNavigationTestUtils::Init() {
34 DCHECK_CURRENTLY_ON(BrowserThread::UI);
35 browser_side_navigation_test_utils.Get().reset(
36 new BrowserSideNavigationTestUtils);
37 }
38
39 // static
40 void BrowserSideNavigationTestUtils::TearDown() {
41 DCHECK_CURRENTLY_ON(BrowserThread::UI);
42 browser_side_navigation_test_utils.Get().reset(nullptr);
43 }
44
45 BrowserSideNavigationTestUtils::~BrowserSideNavigationTestUtils() {
46 }
47
48 scoped_ptr<StreamHandle> BrowserSideNavigationTestUtils::MakeEmptyStream() {
49 GURL url(std::string(url::kBlobScheme) + "://" + base::GenerateGUID());
50 scoped_refptr<Stream> stream(new Stream(stream_registry_.get(), NULL, url));
51 stream->Finalize();
52 return stream->CreateHandle();
53 }
54
55 void BrowserSideNavigationTestUtils::EnableBrowserSideNavigation() {
56 CommandLine::ForCurrentProcess()->AppendSwitch(
57 switches::kEnableBrowserSideNavigation);
58 }
59
60 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
61 : stream_registry_(new StreamRegistry),
62 loader_factory_(new TestNavigationURLLoaderFactory) {
63 }
64
65 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698