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

Unified Diff: cc/output/context_cache_controller_unittest.cc

Issue 2366033002: Revert of Idle cleanup for worker context (Closed)
Patch Set: Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/output/context_cache_controller.cc ('k') | cc/output/context_provider.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/output/context_cache_controller_unittest.cc
diff --git a/cc/output/context_cache_controller_unittest.cc b/cc/output/context_cache_controller_unittest.cc
index 35e1e25a0d5d6356f7320ee0772dcf72c5ad2d23..67831aa16c151e237e7c9e776d10ecb0cd705d67 100644
--- a/cc/output/context_cache_controller_unittest.cc
+++ b/cc/output/context_cache_controller_unittest.cc
@@ -5,7 +5,6 @@
#include "cc/output/context_cache_controller.h"
#include "base/memory/ptr_util.h"
-#include "base/test/test_mock_time_task_runner.h"
#include "cc/test/test_context_provider.h"
#include "cc/test/test_context_support.h"
#include "cc/test/test_web_graphics_context_3d.h"
@@ -26,8 +25,7 @@
TEST(ContextCacheControllerTest, ScopedVisibilityBasic) {
StrictMock<MockContextSupport> context_support;
- auto task_runner = make_scoped_refptr(new base::TestMockTimeTaskRunner);
- ContextCacheController cache_controller(&context_support, task_runner);
+ ContextCacheController cache_controller(&context_support, nullptr);
EXPECT_CALL(context_support, SetAggressivelyFreeResources(false));
std::unique_ptr<ContextCacheController::ScopedVisibility> visibility =
@@ -40,76 +38,19 @@
TEST(ContextCacheControllerTest, ScopedVisibilityMulti) {
StrictMock<MockContextSupport> context_support;
- auto task_runner = make_scoped_refptr(new base::TestMockTimeTaskRunner);
- ContextCacheController cache_controller(&context_support, task_runner);
+ ContextCacheController cache_controller(&context_support, nullptr);
EXPECT_CALL(context_support, SetAggressivelyFreeResources(false));
- auto visibility_1 = cache_controller.ClientBecameVisible();
+ std::unique_ptr<ContextCacheController::ScopedVisibility> visibility_1 =
+ cache_controller.ClientBecameVisible();
Mock::VerifyAndClearExpectations(&context_support);
- auto visibility_2 = cache_controller.ClientBecameVisible();
+ std::unique_ptr<ContextCacheController::ScopedVisibility> visibility_2 =
+ cache_controller.ClientBecameVisible();
cache_controller.ClientBecameNotVisible(std::move(visibility_1));
EXPECT_CALL(context_support, SetAggressivelyFreeResources(true));
cache_controller.ClientBecameNotVisible(std::move(visibility_2));
}
-TEST(ContextCacheControllerTest, ScopedBusyWhileVisible) {
- StrictMock<MockContextSupport> context_support;
- auto task_runner = make_scoped_refptr(new base::TestMockTimeTaskRunner);
- ContextCacheController cache_controller(&context_support, task_runner);
-
- EXPECT_CALL(context_support, SetAggressivelyFreeResources(false));
- auto visibility = cache_controller.ClientBecameVisible();
- Mock::VerifyAndClearExpectations(&context_support);
-
- // Now that we're visible, ensure that going idle triggers a delayed cleanup.
- auto busy = cache_controller.ClientBecameBusy();
- cache_controller.ClientBecameNotBusy(std::move(busy));
-
- EXPECT_CALL(context_support, SetAggressivelyFreeResources(true));
- EXPECT_CALL(context_support, SetAggressivelyFreeResources(false));
- task_runner->FastForwardBy(base::TimeDelta::FromSeconds(5));
- Mock::VerifyAndClearExpectations(&context_support);
-
- EXPECT_CALL(context_support, SetAggressivelyFreeResources(true));
- cache_controller.ClientBecameNotVisible(std::move(visibility));
-}
-
-TEST(ContextCacheControllerTest, ScopedBusyWhileNotVisible) {
- StrictMock<MockContextSupport> context_support;
- auto task_runner = make_scoped_refptr(new base::TestMockTimeTaskRunner);
- ContextCacheController cache_controller(&context_support, task_runner);
-
- auto busy = cache_controller.ClientBecameBusy();
-
- // We are not visible, so becoming busy should not trigger an idle callback.
- cache_controller.ClientBecameNotBusy(std::move(busy));
- task_runner->FastForwardBy(base::TimeDelta::FromSeconds(5));
-}
-
-TEST(ContextCacheControllerTest, ScopedBusyMulitpleWhileVisible) {
- StrictMock<MockContextSupport> context_support;
- auto task_runner = make_scoped_refptr(new base::TestMockTimeTaskRunner);
- ContextCacheController cache_controller(&context_support, task_runner);
-
- EXPECT_CALL(context_support, SetAggressivelyFreeResources(false));
- auto visible = cache_controller.ClientBecameVisible();
- Mock::VerifyAndClearExpectations(&context_support);
-
- auto busy_1 = cache_controller.ClientBecameBusy();
- cache_controller.ClientBecameNotBusy(std::move(busy_1));
- auto busy_2 = cache_controller.ClientBecameBusy();
- cache_controller.ClientBecameNotBusy(std::move(busy_2));
-
- // When we fast forward, only one cleanup should happen.
- EXPECT_CALL(context_support, SetAggressivelyFreeResources(true));
- EXPECT_CALL(context_support, SetAggressivelyFreeResources(false));
- task_runner->FastForwardBy(base::TimeDelta::FromSeconds(5));
- Mock::VerifyAndClearExpectations(&context_support);
-
- EXPECT_CALL(context_support, SetAggressivelyFreeResources(true));
- cache_controller.ClientBecameNotVisible(std::move(visible));
-}
-
} // namespace
} // namespace cc
« no previous file with comments | « cc/output/context_cache_controller.cc ('k') | cc/output/context_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698