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

Side by Side Diff: content/browser/memory/memory_coordinator_browsertest.cc

Issue 2579233002: Merge MemoryCoordinator and MemoryCoordinatorImpl into one class (Closed)
Patch Set: addressed comments Created 4 years 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 2016 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/browser/memory/memory_coordinator.h"
6
7 #include "base/test/scoped_feature_list.h"
8 #include "content/browser/browser_main_loop.h"
9 #include "content/public/common/content_features.h"
10 #include "content/public/test/content_browser_test.h"
11 #include "content/public/test/content_browser_test_utils.h"
12
13 namespace content {
14
15 class TestMemoryCoordinatorDelegate : public MemoryCoordinatorDelegate {
16 public:
17 TestMemoryCoordinatorDelegate() {}
18 ~TestMemoryCoordinatorDelegate() override {}
19
20 bool CanSuspendBackgroundedRenderer(int render_process_id) override {
21 return true;
22 }
23
24 private:
25 DISALLOW_COPY_AND_ASSIGN(TestMemoryCoordinatorDelegate);
26 };
27
28 class MemoryCoordinatorTest : public ContentBrowserTest {
29 public:
30 MemoryCoordinatorTest() {}
31
32 void SetUp() override {
33 scoped_feature_list_.InitAndEnableFeature(features::kMemoryCoordinator);
34 ContentBrowserTest::SetUp();
35 }
36
37 private:
38 base::test::ScopedFeatureList scoped_feature_list_;
39
40 DISALLOW_COPY_AND_ASSIGN(MemoryCoordinatorTest);
41 };
42
43 // TODO(bashi): Enable these tests on macos when MemoryMonitorMac is
44 // implemented.
45 #if !defined(OS_MACOSX)
46
47 IN_PROC_BROWSER_TEST_F(MemoryCoordinatorTest, HandleAdded) {
48 GURL url = GetTestUrl("", "simple_page.html");
49 NavigateToURL(shell(), url);
50 EXPECT_EQ(1u, MemoryCoordinator::GetInstance()->children().size());
51 }
52
53 IN_PROC_BROWSER_TEST_F(MemoryCoordinatorTest, CanSuspendRenderer) {
54 GURL url = GetTestUrl("", "simple_page.html");
55 NavigateToURL(shell(), url);
56 auto* memory_coordinator = MemoryCoordinator::GetInstance();
57 memory_coordinator->SetDelegateForTesting(
58 base::MakeUnique<TestMemoryCoordinatorDelegate>());
59 EXPECT_EQ(1u, memory_coordinator->children().size());
60 int render_process_id = memory_coordinator->children().begin()->first;
61 // Foreground tab cannot be suspended.
62 EXPECT_FALSE(memory_coordinator->CanSuspendRenderer(render_process_id));
63 }
64
65 #endif // !defined(OS_MACOSX)
66
67 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/memory/memory_coordinator.cc ('k') | content/browser/memory/memory_coordinator_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698