OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "components/memory_coordinator/browser/memory_coordinator.h" | 5 #include "content/browser/memory/memory_coordinator.h" |
6 #include "components/memory_coordinator/common/memory_coordinator_features.h" | |
7 #include "content/browser/browser_main_loop.h" | 6 #include "content/browser/browser_main_loop.h" |
| 7 #include "content/public/common/content_features.h" |
8 #include "content/public/test/content_browser_test.h" | 8 #include "content/public/test/content_browser_test.h" |
9 #include "content/public/test/content_browser_test_utils.h" | 9 #include "content/public/test/content_browser_test_utils.h" |
10 | 10 |
11 namespace content { | 11 namespace content { |
12 | 12 |
| 13 namespace { |
| 14 |
| 15 void EnableForTesting() { |
| 16 base::FeatureList::ClearInstanceForTesting(); |
| 17 std::unique_ptr<base::FeatureList> feature_list(new base::FeatureList); |
| 18 feature_list->InitializeFromCommandLine(features::kMemoryCoordinator.name, |
| 19 ""); |
| 20 base::FeatureList::SetInstance(std::move(feature_list)); |
| 21 } |
| 22 |
| 23 } // namespace |
| 24 |
13 class MemoryCoordinatorTest : public ContentBrowserTest { | 25 class MemoryCoordinatorTest : public ContentBrowserTest { |
14 public: | 26 public: |
15 MemoryCoordinatorTest() {} | 27 MemoryCoordinatorTest() {} |
16 | 28 |
17 void SetUp() override { | 29 void SetUp() override { |
18 memory_coordinator::EnableForTesting(); | 30 EnableForTesting(); |
19 ContentBrowserTest::SetUp(); | 31 ContentBrowserTest::SetUp(); |
20 } | 32 } |
21 | 33 |
22 protected: | 34 private: |
23 memory_coordinator::MemoryCoordinator* memory_coordinator() { | |
24 return memory_coordinator::MemoryCoordinator::GetInstance(); | |
25 } | |
26 | |
27 DISALLOW_COPY_AND_ASSIGN(MemoryCoordinatorTest); | 35 DISALLOW_COPY_AND_ASSIGN(MemoryCoordinatorTest); |
28 }; | 36 }; |
29 | 37 |
30 IN_PROC_BROWSER_TEST_F(MemoryCoordinatorTest, HandleAdded) { | 38 IN_PROC_BROWSER_TEST_F(MemoryCoordinatorTest, HandleAdded) { |
31 GURL url = GetTestUrl("", "simple_page.html"); | 39 GURL url = GetTestUrl("", "simple_page.html"); |
32 NavigateToURL(shell(), url); | 40 NavigateToURL(shell(), url); |
33 EXPECT_EQ(1u, memory_coordinator()->NumChildrenForTesting()); | 41 EXPECT_EQ(1u, MemoryCoordinator::GetInstance()->NumChildrenForTesting()); |
34 } | 42 } |
35 | 43 |
36 } // namespace content | 44 } // namespace content |
OLD | NEW |