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

Side by Side Diff: components/memory_pressure/memory_pressure_monitor_unittest.cc

Issue 2823103003: Introduce TaskRunner::RunsTasksInCurrentSequence() (Closed)
Patch Set: fixed build error and commments Created 3 years, 8 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 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_pressure/memory_pressure_monitor.h" 5 #include "components/memory_pressure/memory_pressure_monitor.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 28 matching lines...) Expand all
39 MOCK_METHOD2(PostDelayedTask, 39 MOCK_METHOD2(PostDelayedTask,
40 bool(const tracked_objects::Location&, base::TimeDelta)); 40 bool(const tracked_objects::Location&, base::TimeDelta));
41 }; 41 };
42 using MockTaskRunner = testing::StrictMock<LenientMockTaskRunner>; 42 using MockTaskRunner = testing::StrictMock<LenientMockTaskRunner>;
43 43
44 // A TaskRunner implementation that wraps a MockTaskRunner. 44 // A TaskRunner implementation that wraps a MockTaskRunner.
45 class TaskRunnerProxy : public base::TaskRunner { 45 class TaskRunnerProxy : public base::TaskRunner {
46 public: 46 public:
47 // The provided |mock| must outlive this object. 47 // The provided |mock| must outlive this object.
48 explicit TaskRunnerProxy(MockTaskRunner* mock) : mock_(mock) {} 48 explicit TaskRunnerProxy(MockTaskRunner* mock) : mock_(mock) {}
49 bool RunsTasksOnCurrentThread() const override { return true; } 49 bool RunsTasksInCurrentSequence() const override { return true; }
50 bool PostDelayedTask(const tracked_objects::Location& location, 50 bool PostDelayedTask(const tracked_objects::Location& location,
51 base::OnceClosure closure, 51 base::OnceClosure closure,
52 base::TimeDelta delta) override { 52 base::TimeDelta delta) override {
53 return mock_->PostDelayedTask(location, delta); 53 return mock_->PostDelayedTask(location, delta);
54 } 54 }
55 55
56 private: 56 private:
57 MockTaskRunner* mock_; 57 MockTaskRunner* mock_;
58 ~TaskRunnerProxy() override {} 58 ~TaskRunnerProxy() override {}
59 }; 59 };
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 ExpectDispatchCritical(); 380 ExpectDispatchCritical();
381 monitor_->OnMemoryPressureChanged(MEMORY_PRESSURE_LEVEL_CRITICAL); 381 monitor_->OnMemoryPressureChanged(MEMORY_PRESSURE_LEVEL_CRITICAL);
382 VerifyAndClearExpectations(); 382 VerifyAndClearExpectations();
383 ExpectCritical(); 383 ExpectCritical();
384 EXPECT_EQ(2u, monitor_->scheduled_checks().size()); 384 EXPECT_EQ(2u, monitor_->scheduled_checks().size());
385 } 385 }
386 386
387 #endif // !MEMORY_PRESSURE_IS_POLLING 387 #endif // !MEMORY_PRESSURE_IS_POLLING
388 388
389 } // namespace memory_pressure 389 } // namespace memory_pressure
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698