OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | |
nasko
2014/11/15 00:32:51
No "(c)" needed.
clamy
2014/11/17 12:51:13
Done.
| |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CONTENT_TEST_BROWSER_SIDE_NAVIGATION_TEST_UTILS_H_ | |
6 #define CONTENT_TEST_BROWSER_SIDE_NAVIGATION_TEST_UTILS_H_ | |
7 | |
8 #include "base/macros.h" | |
9 #include "base/memory/scoped_ptr.h" | |
10 | |
11 namespace content { | |
12 | |
13 class StreamHandle; | |
14 class StreamRegistry; | |
15 class TestNavigationURLLoaderFactory; | |
16 | |
17 // PlzNavigate | |
18 // A UI thread singleton helper class for browser side navigations. When browser | |
19 // side navigations are enabled, initialize this class before doing any | |
20 // operation that may start a navigation request on the UI thread. | |
21 class BrowserSideNavigationTestUtils { | |
22 public: | |
23 // Returns a pointer to the BrowserSideNavigationTestUtils. Note: this will be | |
nasko
2014/11/15 00:32:51
nit: Note: on new line.
clamy
2014/11/17 12:51:13
Made all the method static and removed the singlet
| |
24 // NULL if Init was not called (or TearDown was called). | |
25 static BrowserSideNavigationTestUtils* Get(); | |
26 | |
27 // Initializes the BrowserSideNavigationsTestUtils. Following this call, all | |
28 // NavigationURLLoader objects created will be TestNavigationURLLoaders | |
29 // instead of NavigationURLloaderImpls. This should be called before any call | |
30 // in the UI thread unit tests that will start a navigation (eg. | |
31 // TestWebContents::NavigateAndCommit). | |
clamy
2014/11/14 15:45:26
I am not sure if a global LazyInstance is destroye
nasko
2014/11/15 00:32:51
Unittests don't tear down the process, so any glob
carlosk
2014/11/17 10:46:56
There was a similar situation a while ago where I
clamy
2014/11/17 12:51:13
Yes. In particular, we need no to have the singlet
| |
32 static void Init(); | |
nasko
2014/11/15 00:32:51
If you are using TearDown, let's use SetUp instead
clamy
2014/11/17 12:51:13
Done.
| |
33 | |
34 // Destroys the BrowserSideNavigationTestUtils singleton. | |
35 static void TearDown(); | |
36 | |
37 ~BrowserSideNavigationTestUtils(); | |
38 | |
39 // Returns an empty stream. Used when faking a navigation commit notification | |
40 // from the IO thread with a TestNavigationURLLoader. | |
41 scoped_ptr<StreamHandle> MakeEmptyStream(); | |
42 | |
43 void EnableBrowserSideNavigation(); | |
44 | |
45 private: | |
46 BrowserSideNavigationTestUtils(); | |
47 | |
48 scoped_ptr<StreamRegistry> stream_registry_; | |
49 scoped_ptr<TestNavigationURLLoaderFactory> loader_factory_; | |
50 | |
51 DISALLOW_COPY_AND_ASSIGN(BrowserSideNavigationTestUtils); | |
52 }; | |
53 | |
54 } // namespace content | |
55 | |
56 #endif // CONTENT_TEST_BROWSER_SIDE_NAVIGATION_TEST_UTILS_H_ | |
OLD | NEW |