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

Side by Side Diff: athena/resource_manager/memory_pressure_notifier_unittest.cc

Issue 641683003: C++11 override style change for athena (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: rebase Created 6 years, 2 months 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
1 /// Copyright 2014 The Chromium Authors. All rights reserved. 1 /// Copyright 2014 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 "athena/resource_manager/memory_pressure_notifier.h" 5 #include "athena/resource_manager/memory_pressure_notifier.h"
6 #include "athena/resource_manager/public/resource_manager_delegate.h" 6 #include "athena/resource_manager/public/resource_manager_delegate.h"
7 #include "athena/test/base/athena_test_base.h" 7 #include "athena/test/base/athena_test_base.h"
8 8
9 namespace athena { 9 namespace athena {
10 namespace test { 10 namespace test {
11 11
12 namespace { 12 namespace {
13 13
14 // Our OS delegate abstraction class to override the memory fill level. 14 // Our OS delegate abstraction class to override the memory fill level.
15 class TestResourceManagerDelegate : public ResourceManagerDelegate { 15 class TestResourceManagerDelegate : public ResourceManagerDelegate {
16 public: 16 public:
17 TestResourceManagerDelegate() : memory_fill_level_percent_(0) {} 17 TestResourceManagerDelegate() : memory_fill_level_percent_(0) {}
18 virtual ~TestResourceManagerDelegate() {} 18 ~TestResourceManagerDelegate() override {}
19 19
20 virtual int GetUsedMemoryInPercent() override { 20 virtual int GetUsedMemoryInPercent() override {
21 timer_called_++; 21 timer_called_++;
22 return memory_fill_level_percent_; 22 return memory_fill_level_percent_;
23 } 23 }
24 24
25 virtual int MemoryPressureIntervalInMS() override { 25 virtual int MemoryPressureIntervalInMS() override {
26 return 5; 26 return 5;
27 } 27 }
28 28
(...skipping 14 matching lines...) Expand all
43 DISALLOW_COPY_AND_ASSIGN(TestResourceManagerDelegate); 43 DISALLOW_COPY_AND_ASSIGN(TestResourceManagerDelegate);
44 }; 44 };
45 45
46 // Our memory pressure observer class. 46 // Our memory pressure observer class.
47 class TestMemoryPressureObserver : public MemoryPressureObserver { 47 class TestMemoryPressureObserver : public MemoryPressureObserver {
48 public: 48 public:
49 TestMemoryPressureObserver(ResourceManagerDelegate* delegate) 49 TestMemoryPressureObserver(ResourceManagerDelegate* delegate)
50 : delegate_(delegate), 50 : delegate_(delegate),
51 number_of_calls_(0), 51 number_of_calls_(0),
52 pressure_(ResourceManager::MEMORY_PRESSURE_UNKNOWN) {} 52 pressure_(ResourceManager::MEMORY_PRESSURE_UNKNOWN) {}
53 virtual ~TestMemoryPressureObserver() {} 53 ~TestMemoryPressureObserver() override {}
54 54
55 // The observer. 55 // The observer.
56 virtual void OnMemoryPressure( 56 virtual void OnMemoryPressure(
57 ResourceManager::MemoryPressure pressure) override { 57 ResourceManager::MemoryPressure pressure) override {
58 number_of_calls_++; 58 number_of_calls_++;
59 pressure_ = pressure; 59 pressure_ = pressure;
60 } 60 }
61 61
62 virtual ResourceManagerDelegate* GetDelegate() override { 62 virtual ResourceManagerDelegate* GetDelegate() override {
63 return delegate_.get(); 63 return delegate_.get();
(...skipping 13 matching lines...) Expand all
77 77
78 DISALLOW_COPY_AND_ASSIGN(TestMemoryPressureObserver); 78 DISALLOW_COPY_AND_ASSIGN(TestMemoryPressureObserver);
79 }; 79 };
80 80
81 } // namespace 81 } // namespace
82 82
83 // Our testing base. 83 // Our testing base.
84 class MemoryPressureTest : public AthenaTestBase { 84 class MemoryPressureTest : public AthenaTestBase {
85 public: 85 public:
86 MemoryPressureTest() : test_resource_manager_delegate_(nullptr) {} 86 MemoryPressureTest() : test_resource_manager_delegate_(nullptr) {}
87 virtual ~MemoryPressureTest() {} 87 ~MemoryPressureTest() override {}
88 88
89 // AthenaTestBase: 89 // AthenaTestBase:
90 virtual void SetUp() override { 90 virtual void SetUp() override {
91 AthenaTestBase::SetUp(); 91 AthenaTestBase::SetUp();
92 // Create and install our TestAppContentDelegate with instrumentation. 92 // Create and install our TestAppContentDelegate with instrumentation.
93 test_resource_manager_delegate_ = 93 test_resource_manager_delegate_ =
94 new TestResourceManagerDelegate(); 94 new TestResourceManagerDelegate();
95 test_memory_pressure_observer_.reset(new TestMemoryPressureObserver( 95 test_memory_pressure_observer_.reset(new TestMemoryPressureObserver(
96 test_resource_manager_delegate_)); 96 test_resource_manager_delegate_));
97 memory_pressure_notifier_.reset( 97 memory_pressure_notifier_.reset(
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 213
214 // Even if the value does not change, we should not get any more calls. 214 // Even if the value does not change, we should not get any more calls.
215 ASSERT_TRUE(WaitForTimer()); 215 ASSERT_TRUE(WaitForTimer());
216 EXPECT_EQ(calls3, test_memory_pressure_observer()->number_of_calls()); 216 EXPECT_EQ(calls3, test_memory_pressure_observer()->number_of_calls());
217 EXPECT_EQ(ResourceManager::MEMORY_PRESSURE_LOW, 217 EXPECT_EQ(ResourceManager::MEMORY_PRESSURE_LOW,
218 test_memory_pressure_observer()->pressure()); 218 test_memory_pressure_observer()->pressure());
219 } 219 }
220 220
221 } // namespace test 221 } // namespace test
222 } // namespace athena 222 } // namespace athena
OLDNEW
« no previous file with comments | « athena/resource_manager/delegate/resource_manager_delegate.cc ('k') | athena/resource_manager/resource_manager_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698